Skip to content

Commit bc7e3a2

Browse files
author
lrhh123
committed
update: 优化应用性能
1 parent 0b96ffa commit bc7e3a2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+8338
-2838
lines changed

.erb/configs/webpack.config.renderer.dev.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,12 @@ if (
3535
'The DLL files are missing. Sit back while we build them for you with "npm run build-dll"',
3636
),
3737
);
38-
execSync('npm run postinstall');
38+
39+
try {
40+
execSync('npm run postinstall');
41+
} catch (err) {
42+
console.log(chalk.black.bgRed('Failed to build postinstall files', err));
43+
}
3944
}
4045

4146
const configuration: webpack.Configuration = {
@@ -115,7 +120,7 @@ const configuration: webpack.Configuration = {
115120
],
116121
},
117122
plugins: [
118-
...(skipDLLs
123+
...(skipDLLs || !fs.existsSync(manifest)
119124
? []
120125
: [
121126
new webpack.DllReferencePlugin({

.erb/scripts/check-native-dep.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,6 @@ ${chalk.bold(
4949
process.exit(1);
5050
}
5151
} catch (e) {
52-
console.log('Native dependencies could not be checked');
52+
console.log('Native dependencies could not be checked', e);
5353
}
5454
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { execSync } from 'child_process';
2+
import chalk from 'chalk';
3+
4+
try {
5+
execSync('electron-builder install-app-deps', { stdio: 'inherit' });
6+
} catch (error) {
7+
// 错误处理: 输出错误信息和退出码
8+
console.error(
9+
chalk.red('Failed to install dependencies with electron-builder:'),
10+
);
11+
console.error(chalk.red(`Error message: ${error.message}`)); // 错误消息
12+
if (error instanceof Error && error.stack) {
13+
console.error(chalk.red(`Stack trace: ${error.stack}`)); // 堆栈跟踪
14+
}
15+
console.error(chalk.red(`Exit code: ${error.status}`)); // 错误码
16+
process.exit(error.status || 1); // 使用捕获到的退出码作为进程的退出码,或者默认为 1
17+
}

.eslintrc.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ module.exports = {
2626
'react/no-array-index-key': 'off',
2727
'class-methods-use-this': 'off',
2828
'@typescript-eslint/no-unused-vars': 'error',
29+
'no-console': 'off',
30+
'max-classes-per-file': 'off',
2931
},
3032
parserOptions: {
3133
ecmaVersion: 2022,

.vscode/settings.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,8 @@
2626
"test/**/__snapshots__": true,
2727
"package-lock.json": true,
2828
"*.{css,sass,scss}.d.ts": true
29-
}
29+
},
30+
"cSpell.words": [
31+
"dify"
32+
]
3033
}

BUILD.md

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,46 @@ pnpm i
4646
}
4747
]
4848
}
49-
```
49+
```
50+
51+
## 构建 Electron 的 Sqlite3
52+
注意 Electron 有个 Sqlite3 的坑,需要重新编译,可以参考以下命令
53+
54+
```bash
55+
pnpm --prefix=node_modules/sqlite3 run rebuild
56+
57+
https://registry.npmmirror.com
58+
59+
# 使用 Visual Studio 社区中的 Desktop development with C++ 组件安装 C++ 工具集
60+
61+
nvm use 18
62+
63+
npm install --global windows-build-tools
64+
65+
pnpm config set msvs_version=2022
66+
npm config set msvs_version 2022
67+
68+
# 删除node_modules目录和package-lock.json文件:
69+
70+
rm -rf node_modules
71+
rm package-lock.json
72+
73+
# 重新编译sqlite3模块:
74+
75+
npm i -g node-gyp
76+
77+
# 项目根目录下执行
78+
pnpm i -D node-addon-api@7.0.0
79+
80+
cd node_modules/sqlite3
81+
82+
83+
node-gyp rebuild --verbose
84+
# 或者执行
85+
node-gyp rebuild --target=26.2.1 --arch=x64 --target_platform=win32 --dist-url=https://electronjs.org/headers --module_name=node_sqlite3 --module_path=../lib/binding/electron-v26.2.1-win32-x64
86+
87+
# 注意检查一下报错,可能需要在下面路径创建 node-addon-api(复制过去)
88+
89+
pnpm i -D electron-builder
90+
pnpm run postinstall
91+
```

assets/base/windows.png

1.71 KB
Loading

electron-builder.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ files:
99
- package.json
1010
afterSign: ".erb/scripts/notarize.js"
1111
win:
12+
requestedExecutionLevel: requireAdministrator
1213
target:
1314
- nsis
1415
nsis:
@@ -28,6 +29,4 @@ directories:
2829
output: release/build
2930
extraResources:
3031
- "./assets/**"
31-
# build:
32-
# afterPack: "./removeLocales.js"
3332
afterPack: "./removeLocales.js"

package.json

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "chatgpt-on-cs",
33
"description": "多平台智能客服,允许使用 ChatGPT 作为客服机器人",
4-
"version": "1.0.2",
4+
"version": "1.0.3",
55
"keywords": [
66
"electron",
77
"boilerplate",
@@ -101,15 +101,32 @@
101101
"@emotion/styled": "^11.11.0",
102102
"@hw-hmscore/analytics-web": "6.9.9-301",
103103
"@tanstack/react-query": "4.36.1",
104+
"ansi-styles": "^6.2.1",
104105
"axios": "^1.6.7",
106+
"body-parser": "^1.20.2",
107+
"cors": "^2.8.5",
108+
"debug": "^4.3.4",
109+
"dottie": "^2.0.6",
105110
"electron-debug": "^3.2.0",
106111
"electron-log": "^4.4.8",
107112
"electron-store": "^8.1.0",
108113
"electron-updater": "^6.1.4",
114+
"express": "^4.19.2",
115+
"express-async-handler": "^1.2.0",
109116
"framer-motion": "^11.0.3",
110117
"immer": "^10.0.3",
118+
"inflection": "^3.0.0",
119+
"lodash": "^4.17.21",
120+
"lru-cache": "^7.18.3",
121+
"luxon": "^3.4.4",
122+
"moment": "^2.30.1",
123+
"moment-timezone": "^0.5.45",
124+
"ms": "^2.1.3",
111125
"net": "^1.0.2",
112126
"node-cron": "^3.0.3",
127+
"openai": "^4.38.3",
128+
"pg-connection-string": "^2.6.4",
129+
"pg-hstore": "^2.3.4",
113130
"react": "^18.2.0",
114131
"react-dom": "^18.2.0",
115132
"react-hook-form": "^7.50.1",
@@ -118,8 +135,19 @@
118135
"react-router-dom": "^6.16.0",
119136
"react-spinners": "^0.13.8",
120137
"react-use-websocket": "^4.8.1",
138+
"reflect-metadata": "^0.2.2",
121139
"remark-gfm": "^4.0.0",
140+
"retry-as-promised": "^7.0.4",
141+
"semver": "^7.6.0",
142+
"sequelize": "^6.37.3",
143+
"sequelize-pool": "^8.0.0",
144+
"socket.io": "^4.7.5",
122145
"source-map-support": "^0.5.21",
146+
"toposort-class": "^1.0.1",
147+
"tslib": "^2.6.2",
148+
"uuid": "^9.0.1",
149+
"validator": "^13.11.0",
150+
"wkx": "^0.5.0",
123151
"zustand": "^4.5.0"
124152
},
125153
"devDependencies": {
@@ -130,15 +158,21 @@
130158
"@teamsupercell/typings-for-css-modules-loader": "^2.5.2",
131159
"@testing-library/jest-dom": "^6.1.3",
132160
"@testing-library/react": "^14.0.0",
161+
"@types/body-parser": "^1.19.5",
162+
"@types/cors": "^2.8.17",
163+
"@types/express": "^4.17.21",
133164
"@types/jest": "^29.5.5",
165+
"@types/luxon": "^3.4.2",
134166
"@types/node": "20.6.2",
135167
"@types/react": "^18.2.21",
136168
"@types/react-dom": "^18.2.7",
137169
"@types/react-test-renderer": "^18.0.1",
170+
"@types/source-map-support": "^0.5.10",
138171
"@types/terser-webpack-plugin": "^5.0.4",
139172
"@types/webpack-bundle-analyzer": "^4.6.0",
140173
"@typescript-eslint/eslint-plugin": "^6.7.0",
141174
"@typescript-eslint/parser": "^6.7.0",
175+
"app-builder-lib": "25.0.0-alpha.6",
142176
"browserslist-config-erb": "^0.0.3",
143177
"chalk": "^4.1.2",
144178
"concurrently": "^8.2.1",
@@ -149,8 +183,9 @@
149183
"detect-port": "^1.5.1",
150184
"dotenv": "^16.4.4",
151185
"electron": "^26.2.1",
152-
"electron-builder": "^24.6.4",
186+
"electron-builder": "^24.13.3",
153187
"electron-devtools-installer": "^3.2.0",
188+
"electron-rebuild": "^3.2.9",
154189
"electronmon": "^2.0.2",
155190
"eslint": "^8.49.0",
156191
"eslint-config-airbnb-base": "^15.0.0",
@@ -170,19 +205,22 @@
170205
"jest": "^29.7.0",
171206
"jest-environment-jsdom": "^29.7.0",
172207
"mini-css-extract-plugin": "^2.7.6",
208+
"node-addon-api": "file:C:/Users/33204/Documents/project/alsritter.icu/lazy-rap-web/tmp/node-addon-api",
173209
"prettier": "^3.0.3",
174210
"prettier-eslint": "^16.3.0",
175211
"react-refresh": "^0.14.0",
176212
"react-test-renderer": "^18.2.0",
177213
"rimraf": "^5.0.1",
178214
"sass": "^1.67.0",
179215
"sass-loader": "^13.3.2",
216+
"sqlite3": "^5.1.7",
180217
"style-loader": "^3.3.3",
181218
"terser-webpack-plugin": "^5.3.9",
182219
"ts-jest": "^29.1.1",
183220
"ts-loader": "^9.4.4",
184221
"ts-node": "^10.9.1",
185222
"tsconfig-paths-webpack-plugin": "^4.1.0",
223+
"typeorm": "^0.3.20",
186224
"typescript": "^5.2.2",
187225
"url-loader": "^4.1.1",
188226
"webpack": "^5.88.2",

0 commit comments

Comments
 (0)