@tomjs/create-app 1.7.0 → 2.0.0
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/README.md +1 -1
- package/README.zh_CN.md +1 -1
- package/dist/index.js +10 -22
- package/package.json +48 -51
- package/templates/{base/core → config/base}/.editorconfig +0 -4
- package/templates/config/base/.vscode/settings.json +50 -0
- package/templates/{base/core/_gitignore → config/base/_.gitignore} +1 -3
- package/templates/config/base/_commitlint.config.mjs +3 -0
- package/templates/config/base/_eslint.config.mjs +8 -0
- package/templates/config/base/lint-staged.config.mjs +3 -0
- package/templates/config/base/package.json +24 -0
- package/templates/config/base/pnpm-workspace.yaml +3 -0
- package/templates/config/base/simple-git-hooks.mjs +4 -0
- package/templates/{vscode → config/public}/LICENSE +1 -1
- package/templates/config/public/README.md +20 -0
- package/templates/config/public/README.zh_CN.md +20 -0
- package/templates/config/public/package.json +10 -0
- package/templates/config/style/lint-staged.config.mjs +7 -0
- package/templates/config/style/package.json +12 -0
- package/templates/config/style/stylelint.config.mjs +3 -0
- package/templates/{base/electron → electron-react}/.vscode/launch.json +23 -3
- package/templates/electron-react/.vscode/tasks.json +67 -0
- package/templates/electron-react/README.md +1 -1
- package/templates/electron-react/_eslint.config.mjs +8 -0
- package/templates/electron-react/electron/main/index.ts +71 -40
- package/templates/electron-react/electron/preload/index.ts +4 -0
- package/templates/electron-react/index.html +1 -2
- package/templates/electron-react/package.json +35 -1
- package/templates/electron-react/pnpm-workspace.yaml +6 -0
- package/templates/electron-react/src/App.css +6 -2
- package/templates/electron-react/src/App.tsx +12 -5
- package/templates/electron-react/src/index.css +14 -9
- package/templates/electron-react/tsconfig.json +9 -0
- package/templates/{base/electron → electron-react}/tsconfig.node.json +1 -1
- package/templates/electron-react/vite.config.ts +9 -22
- package/templates/electron-vue/.vscode/launch.json +48 -0
- package/templates/electron-vue/.vscode/tasks.json +67 -0
- package/templates/electron-vue/README.md +1 -1
- package/templates/electron-vue/_eslint.config.mjs +8 -0
- package/templates/electron-vue/electron/env.d.ts +1 -0
- package/templates/electron-vue/electron/main/index.ts +46 -30
- package/templates/electron-vue/electron/preload/index.ts +4 -0
- package/templates/electron-vue/index.html +1 -2
- package/templates/electron-vue/package.json +31 -2
- package/templates/electron-vue/pnpm-workspace.yaml +5 -0
- package/templates/electron-vue/src/App.vue +1 -1
- package/templates/electron-vue/src/style.css +15 -10
- package/templates/electron-vue/tsconfig.json +5 -0
- package/templates/electron-vue/tsconfig.node.json +7 -0
- package/templates/electron-vue/vite.config.ts +3 -21
- package/templates/{node-cli-legacy → node-base}/.vscode/launch.json +3 -6
- package/templates/node-base/package.json +15 -0
- package/templates/node-base/src/index.ts +5 -0
- package/templates/{node-cli-legacy → node-base}/tsconfig.json +1 -1
- package/templates/node-cli/.vscode/i18n-ally-custom-framework.yml +35 -0
- package/templates/node-cli/.vscode/launch.json +3 -6
- package/templates/node-cli/.vscode/settings.json +56 -0
- package/templates/node-cli/_.gitignore +59 -0
- package/templates/node-cli/locales/en-US.json +11 -0
- package/templates/node-cli/locales/zh-Hans.json +11 -0
- package/templates/node-cli/locales/zh-Hant.json +11 -0
- package/templates/node-cli/package.json +20 -20
- package/templates/node-cli/src/app.ts +19 -0
- package/templates/node-cli/src/config.ts +2 -2
- package/templates/node-cli/src/index.ts +77 -1
- package/templates/node-cli/src/types.ts +5 -1
- package/templates/node-cli/src/utils/exec.ts +68 -0
- package/templates/node-cli/src/utils/index.ts +3 -0
- package/templates/node-cli/src/utils/lang.ts +104 -0
- package/templates/node-cli/src/utils/util.ts +20 -0
- package/templates/node-cli/tsconfig.json +2 -2
- package/templates/node-cli/{tsup.config.ts → tsdown.config.ts} +3 -4
- package/templates/node-vite/examples/react/README.md +1 -0
- package/templates/node-vite/examples/react/_eslint.config.mjs +6 -0
- package/templates/{react → node-vite/examples/react}/index.html +1 -2
- package/templates/node-vite/examples/react/package.json +27 -0
- package/templates/{react → node-vite/examples/react}/src/App.css +5 -2
- package/templates/{react → node-vite/examples/react}/src/App.tsx +8 -9
- package/templates/{react → node-vite/examples/react}/src/index.css +15 -11
- package/templates/node-vite/examples/react/src/main.tsx +10 -0
- package/templates/node-vite/examples/react/tsconfig.json +5 -0
- package/templates/node-vite/examples/react/vite.config.ts +14 -0
- package/templates/node-vite/examples/vue/README.md +1 -0
- package/templates/node-vite/examples/vue/_eslint.config.mjs +6 -0
- package/templates/{vue → node-vite/examples/vue}/index.html +1 -2
- package/templates/node-vite/examples/vue/package.json +22 -0
- package/templates/{vue → node-vite/examples/vue}/src/App.vue +3 -3
- package/templates/node-vite/examples/vue/src/components/HelloWorld.vue +19 -0
- package/templates/{vue → node-vite/examples/vue}/src/main.ts +0 -1
- package/templates/{vue → node-vite/examples/vue}/src/style.css +16 -12
- package/templates/{base → node-vite/examples}/vue/tsconfig.json +2 -2
- package/templates/{vue → node-vite/examples/vue}/vite.config.ts +1 -1
- package/templates/node-vite/package.json +16 -0
- package/templates/node-vite/pnpm-lock.yaml +2293 -0
- package/templates/node-vite/pnpm-workspace.yaml +6 -0
- package/templates/{node → node-vite}/tsconfig.json +1 -1
- package/templates/{node-cli-legacy/tsup.config.ts → node-vite/tsdown.config.ts} +4 -5
- package/templates/vscode-base/.vscode/settings.json +59 -0
- package/templates/{vscode → vscode-base}/.vscode/tasks.json +2 -2
- package/templates/{base/node → vscode-base}/LICENSE +1 -1
- package/templates/{vscode/_gitignore → vscode-base/_.gitignore} +1 -0
- package/templates/vscode-base/locales/zh-CN.json +6 -0
- package/templates/{vscode → vscode-base}/package.json +12 -19
- package/templates/vscode-base/resources/logo.png +0 -0
- package/templates/vscode-base/resources/logo.svg +1 -0
- package/templates/{vscode/tsup.config.ts → vscode-base/tsdown.config.ts} +3 -3
- package/templates/{base/vscode → vscode-react}/.vscode/launch.json +14 -1
- package/templates/vscode-react/.vscode/settings.json +59 -0
- package/templates/{base/vscode → vscode-react}/.vscode/tasks.json +10 -1
- package/templates/{base/vscode → vscode-react}/LICENSE +1 -1
- package/templates/vscode-react/README.md +2 -2
- package/templates/{base/vscode/_gitignore → vscode-react/_.gitignore} +2 -1
- package/templates/{base/vscode → vscode-react}/extension/views/helper.ts +5 -4
- package/templates/{base/vscode → vscode-react}/extension/views/panel.ts +2 -1
- package/templates/vscode-react/package.json +65 -1
- package/templates/vscode-react/pnpm-workspace.yaml +5 -0
- package/templates/vscode-react/src/App.css +1 -1
- package/templates/vscode-react/src/App.tsx +16 -10
- package/templates/vscode-react/src/utils/vscode.ts +2 -81
- package/templates/vscode-react/src/vite-env.d.ts +1 -0
- package/templates/vscode-react/tsconfig.json +5 -0
- package/templates/vscode-react/vite.config.ts +4 -5
- package/templates/vscode-vue/.vscode/extensions.json +5 -0
- package/templates/vscode-vue/.vscode/launch.json +34 -0
- package/templates/vscode-vue/.vscode/settings.json +59 -0
- package/templates/{base/electron → vscode-vue}/.vscode/tasks.json +14 -6
- package/templates/vscode-vue/.vscodeignore +73 -0
- package/templates/vscode-vue/LICENSE +21 -0
- package/templates/vscode-vue/README.md +2 -2
- package/templates/vscode-vue/_.gitignore +65 -0
- package/templates/vscode-vue/extension/env.d.ts +1 -0
- package/templates/vscode-vue/extension/index.ts +21 -0
- package/templates/vscode-vue/extension/views/helper.ts +28 -0
- package/templates/vscode-vue/extension/views/panel.ts +49 -0
- package/templates/vscode-vue/locales/en.json +6 -0
- package/templates/vscode-vue/package.json +56 -2
- package/templates/vscode-vue/pnpm-workspace.yaml +4 -0
- package/templates/vscode-vue/src/App.vue +17 -11
- package/templates/vscode-vue/src/utils/vscode.ts +2 -81
- package/templates/vscode-vue/src/vite-env.d.ts +1 -0
- package/templates/vscode-vue/tsconfig.json +5 -0
- package/templates/vscode-vue/tsconfig.node.json +7 -0
- package/templates/vscode-vue/vite.config.ts +0 -4
- package/templates/web-react/README.md +1 -0
- package/templates/web-react/_eslint.config.mjs +6 -0
- package/templates/web-react/index.html +13 -0
- package/templates/web-react/package.json +27 -0
- package/templates/web-react/public/vite.svg +1 -0
- package/templates/web-react/src/App.css +45 -0
- package/templates/web-react/src/App.tsx +31 -0
- package/templates/web-react/src/assets/react.svg +1 -0
- package/templates/web-react/src/index.css +73 -0
- package/templates/web-react/src/main.tsx +10 -0
- package/templates/web-react/tsconfig.app.json +28 -0
- package/templates/web-react/tsconfig.json +7 -0
- package/templates/web-react/tsconfig.node.json +26 -0
- package/templates/web-react/vite.config.ts +14 -0
- package/templates/web-vue/README.md +1 -0
- package/templates/web-vue/_eslint.config.mjs +6 -0
- package/templates/web-vue/index.html +13 -0
- package/templates/web-vue/package.json +22 -0
- package/templates/web-vue/public/vite.svg +1 -0
- package/templates/web-vue/src/App.vue +32 -0
- package/templates/web-vue/src/assets/vue.svg +1 -0
- package/templates/web-vue/src/components/HelloWorld.vue +19 -0
- package/templates/web-vue/src/main.ts +5 -0
- package/templates/web-vue/src/style.css +84 -0
- package/templates/web-vue/tsconfig.app.json +4 -0
- package/templates/web-vue/tsconfig.json +7 -0
- package/templates/web-vue/tsconfig.node.json +7 -0
- package/templates/web-vue/vite.config.ts +7 -0
- package/templates/base/core/.commitlintrc.cjs +0 -3
- package/templates/base/core/.eslintignore +0 -14
- package/templates/base/core/.husky/commit-msg +0 -1
- package/templates/base/core/.husky/pre-commit +0 -1
- package/templates/base/core/.prettierignore +0 -17
- package/templates/base/core/.prettierrc.cjs +0 -1
- package/templates/base/core/_eslintrc.cjs +0 -7
- package/templates/base/core/_lintstagedrc.cjs +0 -4
- package/templates/base/core/package.json +0 -31
- package/templates/base/electron/electron/main/index.ts +0 -111
- package/templates/base/electron/electron/polyfills.ts +0 -4
- package/templates/base/electron/electron/preload/index.ts +0 -1
- package/templates/base/electron/package.json +0 -25
- package/templates/base/node/README.md +0 -13
- package/templates/base/node/README.zh_CN.md +0 -13
- package/templates/base/node/package.json +0 -48
- package/templates/base/node/test/index.test.ts +0 -7
- package/templates/base/package/package.json +0 -8
- package/templates/base/react/_eslintrc.cjs +0 -7
- package/templates/base/react/_lintstagedrc.cjs +0 -6
- package/templates/base/react/package.json +0 -19
- package/templates/base/react/tsconfig.json +0 -5
- package/templates/base/style/.stylelintignore +0 -16
- package/templates/base/style/.stylelintrc.cjs +0 -3
- package/templates/base/style/_lintstagedrc.cjs +0 -5
- package/templates/base/style/package.json +0 -10
- package/templates/base/vscode/.vscode/settings.json +0 -10
- package/templates/base/vscode/package.json +0 -67
- package/templates/base/vue/_eslintrc.cjs +0 -7
- package/templates/base/vue/_lintstagedrc.cjs +0 -6
- package/templates/base/vue/package.json +0 -17
- package/templates/config.json +0 -108
- package/templates/electron-react/public/img/icon.png +0 -0
- package/templates/electron-vue/public/img/icon.png +0 -0
- package/templates/node/package.json +0 -10
- package/templates/node/src/index.ts +0 -3
- package/templates/node/tsup.config.ts +0 -19
- package/templates/node-cli/index.d.ts +0 -5
- package/templates/node-cli/src/cli.ts +0 -68
- package/templates/node-cli/xxx.config.cjs +0 -0
- package/templates/node-cli-legacy/index.d.ts +0 -5
- package/templates/node-cli-legacy/package.json +0 -30
- package/templates/node-cli-legacy/src/cli.ts +0 -45
- package/templates/node-cli-legacy/src/config.ts +0 -28
- package/templates/node-cli-legacy/src/index.ts +0 -3
- package/templates/node-cli-legacy/src/types.ts +0 -1
- package/templates/node-cli-legacy/src/utils.ts +0 -5
- package/templates/node-vite-plugin/package.json +0 -18
- package/templates/node-vite-plugin/test/index.test.ts +0 -7
- package/templates/node-vite-plugin/tsconfig.json +0 -4
- package/templates/node-vite-plugin/tsup.config.ts +0 -18
- package/templates/node-workspaces/package.json +0 -8
- package/templates/react/package.json +0 -12
- package/templates/react/src/main.tsx +0 -11
- package/templates/react/src/vite-env.d.ts +0 -1
- package/templates/react/vite.config.ts +0 -7
- package/templates/schema.json +0 -110
- package/templates/vscode/.vscode/settings.json +0 -10
- package/templates/vscode/README.md +0 -3
- package/templates/vue/package.json +0 -12
- package/templates/vue/src/components/HelloWorld.vue +0 -37
- package/templates/vue/src/vite-env.d.ts +0 -1
- package/templates/{base/core → config/base}/.gitattributes +0 -0
- package/templates/{node-cli-legacy/xxx.config.cjs → config/base/README.md} +0 -0
- package/templates/{base/electron → electron-react}/electron/env.d.ts +0 -0
- package/templates/{react → node-vite/examples/react}/public/vite.svg +0 -0
- package/templates/{react → node-vite/examples/react}/src/assets/react.svg +0 -0
- package/templates/{base → node-vite/examples}/react/tsconfig.node.json +0 -0
- package/templates/{vue → node-vite/examples/vue}/public/vite.svg +0 -0
- package/templates/{vue → node-vite/examples/vue}/src/assets/vue.svg +0 -0
- package/templates/{base → node-vite/examples}/vue/tsconfig.node.json +0 -0
- package/templates/{node-vite-plugin → node-vite}/src/index.ts +0 -0
- package/templates/{node-vite-plugin → node-vite}/src/types.ts +0 -0
- package/templates/{base/vscode → vscode-base}/.vscode/extensions.json +0 -0
- package/templates/{vscode → vscode-base}/.vscode/launch.json +0 -0
- package/templates/{vscode → vscode-base}/.vscodeignore +0 -0
- package/templates/{base/vscode → vscode-base}/README.md +0 -0
- package/templates/{vscode → vscode-base}/locales/en.json +0 -0
- package/templates/{vscode → vscode-base}/src/index.ts +1 -1
- package/templates/{vscode → vscode-base}/tsconfig.json +0 -0
- package/templates/{vscode → vscode-react}/.vscode/extensions.json +0 -0
- package/templates/{base/vscode → vscode-react}/.vscodeignore +0 -0
- package/templates/{base/vscode → vscode-react}/extension/env.d.ts +0 -0
- package/templates/{base/vscode → vscode-react}/extension/index.ts +1 -1
- /package/templates/{base/vscode → vscode-react}/locales/en.json +0 -0
- /package/templates/{base/vscode → vscode-react}/locales/zh-CN.json +0 -0
- /package/templates/{base/vscode → vscode-react}/resources/logo.png +0 -0
- /package/templates/{base/vscode → vscode-react}/resources/logo.svg +0 -0
- /package/templates/{base/vscode → vscode-react}/tsconfig.node.json +0 -0
- /package/templates/{vscode → vscode-vue}/locales/zh-CN.json +0 -0
- /package/templates/{vscode → vscode-vue}/resources/logo.png +0 -0
- /package/templates/{vscode → vscode-vue}/resources/logo.svg +0 -0
|
@@ -1,14 +1,20 @@
|
|
|
1
|
-
import '../polyfills';
|
|
2
|
-
|
|
3
1
|
import { release } from 'node:os';
|
|
4
2
|
import { join } from 'node:path';
|
|
3
|
+
import { ELECTRON_EXIT } from '@tomjs/vite-plugin-electron/electron';
|
|
5
4
|
import { app, BrowserWindow, ipcMain, shell } from 'electron';
|
|
6
5
|
|
|
6
|
+
console.log('Electron Main Process!');
|
|
7
|
+
|
|
8
|
+
const isDev = process.env.NODE_ENV === 'development';
|
|
9
|
+
process.env.DIST = join(__dirname, '../renderer');
|
|
10
|
+
|
|
7
11
|
// Disable GPU Acceleration for Windows 7
|
|
8
|
-
if (release().startsWith('6.1'))
|
|
12
|
+
if (release().startsWith('6.1'))
|
|
13
|
+
app.disableHardwareAcceleration();
|
|
9
14
|
|
|
10
15
|
// Set application name for Windows 10+ notifications
|
|
11
|
-
if (process.platform === 'win32')
|
|
16
|
+
if (process.platform === 'win32')
|
|
17
|
+
app.setAppUserModelId(app.getName());
|
|
12
18
|
|
|
13
19
|
if (!app.requestSingleInstanceLock()) {
|
|
14
20
|
app.quit();
|
|
@@ -18,24 +24,19 @@ if (!app.requestSingleInstanceLock()) {
|
|
|
18
24
|
// Remove electron security warnings
|
|
19
25
|
// This warning only shows in development mode
|
|
20
26
|
// Read more on https://www.electronjs.org/docs/latest/tutorial/security
|
|
21
|
-
process.env['ELECTRON_DISABLE_SECURITY_WARNINGS'] = 'true'
|
|
22
|
-
|
|
23
|
-
const isDev = process.env.NODE_ENV === 'development';
|
|
27
|
+
// process.env['ELECTRON_DISABLE_SECURITY_WARNINGS'] = 'true'
|
|
24
28
|
|
|
25
29
|
let win: BrowserWindow | null = null;
|
|
26
|
-
//
|
|
30
|
+
// Here, you can also use other preload
|
|
27
31
|
const preload = join(__dirname, '../preload/index.mjs');
|
|
28
|
-
const
|
|
29
|
-
const
|
|
30
|
-
const indexHtml = join(rendererDist, 'index.html');
|
|
31
|
-
const publicPath = serverUrl ? join(__dirname, '../../public') : rendererDist;
|
|
32
|
+
const url = process.env.VITE_DEV_SERVER_URL as string;
|
|
33
|
+
const indexHtml = join(process.env.DIST, 'index.html');
|
|
32
34
|
|
|
33
|
-
function createWindow() {
|
|
35
|
+
async function createWindow() {
|
|
34
36
|
win = new BrowserWindow({
|
|
35
37
|
title: 'Main window',
|
|
36
38
|
width: 800,
|
|
37
39
|
height: 700,
|
|
38
|
-
icon: join(publicPath, 'img/icon.png'),
|
|
39
40
|
webPreferences: {
|
|
40
41
|
preload,
|
|
41
42
|
// Warning: Enable nodeIntegration and disable contextIsolation is not secure in production
|
|
@@ -47,12 +48,9 @@ function createWindow() {
|
|
|
47
48
|
});
|
|
48
49
|
|
|
49
50
|
if (isDev) {
|
|
50
|
-
win.loadURL(
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
win?.webContents.openDevTools();
|
|
54
|
-
}, 500);
|
|
55
|
-
} else {
|
|
51
|
+
win.loadURL(url);
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
56
54
|
win.loadFile(indexHtml);
|
|
57
55
|
}
|
|
58
56
|
|
|
@@ -63,10 +61,10 @@ function createWindow() {
|
|
|
63
61
|
|
|
64
62
|
// Make all links open with the browser, not with the application
|
|
65
63
|
win.webContents.setWindowOpenHandler(({ url }) => {
|
|
66
|
-
if (url.startsWith('https:'))
|
|
64
|
+
if (url.startsWith('https:'))
|
|
65
|
+
shell.openExternal(url);
|
|
67
66
|
return { action: 'deny' };
|
|
68
67
|
});
|
|
69
|
-
// win.webContents.on('will-navigate', (event, url) => { }) #344
|
|
70
68
|
}
|
|
71
69
|
|
|
72
70
|
app.whenReady().then(async () => {
|
|
@@ -76,10 +74,15 @@ app.whenReady().then(async () => {
|
|
|
76
74
|
const { installExtension, VUEJS_DEVTOOLS } = await import('@tomjs/electron-devtools-installer');
|
|
77
75
|
|
|
78
76
|
installExtension(VUEJS_DEVTOOLS)
|
|
79
|
-
.then(ext => {
|
|
77
|
+
.then((ext) => {
|
|
80
78
|
console.log('Added Extension: ', ext.name);
|
|
79
|
+
// Open devTool if the app is not packaged
|
|
80
|
+
if (win) {
|
|
81
|
+
win.webContents.openDevTools();
|
|
82
|
+
}
|
|
81
83
|
})
|
|
82
|
-
.catch(() => {
|
|
84
|
+
.catch((err) => {
|
|
85
|
+
console.error(err);
|
|
83
86
|
console.log('Failed to install extensions');
|
|
84
87
|
});
|
|
85
88
|
}
|
|
@@ -87,13 +90,15 @@ app.whenReady().then(async () => {
|
|
|
87
90
|
|
|
88
91
|
app.on('window-all-closed', () => {
|
|
89
92
|
win = null;
|
|
90
|
-
if (process.platform !== 'darwin')
|
|
93
|
+
if (process.platform !== 'darwin')
|
|
94
|
+
app.quit();
|
|
91
95
|
});
|
|
92
96
|
|
|
93
97
|
app.on('second-instance', () => {
|
|
94
98
|
if (win) {
|
|
95
99
|
// Focus on the main window if the user tried to open another
|
|
96
|
-
if (win.isMinimized())
|
|
100
|
+
if (win.isMinimized())
|
|
101
|
+
win.restore();
|
|
97
102
|
win.focus();
|
|
98
103
|
}
|
|
99
104
|
});
|
|
@@ -102,7 +107,8 @@ app.on('activate', () => {
|
|
|
102
107
|
const allWindows = BrowserWindow.getAllWindows();
|
|
103
108
|
if (allWindows.length) {
|
|
104
109
|
allWindows[0].focus();
|
|
105
|
-
}
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
106
112
|
createWindow();
|
|
107
113
|
}
|
|
108
114
|
});
|
|
@@ -117,9 +123,19 @@ ipcMain.handle('open-win', (_, arg) => {
|
|
|
117
123
|
},
|
|
118
124
|
});
|
|
119
125
|
|
|
120
|
-
if (
|
|
121
|
-
childWindow.loadURL(`${
|
|
122
|
-
}
|
|
126
|
+
if (process.env.VITE_DEV_SERVER_URL) {
|
|
127
|
+
childWindow.loadURL(`${url}#${arg}`);
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
123
130
|
childWindow.loadFile(indexHtml, { hash: arg });
|
|
124
131
|
}
|
|
125
132
|
});
|
|
133
|
+
|
|
134
|
+
process.on('message', (data) => {
|
|
135
|
+
// Reload Electron
|
|
136
|
+
if (data === ELECTRON_EXIT) {
|
|
137
|
+
if (isDev && win) {
|
|
138
|
+
win.webContents.closeDevTools();
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
});
|
|
@@ -4,8 +4,7 @@
|
|
|
4
4
|
<meta charset="UTF-8" />
|
|
5
5
|
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
|
6
6
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
|
-
<
|
|
8
|
-
<title>Vite + Electron + Vue + TS</title>
|
|
7
|
+
<title>Vite + Electron + Vue</title>
|
|
9
8
|
</head>
|
|
10
9
|
|
|
11
10
|
<body>
|
|
@@ -1,6 +1,35 @@
|
|
|
1
1
|
{
|
|
2
|
-
"
|
|
2
|
+
"name": "template-vue",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "0.0.0",
|
|
5
|
+
"private": true,
|
|
6
|
+
"description": "vite + vue",
|
|
7
|
+
"main": "./dist/main/index.mjs",
|
|
8
|
+
"engines": {
|
|
9
|
+
"node": ">=20"
|
|
10
|
+
},
|
|
3
11
|
"scripts": {
|
|
4
|
-
"
|
|
12
|
+
"dev": "vite",
|
|
13
|
+
"debug": "cross-env VITE_ELECTRON_DEBUG=1 vite",
|
|
14
|
+
"build": "vue-tsc --noEmit && vite build",
|
|
15
|
+
"build:pack": "cross-env VITE_ELECTRON_BUILDER=1 vite build",
|
|
16
|
+
"preview": "vite preview"
|
|
17
|
+
},
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"@tomjs/electron-devtools-installer": "^4.0.1",
|
|
20
|
+
"vue": "^3.5.25"
|
|
21
|
+
},
|
|
22
|
+
"devDependencies": {
|
|
23
|
+
"@tomjs/vite-plugin-electron": "^2.0.2",
|
|
24
|
+
"@types/node": "^20.19.25",
|
|
25
|
+
"@vitejs/plugin-vue": "^6.0.2",
|
|
26
|
+
"@vue/tsconfig": "^0.8.1",
|
|
27
|
+
"cross-env": "^10.1.0",
|
|
28
|
+
"electron": "^39.2.4",
|
|
29
|
+
"electron-builder": "^26.0.12",
|
|
30
|
+
"typescript": "~5.9.3",
|
|
31
|
+
"vite": "^7.2.4",
|
|
32
|
+
"vite-plugin-electron-renderer": "^0.14.6",
|
|
33
|
+
"vue-tsc": "^3.1.5"
|
|
5
34
|
}
|
|
6
35
|
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
:root {
|
|
2
2
|
font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
|
|
3
|
-
line-height: 1.5;
|
|
4
3
|
font-weight: 400;
|
|
5
4
|
|
|
6
|
-
|
|
5
|
+
font-synthesis: none;
|
|
6
|
+
line-height: 1.5;
|
|
7
7
|
color: rgba(255, 255, 255, 0.87);
|
|
8
|
-
background-color: #242424;
|
|
9
8
|
|
|
10
|
-
|
|
9
|
+
color-scheme: light dark;
|
|
10
|
+
background-color: #242424;
|
|
11
11
|
text-rendering: optimizeLegibility;
|
|
12
12
|
-webkit-font-smoothing: antialiased;
|
|
13
13
|
-moz-osx-font-smoothing: grayscale;
|
|
@@ -19,16 +19,17 @@ a {
|
|
|
19
19
|
color: #646cff;
|
|
20
20
|
text-decoration: inherit;
|
|
21
21
|
}
|
|
22
|
+
|
|
22
23
|
a:hover {
|
|
23
24
|
color: #535bf2;
|
|
24
25
|
}
|
|
25
26
|
|
|
26
27
|
body {
|
|
27
|
-
margin: 0;
|
|
28
28
|
display: flex;
|
|
29
29
|
place-items: center;
|
|
30
30
|
min-width: 320px;
|
|
31
31
|
min-height: 100vh;
|
|
32
|
+
margin: 0;
|
|
32
33
|
}
|
|
33
34
|
|
|
34
35
|
h1 {
|
|
@@ -37,19 +38,21 @@ h1 {
|
|
|
37
38
|
}
|
|
38
39
|
|
|
39
40
|
button {
|
|
40
|
-
border-radius: 8px;
|
|
41
|
-
border: 1px solid transparent;
|
|
42
41
|
padding: 0.6em 1.2em;
|
|
42
|
+
font-family: inherit;
|
|
43
43
|
font-size: 1em;
|
|
44
44
|
font-weight: 500;
|
|
45
|
-
font-family: inherit;
|
|
46
|
-
background-color: #1a1a1a;
|
|
47
45
|
cursor: pointer;
|
|
46
|
+
background-color: #1a1a1a;
|
|
47
|
+
border: 1px solid transparent;
|
|
48
|
+
border-radius: 8px;
|
|
48
49
|
transition: border-color 0.25s;
|
|
49
50
|
}
|
|
51
|
+
|
|
50
52
|
button:hover {
|
|
51
53
|
border-color: #646cff;
|
|
52
54
|
}
|
|
55
|
+
|
|
53
56
|
button:focus,
|
|
54
57
|
button:focus-visible {
|
|
55
58
|
outline: 4px auto -webkit-focus-ring-color;
|
|
@@ -61,8 +64,8 @@ button:focus-visible {
|
|
|
61
64
|
|
|
62
65
|
#app {
|
|
63
66
|
max-width: 1280px;
|
|
64
|
-
margin: 0 auto;
|
|
65
67
|
padding: 2rem;
|
|
68
|
+
margin: 0 auto;
|
|
66
69
|
text-align: center;
|
|
67
70
|
}
|
|
68
71
|
|
|
@@ -71,9 +74,11 @@ button:focus-visible {
|
|
|
71
74
|
color: #213547;
|
|
72
75
|
background-color: #ffffff;
|
|
73
76
|
}
|
|
77
|
+
|
|
74
78
|
a:hover {
|
|
75
79
|
color: #747bff;
|
|
76
80
|
}
|
|
81
|
+
|
|
77
82
|
button {
|
|
78
83
|
background-color: #f9f9f9;
|
|
79
84
|
}
|
|
@@ -1,26 +1,8 @@
|
|
|
1
|
-
import path from 'node:path';
|
|
2
1
|
import electron from '@tomjs/vite-plugin-electron';
|
|
3
|
-
import renderer from '@tomjs/vite-plugin-electron-renderer';
|
|
4
2
|
import vue from '@vitejs/plugin-vue';
|
|
5
3
|
import { defineConfig } from 'vite';
|
|
6
|
-
import
|
|
4
|
+
import renderer from 'vite-plugin-electron-renderer';
|
|
7
5
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
process.env.APP_BUILD_TIME = Date.now() + '';
|
|
11
|
-
process.env.APP_VERSION = pkg.version;
|
|
12
|
-
|
|
13
|
-
return {
|
|
14
|
-
resolve: {
|
|
15
|
-
alias: {
|
|
16
|
-
'@': path.join(__dirname, 'src'),
|
|
17
|
-
},
|
|
18
|
-
},
|
|
19
|
-
plugins: [
|
|
20
|
-
vue(),
|
|
21
|
-
electron(),
|
|
22
|
-
// Use Node.js API in the Renderer process
|
|
23
|
-
renderer(),
|
|
24
|
-
],
|
|
25
|
-
};
|
|
6
|
+
export default defineConfig({
|
|
7
|
+
plugins: [vue(), electron({ builder: true }), renderer()],
|
|
26
8
|
});
|
|
@@ -5,18 +5,15 @@
|
|
|
5
5
|
"version": "0.2.0",
|
|
6
6
|
"configurations": [
|
|
7
7
|
{
|
|
8
|
-
"name": "Debug
|
|
8
|
+
"name": "Debug",
|
|
9
9
|
"type": "node",
|
|
10
10
|
"request": "launch",
|
|
11
11
|
"skipFiles": [
|
|
12
12
|
"<node_internals>/**"
|
|
13
13
|
],
|
|
14
14
|
"runtimeExecutable": "tsx",
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
"--config",
|
|
18
|
-
"${workspaceFolder}\\xxx.config.cjs"
|
|
19
|
-
],
|
|
15
|
+
"runtimeArgs": [],
|
|
16
|
+
"program": "${workspaceFolder}/src/index.ts",
|
|
20
17
|
"console": "integratedTerminal"
|
|
21
18
|
}
|
|
22
19
|
]
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# .vscode/i18n-ally-custom-framework.yml
|
|
2
|
+
|
|
3
|
+
# An array of strings which contain Language Ids defined by VS Code
|
|
4
|
+
# You can check available language ids here: https://code.visualstudio.com/docs/languages/identifiers
|
|
5
|
+
languageIds:
|
|
6
|
+
- javascript
|
|
7
|
+
- typescript
|
|
8
|
+
- javascriptreact
|
|
9
|
+
- typescriptreact
|
|
10
|
+
|
|
11
|
+
# An array of RegExes to find the key usage. **The key should be captured in the first match group**.
|
|
12
|
+
# You should unescape RegEx strings in order to fit in the YAML file
|
|
13
|
+
# To help with this, you can use https://www.freeformatter.com/json-escape.html
|
|
14
|
+
usageMatchRegex:
|
|
15
|
+
# The following example shows how to detect `t("your.i18n.keys")`
|
|
16
|
+
# the `{key}` will be placed by a proper keypath matching regex,
|
|
17
|
+
# you can ignore it and use your own matching rules as well
|
|
18
|
+
- "[^\\w\\d]t\\(['\"`]({key})['\"`]"
|
|
19
|
+
|
|
20
|
+
# A RegEx to set a custom scope range. This scope will be used as a prefix when detecting keys
|
|
21
|
+
# and works like how the i18next framework identifies the namespace scope from the
|
|
22
|
+
# useTranslation() hook.
|
|
23
|
+
# You should unescape RegEx strings in order to fit in the YAML file
|
|
24
|
+
# To help with this, you can use https://www.freeformatter.com/json-escape.html
|
|
25
|
+
scopeRangeRegex: "useTranslation\\(\\s*\\[?\\s*['\"`](.*?)['\"`]"
|
|
26
|
+
|
|
27
|
+
# An array of strings containing refactor templates.
|
|
28
|
+
# The "$1" will be replaced by the keypath specified.
|
|
29
|
+
# Optional: uncomment the following two lines to use
|
|
30
|
+
|
|
31
|
+
# refactorTemplates:
|
|
32
|
+
# - i18n.get("$1")
|
|
33
|
+
|
|
34
|
+
# If set to true, only enables this custom framework (will disable all built-in frameworks)
|
|
35
|
+
monopoly: true
|
|
@@ -5,18 +5,15 @@
|
|
|
5
5
|
"version": "0.2.0",
|
|
6
6
|
"configurations": [
|
|
7
7
|
{
|
|
8
|
-
"name": "Debug
|
|
8
|
+
"name": "Debug",
|
|
9
9
|
"type": "node",
|
|
10
10
|
"request": "launch",
|
|
11
11
|
"skipFiles": [
|
|
12
12
|
"<node_internals>/**"
|
|
13
13
|
],
|
|
14
14
|
"runtimeExecutable": "tsx",
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
"--config",
|
|
18
|
-
"${workspaceFolder}\\xxx.config.cjs"
|
|
19
|
-
],
|
|
15
|
+
"runtimeArgs": [],
|
|
16
|
+
"program": "${workspaceFolder}/src/debug.ts",
|
|
20
17
|
"console": "integratedTerminal"
|
|
21
18
|
}
|
|
22
19
|
]
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
{
|
|
2
|
+
// i18n Ally
|
|
3
|
+
"i18n-ally.disabled": false,
|
|
4
|
+
"i18n-ally.localesPaths": "./locales",
|
|
5
|
+
"i18n-ally.displayLanguage": "zh-Hans",
|
|
6
|
+
"i18n-ally.sourceLanguage": "zh-Hans",
|
|
7
|
+
|
|
8
|
+
// Disable the default formatter, use eslint instead
|
|
9
|
+
"prettier.enable": false,
|
|
10
|
+
"editor.formatOnSave": false,
|
|
11
|
+
|
|
12
|
+
// Auto fix
|
|
13
|
+
"editor.codeActionsOnSave": {
|
|
14
|
+
"source.fixAll.eslint": "explicit",
|
|
15
|
+
"source.organizeImports": "never"
|
|
16
|
+
},
|
|
17
|
+
|
|
18
|
+
// Silent the stylistic rules in your IDE, but still auto fix them
|
|
19
|
+
"eslint.rules.customizations": [
|
|
20
|
+
{ "rule": "style/*", "severity": "off", "fixable": true },
|
|
21
|
+
{ "rule": "format/*", "severity": "off", "fixable": true },
|
|
22
|
+
{ "rule": "*-indent", "severity": "off", "fixable": true },
|
|
23
|
+
{ "rule": "*-spacing", "severity": "off", "fixable": true },
|
|
24
|
+
{ "rule": "*-spaces", "severity": "off", "fixable": true },
|
|
25
|
+
{ "rule": "*-order", "severity": "off", "fixable": true },
|
|
26
|
+
{ "rule": "*-dangle", "severity": "off", "fixable": true },
|
|
27
|
+
{ "rule": "*-newline", "severity": "off", "fixable": true },
|
|
28
|
+
{ "rule": "*quotes", "severity": "off", "fixable": true },
|
|
29
|
+
{ "rule": "*semi", "severity": "off", "fixable": true }
|
|
30
|
+
],
|
|
31
|
+
|
|
32
|
+
// Enable eslint for all supported languages
|
|
33
|
+
"eslint.validate": [
|
|
34
|
+
"javascript",
|
|
35
|
+
"javascriptreact",
|
|
36
|
+
"typescript",
|
|
37
|
+
"typescriptreact",
|
|
38
|
+
"vue",
|
|
39
|
+
"html",
|
|
40
|
+
"markdown",
|
|
41
|
+
"json",
|
|
42
|
+
"jsonc",
|
|
43
|
+
"yaml",
|
|
44
|
+
"toml",
|
|
45
|
+
"xml",
|
|
46
|
+
"gql",
|
|
47
|
+
"graphql",
|
|
48
|
+
"astro",
|
|
49
|
+
"svelte",
|
|
50
|
+
"css",
|
|
51
|
+
"less",
|
|
52
|
+
"scss",
|
|
53
|
+
"pcss",
|
|
54
|
+
"postcss"
|
|
55
|
+
]
|
|
56
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# logs
|
|
2
|
+
*.log
|
|
3
|
+
lerna-debug.log*
|
|
4
|
+
logs
|
|
5
|
+
npm-debug.log*
|
|
6
|
+
pnpm-debug.log*
|
|
7
|
+
yarn-debug.log*
|
|
8
|
+
yarn-error.log*
|
|
9
|
+
|
|
10
|
+
# diagnostic reports (https://nodejs.org/api/report.html)
|
|
11
|
+
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
|
|
12
|
+
|
|
13
|
+
# runtime data
|
|
14
|
+
*.pid
|
|
15
|
+
*.pid.lock
|
|
16
|
+
*.seed
|
|
17
|
+
pids
|
|
18
|
+
|
|
19
|
+
# dependency directory
|
|
20
|
+
bower_components
|
|
21
|
+
jspm_packages
|
|
22
|
+
node_modules
|
|
23
|
+
web_modules
|
|
24
|
+
|
|
25
|
+
# cache
|
|
26
|
+
.cache
|
|
27
|
+
.npm
|
|
28
|
+
.tmp
|
|
29
|
+
.temp
|
|
30
|
+
.eslintcache
|
|
31
|
+
.stylelintcache
|
|
32
|
+
tsconfig.tsbuildinfo
|
|
33
|
+
|
|
34
|
+
# environment
|
|
35
|
+
.env
|
|
36
|
+
|
|
37
|
+
# macOS
|
|
38
|
+
.DS_Store
|
|
39
|
+
|
|
40
|
+
# package files
|
|
41
|
+
*.7z
|
|
42
|
+
*.gz
|
|
43
|
+
*.gzip
|
|
44
|
+
*.rar
|
|
45
|
+
*.tar
|
|
46
|
+
*.tar.*
|
|
47
|
+
*.tgz
|
|
48
|
+
*.zip
|
|
49
|
+
|
|
50
|
+
# IDEA
|
|
51
|
+
.idea
|
|
52
|
+
|
|
53
|
+
# vscode
|
|
54
|
+
.history
|
|
55
|
+
.vscode/i18n-ally-reviews.yml
|
|
56
|
+
|
|
57
|
+
# build output
|
|
58
|
+
build
|
|
59
|
+
dist
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"options.config": "Configuration file path (e.g., \"./xxx.config.json\")",
|
|
3
|
+
"options.dir": "Current working directory (default: \".\")",
|
|
4
|
+
"options.help": "Display help information",
|
|
5
|
+
"options.verbose": "Display detailed logs",
|
|
6
|
+
"options.version": "Display version information",
|
|
7
|
+
"prompt.cancel": "Operation canceled",
|
|
8
|
+
"prompt.confirm.no": "No",
|
|
9
|
+
"prompt.confirm.yes": "Yes",
|
|
10
|
+
"prompt.public.message": "Is it public?"
|
|
11
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"options.config": "配置文件路径 (如: \"./xxx.config.json\")",
|
|
3
|
+
"options.dir": "当前工作目录 (默认: \".\")",
|
|
4
|
+
"options.help": "显示帮助信息",
|
|
5
|
+
"options.verbose": "显示详细日志",
|
|
6
|
+
"options.version": "显示版本信息",
|
|
7
|
+
"prompt.cancel": "操作取消",
|
|
8
|
+
"prompt.confirm.no": "否",
|
|
9
|
+
"prompt.confirm.yes": "是",
|
|
10
|
+
"prompt.public.message": "是否为公开?"
|
|
11
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"options.config": "設定檔路徑 (如: \"./xxx.config.json\")",
|
|
3
|
+
"options.dir": "目前工作目錄 (預設: \".\")",
|
|
4
|
+
"options.help": "顯示幫助訊息",
|
|
5
|
+
"options.verbose": "顯示詳細日誌",
|
|
6
|
+
"options.version": "顯示版本資訊",
|
|
7
|
+
"prompt.cancel": "操作取消",
|
|
8
|
+
"prompt.confirm.no": "否",
|
|
9
|
+
"prompt.confirm.yes": "是",
|
|
10
|
+
"prompt.public.message": "是否為公開?"
|
|
11
|
+
}
|
|
@@ -1,31 +1,31 @@
|
|
|
1
1
|
{
|
|
2
|
-
"
|
|
3
|
-
"description": "node
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
],
|
|
7
|
-
"engines": {
|
|
8
|
-
"node": ">=18"
|
|
2
|
+
"name": "cli",
|
|
3
|
+
"description": "cli node project",
|
|
4
|
+
"bin": {
|
|
5
|
+
"xxx": "./dist/index.mjs"
|
|
9
6
|
},
|
|
10
7
|
"files": [
|
|
11
|
-
"dist"
|
|
12
|
-
"index.d.ts"
|
|
8
|
+
"dist"
|
|
13
9
|
],
|
|
14
|
-
"
|
|
15
|
-
"
|
|
16
|
-
"xxx-cli": "./dist/index.js"
|
|
10
|
+
"engines": {
|
|
11
|
+
"node": ">=18"
|
|
17
12
|
},
|
|
18
13
|
"scripts": {
|
|
19
|
-
"dev": "
|
|
20
|
-
"
|
|
21
|
-
"build": "tsup"
|
|
14
|
+
"dev": "tsdown --watch",
|
|
15
|
+
"build": "tsdown"
|
|
22
16
|
},
|
|
23
17
|
"dependencies": {
|
|
24
|
-
"
|
|
18
|
+
"@clack/prompts": "^0.11.0",
|
|
19
|
+
"@tomjs/logger": "^1.4.0",
|
|
20
|
+
"@tomjs/node": "^2.2.3",
|
|
21
|
+
"chalk": "^5.6.2",
|
|
25
22
|
"cosmiconfig": "^9.0.0",
|
|
26
|
-
"execa": "^9.
|
|
27
|
-
"meow": "^
|
|
28
|
-
"ora": "^
|
|
23
|
+
"execa": "^9.6.0",
|
|
24
|
+
"meow": "^14.0.0",
|
|
25
|
+
"ora": "^9.0.0"
|
|
29
26
|
},
|
|
30
|
-
"devDependencies": {
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"publint": "0.3.15",
|
|
29
|
+
"tsdown": "^0.16.7"
|
|
30
|
+
}
|
|
31
31
|
}
|