create-packer 1.45.20 → 1.46.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/template/electron-react/.editorconfig +14 -0
- package/template/electron-react/.env +3 -0
- package/template/electron-react/.env.development +3 -0
- package/template/electron-react/.gitignore +28 -0
- package/template/electron-react/.husky/commit-msg +4 -0
- package/template/electron-react/.husky/pre-commit +4 -0
- package/template/electron-react/.prettierignore +6 -0
- package/template/electron-react/.prettierrc +18 -0
- package/template/electron-react/.stylelintignore +4 -0
- package/template/electron-react/.stylelintrc +35 -0
- package/template/electron-react/.vscode/extensions.json +7 -0
- package/template/electron-react/README.md +14 -0
- package/template/electron-react/assets/rspack.png +0 -0
- package/template/electron-react/build.config.json +40 -0
- package/template/electron-react/commitlint.config.cjs +1 -0
- package/template/electron-react/configs/config.ts +25 -0
- package/template/electron-react/configs/createChunks.ts +26 -0
- package/template/electron-react/configs/rsbuild.main.config.ts +54 -0
- package/template/electron-react/configs/rsbuild.preload.config.ts +54 -0
- package/template/electron-react/configs/rsbuild.renderer.config.ts +73 -0
- package/template/electron-react/env.d.ts +12 -0
- package/template/electron-react/eslint.config.mjs +108 -0
- package/template/electron-react/main/main.ts +83 -0
- package/template/electron-react/main/tools/html.ts +8 -0
- package/template/electron-react/main/tools/index.ts +1 -0
- package/template/electron-react/package.json +97 -0
- package/template/electron-react/pnpm-lock.yaml +10158 -0
- package/template/electron-react/postcss.config.cjs +8 -0
- package/template/electron-react/preload/index.ts +1 -0
- package/template/electron-react/renderer/domain/app/components/app-context.tsx +31 -0
- package/template/electron-react/renderer/domain/app/components/app.tsx +25 -0
- package/template/{web-app/react-vite → electron-react/renderer}/domain/app/startApp.tsx +6 -6
- package/template/electron-react/renderer/domain/router/components/index.ts +2 -0
- package/template/electron-react/renderer/domain/router/components/route-layout.tsx +19 -0
- package/template/electron-react/renderer/domain/router/components/sub-route-outlet.tsx +22 -0
- package/template/electron-react/renderer/domain/router/home/ids.ts +3 -0
- package/template/electron-react/renderer/domain/router/home/index.ts +2 -0
- package/template/electron-react/renderer/domain/router/home/routes.tsx +13 -0
- package/template/electron-react/renderer/domain/router/ids.ts +6 -0
- package/template/electron-react/renderer/domain/router/index.ts +4 -0
- package/template/electron-react/renderer/domain/router/router.tsx +28 -0
- package/template/electron-react/renderer/domain/router/router.types.ts +3 -0
- package/template/electron-react/renderer/global.d.ts +16 -0
- package/template/electron-react/renderer/index.html +11 -0
- package/template/electron-react/renderer/main.ts +3 -0
- package/template/electron-react/renderer/pages/home/index.ts +1 -0
- package/template/electron-react/renderer/pages/home/view.styled.ts +5 -0
- package/template/electron-react/renderer/pages/home/view.tsx +10 -0
- package/template/electron-react/renderer/pages/index.tsx +18 -0
- package/template/electron-react/renderer/pages/not-found.tsx +3 -0
- package/template/electron-react/renderer/public/rsbuild-logo.svg +1 -0
- package/template/electron-react/renderer/scripts/createChunks.ts +26 -0
- package/template/electron-react/renderer/scripts/index.ts +1 -0
- package/template/electron-react/renderer/shared/assets/react.svg +1 -0
- package/template/electron-react/renderer/shared/components/componentInstance.tsx +80 -0
- package/template/electron-react/renderer/shared/components/index.ts +1 -0
- package/template/electron-react/renderer/shared/constant/index.ts +0 -0
- package/template/electron-react/renderer/shared/hooks/defineRouter/defineRouter.types.ts +33 -0
- package/template/electron-react/renderer/shared/hooks/defineRouter/deineRouter.tsx +161 -0
- package/template/electron-react/renderer/shared/hooks/defineRouter/index.ts +2 -0
- package/template/electron-react/renderer/shared/hooks/index.ts +6 -0
- package/template/electron-react/renderer/shared/hooks/useInterval.ts +26 -0
- package/template/electron-react/renderer/shared/hooks/useLoadingAction.ts +27 -0
- package/template/electron-react/renderer/shared/hooks/useLowPriorityState.ts +26 -0
- package/template/electron-react/renderer/shared/hooks/useSyncState.ts +15 -0
- package/template/electron-react/renderer/shared/hooks/useVisible.ts +27 -0
- package/template/electron-react/renderer/shared/service/api.ts +1 -0
- package/template/electron-react/renderer/shared/service/home.ts +9 -0
- package/template/electron-react/renderer/shared/service/index.ts +3 -0
- package/template/electron-react/renderer/shared/service/request.ts +5 -0
- package/template/electron-react/renderer/shared/styles/global.ts +7 -0
- package/template/electron-react/renderer/shared/styles/index.ts +2 -0
- package/template/electron-react/renderer/shared/styles/theme.ts +60 -0
- package/template/electron-react/renderer/shared/tools/index.ts +0 -0
- package/template/electron-react/tsconfig.json +33 -0
- package/template/electron-react/tsconfig.node.json +10 -0
- package/template/electron-vue/package.json +2 -2
- package/template/electron-vue/preload/index.ts +1 -1
- package/template/electron-vue/preload/tools.ts +26 -0
- package/template/web-app/react-rsbuild/domain/models/index.ts +1 -0
- package/template/web-app/react-rsbuild/main.tsx +5 -2
- package/template/web-app/react-rsbuild/rsbuild.config.ts +1 -1
- package/template/web-app/react-vite/domain/components/index.ts +1 -0
- package/template/web-app/react-vite/domain/models/app.ts +7 -0
- package/template/web-app/react-vite/domain/models/index.ts +1 -0
- package/template/web-app/react-vite/main.tsx +5 -2
- package/template/electron-vue/configs/clean.ts +0 -10
- package/template/web-app/react-rsbuild/domain/app/startApp.tsx +0 -6
- package/template/web-app/react-vite/domain/app/index.ts +0 -3
- /package/template/{electron-vue/preload/toolr.ts → electron-react/preload/tools.ts} +0 -0
- /package/template/{web-app/react-rsbuild → electron-react/renderer}/domain/app/app.model.ts +0 -0
- /package/template/{web-app/react-rsbuild → electron-react/renderer}/domain/app/components/index.ts +0 -0
- /package/template/{web-app/react-rsbuild → electron-react/renderer}/domain/app/index.ts +0 -0
- /package/template/web-app/react-rsbuild/domain/{app/components → components}/app-context.tsx +0 -0
- /package/template/web-app/react-rsbuild/domain/{app/components → components}/app.tsx +0 -0
- /package/template/web-app/{react-vite/domain/app → react-rsbuild/domain}/components/index.ts +0 -0
- /package/template/web-app/{react-vite/domain/app/app.model.ts → react-rsbuild/domain/models/app.ts} +0 -0
- /package/template/web-app/react-vite/domain/{app/components → components}/app-context.tsx +0 -0
- /package/template/web-app/react-vite/domain/{app/components → components}/app.tsx +0 -0
package/package.json
CHANGED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# Logs
|
|
2
|
+
logs
|
|
3
|
+
*.log
|
|
4
|
+
npm-debug.log*
|
|
5
|
+
yarn-debug.log*
|
|
6
|
+
yarn-error.log*
|
|
7
|
+
pnpm-debug.log*
|
|
8
|
+
lerna-debug.log*
|
|
9
|
+
|
|
10
|
+
node_modules
|
|
11
|
+
dist
|
|
12
|
+
build
|
|
13
|
+
dist-ssr
|
|
14
|
+
*.local
|
|
15
|
+
stats.html
|
|
16
|
+
vite.config.ts.*
|
|
17
|
+
|
|
18
|
+
# Editor directories and files
|
|
19
|
+
.vscode/*
|
|
20
|
+
!.vscode/extensions.json
|
|
21
|
+
.history
|
|
22
|
+
.idea
|
|
23
|
+
.DS_Store
|
|
24
|
+
*.suo
|
|
25
|
+
*.ntvs*
|
|
26
|
+
*.njsproj
|
|
27
|
+
*.sln
|
|
28
|
+
*.sw?
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"overrides": [
|
|
3
|
+
{
|
|
4
|
+
"files": ".prettierrc",
|
|
5
|
+
"options": { "parser": "json" }
|
|
6
|
+
}
|
|
7
|
+
],
|
|
8
|
+
"printWidth": 100,
|
|
9
|
+
"tabWidth": 4,
|
|
10
|
+
"useTabs": false,
|
|
11
|
+
"semi": false,
|
|
12
|
+
"singleQuote": true,
|
|
13
|
+
"trailingComma": "none",
|
|
14
|
+
"bracketSpacing": true,
|
|
15
|
+
"bracketSameLine": false,
|
|
16
|
+
"arrowParens": "avoid",
|
|
17
|
+
"rangeStart": 0
|
|
18
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "stylelint-config-standard-scss",
|
|
3
|
+
"overrides": [
|
|
4
|
+
{
|
|
5
|
+
"files": ["*.html", "**/*.html", "*.vue", "**/*.vue"],
|
|
6
|
+
"customSyntax": "postcss-html"
|
|
7
|
+
}
|
|
8
|
+
],
|
|
9
|
+
"rules": {
|
|
10
|
+
"comment-empty-line-before": "never",
|
|
11
|
+
"no-empty-source": null,
|
|
12
|
+
"alpha-value-notation": null,
|
|
13
|
+
"color-function-notation": null,
|
|
14
|
+
"at-rule-no-unknown": [
|
|
15
|
+
true,
|
|
16
|
+
{
|
|
17
|
+
"ignoreAtRules": ["tailwind", "apply", "use", "reference"]
|
|
18
|
+
}
|
|
19
|
+
],
|
|
20
|
+
"declaration-block-no-redundant-longhand-properties": null,
|
|
21
|
+
"selector-pseudo-class-no-unknown": [
|
|
22
|
+
true,
|
|
23
|
+
{
|
|
24
|
+
"ignorePseudoClasses": ["global"]
|
|
25
|
+
}
|
|
26
|
+
],
|
|
27
|
+
"selector-class-pattern": null,
|
|
28
|
+
"scss/at-rule-no-unknown": [
|
|
29
|
+
true,
|
|
30
|
+
{
|
|
31
|
+
"ignoreAtRules": ["tailwind", "apply", "reference"]
|
|
32
|
+
}
|
|
33
|
+
]
|
|
34
|
+
}
|
|
35
|
+
}
|
|
Binary file
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"productName": "ElectronReact",
|
|
3
|
+
"appId": "org.erb.ElectronReact",
|
|
4
|
+
"asar": false,
|
|
5
|
+
"files": ["dist"],
|
|
6
|
+
"mac": {
|
|
7
|
+
"target": {
|
|
8
|
+
"target": "default",
|
|
9
|
+
"arch": ["arm64", "x64"]
|
|
10
|
+
},
|
|
11
|
+
"hardenedRuntime": true,
|
|
12
|
+
"gatekeeperAssess": true
|
|
13
|
+
},
|
|
14
|
+
"dmg": {
|
|
15
|
+
"contents": [
|
|
16
|
+
{
|
|
17
|
+
"x": 130,
|
|
18
|
+
"y": 220
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"x": 410,
|
|
22
|
+
"y": 220,
|
|
23
|
+
"type": "link",
|
|
24
|
+
"path": "/Applications"
|
|
25
|
+
}
|
|
26
|
+
]
|
|
27
|
+
},
|
|
28
|
+
"win": {
|
|
29
|
+
"target": ["nsis"]
|
|
30
|
+
},
|
|
31
|
+
"linux": {
|
|
32
|
+
"target": ["AppImage"],
|
|
33
|
+
"category": "Development"
|
|
34
|
+
},
|
|
35
|
+
"directories": {
|
|
36
|
+
"buildResources": "dist",
|
|
37
|
+
"output": "build"
|
|
38
|
+
},
|
|
39
|
+
"extraResources": ["./assets/**"]
|
|
40
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = { extends: ['@commitlint/config-conventional'] }
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ConfigParams } from '@rsbuild/core'
|
|
2
|
+
import { pluginEslint } from '@rsbuild/plugin-eslint'
|
|
3
|
+
import StylelintWebpackPlugin from 'stylelint-webpack-plugin'
|
|
4
|
+
import { pluginTypeCheck } from '@rsbuild/plugin-type-check'
|
|
5
|
+
import { RsdoctorRspackPlugin } from '@rsdoctor/rspack-plugin'
|
|
6
|
+
|
|
7
|
+
export function createPlugins({ command }: Pick<ConfigParams, 'command'>) {
|
|
8
|
+
return {
|
|
9
|
+
plugins: [
|
|
10
|
+
command !== 'build' && pluginTypeCheck(),
|
|
11
|
+
command !== 'build' &&
|
|
12
|
+
pluginEslint({
|
|
13
|
+
eslintPluginOptions: {
|
|
14
|
+
configType: 'flat'
|
|
15
|
+
}
|
|
16
|
+
})
|
|
17
|
+
],
|
|
18
|
+
rspackPlugin: [
|
|
19
|
+
new StylelintWebpackPlugin(),
|
|
20
|
+
process.env.RSDOCTOR && new RsdoctorRspackPlugin()
|
|
21
|
+
]
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export const OUTPUT_ROOT = 'dist'
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { SplitChunks } from '@rsbuild/core'
|
|
2
|
+
|
|
3
|
+
export function createChunks(
|
|
4
|
+
chunks: Array<{ name: string; libs: string[] | RegExp; priority?: number }>
|
|
5
|
+
) {
|
|
6
|
+
const result: Exclude<SplitChunks, false>['cacheGroups'] = {
|
|
7
|
+
vendors: {
|
|
8
|
+
test: /[\\/]node_modules[\\/]/,
|
|
9
|
+
chunks: 'all',
|
|
10
|
+
name: 'vendors',
|
|
11
|
+
priority: -1
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
chunks.forEach(({ name, libs, priority }) => {
|
|
15
|
+
result[name] = {
|
|
16
|
+
test: Array.isArray(libs)
|
|
17
|
+
? new RegExp(`[\\\\/]node_modules[\\\\/](${libs.join('|')})[\\\\/]`)
|
|
18
|
+
: libs,
|
|
19
|
+
chunks: 'all',
|
|
20
|
+
name,
|
|
21
|
+
priority
|
|
22
|
+
}
|
|
23
|
+
return result
|
|
24
|
+
})
|
|
25
|
+
return result
|
|
26
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { defineConfig, loadEnv } from '@rsbuild/core'
|
|
2
|
+
import { createPlugins, OUTPUT_ROOT } from './config'
|
|
3
|
+
|
|
4
|
+
export default defineConfig(({ envMode, command }) => {
|
|
5
|
+
const { parsed: env } = loadEnv()
|
|
6
|
+
const { rspackPlugin, plugins } = createPlugins({ command })
|
|
7
|
+
return {
|
|
8
|
+
source: {
|
|
9
|
+
entry: {
|
|
10
|
+
main: './main/main.ts'
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
resolve: {
|
|
14
|
+
alias: {
|
|
15
|
+
'@': process.cwd()
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
output: {
|
|
19
|
+
distPath: { root: `${OUTPUT_ROOT}/main`, js: '' },
|
|
20
|
+
cleanDistPath: false,
|
|
21
|
+
filenameHash: false
|
|
22
|
+
},
|
|
23
|
+
dev: {
|
|
24
|
+
progressBar: command === 'build',
|
|
25
|
+
writeToDisk: true,
|
|
26
|
+
hmr: false,
|
|
27
|
+
liveReload: false
|
|
28
|
+
},
|
|
29
|
+
tools: {
|
|
30
|
+
htmlPlugin: false,
|
|
31
|
+
rspack: {
|
|
32
|
+
target: 'electron-main',
|
|
33
|
+
plugins: rspackPlugin
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
plugins,
|
|
37
|
+
performance: {
|
|
38
|
+
removeConsole: command === 'build' ? ['log'] : false,
|
|
39
|
+
bundleAnalyze: envMode === 'analyse' ? { openAnalyzer: true } : void 0
|
|
40
|
+
},
|
|
41
|
+
server: {
|
|
42
|
+
base: env.PUBLIC_BASE_URL,
|
|
43
|
+
host: '0.0.0.0',
|
|
44
|
+
port: 3001,
|
|
45
|
+
compress: false,
|
|
46
|
+
proxy: [
|
|
47
|
+
{
|
|
48
|
+
context: [env.PUBLIC_API_HOST],
|
|
49
|
+
target: 'http://127.0.0.1:3000'
|
|
50
|
+
}
|
|
51
|
+
]
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
})
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { defineConfig, loadEnv } from '@rsbuild/core'
|
|
2
|
+
import { createPlugins, OUTPUT_ROOT } from './config'
|
|
3
|
+
|
|
4
|
+
export default defineConfig(({ envMode, command }) => {
|
|
5
|
+
const { parsed: env } = loadEnv()
|
|
6
|
+
const { rspackPlugin, plugins } = createPlugins({ command })
|
|
7
|
+
return {
|
|
8
|
+
source: {
|
|
9
|
+
entry: {
|
|
10
|
+
preload: './preload/index.ts'
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
resolve: {
|
|
14
|
+
alias: {
|
|
15
|
+
'@': process.cwd()
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
output: {
|
|
19
|
+
distPath: { root: OUTPUT_ROOT, js: '' },
|
|
20
|
+
cleanDistPath: false,
|
|
21
|
+
filenameHash: false
|
|
22
|
+
},
|
|
23
|
+
dev: {
|
|
24
|
+
progressBar: command === 'build',
|
|
25
|
+
writeToDisk: true,
|
|
26
|
+
hmr: false,
|
|
27
|
+
liveReload: false
|
|
28
|
+
},
|
|
29
|
+
tools: {
|
|
30
|
+
htmlPlugin: false,
|
|
31
|
+
rspack: {
|
|
32
|
+
target: 'electron-preload',
|
|
33
|
+
plugins: rspackPlugin
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
plugins,
|
|
37
|
+
performance: {
|
|
38
|
+
removeConsole: command === 'build' ? ['log'] : false,
|
|
39
|
+
bundleAnalyze: envMode === 'analyse' ? { openAnalyzer: true } : void 0
|
|
40
|
+
},
|
|
41
|
+
server: {
|
|
42
|
+
base: env.PUBLIC_BASE_URL,
|
|
43
|
+
host: '0.0.0.0',
|
|
44
|
+
port: 3002,
|
|
45
|
+
compress: false,
|
|
46
|
+
proxy: [
|
|
47
|
+
{
|
|
48
|
+
context: [env.PUBLIC_API_HOST],
|
|
49
|
+
target: 'http://127.0.0.1:3000'
|
|
50
|
+
}
|
|
51
|
+
]
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
})
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import path from 'node:path'
|
|
2
|
+
import { defineConfig, loadEnv } from '@rsbuild/core'
|
|
3
|
+
import { pluginReact } from '@rsbuild/plugin-react'
|
|
4
|
+
import { pluginSvgr } from '@rsbuild/plugin-svgr'
|
|
5
|
+
import { createChunks } from './createChunks'
|
|
6
|
+
import { createPlugins, OUTPUT_ROOT } from './config'
|
|
7
|
+
|
|
8
|
+
export default defineConfig(({ envMode, command }) => {
|
|
9
|
+
const { parsed: env } = loadEnv()
|
|
10
|
+
const { rspackPlugin, plugins } = createPlugins({ command })
|
|
11
|
+
const resolveRendererPath = (p: string) => path.resolve('renderer', p)
|
|
12
|
+
return {
|
|
13
|
+
html: {
|
|
14
|
+
template: resolveRendererPath('index.html'),
|
|
15
|
+
title: 'Rsbuild + Vue + TS',
|
|
16
|
+
favicon: resolveRendererPath('shared/assets/react.svg')
|
|
17
|
+
},
|
|
18
|
+
source: {
|
|
19
|
+
entry: {
|
|
20
|
+
index: resolveRendererPath('main.ts')
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
resolve: {
|
|
24
|
+
alias: {
|
|
25
|
+
'@': process.cwd()
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
output: {
|
|
29
|
+
distPath: { root: `${OUTPUT_ROOT}/renderer` },
|
|
30
|
+
assetPrefix: './',
|
|
31
|
+
cleanDistPath: false
|
|
32
|
+
},
|
|
33
|
+
dev: {
|
|
34
|
+
progressBar: command === 'build'
|
|
35
|
+
},
|
|
36
|
+
tools: {
|
|
37
|
+
rspack: {
|
|
38
|
+
plugins: rspackPlugin
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
plugins: [
|
|
42
|
+
...plugins,
|
|
43
|
+
pluginSvgr(),
|
|
44
|
+
pluginReact({
|
|
45
|
+
swcReactOptions: {
|
|
46
|
+
importSource: '@emotion/react'
|
|
47
|
+
}
|
|
48
|
+
})
|
|
49
|
+
],
|
|
50
|
+
performance: {
|
|
51
|
+
removeConsole: command === 'build' ? ['log'] : false,
|
|
52
|
+
chunkSplit: {
|
|
53
|
+
strategy: 'custom',
|
|
54
|
+
splitChunks: {
|
|
55
|
+
minChunks: 1,
|
|
56
|
+
cacheGroups: createChunks([{ libs: ['vue', 'vue-router'], name: 'vue' }])
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
bundleAnalyze: envMode === 'analyse' ? { openAnalyzer: true } : void 0
|
|
60
|
+
},
|
|
61
|
+
server: {
|
|
62
|
+
base: env.PUBLIC_BASE_URL,
|
|
63
|
+
host: '0.0.0.0',
|
|
64
|
+
compress: false,
|
|
65
|
+
proxy: [
|
|
66
|
+
{
|
|
67
|
+
context: [env.PUBLIC_API_HOST],
|
|
68
|
+
target: 'http://127.0.0.1:3000'
|
|
69
|
+
}
|
|
70
|
+
]
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
})
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/// <reference types="@rsbuild/core/types" />
|
|
2
|
+
|
|
3
|
+
interface ImportMetaEnv {
|
|
4
|
+
readonly PUBLIC_BASE_URL: string
|
|
5
|
+
readonly PUBLIC_API_HOST: string
|
|
6
|
+
readonly PUBLIC_ENV_MODE: 'production' | 'development'
|
|
7
|
+
// 更多环境变量...
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
interface ImportMeta {
|
|
11
|
+
readonly env: ImportMetaEnv
|
|
12
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import eslint from '@eslint/js'
|
|
2
|
+
import globals from 'globals'
|
|
3
|
+
import tseslint from 'typescript-eslint'
|
|
4
|
+
import importPlugin from 'eslint-plugin-import'
|
|
5
|
+
import reactPlugin from 'eslint-plugin-react'
|
|
6
|
+
import reactHooksPlugin from 'eslint-plugin-react-hooks'
|
|
7
|
+
|
|
8
|
+
const scriptExtensions = ['js', 'jsx', 'mjs', 'cjs', 'ts', 'tsx']
|
|
9
|
+
const files = scriptExtensions.map(ext => `**/*.${ext}`)
|
|
10
|
+
|
|
11
|
+
export default tseslint.config([
|
|
12
|
+
{
|
|
13
|
+
ignores: ['**/node_modules/', '**/dist/', '**/.history/', '**/.vscode/']
|
|
14
|
+
},
|
|
15
|
+
eslint.configs.recommended,
|
|
16
|
+
importPlugin.flatConfigs.recommended,
|
|
17
|
+
tseslint.configs.recommended,
|
|
18
|
+
{
|
|
19
|
+
plugins: { reactPlugin, reactHooksPlugin },
|
|
20
|
+
files,
|
|
21
|
+
languageOptions: {
|
|
22
|
+
ecmaVersion: 2018,
|
|
23
|
+
sourceType: 'module',
|
|
24
|
+
parserOptions: {
|
|
25
|
+
ecmaFeatures: {
|
|
26
|
+
jsx: true
|
|
27
|
+
},
|
|
28
|
+
useJSXTextNode: true
|
|
29
|
+
},
|
|
30
|
+
globals: {
|
|
31
|
+
...globals.browser,
|
|
32
|
+
...globals.node
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
settings: {
|
|
36
|
+
'import/resolver': {
|
|
37
|
+
typescript: true,
|
|
38
|
+
node: true
|
|
39
|
+
},
|
|
40
|
+
react: {
|
|
41
|
+
version: '18'
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
rules: {
|
|
45
|
+
'import/export': 'off',
|
|
46
|
+
'import/namespace': 'off',
|
|
47
|
+
'import/default': 'off',
|
|
48
|
+
'import/consistent-type-specifier-style': ['error', 'prefer-inline'],
|
|
49
|
+
'import/no-duplicates': ['error', { 'prefer-inline': true }],
|
|
50
|
+
'import/no-named-as-default-member': 'off',
|
|
51
|
+
'import/no-named-as-default': 'off',
|
|
52
|
+
'import/order': [
|
|
53
|
+
'error',
|
|
54
|
+
{
|
|
55
|
+
groups: [
|
|
56
|
+
'builtin',
|
|
57
|
+
'external',
|
|
58
|
+
'internal',
|
|
59
|
+
'parent',
|
|
60
|
+
'sibling',
|
|
61
|
+
'index',
|
|
62
|
+
'object',
|
|
63
|
+
'type'
|
|
64
|
+
],
|
|
65
|
+
pathGroups: [
|
|
66
|
+
{ pattern: 'react', group: 'external', position: 'before' },
|
|
67
|
+
{ pattern: 'react-dom/*', group: 'external', position: 'before' },
|
|
68
|
+
{ pattern: 'react-router', group: 'external', position: 'before' },
|
|
69
|
+
{ pattern: 'react-router-dom', group: 'external', position: 'before' }
|
|
70
|
+
],
|
|
71
|
+
pathGroupsExcludedImportTypes: ['builtin']
|
|
72
|
+
}
|
|
73
|
+
],
|
|
74
|
+
'no-case-declarations': 'off',
|
|
75
|
+
'@typescript-eslint/no-unused-expressions': 'off',
|
|
76
|
+
'@typescript-eslint/no-empty-object-type': 'off',
|
|
77
|
+
'@typescript-eslint/no-var-requires': 0,
|
|
78
|
+
'@typescript-eslint/explicit-function-return-type': 'off',
|
|
79
|
+
'@typescript-eslint/no-explicit-any': 0,
|
|
80
|
+
'@typescript-eslint/no-non-null-assertion': 'off',
|
|
81
|
+
'@typescript-eslint/no-inferrable-types': [
|
|
82
|
+
'warn',
|
|
83
|
+
{
|
|
84
|
+
ignoreParameters: true
|
|
85
|
+
}
|
|
86
|
+
],
|
|
87
|
+
'@typescript-eslint/no-unused-vars': [
|
|
88
|
+
'warn',
|
|
89
|
+
{
|
|
90
|
+
argsIgnorePattern: '^_'
|
|
91
|
+
}
|
|
92
|
+
],
|
|
93
|
+
'@typescript-eslint/member-delimiter-style': 0,
|
|
94
|
+
'@typescript-eslint/class-name-casing': 0,
|
|
95
|
+
'@typescript-eslint/explicit-module-boundary-types': 'off',
|
|
96
|
+
'@typescript-eslint/ban-ts-comment': 'off',
|
|
97
|
+
'@typescript-eslint/no-empty-interface': 'off',
|
|
98
|
+
'@typescript-eslint/triple-slash-reference': 'off',
|
|
99
|
+
'@typescript-eslint/no-require-imports': "off",
|
|
100
|
+
'react/prop-types': 'off',
|
|
101
|
+
'react/no-find-dom-node': 'off',
|
|
102
|
+
'react-hooks/exhaustive-deps': 'off',
|
|
103
|
+
'react/display-name': 'off',
|
|
104
|
+
'react/react-in-jsx-scope': 'off',
|
|
105
|
+
'no-constant-condition': 'off'
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
])
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import path from 'path'
|
|
2
|
+
import { app, BrowserWindow, shell, ipcMain } from 'electron'
|
|
3
|
+
import { resolveHtmlPath } from './tools'
|
|
4
|
+
|
|
5
|
+
let mainWindow: BrowserWindow | null = null
|
|
6
|
+
|
|
7
|
+
ipcMain.on('ipc-example', async (event, arg) => {
|
|
8
|
+
const msgTemplate = (pingPong: string) => `IPC test: ${pingPong}`
|
|
9
|
+
console.log(msgTemplate(arg))
|
|
10
|
+
event.reply('ipc-example', msgTemplate('pong'))
|
|
11
|
+
})
|
|
12
|
+
|
|
13
|
+
const isDebug = process.env.NODE_ENV === 'development' || process.env.DEBUG_PROD === 'true'
|
|
14
|
+
|
|
15
|
+
if (true) {
|
|
16
|
+
require('electron-debug').default()
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const createWindow = async () => {
|
|
20
|
+
const RESOURCES_PATH = app.isPackaged
|
|
21
|
+
? path.join(process.resourcesPath, 'assets')
|
|
22
|
+
: path.join(__dirname, '../../assets')
|
|
23
|
+
|
|
24
|
+
const getAssetPath = (...paths: string[]): string => {
|
|
25
|
+
return path.join(RESOURCES_PATH, ...paths)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
mainWindow = new BrowserWindow({
|
|
29
|
+
show: false,
|
|
30
|
+
width: 1024,
|
|
31
|
+
height: 728,
|
|
32
|
+
icon: getAssetPath('icon.png'),
|
|
33
|
+
webPreferences: {
|
|
34
|
+
preload: path.join(__dirname, '../preload.js')
|
|
35
|
+
}
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
mainWindow.loadURL(resolveHtmlPath('index.html'))
|
|
39
|
+
|
|
40
|
+
mainWindow.on('ready-to-show', () => {
|
|
41
|
+
if (!mainWindow) {
|
|
42
|
+
throw new Error('"mainWindow" is not defined')
|
|
43
|
+
}
|
|
44
|
+
if (process.env.START_MINIMIZED) {
|
|
45
|
+
mainWindow.minimize()
|
|
46
|
+
} else {
|
|
47
|
+
mainWindow.show()
|
|
48
|
+
}
|
|
49
|
+
})
|
|
50
|
+
|
|
51
|
+
mainWindow.on('closed', () => {
|
|
52
|
+
mainWindow = null
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
// Open urls in the user's browser
|
|
56
|
+
mainWindow.webContents.setWindowOpenHandler(edata => {
|
|
57
|
+
shell.openExternal(edata.url)
|
|
58
|
+
return { action: 'deny' }
|
|
59
|
+
})
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Add event listeners...
|
|
64
|
+
*/
|
|
65
|
+
|
|
66
|
+
app.on('window-all-closed', () => {
|
|
67
|
+
// Respect the OSX convention of having the application in memory even
|
|
68
|
+
// after all windows have been closed
|
|
69
|
+
if (process.platform !== 'darwin') {
|
|
70
|
+
app.quit()
|
|
71
|
+
}
|
|
72
|
+
})
|
|
73
|
+
|
|
74
|
+
app.whenReady()
|
|
75
|
+
.then(() => {
|
|
76
|
+
createWindow()
|
|
77
|
+
app.on('activate', () => {
|
|
78
|
+
// On macOS it's common to re-create a window in the app when the
|
|
79
|
+
// dock icon is clicked and there are no other windows open.
|
|
80
|
+
if (mainWindow === null) createWindow()
|
|
81
|
+
})
|
|
82
|
+
})
|
|
83
|
+
.catch(console.log)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './html'
|