Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@
/dist
/.mfsu
.swc
.DS_Store
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"cSpell.words": ["Dexie"]
}
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,32 @@
# Kumi

Koa + Umi = Kumi, an framework for Chrome extension

## Directory structure

```bash
├── config # Build and Environment Configuration
├── mock
├── public # Static resources
└── src
├── assets # Media resources, including img, svg
├── components # Frontend Public components
│ ├── AccountInfo
│ └── Guide
├── constants # Static data structures
├── extension # Chrome extension files
│ ├── background # Service worker
│ ├── common # some common tools or structures for Service Worker and content script
│ └── content # Content scripts, inject to WebSite
├── models # Front-end status containers
├── pages # Front-end pages (Popup UIs)
│ ├── Access
│ ├── Create
│ ├── Home
│ ├── Send
│ └── Table
├── services # Front-end services (API definition)
│ └── demo
└── utils # Front-end utilities
└── tools
```
25 changes: 18 additions & 7 deletions config/config.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { defineConfig } from '@umijs/max'
// import fs from 'fs'
import fs from 'fs'
import GenerateJsonPlugin from 'generate-json-webpack-plugin'
import path from 'path'
import type { Compiler } from 'webpack'

// import path from 'path'
// import type { Compiler } from 'webpack'
import manifest from './manifest'
import routes from './routes'

Expand Down Expand Up @@ -35,10 +35,6 @@ export default defineConfig({
jsMinifierOptions: {
keepNames: true,
},
codeSplitting: {
jsStrategy: 'depPerChunk',
jsStrategyOptions: {},
},
polyfill: {
imports: ['core-js/stable'],
},
Expand All @@ -53,6 +49,21 @@ export default defineConfig({
memo.plugins.delete('hmr')
}

memo.plugin('fixCSP').use(
class {
apply(compiler: Compiler) {
compiler.hooks.done.tap('fixCSP', () => {
const htmlPath = path.resolve(__dirname, '../dist/index.html')
const html = fs.readFileSync(htmlPath).toString()
fs.writeFileSync(
htmlPath,
html.replace(/<script>\s*.*\s*<\/script>/g, ''),
)
})
}
},
)

// generate manifest.json, it will auto load version/env
memo
.plugin('generate-json-webpack-plugin')
Expand Down
5 changes: 4 additions & 1 deletion config/manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export default {
'512': 'icon-512.png',
},
},
permissions: ['alarms'],
permissions: ['alarms', 'storage'],
host_permissions: ['<all_urls>'],
content_scripts: [
{
Expand Down Expand Up @@ -58,4 +58,7 @@ export default {
matches: ['<all_urls>'],
},
],
content_security_policy: {
extension_pages: "script-src 'self' 'wasm-unsafe-eval'; object-src 'self';",
},
}
52 changes: 36 additions & 16 deletions config/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,42 @@ export default defineConfig({
routes: [
{
path: '/',
redirect: '/home',
},
{
name: '首页',
path: '/home',
component: './Home',
},
{
name: '权限演示',
path: '/access',
component: './Access',
},
{
name: ' CRUD 示例',
path: '/table',
component: './Table',
wrappers: ['@/pages/Wrappers/ui-request'],
routes: [
{
path: '/',
redirect: '/home',
},
{
name: 'Home',
path: '/home',
component: './Home',
},
{
name: 'Create',
path: '/create',
component: './Create',
},
{
name: 'Send',
path: '/send',
component: './Send',
},
{
name: 'Access',
path: '/access',
component: './Access',
},
{
name: ' CRUD Example',
path: '/table',
component: './Table',
},
{
path: 'ui-request/:reqId',
component: '@/pages/UIRequest',
},
],
},
],
}).routes
Loading