= {
13 | // mainDir: 'main',
14 | // renderDir: 'render',
15 | // publicDir: 'public',
16 | // libDir: 'lib',
17 | // resourceDir: 'dist',
18 | // outDir: 'out'
19 | // }
20 |
21 | export default defineConfig((env: ConfigEnv) => {
22 | console.log('defineConfig env: ', env)
23 | return {
24 | builderConfig,
25 | tsupConfig,
26 | viteConfig
27 | }
28 | })
29 |
--------------------------------------------------------------------------------
/playground/electronup-test/build/tsup.config.ts:
--------------------------------------------------------------------------------
1 | import type { TsupConfig } from 'electronup'
2 |
3 | /**
4 | * 框架内置的配置
5 | * 无需重复配置
6 | * 在此列出
7 | */
8 | // {
9 | // external: [
10 | // 'electron'
11 | // ... 自行追加忽略文件
12 | // ],
13 | // entry: { electron: 'main/index.ts' },
14 | // outDir: 'dist',
15 | // watch: command === 'serve' dev环境下监听文件改变,
16 | // dts: false,
17 | // clean: false
18 | // env: injectEnv() 自动注入 .env 文件内的环境变量
19 | // }
20 |
21 | export default {} as TsupConfig
22 |
--------------------------------------------------------------------------------
/playground/electronup-test/build/vite.config.ts:
--------------------------------------------------------------------------------
1 | import type { ViteConfig } from 'electronup'
2 | import VueMacros from 'unplugin-vue-macros/vite'
3 | import Vue from '@vitejs/plugin-vue'
4 | import VueJsx from '@vitejs/plugin-vue-jsx'
5 |
6 | /**
7 | * 框架内置的配置
8 | * 无需重复配置
9 | * 在此列出
10 | */
11 | // {
12 | // base: './',
13 | // root: 'render',
14 | // publicDir: 'public',
15 | // server: { host: '0.0.0.0' },
16 | // plugins: [
17 | // 自行导入插件
18 | // ],
19 | // ...config.viteOptions,
20 | // build: {
21 | // outDir: 'dist',
22 | // target: 'esnext',
23 | // minify: 'esbuild',
24 | // reportCompressedSize: false,
25 | // emptyOutDir: false,
26 | // chunkSizeWarningLimit: 2000
27 | // },
28 | // 额外的vite配置
29 | // viteOptions: {}
30 | // }
31 |
32 | export default {
33 | plugins: [VueMacros({
34 | plugins: {
35 | vue: Vue(),
36 | vueJsx: VueJsx()
37 | }
38 | })]
39 | } as ViteConfig
40 |
--------------------------------------------------------------------------------
/playground/electronup-test/electronup.config.ts:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'electronup'
2 | import VueMacros from 'unplugin-vue-macros/vite'
3 | import Vue from '@vitejs/plugin-vue'
4 | import VueJsx from '@vitejs/plugin-vue-jsx'
5 |
6 | export default defineConfig((env) => {
7 | console.log('defineConfig env: ', env)
8 | return {
9 | viteConfig: {
10 | plugins: [VueMacros({
11 | plugins: {
12 | vue: Vue(),
13 | vueJsx: VueJsx()
14 | }
15 | })]
16 | },
17 | builderConfig: {
18 | asar: false,
19 | mac: {
20 | target: [
21 | {
22 | target: 'dmg'
23 | }
24 | ]
25 | }
26 | }
27 | }
28 | })
29 |
--------------------------------------------------------------------------------
/playground/electronup-test/main/index.ts:
--------------------------------------------------------------------------------
1 | import { resolve } from 'path'
2 | import { BrowserWindow, app } from 'electron'
3 | import { Ipc } from '@quiteer/electron-ipc'
4 |
5 | const loadUrl = process.env.NODE_ENV === 'development'
6 | ? `http://localhost:${process.env.RENDER_PORT}`
7 | : `file://${resolve(__dirname, 'index.html')}`
8 |
9 | app.whenReady().then(() => {
10 | Ipc.init()
11 | const win = new BrowserWindow({
12 | height: 700, width: 1000
13 | })
14 |
15 | console.log('loadUrl: ', loadUrl)
16 | console.log('NODE_ENV', process.env.NODE_ENV)
17 | console.log('VITE_HELLO :>> ', process.env.VITE_HELLO)
18 | console.log('VITE_MODE_TEXT :>> ', process.env.VITE_MODE_TEXT)
19 |
20 | win.loadURL(loadUrl)
21 | win.webContents.openDevTools({ mode: 'right' })
22 | // appApiLogs()
23 | })
24 |
25 | function appApiLogs() {
26 | console.log('app.getVersion(): ', app.getVersion())
27 | console.log('app.getAppPath(): ', app.getAppPath())
28 | console.log('app.getName(): ', app.getName())
29 | console.log('app.getLocale(): ', app.getLocale())
30 | console.log('app.getSystemLocale(): ', app.getSystemLocale())
31 | console.log('app.getLocaleCountryCode(): ', app.getLocaleCountryCode())
32 | console.log('app.hasSingleInstanceLock(): ', app.hasSingleInstanceLock())
33 | console.log('app.getAppMetrics(): ', app.getAppMetrics())
34 | console.log('app.getGPUFeatureStatus(): ', app.getGPUFeatureStatus())
35 | console.log('app.getBadgeCount(): ', app.getBadgeCount())
36 | console.log('app.isEmojiPanelSupported(): ', app.isEmojiPanelSupported())
37 | app.showEmojiPanel()
38 | console.log('app.commandLine: ', app.commandLine)
39 | console.log('app.dock: ', app.dock)
40 | console.log('app.isPackaged: ', app.isPackaged)
41 | console.log('app.name: ', app.name)
42 | console.log('app.userAgentFallback: ', app.userAgentFallback)
43 | }
44 |
--------------------------------------------------------------------------------
/playground/electronup-test/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "electronup-test",
3 | "version": "1.0.0",
4 | "description": "description",
5 | "author": "",
6 | "license": "ISC",
7 | "keywords": [],
8 | "main": "dist/resource/electron.js",
9 | "scripts": {
10 | "command": "electronup -h && electronup build -h && electronup -v",
11 | "dev:1": "electronup",
12 | "dev:2": "electronup dev",
13 | "dev:port": "electronup dev --port 1020",
14 | "dev:production": "electronup --mode production",
15 | "dev:test": "electronup --mode test",
16 | "dev:staging": "electronup --mode staging",
17 | "dev:err": "electronup --mode err",
18 | "dev:custom": "electronup dev build/electronup.config.ts",
19 | "build": "electronup build",
20 | "build:dir": "electronup build --dir",
21 | "build:win": "electronup build --win",
22 | "build:win32": "electronup build --win ia32",
23 | "build:win64": "electronup build --win x64",
24 | "build:mac": "electronup build --mac",
25 | "build:mac-x64": "electronup build --mac x64",
26 | "build:mac-arm64": "electronup build --mac arm64",
27 | "build:mac-universal": "electronup build --mac universal",
28 | "build:linux": "electronup build --linux",
29 | "build:custom": "electronup build build/electronup.config.ts",
30 | "build:option": "electronup build build/electronup.config.ts -o"
31 | },
32 | "dependencies": {
33 | "@quiteer/electron-ipc": "^2.0.4",
34 | "@quiteer/electron-preload": "^0.0.10",
35 | "epic-spinners": "^2.0.0"
36 | },
37 | "devDependencies": {
38 | "@quiteer/eslint-config": "^0.0.3",
39 | "@quiteer/ts-config": "^0.0.5",
40 | "@vitejs/plugin-vue": "^4.0.0",
41 | "@vitejs/plugin-vue-jsx": "^3.0.0",
42 | "electron": "^21.2.2",
43 | "electronup": "workspace:^",
44 | "unplugin-vue-macros": "^1.0.3",
45 | "vite": "^5.0.12",
46 | "vue": "^3.2.43"
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/playground/electronup-test/public/vite.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/playground/electronup-test/render/App.vue:
--------------------------------------------------------------------------------
1 |
9 |
10 |
11 |
19 |
20 |
21 |
26 |
27 |
32 |
33 |
34 |
35 |
36 |
49 |
--------------------------------------------------------------------------------
/playground/electronup-test/render/assets/vue.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/playground/electronup-test/render/components/HelloWorld.vue:
--------------------------------------------------------------------------------
1 |
8 |
9 |
10 | {{ msg }}
11 |
12 |
13 |
16 |
17 | Edit
18 | components/HelloWorld.vue
to test HMR
19 |
20 |
21 |
22 |
23 | Check out
24 | create-vue, the official Vue + Vite starter
25 |
26 |
27 | Install
28 | Volar
29 | in your IDE for a better DX
30 |
31 |
32 | Click on the Vite and Vue logos to learn more
33 |
34 |
35 |
36 |
41 |
--------------------------------------------------------------------------------
/playground/electronup-test/render/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Vite + Vue + TS
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/playground/electronup-test/render/main.ts:
--------------------------------------------------------------------------------
1 | import { createApp } from 'vue'
2 | import './style.css'
3 | import App from './App.vue'
4 |
5 | createApp(App).mount('#app')
6 |
7 | console.info(import.meta.env)
8 |
9 |
--------------------------------------------------------------------------------
/playground/electronup-test/render/style.css:
--------------------------------------------------------------------------------
1 | :root {
2 | font-family: Inter, Avenir, Helvetica, Arial, sans-serif;
3 | font-size: 16px;
4 | line-height: 24px;
5 | font-weight: 400;
6 |
7 | color-scheme: light dark;
8 | color: rgba(255, 255, 255, 0.87);
9 | background-color: #242424;
10 |
11 | font-synthesis: none;
12 | text-rendering: optimizeLegibility;
13 | -webkit-font-smoothing: antialiased;
14 | -moz-osx-font-smoothing: grayscale;
15 | -webkit-text-size-adjust: 100%;
16 | }
17 |
18 | a {
19 | font-weight: 500;
20 | color: #646cff;
21 | text-decoration: inherit;
22 | }
23 | a:hover {
24 | color: #535bf2;
25 | }
26 |
27 | body {
28 | margin: 0;
29 | display: flex;
30 | place-items: center;
31 | min-width: 320px;
32 | min-height: 100vh;
33 | }
34 |
35 | h1 {
36 | font-size: 3.2em;
37 | line-height: 1.1;
38 | }
39 |
40 | button {
41 | border-radius: 8px;
42 | border: 1px solid transparent;
43 | padding: 0.6em 1.2em;
44 | font-size: 1em;
45 | font-weight: 500;
46 | font-family: inherit;
47 | background-color: #1a1a1a;
48 | cursor: pointer;
49 | transition: border-color 0.25s;
50 | }
51 | button:hover {
52 | border-color: #646cff;
53 | }
54 | button:focus,
55 | button:focus-visible {
56 | outline: 4px auto -webkit-focus-ring-color;
57 | }
58 |
59 | .card {
60 | padding: 2em;
61 | }
62 |
63 | #app {
64 | max-width: 1280px;
65 | margin: 0 auto;
66 | padding: 2rem;
67 | text-align: center;
68 | }
69 |
70 | @media (prefers-color-scheme: light) {
71 | :root {
72 | color: #213547;
73 | background-color: #ffffff;
74 | }
75 | a:hover {
76 | color: #747bff;
77 | }
78 | button {
79 | background-color: #f9f9f9;
80 | }
81 | }
82 |
--------------------------------------------------------------------------------
/playground/electronup-test/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "@quiteer/ts-config/tsconfig.web.json",
3 | "compilerOptions": {
4 | "ignoreDeprecations": "5.0"
5 | },
6 | "include": [
7 | "typings/*.d.ts",
8 | "render/**/*"
9 | ],
10 | "references": [{ "path": "./tsconfig.node.json" }]
11 | }
12 |
--------------------------------------------------------------------------------
/playground/electronup-test/tsconfig.node.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "composite": true,
4 | "strict": true, // 开启所有严格的类型检查
5 | "strictPropertyInitialization": false, // 类的实例属性必须初始化
6 | "isolatedModules": true,
7 | "resolveJsonModule": true,
8 | "sourceMap": true,
9 | "esModuleInterop": true, // 允许export=导出,由import from 导入
10 | "module": "esnext", // 生成代码的模板标准
11 | "target": "esnext", // 目标语言的版本
12 | "moduleResolution": "node", // 模块解析策略,ts默认用node的解析策略,即相对的方式导入
13 | "allowSyntheticDefaultImports": true,
14 | "emitDecoratorMetadata": true,
15 | "experimentalDecorators": true,
16 | "lib": ["ESNext"],
17 | "types": ["node"]
18 | },
19 | "include": [
20 | "build/**/*.ts",
21 | "main/**/*.ts",
22 | "typings/*.d.ts",
23 | "package.json"
24 | ]
25 | }
26 |
--------------------------------------------------------------------------------
/playground/electronup-test/typings/global.d.ts:
--------------------------------------------------------------------------------
1 | interface Window {
2 | $ipc:import('@quiteer/electron-preload').PreloadIpc & import('@quiteer/electron-ipc/web').ExpandPreloadIpc
3 | $clipboard: import('@quiteer/electron-preload').PreloadClipboard
4 | $webFrame: import('@quiteer/electron-preload').PreloadWebFrame
5 | }
6 |
7 |
--------------------------------------------------------------------------------
/playground/electronup-test/typings/vite-env.d.ts:
--------------------------------------------------------------------------------
1 | ///
2 |
3 | declare module '*.vue' {
4 | import type { DefineComponent } from 'vue'
5 | const component: DefineComponent<{}, {}, any>
6 | export default component
7 | }
8 |
--------------------------------------------------------------------------------
/pnpm-workspace.yaml:
--------------------------------------------------------------------------------
1 | packages:
2 | - 'packages/*'
3 | - 'playground/*'
4 | - 'template/*'
5 |
--------------------------------------------------------------------------------
/template/index.ts:
--------------------------------------------------------------------------------
1 | import { $, fs, path } from 'zx'
2 |
3 | async function createTemplate() {
4 | await $`pnpm create:vanilla && pnpm create:vue && pnpm create:react && pnpm create:react-swc && pnpm create:solid`
5 |
6 | // 读取目录下的目录
7 | const directories = fs.readdirSync(__dirname, { withFileTypes: true }).filter(dirent => dirent.isDirectory() && !dirent.name.startsWith('node_modules'))
8 |
9 | // 重写 electronup 的版本
10 | directories.forEach(async (dir) => {
11 | const packageJsonPath = path.join(__dirname, dir.name, 'package.json')
12 | const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'))
13 | packageJson.devDependencies.electronup = 'workspace:^'
14 | fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2))
15 | })
16 | }
17 |
18 | createTemplate()
19 |
--------------------------------------------------------------------------------
/template/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "template",
3 | "version": "1.0.0",
4 | "description": "",
5 | "author": "",
6 | "license": "ISC",
7 | "keywords": [],
8 | "main": "index.js",
9 | "scripts": {
10 | "create": "create-electronup",
11 | "create:name": "create-electronup user-project",
12 | "create:template": "create-electronup user-project --template vue",
13 | "create:t": "create-electronup user-project -t vue",
14 | "create:err:template": "create-electronup user-project -t vue1",
15 | "create:err:t": "create-electronup user-project -t vue1",
16 | "create:vanilla": "create-electronup vanilla-project -t vanilla",
17 | "create:vue": "create-electronup vue-project -t vue",
18 | "create:react": "create-electronup react-project -t react",
19 | "create:react-swc": "create-electronup react-swc-project -t react-swc",
20 | "create:solid": "create-electronup solid-project -t solid",
21 | "create:all": "esno index.ts"
22 | },
23 | "devDependencies": {
24 | "create-electronup": "workspace:^",
25 | "esno": "^4.0.0",
26 | "zx": "^7.2.3"
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/template/react-project/.env:
--------------------------------------------------------------------------------
1 | VITE_HELLO = 你好!electronup!
2 |
--------------------------------------------------------------------------------
/template/react-project/.env.development:
--------------------------------------------------------------------------------
1 | VITE_MODE_TEXT=这里是开发环境
2 |
--------------------------------------------------------------------------------
/template/react-project/.env.production:
--------------------------------------------------------------------------------
1 | VITE_MODE_TEXT=这里是生产环境
2 |
--------------------------------------------------------------------------------
/template/react-project/.eslintrc.cjs:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | root: true,
3 | env: { browser: true, es2020: true },
4 | extends: [
5 | '@quiteer/eslint-config',
6 | 'plugin:react-hooks/recommended'
7 | ],
8 | ignorePatterns: ['dist'],
9 | plugins: ['react-refresh'],
10 | rules: {
11 | 'react-refresh/only-export-components': [
12 | 'warn',
13 | { allowConstantExport: true }
14 | ]
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/template/react-project/.gitignore:
--------------------------------------------------------------------------------
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 | dist-ssr
13 | *.local
14 |
15 | # Editor directories and files
16 | .vscode/*
17 | !.vscode/extensions.json
18 | .idea
19 | .DS_Store
20 | *.suo
21 | *.ntvs*
22 | *.njsproj
23 | *.sln
24 | *.sw?
25 |
--------------------------------------------------------------------------------
/template/react-project/.npmrc:
--------------------------------------------------------------------------------
1 | # 一些镜像配置
2 | registry=https://registry.npmmirror.com
3 | electron_mirror=https://cdn.npmmirror.com/binaries/electron/
4 | electron_builder_binaries_mirror=https://npmmirror.com/mirrors/electron-builder-binaries/
5 | # sqlite3_mirror=https://cdn.npmmirror.com/binaries/sqlite3/
6 | # node_sqlite3_binary_host_mirror=https://npmmirror.com/mirrors/sqlite3/
7 |
8 | # https://pnpm.io/zh/npmrc#strict-peer-dependencies
9 | strict-peer-dependencies=false
10 | # https://pnpm.io/zh/cli/run#shell-emulator
11 | shell-emulator=true
12 | # https://pnpm.io/zh/npmrc#auto-install-peers
13 | auto-install-peers=false
14 |
--------------------------------------------------------------------------------
/template/react-project/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2023 quiteer
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/template/react-project/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
electronup-project
4 |
使用 electronup cli 驱动。
5 |
6 |
7 | # [electronup](https://github.com/QuiteerJs/electronup)
8 | [](./LICENSE)  
9 |
10 | > electronup 是一个集成 Vite4.x、tsup6.x、electron-builder24.x 的桌面端构建工具,一个配置文件完成多环境多目标的构建包。
11 |
12 | ## 文档地址
13 |
14 | 文档地址 :https://quiteerjs.github.io/electronup
15 |
16 |
17 | ## 特性
18 |
19 | - **多框架支持** : 使用 `create-electronup` 询问式创建项目模板 , 内置 `vue3` , `react` ,`solid` 等项目模板。
20 | - **Vite + tsup** : 双进程热更新 , 快速开发(主进程代码修改会触发软件重启)。
21 | - **统一的环境变量** : `dotenv` 加载 , 构建时注入 , 双进程拥有相同的环境变量。
22 | - **模式构建** : 默认识别当前代码运行的平台输出打包程序 。
23 | - **可选构建功能提示** : 你将获得可选范围内支持的功能提示 , 选项式自定义构建输出。
24 | - **TypeScript** : 应用程序级 `JavaScript` 的语言。
25 | - **集中管理路径** : 解决双进程资源路径的问题。
26 | - **预置配置** : 内置了很多可以覆盖的构建工具配置。
27 | - **单文件配置** : 只需一个 **electronup.config.ts** 即可管理项目的运行构建。
28 | - **多插件** : 作者会继续开发更多无副作用的独立插件,如:创建窗口,预加载,ipc通信,更新等等。
29 |
30 | ## 声明
31 |
32 | 前提条件
33 | > 熟悉命令行
34 | > 已安装 18 或更高版本的 Node.js
35 |
36 |
37 | 因为使用了 tsup 构建主进程代码,所以该命令行及脚手架只支持 TypeScript ,不支持 JavaScript。
38 |
39 |
40 | ### 一些便携包的相关配置参考
41 |
42 | - `electronup`
43 |
44 | https://www.npmjs.com/package/electronup
45 |
46 | - `@quiteer/electron-ipc`
47 |
48 | https://www.npmjs.com/package/@quiteer/electron-ipc
49 |
50 | - `@quiteer/electron-preload`
51 |
52 | https://www.npmjs.com/package/@quiteer/electron-preload
53 |
54 | 如果你觉得这个项目对你有帮助,可以动动小手 `star` 一下 , 非常感谢!!!
55 |
--------------------------------------------------------------------------------
/template/react-project/electronup.config.ts:
--------------------------------------------------------------------------------
1 | import { resolve } from 'node:path'
2 | import { defineConfig } from 'electronup'
3 |
4 | import react from '@vitejs/plugin-react'
5 |
6 | export default defineConfig((env) => {
7 | const srcDir = resolve(env.root, 'render')
8 | return {
9 | viteConfig: {
10 | plugins: [react()],
11 | resolve: {
12 | alias: {
13 | '@': resolve(env.root, 'render')
14 | }
15 | }
16 | },
17 | builderConfig: {
18 | win: {
19 | icon: 'public/icon.png',
20 | target: {
21 | target: 'nsis',
22 | arch: 'ia32'
23 | }
24 | }
25 | }
26 | }
27 | })
28 |
--------------------------------------------------------------------------------
/template/react-project/main/index.ts:
--------------------------------------------------------------------------------
1 | import { Ipc } from '@quiteer/electron-ipc'
2 | import preload from '@quiteer/electron-preload'
3 | import { BrowserWindow, app } from 'electron'
4 | import { Common } from './utils/common'
5 |
6 | app.whenReady().then(() => {
7 | Ipc.init()
8 |
9 | const win = new BrowserWindow({
10 | height: 700,
11 | width: 800,
12 | webPreferences: {
13 | preload: preload as string
14 | }
15 | })
16 |
17 | const child = new BrowserWindow({
18 | parent: win,
19 | height: 730,
20 | width: 700,
21 | frame: false,
22 | show: false,
23 | webPreferences: {
24 | preload: preload as string
25 | }
26 | })
27 |
28 | win.loadURL(Common.loadUrl)
29 | child.loadURL('https://freegpt.one/')
30 |
31 | win.webContents.openDevTools({ mode: 'right' })
32 | win.once('ready-to-show', () => {
33 | setTimeout(() => {
34 | const [x, y] = win.getPosition()
35 | child.setPosition(x + 810, y + 1)
36 | // child.show()
37 | }, 1000)
38 | })
39 |
40 | win.on('will-move', (event, newBounds) => {
41 | child.setPosition(newBounds.x + 810, newBounds.y + 1)
42 | })
43 | })
44 |
--------------------------------------------------------------------------------
/template/react-project/main/utils/common.ts:
--------------------------------------------------------------------------------
1 | import { resolve } from 'path'
2 | import { Is } from './is'
3 |
4 | export class Common {
5 | static get loadUrl() {
6 | const devUrl = `http://localhost:${process.env.RENDER_PORT}`
7 | const prodUrl = `file://${resolve(__dirname, 'index.html')}`
8 | return Is.dev ? devUrl : prodUrl
9 | }
10 |
11 | static get publicPath() {
12 | const dev = resolve(__dirname, '..', '..', 'public')
13 | const prod = __dirname
14 | return Is.dev ? dev : prod
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/template/react-project/main/utils/is.ts:
--------------------------------------------------------------------------------
1 | import { arch, platform } from 'process'
2 |
3 | export class Is {
4 | static get win() {
5 | return platform === 'win32'
6 | }
7 |
8 | static get mac() {
9 | return platform === 'darwin'
10 | }
11 |
12 | static get linux() {
13 | return platform === 'linux'
14 | }
15 |
16 | static get ia32() {
17 | return arch === 'ia32'
18 | }
19 |
20 | static get x64() {
21 | return arch === 'x64'
22 | }
23 |
24 | static get dev() {
25 | return process.env.NODE_ENV === 'development'
26 | }
27 |
28 | static get prod() {
29 | return process.env.NODE_ENV === 'production'
30 | }
31 | }
32 |
33 |
--------------------------------------------------------------------------------
/template/react-project/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "react-project",
3 | "version": "1.0.0",
4 | "license": "MIT",
5 | "main": "dist/resource/electron.js",
6 | "scripts": {
7 | "dev": "electronup --no-minify",
8 | "build": "electronup build",
9 | "dir": "electronup build --dir --no-asar --no-minify",
10 | "lint": "eslint .",
11 | "postinstall": "electron-builder install-app-deps"
12 | },
13 | "dependencies": {
14 | "@quiteer/electron-ipc": "^2.0.4",
15 | "@quiteer/electron-preload": "^0.0.10",
16 | "react": "^18.2.0",
17 | "react-dom": "^18.2.0"
18 | },
19 | "devDependencies": {
20 | "@quiteer/eslint-config": "^0.0.3",
21 | "@types/node": "^20.4.6",
22 | "electron": "22.3.6",
23 | "electron-builder": "^24.6.3",
24 | "electronup": "workspace:^",
25 | "eslint": "^8.43.0",
26 | "sass": "^1.65.1",
27 | "typescript": "^5.1.6",
28 | "@types/react": "^18.2.18",
29 | "@types/react-dom": "^18.2.7",
30 | "@vitejs/plugin-react": "^4.0.4",
31 | "eslint-plugin-react-hooks": "^4.6.0",
32 | "eslint-plugin-react-refresh": "^0.4.3"
33 | }
34 | }
--------------------------------------------------------------------------------
/template/react-project/public/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/QuiteerJs/electronup/668f9c222aa60a30dea56b9f464b752b03391e08/template/react-project/public/icon.png
--------------------------------------------------------------------------------
/template/react-project/public/vite.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/template/react-project/render/App.css:
--------------------------------------------------------------------------------
1 | #root {
2 | max-width: 1280px;
3 | margin: 0 auto;
4 | padding: 2rem;
5 | text-align: center;
6 | }
7 |
8 | .logo {
9 | height: 6em;
10 | padding: 1.5em;
11 | will-change: filter;
12 | transition: filter 300ms;
13 | }
14 | .logo:hover {
15 | filter: drop-shadow(0 0 2em #646cffaa);
16 | }
17 | .logo.react:hover {
18 | filter: drop-shadow(0 0 2em #61dafbaa);
19 | }
20 |
21 | @keyframes logo-spin {
22 | from {
23 | transform: rotate(0deg);
24 | }
25 | to {
26 | transform: rotate(360deg);
27 | }
28 | }
29 |
30 | @media (prefers-reduced-motion: no-preference) {
31 | a:nth-of-type(2) .logo {
32 | animation: logo-spin infinite 20s linear;
33 | }
34 | }
35 |
36 | .card {
37 | padding: 2em;
38 | }
39 |
40 | .read-the-docs {
41 | color: #888;
42 | }
43 |
--------------------------------------------------------------------------------
/template/react-project/render/App.tsx:
--------------------------------------------------------------------------------
1 | import { useState } from 'react'
2 | import reactLogo from './assets/react.svg'
3 | import viteLogo from '/vite.svg'
4 | import './App.css'
5 |
6 | function App() {
7 | const [count, setCount] = useState(0)
8 |
9 | return (
10 | <>
11 |
19 | Vite + React
20 |
21 |
24 |
25 | Edit src/App.tsx
and save to test HMR
26 |
27 |
28 |
29 | Click on the Vite and React logos to learn more
30 |
31 | >
32 | )
33 | }
34 |
35 | export default App
36 |
--------------------------------------------------------------------------------
/template/react-project/render/index.css:
--------------------------------------------------------------------------------
1 | :root {
2 | font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
3 | line-height: 1.5;
4 | font-weight: 400;
5 |
6 | color-scheme: light dark;
7 | color: rgba(255, 255, 255, 0.87);
8 | background-color: #242424;
9 |
10 | font-synthesis: none;
11 | text-rendering: optimizeLegibility;
12 | -webkit-font-smoothing: antialiased;
13 | -moz-osx-font-smoothing: grayscale;
14 | -webkit-text-size-adjust: 100%;
15 | }
16 |
17 | a {
18 | font-weight: 500;
19 | color: #646cff;
20 | text-decoration: inherit;
21 | }
22 | a:hover {
23 | color: #535bf2;
24 | }
25 |
26 | body {
27 | margin: 0;
28 | display: flex;
29 | place-items: center;
30 | min-width: 320px;
31 | min-height: 100vh;
32 | }
33 |
34 | h1 {
35 | font-size: 3.2em;
36 | line-height: 1.1;
37 | }
38 |
39 | button {
40 | border-radius: 8px;
41 | border: 1px solid transparent;
42 | padding: 0.6em 1.2em;
43 | font-size: 1em;
44 | font-weight: 500;
45 | font-family: inherit;
46 | background-color: #1a1a1a;
47 | cursor: pointer;
48 | transition: border-color 0.25s;
49 | }
50 | button:hover {
51 | border-color: #646cff;
52 | }
53 | button:focus,
54 | button:focus-visible {
55 | outline: 4px auto -webkit-focus-ring-color;
56 | }
57 |
58 | @media (prefers-color-scheme: light) {
59 | :root {
60 | color: #213547;
61 | background-color: #ffffff;
62 | }
63 | a:hover {
64 | color: #747bff;
65 | }
66 | button {
67 | background-color: #f9f9f9;
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/template/react-project/render/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | electronup-react
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/template/react-project/render/main.tsx:
--------------------------------------------------------------------------------
1 | import React from 'react'
2 | import ReactDOM from 'react-dom/client'
3 | import App from './App.tsx'
4 | import './index.css'
5 |
6 |
7 | ReactDOM.createRoot(document.getElementById('root')!).render(
8 |
9 |
10 |
11 | )
12 |
--------------------------------------------------------------------------------
/template/react-project/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "ES2020",
4 | "useDefineForClassFields": true,
5 | "module": "ESNext",
6 | "lib": ["ES2020", "DOM", "DOM.Iterable"],
7 | "skipLibCheck": true,
8 |
9 | /* Bundler mode */
10 | "moduleResolution": "bundler",
11 | "allowImportingTsExtensions": true,
12 | "resolveJsonModule": true,
13 | "isolatedModules": true,
14 | "noEmit": true,
15 | "jsx": "react-jsx",
16 |
17 | /* Linting */
18 | "strict": true,
19 | "noUnusedLocals": true,
20 | "noUnusedParameters": true,
21 | "noFallthroughCasesInSwitch": true
22 | },
23 | "include": ["render", "typings"],
24 | "references": [{ "path": "./tsconfig.node.json" }]
25 | }
26 |
--------------------------------------------------------------------------------
/template/react-project/tsconfig.node.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "composite": true,
4 | "skipLibCheck": true,
5 | "module": "ESNext",
6 | "moduleResolution": "bundler",
7 | "allowSyntheticDefaultImports": true
8 | },
9 | "include": ["electronup.config.ts", "main", "typings/*"]
10 | }
11 |
--------------------------------------------------------------------------------
/template/react-project/typings/env.d.ts:
--------------------------------------------------------------------------------
1 | ///
2 |
3 | declare interface ImportMetaEnv {
4 | readonly VITE_MODE_TEXT: string
5 | readonly VITE_HELLO: string
6 | }
7 |
8 | declare interface ImportMeta {
9 | readonly env: ImportMetaEnv
10 | }
11 |
12 | // 主进程环境变量
13 | declare namespace NodeJS {
14 | export interface ProcessEnv {
15 | readonly NODE_ENV: 'development' | 'production'
16 | readonly RENDER_PORT?: string
17 | readonly VITE_HELLO: string
18 | readonly VITE_MODE_TEXT: string
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/template/react-project/typings/global.d.ts:
--------------------------------------------------------------------------------
1 | interface Window {
2 | $ipc: import('@quiteer/electron-preload').PreloadIpc & import('@quiteer/electron-ipc/web').ExpandPreloadIpc
3 | $clipboard: import('@quiteer/electron-preload').PreloadClipboard
4 | $webFrame: import('@quiteer/electron-preload').PreloadWebFrame
5 | }
6 |
7 |
8 |
--------------------------------------------------------------------------------
/template/react-swc-project/.env:
--------------------------------------------------------------------------------
1 | VITE_HELLO = 你好!electronup!
2 |
--------------------------------------------------------------------------------
/template/react-swc-project/.env.development:
--------------------------------------------------------------------------------
1 | VITE_MODE_TEXT=这里是开发环境
2 |
--------------------------------------------------------------------------------
/template/react-swc-project/.env.production:
--------------------------------------------------------------------------------
1 | VITE_MODE_TEXT=这里是生产环境
2 |
--------------------------------------------------------------------------------
/template/react-swc-project/.eslintrc.cjs:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | root: true,
3 | env: { browser: true, es2020: true },
4 | extends: [
5 | '@quiteer/eslint-config',
6 | 'plugin:react-hooks/recommended'
7 | ],
8 | ignorePatterns: ['dist'],
9 | plugins: ['react-refresh'],
10 | rules: {
11 | 'react-refresh/only-export-components': [
12 | 'warn',
13 | { allowConstantExport: true }
14 | ]
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/template/react-swc-project/.gitignore:
--------------------------------------------------------------------------------
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 | dist-ssr
13 | *.local
14 |
15 | # Editor directories and files
16 | .vscode/*
17 | !.vscode/extensions.json
18 | .idea
19 | .DS_Store
20 | *.suo
21 | *.ntvs*
22 | *.njsproj
23 | *.sln
24 | *.sw?
25 |
--------------------------------------------------------------------------------
/template/react-swc-project/.npmrc:
--------------------------------------------------------------------------------
1 | # 一些镜像配置
2 | registry=https://registry.npmmirror.com
3 | electron_mirror=https://cdn.npmmirror.com/binaries/electron/
4 | electron_builder_binaries_mirror=https://npmmirror.com/mirrors/electron-builder-binaries/
5 | # sqlite3_mirror=https://cdn.npmmirror.com/binaries/sqlite3/
6 | # node_sqlite3_binary_host_mirror=https://npmmirror.com/mirrors/sqlite3/
7 |
8 | # https://pnpm.io/zh/npmrc#strict-peer-dependencies
9 | strict-peer-dependencies=false
10 | # https://pnpm.io/zh/cli/run#shell-emulator
11 | shell-emulator=true
12 | # https://pnpm.io/zh/npmrc#auto-install-peers
13 | auto-install-peers=false
14 |
--------------------------------------------------------------------------------
/template/react-swc-project/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2023 quiteer
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/template/react-swc-project/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
electronup-project
4 |
使用 electronup cli 驱动。
5 |
6 |
7 | # [electronup](https://github.com/QuiteerJs/electronup)
8 | [](./LICENSE)  
9 |
10 | > electronup 是一个集成 Vite4.x、tsup6.x、electron-builder24.x 的桌面端构建工具,一个配置文件完成多环境多目标的构建包。
11 |
12 | ## 文档地址
13 |
14 | 文档地址 :https://quiteerjs.github.io/electronup
15 |
16 |
17 | ## 特性
18 |
19 | - **多框架支持** : 使用 `create-electronup` 询问式创建项目模板 , 内置 `vue3` , `react` ,`solid` 等项目模板。
20 | - **Vite + tsup** : 双进程热更新 , 快速开发(主进程代码修改会触发软件重启)。
21 | - **统一的环境变量** : `dotenv` 加载 , 构建时注入 , 双进程拥有相同的环境变量。
22 | - **模式构建** : 默认识别当前代码运行的平台输出打包程序 。
23 | - **可选构建功能提示** : 你将获得可选范围内支持的功能提示 , 选项式自定义构建输出。
24 | - **TypeScript** : 应用程序级 `JavaScript` 的语言。
25 | - **集中管理路径** : 解决双进程资源路径的问题。
26 | - **预置配置** : 内置了很多可以覆盖的构建工具配置。
27 | - **单文件配置** : 只需一个 **electronup.config.ts** 即可管理项目的运行构建。
28 | - **多插件** : 作者会继续开发更多无副作用的独立插件,如:创建窗口,预加载,ipc通信,更新等等。
29 |
30 | ## 声明
31 |
32 | 前提条件
33 | > 熟悉命令行
34 | > 已安装 18 或更高版本的 Node.js
35 |
36 |
37 | 因为使用了 tsup 构建主进程代码,所以该命令行及脚手架只支持 TypeScript ,不支持 JavaScript。
38 |
39 |
40 | ### 一些便携包的相关配置参考
41 |
42 | - `electronup`
43 |
44 | https://www.npmjs.com/package/electronup
45 |
46 | - `@quiteer/electron-ipc`
47 |
48 | https://www.npmjs.com/package/@quiteer/electron-ipc
49 |
50 | - `@quiteer/electron-preload`
51 |
52 | https://www.npmjs.com/package/@quiteer/electron-preload
53 |
54 | 如果你觉得这个项目对你有帮助,可以动动小手 `star` 一下 , 非常感谢!!!
55 |
--------------------------------------------------------------------------------
/template/react-swc-project/electronup.config.ts:
--------------------------------------------------------------------------------
1 | import { resolve } from 'node:path'
2 | import { defineConfig } from 'electronup'
3 |
4 | import reactSwc from '@vitejs/plugin-react-swc'
5 |
6 | export default defineConfig((env) => {
7 | const srcDir = resolve(env.root, 'render')
8 | return {
9 | viteConfig: {
10 | plugins: [reactSwc()],
11 | resolve: {
12 | alias: {
13 | '@': resolve(env.root, 'render')
14 | }
15 | }
16 | },
17 | builderConfig: {
18 | win: {
19 | icon: 'public/icon.png',
20 | target: {
21 | target: 'nsis',
22 | arch: 'ia32'
23 | }
24 | }
25 | }
26 | }
27 | })
28 |
--------------------------------------------------------------------------------
/template/react-swc-project/main/index.ts:
--------------------------------------------------------------------------------
1 | import { Ipc } from '@quiteer/electron-ipc'
2 | import preload from '@quiteer/electron-preload'
3 | import { BrowserWindow, app } from 'electron'
4 | import { Common } from './utils/common'
5 |
6 | app.whenReady().then(() => {
7 | Ipc.init()
8 |
9 | const win = new BrowserWindow({
10 | height: 700,
11 | width: 800,
12 | webPreferences: {
13 | preload: preload as string
14 | }
15 | })
16 |
17 | const child = new BrowserWindow({
18 | parent: win,
19 | height: 730,
20 | width: 700,
21 | frame: false,
22 | show: false,
23 | webPreferences: {
24 | preload: preload as string
25 | }
26 | })
27 |
28 | win.loadURL(Common.loadUrl)
29 | child.loadURL('https://freegpt.one/')
30 |
31 | win.webContents.openDevTools({ mode: 'right' })
32 | win.once('ready-to-show', () => {
33 | setTimeout(() => {
34 | const [x, y] = win.getPosition()
35 | child.setPosition(x + 810, y + 1)
36 | // child.show()
37 | }, 1000)
38 | })
39 |
40 | win.on('will-move', (event, newBounds) => {
41 | child.setPosition(newBounds.x + 810, newBounds.y + 1)
42 | })
43 | })
44 |
--------------------------------------------------------------------------------
/template/react-swc-project/main/utils/common.ts:
--------------------------------------------------------------------------------
1 | import { resolve } from 'path'
2 | import { Is } from './is'
3 |
4 | export class Common {
5 | static get loadUrl() {
6 | const devUrl = `http://localhost:${process.env.RENDER_PORT}`
7 | const prodUrl = `file://${resolve(__dirname, 'index.html')}`
8 | return Is.dev ? devUrl : prodUrl
9 | }
10 |
11 | static get publicPath() {
12 | const dev = resolve(__dirname, '..', '..', 'public')
13 | const prod = __dirname
14 | return Is.dev ? dev : prod
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/template/react-swc-project/main/utils/is.ts:
--------------------------------------------------------------------------------
1 | import { arch, platform } from 'process'
2 |
3 | export class Is {
4 | static get win() {
5 | return platform === 'win32'
6 | }
7 |
8 | static get mac() {
9 | return platform === 'darwin'
10 | }
11 |
12 | static get linux() {
13 | return platform === 'linux'
14 | }
15 |
16 | static get ia32() {
17 | return arch === 'ia32'
18 | }
19 |
20 | static get x64() {
21 | return arch === 'x64'
22 | }
23 |
24 | static get dev() {
25 | return process.env.NODE_ENV === 'development'
26 | }
27 |
28 | static get prod() {
29 | return process.env.NODE_ENV === 'production'
30 | }
31 | }
32 |
33 |
--------------------------------------------------------------------------------
/template/react-swc-project/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "react-swc-project",
3 | "version": "1.0.0",
4 | "license": "MIT",
5 | "main": "dist/resource/electron.js",
6 | "scripts": {
7 | "dev": "electronup --no-minify",
8 | "build": "electronup build",
9 | "dir": "electronup build --dir --no-asar --no-minify",
10 | "lint": "eslint .",
11 | "postinstall": "electron-builder install-app-deps"
12 | },
13 | "dependencies": {
14 | "@quiteer/electron-ipc": "^2.0.4",
15 | "@quiteer/electron-preload": "^0.0.10",
16 | "react": "^18.2.0",
17 | "react-dom": "^18.2.0"
18 | },
19 | "devDependencies": {
20 | "@quiteer/eslint-config": "^0.0.3",
21 | "@types/node": "^20.4.6",
22 | "electron": "22.3.6",
23 | "electron-builder": "^24.6.3",
24 | "electronup": "workspace:^",
25 | "eslint": "^8.43.0",
26 | "sass": "^1.65.1",
27 | "typescript": "^5.1.6",
28 | "@types/react": "^18.2.18",
29 | "@types/react-dom": "^18.2.7",
30 | "@vitejs/plugin-react-swc": "^3.3.2",
31 | "eslint-plugin-react-hooks": "^4.6.0",
32 | "eslint-plugin-react-refresh": "^0.4.3"
33 | }
34 | }
--------------------------------------------------------------------------------
/template/react-swc-project/public/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/QuiteerJs/electronup/668f9c222aa60a30dea56b9f464b752b03391e08/template/react-swc-project/public/icon.png
--------------------------------------------------------------------------------
/template/react-swc-project/public/vite.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/template/react-swc-project/render/App.css:
--------------------------------------------------------------------------------
1 | #root {
2 | max-width: 1280px;
3 | margin: 0 auto;
4 | padding: 2rem;
5 | text-align: center;
6 | }
7 |
8 | .logo {
9 | height: 6em;
10 | padding: 1.5em;
11 | will-change: filter;
12 | transition: filter 300ms;
13 | }
14 | .logo:hover {
15 | filter: drop-shadow(0 0 2em #646cffaa);
16 | }
17 | .logo.react:hover {
18 | filter: drop-shadow(0 0 2em #61dafbaa);
19 | }
20 |
21 | @keyframes logo-spin {
22 | from {
23 | transform: rotate(0deg);
24 | }
25 | to {
26 | transform: rotate(360deg);
27 | }
28 | }
29 |
30 | @media (prefers-reduced-motion: no-preference) {
31 | a:nth-of-type(2) .logo {
32 | animation: logo-spin infinite 20s linear;
33 | }
34 | }
35 |
36 | .card {
37 | padding: 2em;
38 | }
39 |
40 | .read-the-docs {
41 | color: #888;
42 | }
43 |
--------------------------------------------------------------------------------
/template/react-swc-project/render/App.tsx:
--------------------------------------------------------------------------------
1 | import { useState } from 'react'
2 | import reactLogo from './assets/react.svg'
3 | import viteLogo from '/vite.svg'
4 | import './App.css'
5 |
6 | function App() {
7 | const [count, setCount] = useState(0)
8 |
9 | return (
10 | <>
11 |
19 | Vite + React
20 |
21 |
24 |
25 | Edit src/App.tsx
and save to test HMR
26 |
27 |
28 |
29 | Click on the Vite and React logos to learn more
30 |
31 | >
32 | )
33 | }
34 |
35 | export default App
36 |
--------------------------------------------------------------------------------
/template/react-swc-project/render/index.css:
--------------------------------------------------------------------------------
1 | :root {
2 | font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
3 | line-height: 1.5;
4 | font-weight: 400;
5 |
6 | color-scheme: light dark;
7 | color: rgba(255, 255, 255, 0.87);
8 | background-color: #242424;
9 |
10 | font-synthesis: none;
11 | text-rendering: optimizeLegibility;
12 | -webkit-font-smoothing: antialiased;
13 | -moz-osx-font-smoothing: grayscale;
14 | -webkit-text-size-adjust: 100%;
15 | }
16 |
17 | a {
18 | font-weight: 500;
19 | color: #646cff;
20 | text-decoration: inherit;
21 | }
22 | a:hover {
23 | color: #535bf2;
24 | }
25 |
26 | body {
27 | margin: 0;
28 | display: flex;
29 | place-items: center;
30 | min-width: 320px;
31 | min-height: 100vh;
32 | }
33 |
34 | h1 {
35 | font-size: 3.2em;
36 | line-height: 1.1;
37 | }
38 |
39 | button {
40 | border-radius: 8px;
41 | border: 1px solid transparent;
42 | padding: 0.6em 1.2em;
43 | font-size: 1em;
44 | font-weight: 500;
45 | font-family: inherit;
46 | background-color: #1a1a1a;
47 | cursor: pointer;
48 | transition: border-color 0.25s;
49 | }
50 | button:hover {
51 | border-color: #646cff;
52 | }
53 | button:focus,
54 | button:focus-visible {
55 | outline: 4px auto -webkit-focus-ring-color;
56 | }
57 |
58 | @media (prefers-color-scheme: light) {
59 | :root {
60 | color: #213547;
61 | background-color: #ffffff;
62 | }
63 | a:hover {
64 | color: #747bff;
65 | }
66 | button {
67 | background-color: #f9f9f9;
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/template/react-swc-project/render/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | electronup-react
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/template/react-swc-project/render/main.tsx:
--------------------------------------------------------------------------------
1 | import React from 'react'
2 | import ReactDOM from 'react-dom/client'
3 | import App from './App.tsx'
4 | import './index.css'
5 |
6 |
7 | ReactDOM.createRoot(document.getElementById('root')!).render(
8 |
9 |
10 |
11 | )
12 |
--------------------------------------------------------------------------------
/template/react-swc-project/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "ES2020",
4 | "useDefineForClassFields": true,
5 | "module": "ESNext",
6 | "lib": ["ES2020", "DOM", "DOM.Iterable"],
7 | "skipLibCheck": true,
8 |
9 | /* Bundler mode */
10 | "moduleResolution": "bundler",
11 | "allowImportingTsExtensions": true,
12 | "resolveJsonModule": true,
13 | "isolatedModules": true,
14 | "noEmit": true,
15 | "jsx": "react-jsx",
16 |
17 | /* Linting */
18 | "strict": true,
19 | "noUnusedLocals": true,
20 | "noUnusedParameters": true,
21 | "noFallthroughCasesInSwitch": true
22 | },
23 | "include": ["render", "typings"],
24 | "references": [{ "path": "./tsconfig.node.json" }]
25 | }
26 |
--------------------------------------------------------------------------------
/template/react-swc-project/tsconfig.node.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "composite": true,
4 | "skipLibCheck": true,
5 | "module": "ESNext",
6 | "moduleResolution": "bundler",
7 | "allowSyntheticDefaultImports": true
8 | },
9 | "include": ["electronup.config.ts", "main", "typings/*"]
10 | }
11 |
--------------------------------------------------------------------------------
/template/react-swc-project/typings/env.d.ts:
--------------------------------------------------------------------------------
1 | ///
2 |
3 | declare interface ImportMetaEnv {
4 | readonly VITE_MODE_TEXT: string
5 | readonly VITE_HELLO: string
6 | }
7 |
8 | declare interface ImportMeta {
9 | readonly env: ImportMetaEnv
10 | }
11 |
12 | // 主进程环境变量
13 | declare namespace NodeJS {
14 | export interface ProcessEnv {
15 | readonly NODE_ENV: 'development' | 'production'
16 | readonly RENDER_PORT?: string
17 | readonly VITE_HELLO: string
18 | readonly VITE_MODE_TEXT: string
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/template/react-swc-project/typings/global.d.ts:
--------------------------------------------------------------------------------
1 | interface Window {
2 | $ipc: import('@quiteer/electron-preload').PreloadIpc & import('@quiteer/electron-ipc/web').ExpandPreloadIpc
3 | $clipboard: import('@quiteer/electron-preload').PreloadClipboard
4 | $webFrame: import('@quiteer/electron-preload').PreloadWebFrame
5 | }
6 |
7 |
8 |
--------------------------------------------------------------------------------
/template/solid-project/.env:
--------------------------------------------------------------------------------
1 | VITE_HELLO = 你好!electronup!
2 |
--------------------------------------------------------------------------------
/template/solid-project/.env.development:
--------------------------------------------------------------------------------
1 | VITE_MODE_TEXT=这里是开发环境
2 |
--------------------------------------------------------------------------------
/template/solid-project/.env.production:
--------------------------------------------------------------------------------
1 | VITE_MODE_TEXT=这里是生产环境
2 |
--------------------------------------------------------------------------------
/template/solid-project/.eslintrc.cjs:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | }
3 |
--------------------------------------------------------------------------------
/template/solid-project/.gitignore:
--------------------------------------------------------------------------------
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 | dist-ssr
13 | *.local
14 |
15 | # Editor directories and files
16 | .vscode/*
17 | !.vscode/extensions.json
18 | .idea
19 | .DS_Store
20 | *.suo
21 | *.ntvs*
22 | *.njsproj
23 | *.sln
24 | *.sw?
25 |
--------------------------------------------------------------------------------
/template/solid-project/.npmrc:
--------------------------------------------------------------------------------
1 | # 一些镜像配置
2 | registry=https://registry.npmmirror.com
3 | electron_mirror=https://cdn.npmmirror.com/binaries/electron/
4 | electron_builder_binaries_mirror=https://npmmirror.com/mirrors/electron-builder-binaries/
5 | # sqlite3_mirror=https://cdn.npmmirror.com/binaries/sqlite3/
6 | # node_sqlite3_binary_host_mirror=https://npmmirror.com/mirrors/sqlite3/
7 |
8 | # https://pnpm.io/zh/npmrc#strict-peer-dependencies
9 | strict-peer-dependencies=false
10 | # https://pnpm.io/zh/cli/run#shell-emulator
11 | shell-emulator=true
12 | # https://pnpm.io/zh/npmrc#auto-install-peers
13 | auto-install-peers=false
14 |
--------------------------------------------------------------------------------
/template/solid-project/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2023 quiteer
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/template/solid-project/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
electronup-project
4 |
使用 electronup cli 驱动。
5 |
6 |
7 | # [electronup](https://github.com/QuiteerJs/electronup)
8 | [](./LICENSE)  
9 |
10 | > electronup 是一个集成 Vite4.x、tsup6.x、electron-builder24.x 的桌面端构建工具,一个配置文件完成多环境多目标的构建包。
11 |
12 | ## 文档地址
13 |
14 | 文档地址 :https://quiteerjs.github.io/electronup
15 |
16 |
17 | ## 特性
18 |
19 | - **多框架支持** : 使用 `create-electronup` 询问式创建项目模板 , 内置 `vue3` , `react` ,`solid` 等项目模板。
20 | - **Vite + tsup** : 双进程热更新 , 快速开发(主进程代码修改会触发软件重启)。
21 | - **统一的环境变量** : `dotenv` 加载 , 构建时注入 , 双进程拥有相同的环境变量。
22 | - **模式构建** : 默认识别当前代码运行的平台输出打包程序 。
23 | - **可选构建功能提示** : 你将获得可选范围内支持的功能提示 , 选项式自定义构建输出。
24 | - **TypeScript** : 应用程序级 `JavaScript` 的语言。
25 | - **集中管理路径** : 解决双进程资源路径的问题。
26 | - **预置配置** : 内置了很多可以覆盖的构建工具配置。
27 | - **单文件配置** : 只需一个 **electronup.config.ts** 即可管理项目的运行构建。
28 | - **多插件** : 作者会继续开发更多无副作用的独立插件,如:创建窗口,预加载,ipc通信,更新等等。
29 |
30 | ## 声明
31 |
32 | 前提条件
33 | > 熟悉命令行
34 | > 已安装 18 或更高版本的 Node.js
35 |
36 |
37 | 因为使用了 tsup 构建主进程代码,所以该命令行及脚手架只支持 TypeScript ,不支持 JavaScript。
38 |
39 |
40 | ### 一些便携包的相关配置参考
41 |
42 | - `electronup`
43 |
44 | https://www.npmjs.com/package/electronup
45 |
46 | - `@quiteer/electron-ipc`
47 |
48 | https://www.npmjs.com/package/@quiteer/electron-ipc
49 |
50 | - `@quiteer/electron-preload`
51 |
52 | https://www.npmjs.com/package/@quiteer/electron-preload
53 |
54 | 如果你觉得这个项目对你有帮助,可以动动小手 `star` 一下 , 非常感谢!!!
55 |
--------------------------------------------------------------------------------
/template/solid-project/electronup.config.ts:
--------------------------------------------------------------------------------
1 | import { resolve } from 'node:path'
2 | import { defineConfig } from 'electronup'
3 |
4 | import solid from 'vite-plugin-solid'
5 |
6 | export default defineConfig((env) => {
7 | const srcDir = resolve(env.root, 'render')
8 | return {
9 | viteConfig: {
10 | plugins: [solid()],
11 | resolve: {
12 | alias: {
13 | '@': resolve(env.root, 'render')
14 | }
15 | }
16 | },
17 | builderConfig: {
18 | win: {
19 | icon: 'public/icon.png',
20 | target: {
21 | target: 'nsis',
22 | arch: 'ia32'
23 | }
24 | }
25 | }
26 | }
27 | })
28 |
--------------------------------------------------------------------------------
/template/solid-project/main/index.ts:
--------------------------------------------------------------------------------
1 | import { Ipc } from '@quiteer/electron-ipc'
2 | import preload from '@quiteer/electron-preload'
3 | import { BrowserWindow, app } from 'electron'
4 | import { Common } from './utils/common'
5 |
6 | app.whenReady().then(() => {
7 | Ipc.init()
8 |
9 | const win = new BrowserWindow({
10 | height: 700,
11 | width: 800,
12 | webPreferences: {
13 | preload: preload as string
14 | }
15 | })
16 |
17 | const child = new BrowserWindow({
18 | parent: win,
19 | height: 730,
20 | width: 700,
21 | frame: false,
22 | show: false,
23 | webPreferences: {
24 | preload: preload as string
25 | }
26 | })
27 |
28 | win.loadURL(Common.loadUrl)
29 | child.loadURL('https://freegpt.one/')
30 |
31 | win.webContents.openDevTools({ mode: 'right' })
32 | win.once('ready-to-show', () => {
33 | setTimeout(() => {
34 | const [x, y] = win.getPosition()
35 | child.setPosition(x + 810, y + 1)
36 | // child.show()
37 | }, 1000)
38 | })
39 |
40 | win.on('will-move', (event, newBounds) => {
41 | child.setPosition(newBounds.x + 810, newBounds.y + 1)
42 | })
43 | })
44 |
--------------------------------------------------------------------------------
/template/solid-project/main/utils/common.ts:
--------------------------------------------------------------------------------
1 | import { resolve } from 'path'
2 | import { Is } from './is'
3 |
4 | export class Common {
5 | static get loadUrl() {
6 | const devUrl = `http://localhost:${process.env.RENDER_PORT}`
7 | const prodUrl = `file://${resolve(__dirname, 'index.html')}`
8 | return Is.dev ? devUrl : prodUrl
9 | }
10 |
11 | static get publicPath() {
12 | const dev = resolve(__dirname, '..', '..', 'public')
13 | const prod = __dirname
14 | return Is.dev ? dev : prod
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/template/solid-project/main/utils/is.ts:
--------------------------------------------------------------------------------
1 | import { arch, platform } from 'process'
2 |
3 | export class Is {
4 | static get win() {
5 | return platform === 'win32'
6 | }
7 |
8 | static get mac() {
9 | return platform === 'darwin'
10 | }
11 |
12 | static get linux() {
13 | return platform === 'linux'
14 | }
15 |
16 | static get ia32() {
17 | return arch === 'ia32'
18 | }
19 |
20 | static get x64() {
21 | return arch === 'x64'
22 | }
23 |
24 | static get dev() {
25 | return process.env.NODE_ENV === 'development'
26 | }
27 |
28 | static get prod() {
29 | return process.env.NODE_ENV === 'production'
30 | }
31 | }
32 |
33 |
--------------------------------------------------------------------------------
/template/solid-project/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "solid-project",
3 | "version": "1.0.0",
4 | "license": "MIT",
5 | "main": "dist/resource/electron.js",
6 | "scripts": {
7 | "dev": "electronup --no-minify",
8 | "build": "electronup build",
9 | "dir": "electronup build --dir --no-asar --no-minify",
10 | "lint": "eslint .",
11 | "postinstall": "electron-builder install-app-deps"
12 | },
13 | "dependencies": {
14 | "@quiteer/electron-ipc": "^2.0.4",
15 | "@quiteer/electron-preload": "^0.0.10",
16 | "solid-js": "^1.7.9"
17 | },
18 | "devDependencies": {
19 | "@quiteer/eslint-config": "^0.0.3",
20 | "@types/node": "^20.4.6",
21 | "electron": "22.3.6",
22 | "electron-builder": "^24.6.3",
23 | "electronup": "workspace:^",
24 | "eslint": "^8.43.0",
25 | "sass": "^1.65.1",
26 | "typescript": "^5.1.6",
27 | "vite-plugin-solid": "^2.7.0"
28 | }
29 | }
--------------------------------------------------------------------------------
/template/solid-project/public/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/QuiteerJs/electronup/668f9c222aa60a30dea56b9f464b752b03391e08/template/solid-project/public/icon.png
--------------------------------------------------------------------------------
/template/solid-project/public/vite.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/template/solid-project/render/App.css:
--------------------------------------------------------------------------------
1 | #root {
2 | max-width: 1280px;
3 | margin: 0 auto;
4 | padding: 2rem;
5 | text-align: center;
6 | }
7 |
8 | .logo {
9 | height: 6em;
10 | padding: 1.5em;
11 | will-change: filter;
12 | transition: filter 300ms;
13 | }
14 | .logo:hover {
15 | filter: drop-shadow(0 0 2em #646cffaa);
16 | }
17 | .logo.solid:hover {
18 | filter: drop-shadow(0 0 2em #61dafbaa);
19 | }
20 |
21 | .card {
22 | padding: 2em;
23 | }
24 |
25 | .read-the-docs {
26 | color: #888;
27 | }
28 |
--------------------------------------------------------------------------------
/template/solid-project/render/App.tsx:
--------------------------------------------------------------------------------
1 | import { createSignal } from 'solid-js'
2 | import solidLogo from './assets/solid.svg'
3 | import viteLogo from '/vite.svg'
4 | import './App.css'
5 |
6 | function App() {
7 | const [count, setCount] = createSignal(0)
8 |
9 | return (
10 | <>
11 |
19 | Vite + Solid
20 |
21 |
24 |
25 | Edit src/App.tsx
and save to test HMR
26 |
27 |
28 |
29 | Click on the Vite and Solid logos to learn more
30 |
31 | >
32 | )
33 | }
34 |
35 | export default App
36 |
--------------------------------------------------------------------------------
/template/solid-project/render/assets/solid.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/template/solid-project/render/index.css:
--------------------------------------------------------------------------------
1 | :root {
2 | font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
3 | line-height: 1.5;
4 | font-weight: 400;
5 |
6 | color-scheme: light dark;
7 | color: rgba(255, 255, 255, 0.87);
8 | background-color: #242424;
9 |
10 | font-synthesis: none;
11 | text-rendering: optimizeLegibility;
12 | -webkit-font-smoothing: antialiased;
13 | -moz-osx-font-smoothing: grayscale;
14 | -webkit-text-size-adjust: 100%;
15 | }
16 |
17 | a {
18 | font-weight: 500;
19 | color: #646cff;
20 | text-decoration: inherit;
21 | }
22 | a:hover {
23 | color: #535bf2;
24 | }
25 |
26 | body {
27 | margin: 0;
28 | display: flex;
29 | place-items: center;
30 | min-width: 320px;
31 | min-height: 100vh;
32 | }
33 |
34 | h1 {
35 | font-size: 3.2em;
36 | line-height: 1.1;
37 | }
38 |
39 | button {
40 | border-radius: 8px;
41 | border: 1px solid transparent;
42 | padding: 0.6em 1.2em;
43 | font-size: 1em;
44 | font-weight: 500;
45 | font-family: inherit;
46 | background-color: #1a1a1a;
47 | cursor: pointer;
48 | transition: border-color 0.25s;
49 | }
50 | button:hover {
51 | border-color: #646cff;
52 | }
53 | button:focus,
54 | button:focus-visible {
55 | outline: 4px auto -webkit-focus-ring-color;
56 | }
57 |
58 | @media (prefers-color-scheme: light) {
59 | :root {
60 | color: #213547;
61 | background-color: #ffffff;
62 | }
63 | a:hover {
64 | color: #747bff;
65 | }
66 | button {
67 | background-color: #f9f9f9;
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/template/solid-project/render/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | electronup-solid
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/template/solid-project/render/index.tsx:
--------------------------------------------------------------------------------
1 | /* @refresh reload */
2 | import { render } from 'solid-js/web'
3 |
4 | import './index.css'
5 | import App from './App'
6 |
7 | const root = document.getElementById('root')
8 |
9 | render(() => , root!)
10 |
--------------------------------------------------------------------------------
/template/solid-project/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "ES2020",
4 | "useDefineForClassFields": true,
5 | "module": "ESNext",
6 | "lib": ["ES2020", "DOM", "DOM.Iterable"],
7 | "skipLibCheck": true,
8 |
9 | /* Bundler mode */
10 | "moduleResolution": "bundler",
11 | "allowImportingTsExtensions": true,
12 | "resolveJsonModule": true,
13 | "isolatedModules": true,
14 | "noEmit": true,
15 | "jsx": "preserve",
16 | "jsxImportSource": "solid-js",
17 |
18 | /* Linting */
19 | "strict": true,
20 | "noUnusedLocals": true,
21 | "noUnusedParameters": true,
22 | "noFallthroughCasesInSwitch": true
23 | },
24 | "include": ["render", "typings"],
25 | "references": [{ "path": "./tsconfig.node.json" }]
26 | }
27 |
--------------------------------------------------------------------------------
/template/solid-project/tsconfig.node.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "composite": true,
4 | "skipLibCheck": true,
5 | "module": "ESNext",
6 | "moduleResolution": "bundler",
7 | "allowSyntheticDefaultImports": true
8 | },
9 | "include": ["electronup.config.ts", "main", "typings/*"]
10 | }
11 |
--------------------------------------------------------------------------------
/template/solid-project/typings/env.d.ts:
--------------------------------------------------------------------------------
1 | ///
2 |
3 | declare interface ImportMetaEnv {
4 | readonly VITE_MODE_TEXT: string
5 | readonly VITE_HELLO: string
6 | }
7 |
8 | declare interface ImportMeta {
9 | readonly env: ImportMetaEnv
10 | }
11 |
12 | // 主进程环境变量
13 | declare namespace NodeJS {
14 | export interface ProcessEnv {
15 | readonly NODE_ENV: 'development' | 'production'
16 | readonly RENDER_PORT?: string
17 | readonly VITE_HELLO: string
18 | readonly VITE_MODE_TEXT: string
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/template/solid-project/typings/global.d.ts:
--------------------------------------------------------------------------------
1 | interface Window {
2 | $ipc: import('@quiteer/electron-preload').PreloadIpc & import('@quiteer/electron-ipc/web').ExpandPreloadIpc
3 | $clipboard: import('@quiteer/electron-preload').PreloadClipboard
4 | $webFrame: import('@quiteer/electron-preload').PreloadWebFrame
5 | }
6 |
7 |
8 |
--------------------------------------------------------------------------------
/template/vanilla-project/.env:
--------------------------------------------------------------------------------
1 | VITE_HELLO = 你好!electronup!
2 |
--------------------------------------------------------------------------------
/template/vanilla-project/.env.development:
--------------------------------------------------------------------------------
1 | VITE_MODE_TEXT=这里是开发环境
2 |
--------------------------------------------------------------------------------
/template/vanilla-project/.env.production:
--------------------------------------------------------------------------------
1 | VITE_MODE_TEXT=这里是生产环境
2 |
--------------------------------------------------------------------------------
/template/vanilla-project/.eslintrc.cjs:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | extends: ['@quiteer/eslint-config'],
3 | }
4 |
--------------------------------------------------------------------------------
/template/vanilla-project/.gitignore:
--------------------------------------------------------------------------------
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 | dist-ssr
13 | *.local
14 |
15 | # Editor directories and files
16 | .vscode/*
17 | !.vscode/extensions.json
18 | .idea
19 | .DS_Store
20 | *.suo
21 | *.ntvs*
22 | *.njsproj
23 | *.sln
24 | *.sw?
25 |
--------------------------------------------------------------------------------
/template/vanilla-project/.npmrc:
--------------------------------------------------------------------------------
1 | # 一些镜像配置
2 | registry=https://registry.npmmirror.com
3 | electron_mirror=https://cdn.npmmirror.com/binaries/electron/
4 | electron_builder_binaries_mirror=https://npmmirror.com/mirrors/electron-builder-binaries/
5 | # sqlite3_mirror=https://cdn.npmmirror.com/binaries/sqlite3/
6 | # node_sqlite3_binary_host_mirror=https://npmmirror.com/mirrors/sqlite3/
7 |
8 | # https://pnpm.io/zh/npmrc#strict-peer-dependencies
9 | strict-peer-dependencies=false
10 | # https://pnpm.io/zh/cli/run#shell-emulator
11 | shell-emulator=true
12 | # https://pnpm.io/zh/npmrc#auto-install-peers
13 | auto-install-peers=false
14 |
--------------------------------------------------------------------------------
/template/vanilla-project/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2023 quiteer
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/template/vanilla-project/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
electronup-project
4 |
使用 electronup cli 驱动。
5 |
6 |
7 | # [electronup](https://github.com/QuiteerJs/electronup)
8 | [](./LICENSE)  
9 |
10 | > electronup 是一个集成 Vite4.x、tsup6.x、electron-builder24.x 的桌面端构建工具,一个配置文件完成多环境多目标的构建包。
11 |
12 | ## 文档地址
13 |
14 | 文档地址 :https://quiteerjs.github.io/electronup
15 |
16 |
17 | ## 特性
18 |
19 | - **多框架支持** : 使用 `create-electronup` 询问式创建项目模板 , 内置 `vue3` , `react` ,`solid` 等项目模板。
20 | - **Vite + tsup** : 双进程热更新 , 快速开发(主进程代码修改会触发软件重启)。
21 | - **统一的环境变量** : `dotenv` 加载 , 构建时注入 , 双进程拥有相同的环境变量。
22 | - **模式构建** : 默认识别当前代码运行的平台输出打包程序 。
23 | - **可选构建功能提示** : 你将获得可选范围内支持的功能提示 , 选项式自定义构建输出。
24 | - **TypeScript** : 应用程序级 `JavaScript` 的语言。
25 | - **集中管理路径** : 解决双进程资源路径的问题。
26 | - **预置配置** : 内置了很多可以覆盖的构建工具配置。
27 | - **单文件配置** : 只需一个 **electronup.config.ts** 即可管理项目的运行构建。
28 | - **多插件** : 作者会继续开发更多无副作用的独立插件,如:创建窗口,预加载,ipc通信,更新等等。
29 |
30 | ## 声明
31 |
32 | 前提条件
33 | > 熟悉命令行
34 | > 已安装 18 或更高版本的 Node.js
35 |
36 |
37 | 因为使用了 tsup 构建主进程代码,所以该命令行及脚手架只支持 TypeScript ,不支持 JavaScript。
38 |
39 |
40 | ### 一些便携包的相关配置参考
41 |
42 | - `electronup`
43 |
44 | https://www.npmjs.com/package/electronup
45 |
46 | - `@quiteer/electron-ipc`
47 |
48 | https://www.npmjs.com/package/@quiteer/electron-ipc
49 |
50 | - `@quiteer/electron-preload`
51 |
52 | https://www.npmjs.com/package/@quiteer/electron-preload
53 |
54 | 如果你觉得这个项目对你有帮助,可以动动小手 `star` 一下 , 非常感谢!!!
55 |
--------------------------------------------------------------------------------
/template/vanilla-project/electronup.config.ts:
--------------------------------------------------------------------------------
1 | import { resolve } from 'node:path'
2 | import { defineConfig } from 'electronup'
3 |
4 |
5 |
6 | export default defineConfig((env) => {
7 | const srcDir = resolve(env.root, 'render')
8 | return {
9 | viteConfig: {
10 | plugins: [],
11 | resolve: {
12 | alias: {
13 | '@': resolve(env.root, 'render')
14 | }
15 | }
16 | },
17 | builderConfig: {
18 | win: {
19 | icon: 'public/icon.png',
20 | target: {
21 | target: 'nsis',
22 | arch: 'ia32'
23 | }
24 | }
25 | }
26 | }
27 | })
28 |
--------------------------------------------------------------------------------
/template/vanilla-project/main/index.ts:
--------------------------------------------------------------------------------
1 | import { Ipc } from '@quiteer/electron-ipc'
2 | import preload from '@quiteer/electron-preload'
3 | import { BrowserWindow, app } from 'electron'
4 | import { Common } from './utils/common'
5 |
6 | app.whenReady().then(() => {
7 | Ipc.init()
8 |
9 | const win = new BrowserWindow({
10 | height: 700,
11 | width: 800,
12 | webPreferences: {
13 | preload: preload as string
14 | }
15 | })
16 |
17 | const child = new BrowserWindow({
18 | parent: win,
19 | height: 730,
20 | width: 700,
21 | frame: false,
22 | show: false,
23 | webPreferences: {
24 | preload: preload as string
25 | }
26 | })
27 |
28 | win.loadURL(Common.loadUrl)
29 | child.loadURL('https://freegpt.one/')
30 |
31 | win.webContents.openDevTools({ mode: 'right' })
32 | win.once('ready-to-show', () => {
33 | setTimeout(() => {
34 | const [x, y] = win.getPosition()
35 | child.setPosition(x + 810, y + 1)
36 | // child.show()
37 | }, 1000)
38 | })
39 |
40 | win.on('will-move', (event, newBounds) => {
41 | child.setPosition(newBounds.x + 810, newBounds.y + 1)
42 | })
43 | })
44 |
--------------------------------------------------------------------------------
/template/vanilla-project/main/utils/common.ts:
--------------------------------------------------------------------------------
1 | import { resolve } from 'path'
2 | import { Is } from './is'
3 |
4 | export class Common {
5 | static get loadUrl() {
6 | const devUrl = `http://localhost:${process.env.RENDER_PORT}`
7 | const prodUrl = `file://${resolve(__dirname, 'index.html')}`
8 | return Is.dev ? devUrl : prodUrl
9 | }
10 |
11 | static get publicPath() {
12 | const dev = resolve(__dirname, '..', '..', 'public')
13 | const prod = __dirname
14 | return Is.dev ? dev : prod
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/template/vanilla-project/main/utils/is.ts:
--------------------------------------------------------------------------------
1 | import { arch, platform } from 'process'
2 |
3 | export class Is {
4 | static get win() {
5 | return platform === 'win32'
6 | }
7 |
8 | static get mac() {
9 | return platform === 'darwin'
10 | }
11 |
12 | static get linux() {
13 | return platform === 'linux'
14 | }
15 |
16 | static get ia32() {
17 | return arch === 'ia32'
18 | }
19 |
20 | static get x64() {
21 | return arch === 'x64'
22 | }
23 |
24 | static get dev() {
25 | return process.env.NODE_ENV === 'development'
26 | }
27 |
28 | static get prod() {
29 | return process.env.NODE_ENV === 'production'
30 | }
31 | }
32 |
33 |
--------------------------------------------------------------------------------
/template/vanilla-project/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "vanilla-project",
3 | "version": "1.0.0",
4 | "license": "MIT",
5 | "main": "dist/resource/electron.js",
6 | "scripts": {
7 | "dev": "electronup --no-minify",
8 | "build": "electronup build",
9 | "dir": "electronup build --dir --no-asar --no-minify",
10 | "lint": "eslint .",
11 | "postinstall": "electron-builder install-app-deps"
12 | },
13 | "dependencies": {
14 | "@quiteer/electron-ipc": "^2.0.4",
15 | "@quiteer/electron-preload": "^0.0.10"
16 | },
17 | "devDependencies": {
18 | "@quiteer/eslint-config": "^0.0.3",
19 | "@types/node": "^20.4.6",
20 | "electron": "22.3.6",
21 | "electron-builder": "^24.6.3",
22 | "electronup": "workspace:^",
23 | "eslint": "^8.43.0",
24 | "sass": "^1.65.1",
25 | "typescript": "^5.1.6"
26 | }
27 | }
--------------------------------------------------------------------------------
/template/vanilla-project/public/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/QuiteerJs/electronup/668f9c222aa60a30dea56b9f464b752b03391e08/template/vanilla-project/public/icon.png
--------------------------------------------------------------------------------
/template/vanilla-project/public/vite.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/template/vanilla-project/render/counter.ts:
--------------------------------------------------------------------------------
1 | export function setupCounter(element: HTMLButtonElement) {
2 | let counter = 0
3 | const setCounter = (count: number) => {
4 | counter = count
5 | element.innerHTML = `count is ${counter}`
6 | }
7 | element.addEventListener('click', () => setCounter(counter + 1))
8 | setCounter(0)
9 | }
10 |
--------------------------------------------------------------------------------
/template/vanilla-project/render/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | electronup-vanilla
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/template/vanilla-project/render/main.ts:
--------------------------------------------------------------------------------
1 | import './style.css'
2 | import typescriptLogo from './typescript.svg'
3 | import viteLogo from '/vite.svg'
4 | import { setupCounter } from './counter'
5 |
6 | document.querySelector('#app')!.innerHTML = `
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
Vite + TypeScript
15 |
16 |
17 |
18 |
19 | Click on the Vite and TypeScript logos to learn more
20 |
21 |
22 | `
23 |
24 | setupCounter(document.querySelector('#counter')!)
25 |
--------------------------------------------------------------------------------
/template/vanilla-project/render/style.css:
--------------------------------------------------------------------------------
1 | :root {
2 | font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
3 | line-height: 1.5;
4 | font-weight: 400;
5 |
6 | color-scheme: light dark;
7 | color: rgba(255, 255, 255, 0.87);
8 | background-color: #242424;
9 |
10 | font-synthesis: none;
11 | text-rendering: optimizeLegibility;
12 | -webkit-font-smoothing: antialiased;
13 | -moz-osx-font-smoothing: grayscale;
14 | -webkit-text-size-adjust: 100%;
15 | }
16 |
17 | a {
18 | font-weight: 500;
19 | color: #646cff;
20 | text-decoration: inherit;
21 | }
22 | a:hover {
23 | color: #535bf2;
24 | }
25 |
26 | body {
27 | margin: 0;
28 | display: flex;
29 | place-items: center;
30 | min-width: 320px;
31 | min-height: 100vh;
32 | }
33 |
34 | h1 {
35 | font-size: 3.2em;
36 | line-height: 1.1;
37 | }
38 |
39 | #app {
40 | max-width: 1280px;
41 | margin: 0 auto;
42 | padding: 2rem;
43 | text-align: center;
44 | }
45 |
46 | .logo {
47 | height: 6em;
48 | padding: 1.5em;
49 | will-change: filter;
50 | transition: filter 300ms;
51 | }
52 | .logo:hover {
53 | filter: drop-shadow(0 0 2em #646cffaa);
54 | }
55 | .logo.vanilla:hover {
56 | filter: drop-shadow(0 0 2em #3178c6aa);
57 | }
58 |
59 | .card {
60 | padding: 2em;
61 | }
62 |
63 | .read-the-docs {
64 | color: #888;
65 | }
66 |
67 | button {
68 | border-radius: 8px;
69 | border: 1px solid transparent;
70 | padding: 0.6em 1.2em;
71 | font-size: 1em;
72 | font-weight: 500;
73 | font-family: inherit;
74 | background-color: #1a1a1a;
75 | cursor: pointer;
76 | transition: border-color 0.25s;
77 | }
78 | button:hover {
79 | border-color: #646cff;
80 | }
81 | button:focus,
82 | button:focus-visible {
83 | outline: 4px auto -webkit-focus-ring-color;
84 | }
85 |
86 | @media (prefers-color-scheme: light) {
87 | :root {
88 | color: #213547;
89 | background-color: #ffffff;
90 | }
91 | a:hover {
92 | color: #747bff;
93 | }
94 | button {
95 | background-color: #f9f9f9;
96 | }
97 | }
98 |
--------------------------------------------------------------------------------
/template/vanilla-project/render/typescript.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/template/vanilla-project/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "ES2020",
4 | "useDefineForClassFields": true,
5 | "module": "ESNext",
6 | "lib": ["ES2020", "DOM", "DOM.Iterable"],
7 | "skipLibCheck": true,
8 |
9 | /* Bundler mode */
10 | "moduleResolution": "bundler",
11 | "allowImportingTsExtensions": true,
12 | "resolveJsonModule": true,
13 | "isolatedModules": true,
14 | "noEmit": true,
15 | "jsx": "preserve",
16 |
17 | /* Linting */
18 | "strict": true,
19 | "noUnusedLocals": true,
20 | "noUnusedParameters": true,
21 | "noFallthroughCasesInSwitch": true
22 | },
23 | "include": ["render", "typings"],
24 | "references": [{ "path": "./tsconfig.node.json" }]
25 | }
26 |
--------------------------------------------------------------------------------
/template/vanilla-project/tsconfig.node.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "composite": true,
4 | "skipLibCheck": true,
5 | "module": "ESNext",
6 | "moduleResolution": "bundler",
7 | "allowSyntheticDefaultImports": true
8 | },
9 | "include": ["electronup.config.ts", "main", "typings/*"]
10 | }
11 |
--------------------------------------------------------------------------------
/template/vanilla-project/typings/env.d.ts:
--------------------------------------------------------------------------------
1 | ///
2 |
3 | declare interface ImportMetaEnv {
4 | readonly VITE_MODE_TEXT: string
5 | readonly VITE_HELLO: string
6 | }
7 |
8 | declare interface ImportMeta {
9 | readonly env: ImportMetaEnv
10 | }
11 |
12 | // 主进程环境变量
13 | declare namespace NodeJS {
14 | export interface ProcessEnv {
15 | readonly NODE_ENV: 'development' | 'production'
16 | readonly RENDER_PORT?: string
17 | readonly VITE_HELLO: string
18 | readonly VITE_MODE_TEXT: string
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/template/vanilla-project/typings/global.d.ts:
--------------------------------------------------------------------------------
1 | interface Window {
2 | $ipc: import('@quiteer/electron-preload').PreloadIpc & import('@quiteer/electron-ipc/web').ExpandPreloadIpc
3 | $clipboard: import('@quiteer/electron-preload').PreloadClipboard
4 | $webFrame: import('@quiteer/electron-preload').PreloadWebFrame
5 | }
6 |
7 |
8 |
--------------------------------------------------------------------------------
/template/vue-project/.env:
--------------------------------------------------------------------------------
1 | VITE_HELLO = 你好!electronup!
2 |
--------------------------------------------------------------------------------
/template/vue-project/.env.development:
--------------------------------------------------------------------------------
1 | VITE_MODE_TEXT=这里是开发环境
2 |
--------------------------------------------------------------------------------
/template/vue-project/.env.production:
--------------------------------------------------------------------------------
1 | VITE_MODE_TEXT=这里是生产环境
2 |
--------------------------------------------------------------------------------
/template/vue-project/.eslintrc.cjs:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | extends: ['@quiteer/eslint-config'],
3 | }
4 |
--------------------------------------------------------------------------------
/template/vue-project/.gitignore:
--------------------------------------------------------------------------------
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 | dist-ssr
13 | *.local
14 |
15 | # Editor directories and files
16 | .vscode/*
17 | !.vscode/extensions.json
18 | .idea
19 | .DS_Store
20 | *.suo
21 | *.ntvs*
22 | *.njsproj
23 | *.sln
24 | *.sw?
25 |
--------------------------------------------------------------------------------
/template/vue-project/.npmrc:
--------------------------------------------------------------------------------
1 | # 一些镜像配置
2 | registry=https://registry.npmmirror.com
3 | electron_mirror=https://cdn.npmmirror.com/binaries/electron/
4 | electron_builder_binaries_mirror=https://npmmirror.com/mirrors/electron-builder-binaries/
5 | # sqlite3_mirror=https://cdn.npmmirror.com/binaries/sqlite3/
6 | # node_sqlite3_binary_host_mirror=https://npmmirror.com/mirrors/sqlite3/
7 |
8 | # https://pnpm.io/zh/npmrc#strict-peer-dependencies
9 | strict-peer-dependencies=false
10 | # https://pnpm.io/zh/cli/run#shell-emulator
11 | shell-emulator=true
12 | # https://pnpm.io/zh/npmrc#auto-install-peers
13 | auto-install-peers=false
14 |
--------------------------------------------------------------------------------
/template/vue-project/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2023 quiteer
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/template/vue-project/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
electronup-project
4 |
使用 electronup cli 驱动。
5 |
6 |
7 | # [electronup](https://github.com/QuiteerJs/electronup)
8 | [](./LICENSE)  
9 |
10 | > electronup 是一个集成 Vite4.x、tsup6.x、electron-builder24.x 的桌面端构建工具,一个配置文件完成多环境多目标的构建包。
11 |
12 | ## 文档地址
13 |
14 | 文档地址 :https://quiteerjs.github.io/electronup
15 |
16 |
17 | ## 特性
18 |
19 | - **多框架支持** : 使用 `create-electronup` 询问式创建项目模板 , 内置 `vue3` , `react` ,`solid` 等项目模板。
20 | - **Vite + tsup** : 双进程热更新 , 快速开发(主进程代码修改会触发软件重启)。
21 | - **统一的环境变量** : `dotenv` 加载 , 构建时注入 , 双进程拥有相同的环境变量。
22 | - **模式构建** : 默认识别当前代码运行的平台输出打包程序 。
23 | - **可选构建功能提示** : 你将获得可选范围内支持的功能提示 , 选项式自定义构建输出。
24 | - **TypeScript** : 应用程序级 `JavaScript` 的语言。
25 | - **集中管理路径** : 解决双进程资源路径的问题。
26 | - **预置配置** : 内置了很多可以覆盖的构建工具配置。
27 | - **单文件配置** : 只需一个 **electronup.config.ts** 即可管理项目的运行构建。
28 | - **多插件** : 作者会继续开发更多无副作用的独立插件,如:创建窗口,预加载,ipc通信,更新等等。
29 |
30 | ## 声明
31 |
32 | 前提条件
33 | > 熟悉命令行
34 | > 已安装 18 或更高版本的 Node.js
35 |
36 |
37 | 因为使用了 tsup 构建主进程代码,所以该命令行及脚手架只支持 TypeScript ,不支持 JavaScript。
38 |
39 |
40 | ### 一些便携包的相关配置参考
41 |
42 | - `electronup`
43 |
44 | https://www.npmjs.com/package/electronup
45 |
46 | - `@quiteer/electron-ipc`
47 |
48 | https://www.npmjs.com/package/@quiteer/electron-ipc
49 |
50 | - `@quiteer/electron-preload`
51 |
52 | https://www.npmjs.com/package/@quiteer/electron-preload
53 |
54 | 如果你觉得这个项目对你有帮助,可以动动小手 `star` 一下 , 非常感谢!!!
55 |
--------------------------------------------------------------------------------
/template/vue-project/electronup.config.ts:
--------------------------------------------------------------------------------
1 | import { resolve } from 'node:path'
2 | import { defineConfig } from 'electronup'
3 |
4 | import vue from '@vitejs/plugin-vue'
5 |
6 | export default defineConfig((env) => {
7 | const srcDir = resolve(env.root, 'render')
8 | return {
9 | viteConfig: {
10 | plugins: [vue()],
11 | resolve: {
12 | alias: {
13 | '@': resolve(env.root, 'render')
14 | }
15 | }
16 | },
17 | builderConfig: {
18 | win: {
19 | icon: 'public/icon.png',
20 | target: {
21 | target: 'nsis',
22 | arch: 'ia32'
23 | }
24 | }
25 | }
26 | }
27 | })
28 |
--------------------------------------------------------------------------------
/template/vue-project/main/index.ts:
--------------------------------------------------------------------------------
1 | import { Ipc } from '@quiteer/electron-ipc'
2 | import preload from '@quiteer/electron-preload'
3 | import { BrowserWindow, app } from 'electron'
4 | import { Common } from './utils/common'
5 |
6 | app.whenReady().then(() => {
7 | Ipc.init()
8 |
9 | const win = new BrowserWindow({
10 | height: 700,
11 | width: 800,
12 | webPreferences: {
13 | preload: preload as string
14 | }
15 | })
16 |
17 | const child = new BrowserWindow({
18 | parent: win,
19 | height: 730,
20 | width: 700,
21 | frame: false,
22 | show: false,
23 | webPreferences: {
24 | preload: preload as string
25 | }
26 | })
27 |
28 | win.loadURL(Common.loadUrl)
29 | child.loadURL('https://freegpt.one/')
30 |
31 | win.webContents.openDevTools({ mode: 'right' })
32 | win.once('ready-to-show', () => {
33 | setTimeout(() => {
34 | const [x, y] = win.getPosition()
35 | child.setPosition(x + 810, y + 1)
36 | // child.show()
37 | }, 1000)
38 | })
39 |
40 | win.on('will-move', (event, newBounds) => {
41 | child.setPosition(newBounds.x + 810, newBounds.y + 1)
42 | })
43 | })
44 |
--------------------------------------------------------------------------------
/template/vue-project/main/utils/common.ts:
--------------------------------------------------------------------------------
1 | import { resolve } from 'path'
2 | import { Is } from './is'
3 |
4 | export class Common {
5 | static get loadUrl() {
6 | const devUrl = `http://localhost:${process.env.RENDER_PORT}`
7 | const prodUrl = `file://${resolve(__dirname, 'index.html')}`
8 | return Is.dev ? devUrl : prodUrl
9 | }
10 |
11 | static get publicPath() {
12 | const dev = resolve(__dirname, '..', '..', 'public')
13 | const prod = __dirname
14 | return Is.dev ? dev : prod
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/template/vue-project/main/utils/is.ts:
--------------------------------------------------------------------------------
1 | import { arch, platform } from 'process'
2 |
3 | export class Is {
4 | static get win() {
5 | return platform === 'win32'
6 | }
7 |
8 | static get mac() {
9 | return platform === 'darwin'
10 | }
11 |
12 | static get linux() {
13 | return platform === 'linux'
14 | }
15 |
16 | static get ia32() {
17 | return arch === 'ia32'
18 | }
19 |
20 | static get x64() {
21 | return arch === 'x64'
22 | }
23 |
24 | static get dev() {
25 | return process.env.NODE_ENV === 'development'
26 | }
27 |
28 | static get prod() {
29 | return process.env.NODE_ENV === 'production'
30 | }
31 | }
32 |
33 |
--------------------------------------------------------------------------------
/template/vue-project/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "vue-project",
3 | "version": "1.0.0",
4 | "license": "MIT",
5 | "main": "dist/resource/electron.js",
6 | "scripts": {
7 | "dev": "electronup --no-minify",
8 | "build": "electronup build",
9 | "dir": "electronup build --dir --no-asar --no-minify",
10 | "typecheck": "vue-tsc --noEmit --skipLibCheck",
11 | "lint": "eslint .",
12 | "postinstall": "electron-builder install-app-deps"
13 | },
14 | "dependencies": {
15 | "@quiteer/electron-ipc": "^2.0.4",
16 | "@quiteer/electron-preload": "^0.0.10",
17 | "echarts": "^5.4.2"
18 | },
19 | "devDependencies": {
20 | "@quiteer/eslint-config": "^0.0.3",
21 | "@types/node": "^20.4.6",
22 | "electron": "22.3.6",
23 | "electron-builder": "^24.6.3",
24 | "electronup": "workspace:^",
25 | "eslint": "^8.43.0",
26 | "sass": "^1.65.1",
27 | "typescript": "^5.1.6",
28 | "@vitejs/plugin-vue": "^5.0.3",
29 | "pinia": "^2.1.7",
30 | "vue": "^3.4.15",
31 | "vue-router": "^4.2.5",
32 | "vue-tsc": "^1.8.1"
33 | }
34 | }
--------------------------------------------------------------------------------
/template/vue-project/public/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/QuiteerJs/electronup/668f9c222aa60a30dea56b9f464b752b03391e08/template/vue-project/public/icon.png
--------------------------------------------------------------------------------
/template/vue-project/public/vite.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/template/vue-project/render/App.vue:
--------------------------------------------------------------------------------
1 |
31 |
32 |
33 |
34 |

35 |
36 |
39 |
40 |
41 |
90 |
--------------------------------------------------------------------------------
/template/vue-project/render/assets/avatar.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/QuiteerJs/electronup/668f9c222aa60a30dea56b9f464b752b03391e08/template/vue-project/render/assets/avatar.png
--------------------------------------------------------------------------------
/template/vue-project/render/assets/vue.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/template/vue-project/render/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | electronup-vue
8 |
9 |
10 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/template/vue-project/render/loading/index.vue:
--------------------------------------------------------------------------------
1 |
58 |
59 |
60 |
61 |
62 |
63 |
73 |
--------------------------------------------------------------------------------
/template/vue-project/render/main.ts:
--------------------------------------------------------------------------------
1 | import './styles/style.css'
2 | import { createPinia } from 'pinia'
3 | import { createApp } from 'vue'
4 | import App from './App.vue'
5 | import Loading from './loading/index.vue'
6 |
7 | createApp(Loading).mount('#app-loading')
8 |
9 | console.log(import.meta.env)
10 |
11 | setTimeout(() => {
12 | const app = createApp(App)
13 | app.use(createPinia())
14 | .mount('#app')
15 | }, 2000)
16 |
17 |
--------------------------------------------------------------------------------
/template/vue-project/render/store/index.ts:
--------------------------------------------------------------------------------
1 | import { defineStore } from 'pinia'
2 |
3 | interface DemoState {
4 | demo: {
5 | name: string
6 | }
7 | }
8 |
9 | export const useDemoStore = defineStore('demo', {
10 | state: (): DemoState => ({
11 | demo: {
12 | name: 'demo'
13 | }
14 | }),
15 | getters: {
16 | name: (state): string => state.demo.name
17 | },
18 | actions: {
19 | actionDemo(data: string) {
20 | this.demo.name = data
21 | }
22 | }
23 | })
24 |
--------------------------------------------------------------------------------
/template/vue-project/render/styles/style.css:
--------------------------------------------------------------------------------
1 | body {
2 | margin: 0;
3 | }
4 |
5 | #app {
6 | max-width: 1280px;
7 | margin: 0 auto;
8 | padding: 2rem;
9 | text-align: center;
10 | }
11 |
12 | #app-loading{
13 | position:absolut;
14 | top:0;
15 | left:0;
16 | }
17 |
--------------------------------------------------------------------------------
/template/vue-project/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "ES2020",
4 | "useDefineForClassFields": true,
5 | "module": "ESNext",
6 | "lib": ["ES2020", "DOM", "DOM.Iterable"],
7 | "skipLibCheck": true,
8 |
9 | /* Bundler mode */
10 | "moduleResolution": "bundler",
11 | "allowImportingTsExtensions": true,
12 | "resolveJsonModule": true,
13 | "isolatedModules": true,
14 | "noEmit": true,
15 | "jsx": "preserve",
16 |
17 | /* Linting */
18 | "strict": true,
19 | "noUnusedLocals": true,
20 | "noUnusedParameters": true,
21 | "noFallthroughCasesInSwitch": true
22 | },
23 | "include": ["render", "typings"],
24 | "references": [{ "path": "./tsconfig.node.json" }]
25 | }
26 |
--------------------------------------------------------------------------------
/template/vue-project/tsconfig.node.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "composite": true,
4 | "skipLibCheck": true,
5 | "module": "ESNext",
6 | "moduleResolution": "bundler",
7 | "allowSyntheticDefaultImports": true
8 | },
9 | "include": ["electronup.config.ts", "main", "typings/*"]
10 | }
11 |
--------------------------------------------------------------------------------
/template/vue-project/typings/env.d.ts:
--------------------------------------------------------------------------------
1 | ///
2 |
3 | declare interface ImportMetaEnv {
4 | readonly VITE_MODE_TEXT: string
5 | readonly VITE_HELLO: string
6 | }
7 |
8 | declare interface ImportMeta {
9 | readonly env: ImportMetaEnv
10 | }
11 |
12 | // 主进程环境变量
13 | declare namespace NodeJS {
14 | export interface ProcessEnv {
15 | readonly NODE_ENV: 'development' | 'production'
16 | readonly RENDER_PORT?: string
17 | readonly VITE_HELLO: string
18 | readonly VITE_MODE_TEXT: string
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/template/vue-project/typings/global.d.ts:
--------------------------------------------------------------------------------
1 | interface Window {
2 | $ipc: import('@quiteer/electron-preload').PreloadIpc & import('@quiteer/electron-ipc/web').ExpandPreloadIpc
3 | $clipboard: import('@quiteer/electron-preload').PreloadClipboard
4 | $webFrame: import('@quiteer/electron-preload').PreloadWebFrame
5 | }
6 |
7 |
8 |
--------------------------------------------------------------------------------
/vitest.config.ts:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vitest/config'
2 |
3 | export default defineConfig({
4 | test: {
5 | include: ['**/__tests__/**/*.spec.[tj]s'],
6 | exclude: [
7 | '**/node_modules/**',
8 | '**/dist/**',
9 | './playground/**/*.*'
10 | ],
11 | testTimeout: 20000,
12 | // node14 segfaults often with threads
13 | threads: !process.versions.node.startsWith('14')
14 | },
15 | esbuild: {
16 | target: 'node14'
17 | }
18 | })
19 |
--------------------------------------------------------------------------------