@tomjs/create-app 1.7.0 → 2.0.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.
Files changed (262) hide show
  1. package/README.md +14 -21
  2. package/README.zh_CN.md +14 -21
  3. package/dist/index.js +9 -22
  4. package/package.json +49 -52
  5. package/templates/{base/core → config/base}/.editorconfig +0 -4
  6. package/templates/config/base/.vscode/settings.json +50 -0
  7. package/templates/{base/core/_gitignore → config/base/_.gitignore} +1 -3
  8. package/templates/config/base/_commitlint.config.mjs +3 -0
  9. package/templates/config/base/_eslint.config.mjs +8 -0
  10. package/templates/config/base/lint-staged.config.mjs +3 -0
  11. package/templates/config/base/package.json +24 -0
  12. package/templates/config/base/pnpm-workspace.yaml +3 -0
  13. package/templates/config/base/simple-git-hooks.mjs +4 -0
  14. package/templates/{vscode → config/public}/LICENSE +1 -1
  15. package/templates/config/public/README.md +20 -0
  16. package/templates/config/public/README.zh_CN.md +20 -0
  17. package/templates/config/public/package.json +10 -0
  18. package/templates/config/style/lint-staged.config.mjs +7 -0
  19. package/templates/config/style/package.json +12 -0
  20. package/templates/config/style/stylelint.config.mjs +3 -0
  21. package/templates/{base/electron → electron-react}/.vscode/launch.json +23 -3
  22. package/templates/electron-react/.vscode/tasks.json +67 -0
  23. package/templates/electron-react/README.md +1 -1
  24. package/templates/electron-react/_eslint.config.mjs +8 -0
  25. package/templates/electron-react/electron/main/index.ts +71 -40
  26. package/templates/electron-react/electron/preload/index.ts +4 -0
  27. package/templates/electron-react/index.html +1 -2
  28. package/templates/electron-react/package.json +35 -1
  29. package/templates/electron-react/pnpm-workspace.yaml +6 -0
  30. package/templates/electron-react/src/App.css +6 -2
  31. package/templates/electron-react/src/App.tsx +12 -5
  32. package/templates/electron-react/src/index.css +14 -9
  33. package/templates/electron-react/tsconfig.json +9 -0
  34. package/templates/{base/electron → electron-react}/tsconfig.node.json +1 -1
  35. package/templates/electron-react/vite.config.ts +9 -22
  36. package/templates/electron-vue/.vscode/launch.json +48 -0
  37. package/templates/electron-vue/.vscode/tasks.json +67 -0
  38. package/templates/electron-vue/README.md +1 -1
  39. package/templates/electron-vue/_eslint.config.mjs +8 -0
  40. package/templates/electron-vue/electron/env.d.ts +1 -0
  41. package/templates/electron-vue/electron/main/index.ts +46 -30
  42. package/templates/electron-vue/electron/preload/index.ts +4 -0
  43. package/templates/electron-vue/index.html +1 -2
  44. package/templates/electron-vue/package.json +31 -2
  45. package/templates/electron-vue/pnpm-workspace.yaml +5 -0
  46. package/templates/electron-vue/src/App.vue +1 -1
  47. package/templates/electron-vue/src/style.css +15 -10
  48. package/templates/electron-vue/tsconfig.json +5 -0
  49. package/templates/electron-vue/tsconfig.node.json +7 -0
  50. package/templates/electron-vue/vite.config.ts +3 -21
  51. package/templates/{node-cli-legacy → node-base}/.vscode/launch.json +3 -6
  52. package/templates/node-base/package.json +15 -0
  53. package/templates/node-base/src/index.ts +5 -0
  54. package/templates/{node-cli-legacy → node-base}/tsconfig.json +1 -1
  55. package/templates/node-cli/.vscode/i18n-ally-custom-framework.yml +35 -0
  56. package/templates/node-cli/.vscode/launch.json +3 -6
  57. package/templates/node-cli/.vscode/settings.json +56 -0
  58. package/templates/node-cli/_.gitignore +59 -0
  59. package/templates/node-cli/locales/en-US.json +12 -0
  60. package/templates/node-cli/locales/zh-CN.json +12 -0
  61. package/templates/node-cli/package.json +20 -20
  62. package/templates/node-cli/src/app.ts +19 -0
  63. package/templates/node-cli/src/config.ts +2 -2
  64. package/templates/node-cli/src/index.ts +78 -1
  65. package/templates/node-cli/src/types.ts +5 -1
  66. package/templates/node-cli/src/utils/exec.ts +68 -0
  67. package/templates/node-cli/src/utils/index.ts +3 -0
  68. package/templates/node-cli/src/utils/lang.ts +104 -0
  69. package/templates/node-cli/src/utils/util.ts +20 -0
  70. package/templates/node-cli/tsconfig.json +2 -2
  71. package/templates/node-cli/{tsup.config.ts → tsdown.config.ts} +3 -4
  72. package/templates/node-vite/examples/react/README.md +1 -0
  73. package/templates/node-vite/examples/react/_eslint.config.mjs +6 -0
  74. package/templates/{react → node-vite/examples/react}/index.html +1 -2
  75. package/templates/node-vite/examples/react/package.json +27 -0
  76. package/templates/{react → node-vite/examples/react}/src/App.css +5 -2
  77. package/templates/{react → node-vite/examples/react}/src/App.tsx +8 -9
  78. package/templates/{react → node-vite/examples/react}/src/index.css +15 -11
  79. package/templates/node-vite/examples/react/src/main.tsx +10 -0
  80. package/templates/node-vite/examples/react/tsconfig.json +5 -0
  81. package/templates/node-vite/examples/react/vite.config.ts +14 -0
  82. package/templates/node-vite/examples/vue/README.md +1 -0
  83. package/templates/node-vite/examples/vue/_eslint.config.mjs +6 -0
  84. package/templates/{vue → node-vite/examples/vue}/index.html +1 -2
  85. package/templates/node-vite/examples/vue/package.json +22 -0
  86. package/templates/{vue → node-vite/examples/vue}/src/App.vue +3 -3
  87. package/templates/node-vite/examples/vue/src/components/HelloWorld.vue +19 -0
  88. package/templates/{vue → node-vite/examples/vue}/src/main.ts +0 -1
  89. package/templates/{vue → node-vite/examples/vue}/src/style.css +16 -12
  90. package/templates/{base → node-vite/examples}/vue/tsconfig.json +2 -2
  91. package/templates/{vue → node-vite/examples/vue}/vite.config.ts +1 -1
  92. package/templates/node-vite/package.json +16 -0
  93. package/templates/node-vite/pnpm-lock.yaml +2293 -0
  94. package/templates/node-vite/pnpm-workspace.yaml +6 -0
  95. package/templates/{node → node-vite}/tsconfig.json +1 -1
  96. package/templates/{node-cli-legacy/tsup.config.ts → node-vite/tsdown.config.ts} +4 -5
  97. package/templates/vscode-base/.vscode/settings.json +59 -0
  98. package/templates/{vscode → vscode-base}/.vscode/tasks.json +2 -2
  99. package/templates/{base/node → vscode-base}/LICENSE +1 -1
  100. package/templates/{vscode/_gitignore → vscode-base/_.gitignore} +1 -0
  101. package/templates/vscode-base/locales/zh-CN.json +6 -0
  102. package/templates/{vscode → vscode-base}/package.json +12 -19
  103. package/templates/vscode-base/resources/logo.png +0 -0
  104. package/templates/vscode-base/resources/logo.svg +1 -0
  105. package/templates/{vscode/tsup.config.ts → vscode-base/tsdown.config.ts} +3 -3
  106. package/templates/{base/vscode → vscode-react}/.vscode/launch.json +14 -1
  107. package/templates/vscode-react/.vscode/settings.json +59 -0
  108. package/templates/{base/vscode → vscode-react}/.vscode/tasks.json +10 -1
  109. package/templates/{base/vscode → vscode-react}/LICENSE +1 -1
  110. package/templates/vscode-react/README.md +2 -2
  111. package/templates/{base/vscode/_gitignore → vscode-react/_.gitignore} +2 -1
  112. package/templates/{base/vscode → vscode-react}/extension/views/helper.ts +5 -4
  113. package/templates/{base/vscode → vscode-react}/extension/views/panel.ts +2 -1
  114. package/templates/vscode-react/package.json +65 -1
  115. package/templates/vscode-react/pnpm-workspace.yaml +5 -0
  116. package/templates/vscode-react/src/App.css +1 -1
  117. package/templates/vscode-react/src/App.tsx +16 -10
  118. package/templates/vscode-react/src/utils/vscode.ts +2 -81
  119. package/templates/vscode-react/src/vite-env.d.ts +1 -0
  120. package/templates/vscode-react/tsconfig.json +5 -0
  121. package/templates/vscode-react/vite.config.ts +4 -5
  122. package/templates/vscode-vue/.vscode/extensions.json +5 -0
  123. package/templates/vscode-vue/.vscode/launch.json +34 -0
  124. package/templates/vscode-vue/.vscode/settings.json +59 -0
  125. package/templates/{base/electron → vscode-vue}/.vscode/tasks.json +14 -6
  126. package/templates/vscode-vue/.vscodeignore +73 -0
  127. package/templates/vscode-vue/LICENSE +21 -0
  128. package/templates/vscode-vue/README.md +2 -2
  129. package/templates/vscode-vue/_.gitignore +65 -0
  130. package/templates/vscode-vue/extension/env.d.ts +1 -0
  131. package/templates/vscode-vue/extension/index.ts +21 -0
  132. package/templates/vscode-vue/extension/views/helper.ts +28 -0
  133. package/templates/vscode-vue/extension/views/panel.ts +49 -0
  134. package/templates/vscode-vue/locales/en.json +6 -0
  135. package/templates/vscode-vue/package.json +56 -2
  136. package/templates/vscode-vue/pnpm-workspace.yaml +4 -0
  137. package/templates/vscode-vue/src/App.vue +17 -11
  138. package/templates/vscode-vue/src/utils/vscode.ts +2 -81
  139. package/templates/vscode-vue/src/vite-env.d.ts +1 -0
  140. package/templates/vscode-vue/tsconfig.json +5 -0
  141. package/templates/vscode-vue/tsconfig.node.json +7 -0
  142. package/templates/vscode-vue/vite.config.ts +0 -4
  143. package/templates/web-react/README.md +1 -0
  144. package/templates/web-react/_eslint.config.mjs +6 -0
  145. package/templates/web-react/index.html +13 -0
  146. package/templates/web-react/package.json +27 -0
  147. package/templates/web-react/public/vite.svg +1 -0
  148. package/templates/web-react/src/App.css +45 -0
  149. package/templates/web-react/src/App.tsx +31 -0
  150. package/templates/web-react/src/assets/react.svg +1 -0
  151. package/templates/web-react/src/index.css +73 -0
  152. package/templates/web-react/src/main.tsx +10 -0
  153. package/templates/web-react/tsconfig.app.json +28 -0
  154. package/templates/web-react/tsconfig.json +7 -0
  155. package/templates/web-react/tsconfig.node.json +26 -0
  156. package/templates/web-react/vite.config.ts +14 -0
  157. package/templates/web-vue/README.md +1 -0
  158. package/templates/web-vue/_eslint.config.mjs +6 -0
  159. package/templates/web-vue/index.html +13 -0
  160. package/templates/web-vue/package.json +22 -0
  161. package/templates/web-vue/public/vite.svg +1 -0
  162. package/templates/web-vue/src/App.vue +32 -0
  163. package/templates/web-vue/src/assets/vue.svg +1 -0
  164. package/templates/web-vue/src/components/HelloWorld.vue +19 -0
  165. package/templates/web-vue/src/main.ts +5 -0
  166. package/templates/web-vue/src/style.css +84 -0
  167. package/templates/web-vue/tsconfig.app.json +4 -0
  168. package/templates/web-vue/tsconfig.json +7 -0
  169. package/templates/web-vue/tsconfig.node.json +7 -0
  170. package/templates/web-vue/vite.config.ts +7 -0
  171. package/templates/base/core/.commitlintrc.cjs +0 -3
  172. package/templates/base/core/.eslintignore +0 -14
  173. package/templates/base/core/.husky/commit-msg +0 -1
  174. package/templates/base/core/.husky/pre-commit +0 -1
  175. package/templates/base/core/.prettierignore +0 -17
  176. package/templates/base/core/.prettierrc.cjs +0 -1
  177. package/templates/base/core/_eslintrc.cjs +0 -7
  178. package/templates/base/core/_lintstagedrc.cjs +0 -4
  179. package/templates/base/core/package.json +0 -31
  180. package/templates/base/electron/electron/main/index.ts +0 -111
  181. package/templates/base/electron/electron/polyfills.ts +0 -4
  182. package/templates/base/electron/electron/preload/index.ts +0 -1
  183. package/templates/base/electron/package.json +0 -25
  184. package/templates/base/node/README.md +0 -13
  185. package/templates/base/node/README.zh_CN.md +0 -13
  186. package/templates/base/node/package.json +0 -48
  187. package/templates/base/node/test/index.test.ts +0 -7
  188. package/templates/base/package/package.json +0 -8
  189. package/templates/base/react/_eslintrc.cjs +0 -7
  190. package/templates/base/react/_lintstagedrc.cjs +0 -6
  191. package/templates/base/react/package.json +0 -19
  192. package/templates/base/react/tsconfig.json +0 -5
  193. package/templates/base/style/.stylelintignore +0 -16
  194. package/templates/base/style/.stylelintrc.cjs +0 -3
  195. package/templates/base/style/_lintstagedrc.cjs +0 -5
  196. package/templates/base/style/package.json +0 -10
  197. package/templates/base/vscode/.vscode/settings.json +0 -10
  198. package/templates/base/vscode/package.json +0 -67
  199. package/templates/base/vue/_eslintrc.cjs +0 -7
  200. package/templates/base/vue/_lintstagedrc.cjs +0 -6
  201. package/templates/base/vue/package.json +0 -17
  202. package/templates/config.json +0 -108
  203. package/templates/electron-react/public/img/icon.png +0 -0
  204. package/templates/electron-vue/public/img/icon.png +0 -0
  205. package/templates/node/package.json +0 -10
  206. package/templates/node/src/index.ts +0 -3
  207. package/templates/node/tsup.config.ts +0 -19
  208. package/templates/node-cli/index.d.ts +0 -5
  209. package/templates/node-cli/src/cli.ts +0 -68
  210. package/templates/node-cli/xxx.config.cjs +0 -0
  211. package/templates/node-cli-legacy/index.d.ts +0 -5
  212. package/templates/node-cli-legacy/package.json +0 -30
  213. package/templates/node-cli-legacy/src/cli.ts +0 -45
  214. package/templates/node-cli-legacy/src/config.ts +0 -28
  215. package/templates/node-cli-legacy/src/index.ts +0 -3
  216. package/templates/node-cli-legacy/src/types.ts +0 -1
  217. package/templates/node-cli-legacy/src/utils.ts +0 -5
  218. package/templates/node-vite-plugin/package.json +0 -18
  219. package/templates/node-vite-plugin/test/index.test.ts +0 -7
  220. package/templates/node-vite-plugin/tsconfig.json +0 -4
  221. package/templates/node-vite-plugin/tsup.config.ts +0 -18
  222. package/templates/node-workspaces/package.json +0 -8
  223. package/templates/react/package.json +0 -12
  224. package/templates/react/src/main.tsx +0 -11
  225. package/templates/react/src/vite-env.d.ts +0 -1
  226. package/templates/react/vite.config.ts +0 -7
  227. package/templates/schema.json +0 -110
  228. package/templates/vscode/.vscode/settings.json +0 -10
  229. package/templates/vscode/README.md +0 -3
  230. package/templates/vue/package.json +0 -12
  231. package/templates/vue/src/components/HelloWorld.vue +0 -37
  232. package/templates/vue/src/vite-env.d.ts +0 -1
  233. package/templates/{base/core → config/base}/.gitattributes +0 -0
  234. package/templates/{node-cli-legacy/xxx.config.cjs → config/base/README.md} +0 -0
  235. package/templates/{base/electron → electron-react}/electron/env.d.ts +0 -0
  236. package/templates/{react → node-vite/examples/react}/public/vite.svg +0 -0
  237. package/templates/{react → node-vite/examples/react}/src/assets/react.svg +0 -0
  238. package/templates/{base → node-vite/examples}/react/tsconfig.node.json +0 -0
  239. package/templates/{vue → node-vite/examples/vue}/public/vite.svg +0 -0
  240. package/templates/{vue → node-vite/examples/vue}/src/assets/vue.svg +0 -0
  241. package/templates/{base → node-vite/examples}/vue/tsconfig.node.json +0 -0
  242. package/templates/{node-vite-plugin → node-vite}/src/index.ts +0 -0
  243. package/templates/{node-vite-plugin → node-vite}/src/types.ts +0 -0
  244. package/templates/{base/vscode → vscode-base}/.vscode/extensions.json +0 -0
  245. package/templates/{vscode → vscode-base}/.vscode/launch.json +0 -0
  246. package/templates/{vscode → vscode-base}/.vscodeignore +0 -0
  247. package/templates/{base/vscode → vscode-base}/README.md +0 -0
  248. package/templates/{vscode → vscode-base}/locales/en.json +0 -0
  249. package/templates/{vscode → vscode-base}/src/index.ts +1 -1
  250. package/templates/{vscode → vscode-base}/tsconfig.json +0 -0
  251. package/templates/{vscode → vscode-react}/.vscode/extensions.json +0 -0
  252. package/templates/{base/vscode → vscode-react}/.vscodeignore +0 -0
  253. package/templates/{base/vscode → vscode-react}/extension/env.d.ts +0 -0
  254. package/templates/{base/vscode → vscode-react}/extension/index.ts +1 -1
  255. /package/templates/{base/vscode → vscode-react}/locales/en.json +0 -0
  256. /package/templates/{base/vscode → vscode-react}/locales/zh-CN.json +0 -0
  257. /package/templates/{base/vscode → vscode-react}/resources/logo.png +0 -0
  258. /package/templates/{base/vscode → vscode-react}/resources/logo.svg +0 -0
  259. /package/templates/{base/vscode → vscode-react}/tsconfig.node.json +0 -0
  260. /package/templates/{vscode → vscode-vue}/locales/zh-CN.json +0 -0
  261. /package/templates/{vscode → vscode-vue}/resources/logo.png +0 -0
  262. /package/templates/{vscode → vscode-vue}/resources/logo.svg +0 -0
@@ -0,0 +1,67 @@
1
+ {
2
+ // See https://go.microsoft.com/fwlink/?LinkId=733558
3
+ // for the documentation about the tasks.json format
4
+ "version": "2.0.0",
5
+ "tasks": [
6
+ {
7
+ "type": "npm",
8
+ "script": "dev",
9
+ "label": "npm:dev",
10
+ "problemMatcher": {
11
+ "owner": "typescript",
12
+ "fileLocation": "relative",
13
+ "pattern": {
14
+ "regexp": "^([a-zA-Z]\\:\\/?([\\w\\-]\\/?)+\\.\\w+):(\\d+):(\\d+): (ERROR|WARNING)\\: (.*)$",
15
+ "file": 1,
16
+ "line": 3,
17
+ "column": 4,
18
+ "code": 5,
19
+ "message": 6
20
+ },
21
+ "background": {
22
+ "activeOnStart": true,
23
+ "beginsPattern": "^.*VITE v.* ready in \\d* ms.*$",
24
+ "endsPattern": "^.*\\[tomjs:electron\\] startup electron*$"
25
+ }
26
+ },
27
+ "isBackground": true,
28
+ "presentation": {
29
+ "reveal": "never"
30
+ },
31
+ "group": {
32
+ "kind": "build",
33
+ "isDefault": true
34
+ }
35
+ },
36
+ {
37
+ "type": "npm",
38
+ "script": "debug",
39
+ "label": "npm:debug",
40
+ "problemMatcher": {
41
+ "owner": "typescript",
42
+ "fileLocation": "relative",
43
+ "pattern": {
44
+ "regexp": "^([a-zA-Z]\\:\\/?([\\w\\-]\\/?)+\\.\\w+):(\\d+):(\\d+): (ERROR|WARNING)\\: (.*)$",
45
+ "file": 1,
46
+ "line": 3,
47
+ "column": 4,
48
+ "code": 5,
49
+ "message": 6
50
+ },
51
+ "background": {
52
+ "activeOnStart": true,
53
+ "beginsPattern": "^.*VITE v.* ready in \\d* ms.*$",
54
+ "endsPattern": "^.*\\[tomjs:electron\\] startup electron*$"
55
+ }
56
+ },
57
+ "isBackground": true,
58
+ "presentation": {
59
+ "reveal": "never"
60
+ },
61
+ "group": {
62
+ "kind": "build",
63
+ "isDefault": true
64
+ }
65
+ }
66
+ ]
67
+ }
@@ -1,3 +1,3 @@
1
- # electron-vue
1
+ # vue
2
2
 
3
3
  vite + electron + vue
@@ -0,0 +1,8 @@
1
+ import { defineConfig } from '@tomjs/eslint';
2
+
3
+ export default defineConfig({
4
+ rules: {
5
+ 'no-console': 'off',
6
+ 'n/prefer-global/process': 'off',
7
+ },
8
+ });
@@ -0,0 +1 @@
1
+ /// <reference types="@tomjs/vite-plugin-electron/env" />
@@ -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')) app.disableHardwareAcceleration();
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') app.setAppUserModelId(app.getName());
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
- // package.json "type":"module", must use mjs extension
30
+ // Here, you can also use other preload
27
31
  const preload = join(__dirname, '../preload/index.mjs');
28
- const serverUrl = process.env.VITE_DEV_SERVER_URL as string;
29
- const rendererDist = join(__dirname, '../renderer');
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(serverUrl);
51
- // Open devTool if the app is not packaged
52
- setTimeout(() => {
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:')) shell.openExternal(url);
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') app.quit();
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()) win.restore();
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
- } else {
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 (serverUrl) {
121
- childWindow.loadURL(`${serverUrl}#${arg}`);
122
- } else {
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
+ });
@@ -0,0 +1,4 @@
1
+ import os from 'node:os';
2
+
3
+ console.log('Electron Preload Process!');
4
+ console.log(os.homedir());
@@ -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
- <meta http-equiv="Content-Security-Policy" content="script-src 'self' 'unsafe-inline';" />
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
- "description": "vite + electron + vue",
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
- "lint:eslint": "eslint \"{src,electron}/**/*.{ts,tsx,vue}\" *.{js,cjs,mjs,ts} --fix --cache"
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
  }
@@ -0,0 +1,5 @@
1
+ onlyBuiltDependencies:
2
+ - electron
3
+ - electron-winstaller
4
+ - esbuild
5
+ - simple-git-hooks
@@ -21,8 +21,8 @@ import HelloWorld from './components/HelloWorld.vue';
21
21
  .logo {
22
22
  height: 6em;
23
23
  padding: 1.5em;
24
- will-change: filter;
25
24
  transition: filter 300ms;
25
+ will-change: filter;
26
26
  }
27
27
 
28
28
  .logo:hover {
@@ -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
- color-scheme: light dark;
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
- font-synthesis: none;
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
  }
@@ -0,0 +1,5 @@
1
+ {
2
+ "extends": "@tomjs/tsconfig/vue-dom.json",
3
+ "references": [{ "path": "./tsconfig.node.json" }],
4
+ "include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue"]
5
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "extends": "@tomjs/tsconfig/node.json",
3
+ "compilerOptions": {
4
+ "composite": true
5
+ },
6
+ "include": ["electron", "vite.config.ts"]
7
+ }
@@ -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 pkg from './package.json';
4
+ import renderer from 'vite-plugin-electron-renderer';
7
5
 
8
- // https://vitejs.dev/config/
9
- export default defineConfig(() => {
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 CLI",
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
- "program": "${workspaceFolder}\\src\\index.ts",
16
- "args": [
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,15 @@
1
+ {
2
+ "description": "node base template",
3
+ "files": [
4
+ "dist"
5
+ ],
6
+ "engines": {
7
+ "node": ">=20"
8
+ },
9
+ "scripts": {
10
+ "dev": "tsx ./src/index.ts"
11
+ },
12
+ "devDependencies": {
13
+ "chalk": "^5.6.2"
14
+ }
15
+ }
@@ -0,0 +1,5 @@
1
+ import chalk from 'chalk';
2
+
3
+ const num = 1 + 1;
4
+ console.log(`1 + 1 = ${num}`);
5
+ console.log(chalk.green('Starting Node App...'));
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "extends": "@tomjs/tsconfig/node.json",
3
- "include": ["src", "test", "*.ts"]
3
+ "include": ["src", "*.ts"]
4
4
  }
@@ -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 CLI",
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
- "program": "${workspaceFolder}\\src\\index.ts",
16
- "args": [
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