Skip to content

Commit

Permalink
✨ feat: Manifest V3 版 background 和 schema 适配
Browse files Browse the repository at this point in the history
  • Loading branch information
arvinxx committed Aug 27, 2022
1 parent 0699575 commit 4d8575f
Show file tree
Hide file tree
Showing 15 changed files with 393 additions and 241 deletions.
20 changes: 9 additions & 11 deletions example/.umirc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ export default defineConfig({
extensions: {
name: 'Umi Extension Plugin',
description: '用于 Chrome 插件开发的 Umi 插件',
manifestVersion: 2,
minimumChromeVersion: '80',
icons: {
16: 'logo/logo@16.png',
32: 'logo/logo@32.png',
Expand All @@ -20,17 +18,12 @@ export default defineConfig({
openInTab: true,
},
popupUI: '@/pages/index',
permissions: ['http://*/*', 'https://*/*'],
permissions: ['storage'],
host_permissions: ['http://*/*', 'https://*/*'],
background: {
scripts: ['@/background/index'],
persistent: true,
service_worker: '@/background/index',
},
contentScripts: [
{
matches: ['http://*/*', 'https://*/*'],
entries: ['jquery', 'require.js'],
runAt: 'document_end',
},
{
matches: ['https://github.com/*'],
entries: ['@/contentScripts/github'],
Expand All @@ -41,7 +34,12 @@ export default defineConfig({
},
],
extends: {
web_accessible_resources: ['*'],
web_accessible_resources: [
{
resources: ['test1.png', 'test2.png'],
matches: ['https://web-accessible-resources-1.glitch.me/*'],
},
],
},
},
});
4 changes: 2 additions & 2 deletions example/package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"version": "1.0.0",
"dependencies": {
"jquery": "^3.6.0",
"require.js": "^1.0.0"
},
"devDependencies": {
"@types/jquery": "^3.5.5"
},
"version": "1.0.0"
}
}
6 changes: 4 additions & 2 deletions example/src/contentScripts/github/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import ReactDOM from 'react-dom';
import ReactDOM from 'react-dom/client';
import styles from './style.less';

console.log(`Current page's url must be prefixed with https://github.com`);
Expand All @@ -10,7 +10,9 @@ const App = () => {
};

const container = document.createElement('div');

container.id = 'umi';
document.body.append(container);

ReactDOM.render(<App />, container);
const root = ReactDOM.createRoot(container);
root.render(<App />);
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,6 @@
"typedoc-plugin-external-module-map": "^1.3.2",
"typedoc-plugin-markdown": "^3.13.4",
"typescript": "^4.2.3",
"umi": "^3.4.11"
"umi": "^3.5.33"
}
}

0 comments on commit 4d8575f

Please sign in to comment.