Compare commits
13 Commits
2025-09
...
d050dbc6e7
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d050dbc6e7 | ||
|
|
3b2f6b2517 | ||
|
|
45a010b3a4 | ||
| 081a77ac4c | |||
|
|
ca8f173394 | ||
|
|
2e377bcca2 | ||
|
|
2a8757c9f1 | ||
|
|
35f21b7140 | ||
|
|
b0ca84c8fd | ||
|
|
045acfa061 | ||
|
|
55ff45f9a9 | ||
|
|
7afccb58fd | ||
|
|
11c6704f11 |
3
.gitignore
vendored
@@ -7,5 +7,6 @@ package-lock.json
|
|||||||
data/
|
data/
|
||||||
.vscode/launch.json
|
.vscode/launch.json
|
||||||
public/electron/
|
public/electron/
|
||||||
public/dist/
|
|
||||||
pnpm-lock.yaml
|
pnpm-lock.yaml
|
||||||
|
CLAUDE.md
|
||||||
|
/public/dist/
|
||||||
|
|||||||
6
.npmrc
@@ -2,3 +2,9 @@ registry=https://registry.npmmirror.com/
|
|||||||
disturl=https://registry.npmmirror.com/-/binary/node
|
disturl=https://registry.npmmirror.com/-/binary/node
|
||||||
electron_mirror=https://npmmirror.com/mirrors/electron/
|
electron_mirror=https://npmmirror.com/mirrors/electron/
|
||||||
electron-builder-binaries_mirror=https://registry.npmmirror.com/-/binary/electron-builder-binaries/
|
electron-builder-binaries_mirror=https://registry.npmmirror.com/-/binary/electron-builder-binaries/
|
||||||
|
|
||||||
|
# 屏蔽警告配置
|
||||||
|
legacy-peer-deps=true
|
||||||
|
audit=false
|
||||||
|
fund=false
|
||||||
|
loglevel=error
|
||||||
|
|||||||
61
README.md
@@ -1,61 +0,0 @@
|
|||||||
#### 项目简介
|
|
||||||
|
|
||||||
#### 常用命令
|
|
||||||
```shell
|
|
||||||
|
|
||||||
# 运行项目
|
|
||||||
npm run dev
|
|
||||||
|
|
||||||
# 仅运行前端
|
|
||||||
npm run dev-frontend
|
|
||||||
|
|
||||||
# 仅运行后端
|
|
||||||
npm run dev-electron
|
|
||||||
|
|
||||||
|
|
||||||
# 预发布模式(环境变量为:prod),请先移动资源
|
|
||||||
npm run start
|
|
||||||
|
|
||||||
# 移动前端静态资源
|
|
||||||
npm run rd
|
|
||||||
|
|
||||||
# 移动资源,可配置
|
|
||||||
npm run move
|
|
||||||
|
|
||||||
# 代码加密
|
|
||||||
npm run encrypt
|
|
||||||
|
|
||||||
# 清除加密的代码
|
|
||||||
npm run clean
|
|
||||||
|
|
||||||
# 生成logo
|
|
||||||
npm run icon
|
|
||||||
|
|
||||||
# 打包 (windows版)
|
|
||||||
npm run build-w (调整为64位)
|
|
||||||
npm run build-w-32 (32位)
|
|
||||||
npm run build-w-64 (64位)
|
|
||||||
npm run build-w-arm64 (arm64)
|
|
||||||
|
|
||||||
# 打包 (windows 免安装版)
|
|
||||||
# ee > v2.2.1
|
|
||||||
npm run build-wz (调整为64位)
|
|
||||||
npm run build-wz-32 (32位)
|
|
||||||
npm run build-wz-64 (64位)
|
|
||||||
npm run build-wz-arm64 (arm64)
|
|
||||||
|
|
||||||
# 打包 (mac版)
|
|
||||||
npm run build-m
|
|
||||||
npm run build-m-arm64 (m1芯片架构)
|
|
||||||
|
|
||||||
# 打包 (linux版)
|
|
||||||
# ee > v2.2.1
|
|
||||||
npm run build-l (默认64位 deb包)
|
|
||||||
npm run build-l-32 (32位 deb包)
|
|
||||||
npm run build-l-64 (64位 deb包)
|
|
||||||
npm run build-l-arm64 (64位 deb包 arm64)
|
|
||||||
npm run build-l-armv7l (64位 deb包 armv7l)
|
|
||||||
npm run build-lr-64 (64位 rpm包)
|
|
||||||
npm run build-lp-64 (64位 pacman包)
|
|
||||||
|
|
||||||
```
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
chrome应用商店ctx文件,解压后,放置在此目录中,打包时会将资源加入安装包内。
|
|
||||||
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 745 B After Width: | Height: | Size: 930 B |
|
Before Width: | Height: | Size: 33 KiB After Width: | Height: | Size: 26 KiB |
|
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 2.5 KiB |
|
Before Width: | Height: | Size: 3.2 KiB After Width: | Height: | Size: 4.6 KiB |
|
Before Width: | Height: | Size: 119 KiB After Width: | Height: | Size: 26 KiB |
|
Before Width: | Height: | Size: 4.6 KiB After Width: | Height: | Size: 7.1 KiB |
|
Before Width: | Height: | Size: 34 KiB After Width: | Height: | Size: 6.6 KiB |
|
Before Width: | Height: | Size: 119 KiB After Width: | Height: | Size: 26 KiB |
205
cmd/bin.js
Normal file
@@ -0,0 +1,205 @@
|
|||||||
|
/**
|
||||||
|
* ee-bin 配置
|
||||||
|
* 仅适用于开发环境
|
||||||
|
*/
|
||||||
|
module.exports = {
|
||||||
|
/**
|
||||||
|
* development serve ("frontend" "electron" )
|
||||||
|
* ee-bin dev
|
||||||
|
*/
|
||||||
|
dev: {
|
||||||
|
// frontend:前端服务
|
||||||
|
// 说明:该配置的意思是,进入 frontend 目录,执行 npm run dev
|
||||||
|
// 运行后的服务为 http://localhost:8080
|
||||||
|
// 如果 protocol 属性为 'file://' 那么不会执行命令,项目直接加载 indexPath 对应的文件。
|
||||||
|
frontend: {
|
||||||
|
directory: './frontend',
|
||||||
|
cmd: 'npm',
|
||||||
|
args: ['run', 'dev'],
|
||||||
|
port: 18091,
|
||||||
|
},
|
||||||
|
// electron:主进程服务
|
||||||
|
// 说明:该配置的意思是,在根目录,执行 electron . --env=local
|
||||||
|
electron: {
|
||||||
|
directory: './',
|
||||||
|
cmd: 'electron',
|
||||||
|
args: ['.', '--env=local'],
|
||||||
|
watch: false,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 构建
|
||||||
|
* ee-bin build
|
||||||
|
*/
|
||||||
|
build: {
|
||||||
|
frontend: {
|
||||||
|
directory: './frontend',
|
||||||
|
cmd: 'npm',
|
||||||
|
args: ['run', 'build'],
|
||||||
|
},
|
||||||
|
electron: {
|
||||||
|
type: 'javascript',
|
||||||
|
bundleType: 'copy'
|
||||||
|
},
|
||||||
|
win64: {
|
||||||
|
cmd: 'electron-builder',
|
||||||
|
directory: './',
|
||||||
|
args: ['--config=./cmd/builder.json', '-w=nsis', '--x64'],
|
||||||
|
},
|
||||||
|
win32: {
|
||||||
|
args: ['--config=./cmd/builder.json', '-w=nsis', '--ia32'],
|
||||||
|
},
|
||||||
|
win_e: {
|
||||||
|
args: ['--config=./cmd/builder.json', '-w=portable', '--x64'],
|
||||||
|
},
|
||||||
|
win_7z: {
|
||||||
|
args: ['--config=./cmd/builder.json', '-w=7z', '--x64'],
|
||||||
|
},
|
||||||
|
mac: {
|
||||||
|
args: ['--config=./cmd/builder-mac.json', '-m'],
|
||||||
|
},
|
||||||
|
mac_arm64: {
|
||||||
|
args: ['--config=./cmd/builder-mac-arm64.json', '-m', '--arm64'],
|
||||||
|
},
|
||||||
|
linux: {
|
||||||
|
args: ['--config=./cmd/builder-linux.json', '-l=deb', '--x64'],
|
||||||
|
},
|
||||||
|
linux_arm64: {
|
||||||
|
args: ['--config=./cmd/builder-linux.json', '-l=deb', '--arm64'],
|
||||||
|
},
|
||||||
|
go_w: {
|
||||||
|
directory: './go',
|
||||||
|
cmd: 'go',
|
||||||
|
args: ['build', '-o=../build/extraResources/goapp.exe'],
|
||||||
|
},
|
||||||
|
go_m: {
|
||||||
|
directory: './go',
|
||||||
|
cmd: 'go',
|
||||||
|
args: ['build', '-o=../build/extraResources/goapp'],
|
||||||
|
},
|
||||||
|
go_l: {
|
||||||
|
directory: './go',
|
||||||
|
cmd: 'go',
|
||||||
|
args: ['build', '-o=../build/extraResources/goapp'],
|
||||||
|
},
|
||||||
|
python: {
|
||||||
|
directory: './python',
|
||||||
|
cmd: 'python',
|
||||||
|
args: ['./setup.py', 'build'],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 移动资源
|
||||||
|
* ee-bin move
|
||||||
|
*/
|
||||||
|
move: {
|
||||||
|
frontend_dist: {
|
||||||
|
src: './frontend/dist',
|
||||||
|
dest: './public/dist'
|
||||||
|
},
|
||||||
|
go_static: {
|
||||||
|
src: './frontend/dist',
|
||||||
|
dest: './go/public/dist'
|
||||||
|
},
|
||||||
|
go_config: {
|
||||||
|
src: './go/config',
|
||||||
|
dest: './go/public/config'
|
||||||
|
},
|
||||||
|
go_package: {
|
||||||
|
src: './package.json',
|
||||||
|
dest: './go/public/package.json'
|
||||||
|
},
|
||||||
|
go_images: {
|
||||||
|
src: './public/images',
|
||||||
|
dest: './go/public/images'
|
||||||
|
},
|
||||||
|
python_dist: {
|
||||||
|
src: './python/dist',
|
||||||
|
dest: './build/extraResources/py'
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 预发布模式(prod)
|
||||||
|
* ee-bin start
|
||||||
|
*/
|
||||||
|
start: {
|
||||||
|
directory: './',
|
||||||
|
cmd: 'electron',
|
||||||
|
args: ['.', '--env=prod']
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 加密
|
||||||
|
*/
|
||||||
|
encrypt: {
|
||||||
|
frontend: {
|
||||||
|
type: 'none',
|
||||||
|
files: [
|
||||||
|
'./public/dist/**/*.(js|json)',
|
||||||
|
],
|
||||||
|
cleanFiles: ['./public/dist'],
|
||||||
|
confusionOptions: {
|
||||||
|
compact: true,
|
||||||
|
stringArray: true,
|
||||||
|
stringArrayEncoding: ['none'],
|
||||||
|
stringArrayCallsTransform: true,
|
||||||
|
numbersToExpressions: true,
|
||||||
|
target: 'browser',
|
||||||
|
}
|
||||||
|
},
|
||||||
|
electron: {
|
||||||
|
type: 'confusion',
|
||||||
|
files: [
|
||||||
|
'./public/electron/**/*.(js|json)',
|
||||||
|
],
|
||||||
|
cleanFiles: ['./public/electron'],
|
||||||
|
specificFiles: [
|
||||||
|
'./public/electron/main.js',
|
||||||
|
'./public/electron/preload/bridge.js',
|
||||||
|
],
|
||||||
|
confusionOptions: {
|
||||||
|
compact: true,
|
||||||
|
stringArray: true,
|
||||||
|
stringArrayEncoding: ['rc4'],
|
||||||
|
deadCodeInjection: false,
|
||||||
|
stringArrayCallsTransform: true,
|
||||||
|
numbersToExpressions: true,
|
||||||
|
target: 'node',
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 执行自定义命令
|
||||||
|
* ee-bin exec
|
||||||
|
*/
|
||||||
|
exec: {
|
||||||
|
// 单独调试,air 实现 go 热重载
|
||||||
|
go: {
|
||||||
|
directory: './go',
|
||||||
|
cmd: 'air',
|
||||||
|
args: ['-c=config/.air.toml' ],
|
||||||
|
},
|
||||||
|
// windows 单独调试,air 实现 go 热重载
|
||||||
|
go_w: {
|
||||||
|
directory: './go',
|
||||||
|
cmd: 'air',
|
||||||
|
args: ['-c=config/.air.windows.toml' ],
|
||||||
|
},
|
||||||
|
// 单独调试,以基础方式启动 go
|
||||||
|
go2: {
|
||||||
|
directory: './go',
|
||||||
|
cmd: 'go',
|
||||||
|
args: ['run', './main.go', '--env=dev','--basedir=../', '--port=7073'],
|
||||||
|
},
|
||||||
|
python: {
|
||||||
|
directory: './python',
|
||||||
|
cmd: 'python',
|
||||||
|
args: ['./main.py', '--port=7074'],
|
||||||
|
stdio: "inherit", // ignore
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
40
cmd/builder-linux.json
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
{
|
||||||
|
"productName": "ee",
|
||||||
|
"appId": "com.bilibili.ee",
|
||||||
|
"copyright": "© 2025 duola Technology Co., Ltd.",
|
||||||
|
"directories": {
|
||||||
|
"output": "out"
|
||||||
|
},
|
||||||
|
"asar": true,
|
||||||
|
"files": [
|
||||||
|
"**/*",
|
||||||
|
"!cmd/",
|
||||||
|
"!data/",
|
||||||
|
"!electron/",
|
||||||
|
"!frontend/",
|
||||||
|
"!logs/",
|
||||||
|
"!out/",
|
||||||
|
"!go/",
|
||||||
|
"!python/"
|
||||||
|
],
|
||||||
|
"extraResources": [
|
||||||
|
{
|
||||||
|
"from": "build/extraResources",
|
||||||
|
"to": "extraResources"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"publish": [
|
||||||
|
{
|
||||||
|
"provider": "generic",
|
||||||
|
"url": ""
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"linux": {
|
||||||
|
"icon": "build/icons/icon.icns",
|
||||||
|
"artifactName": "${productName}-${os}-${version}-${arch}.${ext}",
|
||||||
|
"target": [
|
||||||
|
"deb"
|
||||||
|
],
|
||||||
|
"category": "Utility"
|
||||||
|
}
|
||||||
|
}
|
||||||
38
cmd/builder-mac-arm64.json
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
{
|
||||||
|
"productName": "ee",
|
||||||
|
"appId": "com.bilibili.ee",
|
||||||
|
"copyright": "© 2025 duola Technology Co., Ltd.",
|
||||||
|
"directories": {
|
||||||
|
"output": "out"
|
||||||
|
},
|
||||||
|
"asar": true,
|
||||||
|
"files": [
|
||||||
|
"**/*",
|
||||||
|
"!cmd/",
|
||||||
|
"!data/",
|
||||||
|
"!electron/",
|
||||||
|
"!frontend/",
|
||||||
|
"!logs/",
|
||||||
|
"!out/",
|
||||||
|
"!go/",
|
||||||
|
"!python/"
|
||||||
|
],
|
||||||
|
"extraResources": [
|
||||||
|
{
|
||||||
|
"from": "build/extraResources",
|
||||||
|
"to": "extraResources"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"publish": [
|
||||||
|
{
|
||||||
|
"provider": "generic",
|
||||||
|
"url": ""
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"mac": {
|
||||||
|
"icon": "build/icons/icon.icns",
|
||||||
|
"artifactName": "${productName}-${os}-${version}-${arch}.${ext}",
|
||||||
|
"darkModeSupport": true,
|
||||||
|
"hardenedRuntime": false
|
||||||
|
}
|
||||||
|
}
|
||||||
38
cmd/builder-mac.json
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
{
|
||||||
|
"productName": "ee",
|
||||||
|
"appId": "com.bilibili.ee",
|
||||||
|
"copyright": "© 2025 duola Technology Co., Ltd.",
|
||||||
|
"directories": {
|
||||||
|
"output": "out"
|
||||||
|
},
|
||||||
|
"asar": true,
|
||||||
|
"files": [
|
||||||
|
"**/*",
|
||||||
|
"!cmd/",
|
||||||
|
"!data/",
|
||||||
|
"!electron/",
|
||||||
|
"!frontend/",
|
||||||
|
"!logs/",
|
||||||
|
"!out/",
|
||||||
|
"!go/",
|
||||||
|
"!python/"
|
||||||
|
],
|
||||||
|
"extraResources": [
|
||||||
|
{
|
||||||
|
"from": "build/extraResources",
|
||||||
|
"to": "extraResources"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"publish": [
|
||||||
|
{
|
||||||
|
"provider": "generic",
|
||||||
|
"url": ""
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"mac": {
|
||||||
|
"icon": "build/icons/icon.icns",
|
||||||
|
"artifactName": "${productName}-${os}-${version}-${arch}.${ext}",
|
||||||
|
"darkModeSupport": true,
|
||||||
|
"hardenedRuntime": false
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,17 +1,21 @@
|
|||||||
{
|
{
|
||||||
"productName": "pqs9100",
|
"productName": "NPQS9100",
|
||||||
"appId": "com.njcn.pqs9100",
|
"appId": "NQPS9100",
|
||||||
"copyright": "hongawen.com",
|
"copyright": "© 2025 南京灿能",
|
||||||
"directories": {
|
"directories": {
|
||||||
"output": "out"
|
"output": "out"
|
||||||
},
|
},
|
||||||
"asar": true,
|
"asar": true,
|
||||||
"files": [
|
"files": [
|
||||||
"**/*",
|
"**/*",
|
||||||
|
"!cmd/",
|
||||||
|
"!data/",
|
||||||
|
"!electron/",
|
||||||
"!frontend/",
|
"!frontend/",
|
||||||
"!run/",
|
|
||||||
"!logs/",
|
"!logs/",
|
||||||
"!data/"
|
"!out/",
|
||||||
|
"!go/",
|
||||||
|
"!python/"
|
||||||
],
|
],
|
||||||
"extraResources": {
|
"extraResources": {
|
||||||
"from": "build/extraResources/",
|
"from": "build/extraResources/",
|
||||||
@@ -26,35 +30,15 @@
|
|||||||
"installerHeaderIcon": "build/icons/icon.ico",
|
"installerHeaderIcon": "build/icons/icon.ico",
|
||||||
"createDesktopShortcut": true,
|
"createDesktopShortcut": true,
|
||||||
"createStartMenuShortcut": true,
|
"createStartMenuShortcut": true,
|
||||||
"shortcutName": "自动检测平台"
|
"shortcutName": "灿能检测"
|
||||||
},
|
|
||||||
"publish": [
|
|
||||||
{
|
|
||||||
"provider": "generic",
|
|
||||||
"url": "http://www.shining-electric.com/"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"mac": {
|
|
||||||
"icon": "build/icons/icon.icns",
|
|
||||||
"artifactName": "${productName}-${os}-${version}-${arch}.${ext}",
|
|
||||||
"darkModeSupport": true,
|
|
||||||
"hardenedRuntime": false
|
|
||||||
},
|
},
|
||||||
"win": {
|
"win": {
|
||||||
"icon": "build/icons/icon.ico",
|
"icon": "build/icons/icon.ico",
|
||||||
"artifactName": "${productName}-${os}-${version}-${arch}.${ext}",
|
"artifactName": "${productName}-${os}-${version}-${arch}.${ext}",
|
||||||
"target": [
|
"target": [
|
||||||
{
|
{
|
||||||
"target": "nsis"
|
"target": "portable"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
|
||||||
"linux": {
|
|
||||||
"icon": "build/icons/icon.icns",
|
|
||||||
"artifactName": "${productName}-${os}-${version}-${arch}.${ext}",
|
|
||||||
"target": [
|
|
||||||
"deb"
|
|
||||||
],
|
|
||||||
"category": "Utility"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
133
doc/便携式JRE集成指南.md
Normal file
@@ -0,0 +1,133 @@
|
|||||||
|
## 便携式 JRE/JDK8 集成指南
|
||||||
|
|
||||||
|
本指南介绍如何将 JRE 8 以“便携式”(解压即用、无需安装)的方式随应用打包,并在 Electron 主进程中通过绝对路径调用,从而避免要求用户在系统中安装 JDK/JRE。
|
||||||
|
|
||||||
|
### 为什么选择便携式 JRE
|
||||||
|
- 无需管理员权限与系统环境变量配置,用户无感知。
|
||||||
|
- 不污染系统环境(不写入 JAVA_HOME/PATH)。
|
||||||
|
- 跨平台一致,可精简体积、可控版本。
|
||||||
|
|
||||||
|
### 适用场景
|
||||||
|
- 运行 Java 程序或 JAR 包(仅需运行时)。
|
||||||
|
- 不需要 javac/jcmd/jmap 等开发/诊断工具(若需要,请改为随包便携式 JDK)。
|
||||||
|
|
||||||
|
### 推荐的 JRE 8 发行版(可再分发)
|
||||||
|
- Azul Zulu 8 JRE(可选 ZuluFX 含 JavaFX):[下载页面](https://www.azul.com/downloads/?version=java-8-lts&package=jre)
|
||||||
|
- BellSoft Liberica 8 JRE(Standard/Full,Full 含 JavaFX):[下载页面](https://bell-sw.com/pages/downloads/#/java-8-lts)
|
||||||
|
- Eclipse Temurin 8 JRE(Adoptium):[下载页面](https://adoptium.net/temurin/releases/?version=8)
|
||||||
|
|
||||||
|
选择要点:
|
||||||
|
- 需要 AWT/Swing/字体/打印 → 选择非 headless 包。
|
||||||
|
- 需要 JavaFX → 选择 Liberica Full 或 ZuluFX。
|
||||||
|
- 仅命令行/服务端 → 任意 JRE 8(headless 也可)。
|
||||||
|
|
||||||
|
### 目录放置约定
|
||||||
|
将解压后的 JRE 放入项目的 `build/extraResources/jre`,保证内部存在 `bin/java(.exe)`:
|
||||||
|
|
||||||
|
```
|
||||||
|
build/
|
||||||
|
extraResources/
|
||||||
|
jre/
|
||||||
|
bin/
|
||||||
|
java(.exe)
|
||||||
|
lib/
|
||||||
|
...
|
||||||
|
```
|
||||||
|
|
||||||
|
构建后在生产环境可通过 `process.resourcesPath` 访问:
|
||||||
|
`<app>/resources/extraResources/jre/bin/java(.exe)`。
|
||||||
|
|
||||||
|
### 主进程调用示例
|
||||||
|
在 `electron/preload/lifecycle.js` 或你的业务模块中封装 Java 运行工具(开发/生产两种路径):
|
||||||
|
|
||||||
|
```js
|
||||||
|
const path = require('path');
|
||||||
|
const { spawn } = require('child_process');
|
||||||
|
|
||||||
|
function getExtraResourcesDir() {
|
||||||
|
// 开发态:使用项目目录;生产态:使用 asar/resources 目录
|
||||||
|
const isDev = !!process.env.EE_DEV || process.env.NODE_ENV === 'development';
|
||||||
|
return isDev
|
||||||
|
? path.join(process.cwd(), 'build', 'extraResources')
|
||||||
|
: path.join(process.resourcesPath, 'extraResources');
|
||||||
|
}
|
||||||
|
|
||||||
|
function getJavaBinPath() {
|
||||||
|
const extraDir = getExtraResourcesDir();
|
||||||
|
const javaBinName = process.platform === 'win32' ? 'java.exe' : 'java';
|
||||||
|
return path.join(extraDir, 'jre', 'bin', javaBinName);
|
||||||
|
}
|
||||||
|
|
||||||
|
function runJavaJar(jarAbsPath, args = [], options = {}) {
|
||||||
|
const javaPath = getJavaBinPath();
|
||||||
|
const child = spawn(javaPath, ['-jar', jarAbsPath, ...args], {
|
||||||
|
stdio: 'inherit',
|
||||||
|
...options,
|
||||||
|
});
|
||||||
|
return child;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function ensureJavaVersion(logger) {
|
||||||
|
return new Promise((resolve) => {
|
||||||
|
const child = spawn(getJavaBinPath(), ['-version']);
|
||||||
|
let out = '';
|
||||||
|
let err = '';
|
||||||
|
child.stdout && child.stdout.on('data', (d) => (out += d.toString()))
|
||||||
|
child.stderr && child.stderr.on('data', (d) => (err += d.toString()))
|
||||||
|
child.on('close', () => {
|
||||||
|
const text = (out + '\n' + err).trim();
|
||||||
|
logger && logger.info('[java] version check:', text);
|
||||||
|
resolve(text.includes('1.8.0'));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = { getJavaBinPath, runJavaJar, ensureJavaVersion };
|
||||||
|
```
|
||||||
|
|
||||||
|
在生命周期中调用(示例):
|
||||||
|
|
||||||
|
```js
|
||||||
|
const { logger } = require('ee-core/log');
|
||||||
|
const path = require('path');
|
||||||
|
const { runJavaJar, ensureJavaVersion } = require('./java-runner');
|
||||||
|
|
||||||
|
class Lifecycle {
|
||||||
|
async ready() {
|
||||||
|
const ok = await ensureJavaVersion(logger);
|
||||||
|
if (!ok) {
|
||||||
|
logger.error('[java] 未检测到 JRE 8,请检查 extraResources/jre 是否存在');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async windowReady() {
|
||||||
|
const jarPath = path.join(process.resourcesPath || process.cwd(), 'extraResources', 'tools', 'your-app.jar');
|
||||||
|
// 示例:延后在某业务时机再启动 Java 进程
|
||||||
|
// const proc = runJavaJar(jarPath, ['--arg1', 'value']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
注意:示例中的 `java-runner` 为上文工具函数文件,实际请按你的项目结构放置。
|
||||||
|
|
||||||
|
### 验证清单
|
||||||
|
- 运行 `jre/bin/java -version` 输出包含 `1.8.0_xxx`。
|
||||||
|
- 若涉及 GUI/字体/打印,验证 AWT/Swing 中文渲染与打印。
|
||||||
|
- 若需 JavaFX,验证 JavaFX Demo 启动。
|
||||||
|
- 若涉及 TLS/HTTPS,验证 SSL 通信正常。
|
||||||
|
|
||||||
|
### 许可与合规
|
||||||
|
- Azul Zulu、Eclipse Temurin(Adoptium)、BellSoft Liberica 的 JRE/JDK 8 发行包均可免费再分发(GPLv2+CE 或厂商许可证)。
|
||||||
|
- 建议在应用的“关于/许可证”中附上所选发行版的许可证链接与致谢。
|
||||||
|
|
||||||
|
### 常见问题
|
||||||
|
1) 是否“阉割”?
|
||||||
|
— 上述 JRE 8 发行版均为标准运行时,通过兼容性测试;JRE 不包含开发者工具属于正常区别,不是删减。
|
||||||
|
|
||||||
|
2) 何时需要 JDK 而不是 JRE?
|
||||||
|
— 需要 `javac` 编译或 `jcmd/jmap` 等诊断工具,或你的 Java 组件依赖 `tools.jar` 时。
|
||||||
|
|
||||||
|
3) 体积如何优化?
|
||||||
|
— 选择 headless(若无 GUI 需求)、去除无用语言/字体包;或改用 JDK 9+ 使用 jlink(不适用于 8)。
|
||||||
|
|
||||||
|
|
||||||
436
doc/打包方案对比.md
Normal file
@@ -0,0 +1,436 @@
|
|||||||
|
# 应用打包方案对比与实现
|
||||||
|
|
||||||
|
本文档详细说明 ElectronEgg 应用的两种打包方案:纯绿色版方案 和 双版本方案。
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 方案对比
|
||||||
|
|
||||||
|
| 特性 | 方案一:纯绿色版 | 方案二:双版本打包 |
|
||||||
|
|------|-----------------|-------------------|
|
||||||
|
| **打包产物** | 单个便携版 exe | 安装版 exe + 便携版 exe |
|
||||||
|
| **安装过程** | 无需安装 | 安装版需安装,便携版无需 |
|
||||||
|
| **桌面快捷方式** | 应用内自动创建 | 安装版自动创建,便携版手动或自动 |
|
||||||
|
| **开始菜单** | 无 | 安装版有 |
|
||||||
|
| **卸载程序** | 无(直接删除) | 安装版有 |
|
||||||
|
| **适用场景** | 临时使用、U盘携带 | 正式部署、企业分发 |
|
||||||
|
| **用户体验** | 灵活、轻量 | 专业、完整 |
|
||||||
|
| **打包时间** | 快 | 较慢(打包两次) |
|
||||||
|
| **分发复杂度** | 简单(单文件) | 中等(两个文件) |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 方案一:纯绿色版 + 自动创建快捷方式
|
||||||
|
|
||||||
|
### 特点
|
||||||
|
- ✅ 单个 exe 文件,双击即用
|
||||||
|
- ✅ 首次启动时询问是否创建桌面快捷方式
|
||||||
|
- ✅ 无需安装,无需卸载
|
||||||
|
- ✅ 适合快速分发和临时使用
|
||||||
|
|
||||||
|
### 实现步骤
|
||||||
|
|
||||||
|
#### 1. 修改打包配置
|
||||||
|
|
||||||
|
**文件**:[cmd/builder.json](../cmd/builder.json)
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"productName": "南京灿能工具",
|
||||||
|
"appId": "com.canneng.tool",
|
||||||
|
"copyright": "© 2025 hongawen",
|
||||||
|
"directories": {
|
||||||
|
"output": "out"
|
||||||
|
},
|
||||||
|
"asar": true,
|
||||||
|
"files": [
|
||||||
|
"**/*",
|
||||||
|
"!cmd/",
|
||||||
|
"!data/",
|
||||||
|
"!electron/",
|
||||||
|
"!frontend/",
|
||||||
|
"!logs/",
|
||||||
|
"!out/",
|
||||||
|
"!go/",
|
||||||
|
"!python/"
|
||||||
|
],
|
||||||
|
"extraResources": {
|
||||||
|
"from": "build/extraResources/",
|
||||||
|
"to": "extraResources"
|
||||||
|
},
|
||||||
|
"publish": [
|
||||||
|
{
|
||||||
|
"provider": "generic",
|
||||||
|
"url": "https://your-update-server.com"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"win": {
|
||||||
|
"icon": "build/icons/icon.ico",
|
||||||
|
"artifactName": "${productName}-${os}-${version}-${arch}.${ext}",
|
||||||
|
"target": [
|
||||||
|
{
|
||||||
|
"target": "portable"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
#### 2. 添加自动创建快捷方式功能
|
||||||
|
|
||||||
|
**文件**:[electron/preload/lifecycle.js](../electron/preload/lifecycle.js)
|
||||||
|
|
||||||
|
在 `windowReady()` 钩子中添加以下代码:
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
const { logger } = require('ee-core/log');
|
||||||
|
const { getConfig } = require('ee-core/config');
|
||||||
|
const { getMainWindow } = require('ee-core/electron');
|
||||||
|
|
||||||
|
class Lifecycle {
|
||||||
|
|
||||||
|
async ready() {
|
||||||
|
logger.info('[lifecycle] ready');
|
||||||
|
}
|
||||||
|
|
||||||
|
async electronAppReady() {
|
||||||
|
logger.info('[lifecycle] electron-app-ready');
|
||||||
|
}
|
||||||
|
|
||||||
|
async windowReady() {
|
||||||
|
logger.info('[lifecycle] window-ready');
|
||||||
|
|
||||||
|
// 延迟加载,无白屏
|
||||||
|
const { windowsOption } = getConfig();
|
||||||
|
if (windowsOption.show == false) {
|
||||||
|
const win = getMainWindow();
|
||||||
|
win.once('ready-to-show', () => {
|
||||||
|
win.show();
|
||||||
|
win.focus();
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 绿色版自动创建桌面快捷方式
|
||||||
|
await this.createDesktopShortcut();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 为绿色版创建桌面快捷方式
|
||||||
|
*/
|
||||||
|
async createDesktopShortcut() {
|
||||||
|
const { app, dialog, shell } = require('electron');
|
||||||
|
const path = require('path');
|
||||||
|
const fs = require('fs');
|
||||||
|
|
||||||
|
// 判断是否为便携版(绿色版)
|
||||||
|
// 安装版通常在 C:\Program Files 或 AppData\Local\Programs
|
||||||
|
const isPortable = process.platform === 'win32' &&
|
||||||
|
!process.execPath.includes('Program Files') &&
|
||||||
|
!process.execPath.includes('AppData\\Local\\Programs');
|
||||||
|
|
||||||
|
if (!isPortable) {
|
||||||
|
logger.info('[lifecycle] 非便携版,跳过快捷方式创建');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
const desktopPath = app.getPath('desktop');
|
||||||
|
const shortcutPath = path.join(desktopPath, '南京灿能工具.lnk');
|
||||||
|
|
||||||
|
// 如果快捷方式已存在,跳过
|
||||||
|
if (fs.existsSync(shortcutPath)) {
|
||||||
|
logger.info('[lifecycle] 桌面快捷方式已存在');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 询问用户是否创建快捷方式
|
||||||
|
const result = await dialog.showMessageBox({
|
||||||
|
type: 'question',
|
||||||
|
buttons: ['创建', '跳过'],
|
||||||
|
defaultId: 0,
|
||||||
|
title: '创建桌面快捷方式',
|
||||||
|
message: '是否在桌面创建快捷方式?',
|
||||||
|
detail: '方便您下次快速启动应用'
|
||||||
|
});
|
||||||
|
|
||||||
|
if (result.response === 0) {
|
||||||
|
// Windows 下创建快捷方式
|
||||||
|
const success = shell.writeShortcutLink(shortcutPath, {
|
||||||
|
target: process.execPath,
|
||||||
|
cwd: path.dirname(process.execPath),
|
||||||
|
description: '南京灿能C端工具',
|
||||||
|
icon: process.execPath,
|
||||||
|
iconIndex: 0
|
||||||
|
});
|
||||||
|
|
||||||
|
if (success) {
|
||||||
|
logger.info('[lifecycle] 桌面快捷方式创建成功');
|
||||||
|
await dialog.showMessageBox({
|
||||||
|
type: 'info',
|
||||||
|
title: '成功',
|
||||||
|
message: '桌面快捷方式已创建',
|
||||||
|
buttons: ['确定']
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
logger.error('[lifecycle] 桌面快捷方式创建失败');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
logger.info('[lifecycle] 用户跳过创建快捷方式');
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
logger.error('[lifecycle] 创建快捷方式时出错:', error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async beforeClose() {
|
||||||
|
logger.info('[lifecycle] before-close');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Lifecycle.toString = () => '[class Lifecycle]';
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
Lifecycle
|
||||||
|
};
|
||||||
|
```
|
||||||
|
|
||||||
|
#### 3. 打包命令
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm run build # 完整构建
|
||||||
|
npm run build-w # 打包 Windows 便携版
|
||||||
|
```
|
||||||
|
|
||||||
|
#### 4. 产物说明
|
||||||
|
|
||||||
|
打包完成后,在 `out/` 目录下会生成:
|
||||||
|
```
|
||||||
|
out/
|
||||||
|
└── 南京灿能工具-win-4.0.0-x64.exe (便携版,约 150-200MB)
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 方案二:双版本打包(安装版 + 便携版)
|
||||||
|
|
||||||
|
### 特点
|
||||||
|
- ✅ 提供两种版本供用户选择
|
||||||
|
- ✅ 安装版:专业、完整的安装体验
|
||||||
|
- ✅ 便携版:灵活、轻量,无需安装
|
||||||
|
- ✅ 适合正式产品发布
|
||||||
|
|
||||||
|
### 实现步骤
|
||||||
|
|
||||||
|
#### 1. 修改打包配置
|
||||||
|
|
||||||
|
**文件**:[cmd/builder.json](../cmd/builder.json)
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"productName": "南京灿能工具",
|
||||||
|
"appId": "com.canneng.tool",
|
||||||
|
"copyright": "© 2025 hongawen",
|
||||||
|
"directories": {
|
||||||
|
"output": "out"
|
||||||
|
},
|
||||||
|
"asar": true,
|
||||||
|
"files": [
|
||||||
|
"**/*",
|
||||||
|
"!cmd/",
|
||||||
|
"!data/",
|
||||||
|
"!electron/",
|
||||||
|
"!frontend/",
|
||||||
|
"!logs/",
|
||||||
|
"!out/",
|
||||||
|
"!go/",
|
||||||
|
"!python/"
|
||||||
|
],
|
||||||
|
"extraResources": {
|
||||||
|
"from": "build/extraResources/",
|
||||||
|
"to": "extraResources"
|
||||||
|
},
|
||||||
|
"nsis": {
|
||||||
|
"oneClick": false,
|
||||||
|
"allowElevation": true,
|
||||||
|
"allowToChangeInstallationDirectory": true,
|
||||||
|
"installerIcon": "build/icons/icon.ico",
|
||||||
|
"uninstallerIcon": "build/icons/icon.ico",
|
||||||
|
"installerHeaderIcon": "build/icons/icon.ico",
|
||||||
|
"createDesktopShortcut": true,
|
||||||
|
"createStartMenuShortcut": true,
|
||||||
|
"shortcutName": "南京灿能工具",
|
||||||
|
"artifactName": "${productName}-Setup-${version}.${ext}"
|
||||||
|
},
|
||||||
|
"portable": {
|
||||||
|
"artifactName": "${productName}-Portable-${version}.${ext}"
|
||||||
|
},
|
||||||
|
"publish": [
|
||||||
|
{
|
||||||
|
"provider": "generic",
|
||||||
|
"url": "https://your-update-server.com"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"win": {
|
||||||
|
"icon": "build/icons/icon.ico",
|
||||||
|
"target": [
|
||||||
|
{
|
||||||
|
"target": "nsis",
|
||||||
|
"arch": ["x64"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"target": "portable",
|
||||||
|
"arch": ["x64"]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
#### 2. 便携版快捷方式功能(可选)
|
||||||
|
|
||||||
|
如果希望便携版也能自动创建快捷方式,使用**方案一**中的 `createDesktopShortcut()` 代码。
|
||||||
|
|
||||||
|
#### 3. 打包命令
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm run build # 完整构建
|
||||||
|
npm run build-w # 打包两个版本
|
||||||
|
```
|
||||||
|
|
||||||
|
#### 4. 产物说明
|
||||||
|
|
||||||
|
打包完成后,在 `out/` 目录下会生成:
|
||||||
|
```
|
||||||
|
out/
|
||||||
|
├── 南京灿能工具-Setup-4.0.0.exe (安装版,约 150MB)
|
||||||
|
└── 南京灿能工具-Portable-4.0.0.exe (便携版,约 150-200MB)
|
||||||
|
```
|
||||||
|
|
||||||
|
#### 5. 版本差异说明
|
||||||
|
|
||||||
|
**安装版 (NSIS)**:
|
||||||
|
- 需要安装到系统(默认 C:\Program Files)
|
||||||
|
- 自动创建桌面快捷方式
|
||||||
|
- 自动创建开始菜单项
|
||||||
|
- 提供卸载程序
|
||||||
|
- 支持自动更新
|
||||||
|
- 适合企业部署、长期使用
|
||||||
|
|
||||||
|
**便携版 (Portable)**:
|
||||||
|
- 单个 exe 文件
|
||||||
|
- 双击直接运行(首次会自解压)
|
||||||
|
- 无需安装,无需卸载
|
||||||
|
- 可放在 U 盘随身携带
|
||||||
|
- 适合临时使用、测试环境
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 快捷方式创建原理(技术细节)
|
||||||
|
|
||||||
|
### Windows 快捷方式 (.lnk)
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
shell.writeShortcutLink(shortcutPath, {
|
||||||
|
target: process.execPath, // 目标程序路径
|
||||||
|
cwd: path.dirname(process.execPath), // 工作目录
|
||||||
|
description: '应用描述', // 快捷方式描述
|
||||||
|
icon: process.execPath, // 图标路径
|
||||||
|
iconIndex: 0, // 图标索引
|
||||||
|
args: '', // 启动参数(可选)
|
||||||
|
appUserModelId: 'com.app.id' // Windows 应用 ID(可选)
|
||||||
|
})
|
||||||
|
```
|
||||||
|
|
||||||
|
### 判断是否为便携版
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
const isPortable = process.platform === 'win32' &&
|
||||||
|
!process.execPath.includes('Program Files') &&
|
||||||
|
!process.execPath.includes('AppData\\Local\\Programs');
|
||||||
|
```
|
||||||
|
|
||||||
|
**原理**:
|
||||||
|
- 安装版通常安装在 `C:\Program Files\YourApp\`
|
||||||
|
- 或者 `C:\Users\用户名\AppData\Local\Programs\YourApp\`
|
||||||
|
- 便携版可以在任意位置运行
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 推荐配置
|
||||||
|
|
||||||
|
### 企业级应用(推荐方案二)
|
||||||
|
```
|
||||||
|
✅ 提供两个版本
|
||||||
|
✅ 主推安装版(专业形象)
|
||||||
|
✅ 提供便携版作为备选
|
||||||
|
```
|
||||||
|
|
||||||
|
### 轻量工具(推荐方案一)
|
||||||
|
```
|
||||||
|
✅ 只提供便携版
|
||||||
|
✅ 应用内自动创建快捷方式
|
||||||
|
✅ 简化分发流程
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 常见问题
|
||||||
|
|
||||||
|
### Q1: 便携版首次启动为什么慢?
|
||||||
|
**A**: 便携版是自解压程序,首次运行需要解压资源到临时目录(约 3-5 秒)。后续启动会快很多。
|
||||||
|
|
||||||
|
### Q2: 便携版数据存储在哪里?
|
||||||
|
**A**:
|
||||||
|
- 用户数据:`C:\Users\用户名\AppData\Roaming\你的appId\`
|
||||||
|
- 临时文件:`C:\Users\用户名\AppData\Local\Temp\`
|
||||||
|
|
||||||
|
### Q3: 如何让便携版也支持自动更新?
|
||||||
|
**A**: 需要配置 `electron-updater`,但便携版更新体验不如安装版。建议:
|
||||||
|
- 安装版:使用自动更新
|
||||||
|
- 便携版:提示用户下载新版本
|
||||||
|
|
||||||
|
### Q4: 可以同时运行两个版本吗?
|
||||||
|
**A**: 不建议。虽然技术上可行,但会导致数据冲突(共享同一个 userData 目录)。
|
||||||
|
|
||||||
|
### Q5: 如何自定义快捷方式图标?
|
||||||
|
**A**: 在 `build/icons/` 目录放置 `.ico` 文件,并在 `builder.json` 中配置:
|
||||||
|
```json
|
||||||
|
"win": {
|
||||||
|
"icon": "build/icons/custom-icon.ico"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 测试检查清单
|
||||||
|
|
||||||
|
打包完成后,请进行以下测试:
|
||||||
|
|
||||||
|
### 安装版测试
|
||||||
|
- [ ] 安装到默认路径成功
|
||||||
|
- [ ] 安装到自定义路径成功
|
||||||
|
- [ ] 桌面快捷方式正常
|
||||||
|
- [ ] 开始菜单项正常
|
||||||
|
- [ ] 应用启动正常
|
||||||
|
- [ ] 卸载程序正常
|
||||||
|
|
||||||
|
### 便携版测试
|
||||||
|
- [ ] 双击 exe 正常启动
|
||||||
|
- [ ] 首次启动自动创建快捷方式(如已实现)
|
||||||
|
- [ ] 桌面快捷方式可用
|
||||||
|
- [ ] 应用功能正常
|
||||||
|
- [ ] 关闭后再次启动正常
|
||||||
|
- [ ] 可移动到其他目录运行
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 参考资源
|
||||||
|
|
||||||
|
- electron-builder 官方文档: https://www.electron.build/
|
||||||
|
- NSIS 配置: https://www.electron.build/configuration/nsis
|
||||||
|
- Portable 配置: https://www.electron.build/configuration/portable
|
||||||
|
- Electron shell API: https://www.electronjs.org/docs/latest/api/shell
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
*文档创建时间: 2025-10-14*
|
||||||
|
*作者: hongawen*
|
||||||
459
doc/生命周期描述.md
Normal file
@@ -0,0 +1,459 @@
|
|||||||
|
# ElectronEgg 生命周期详解
|
||||||
|
|
||||||
|
本文档详细说明 ElectronEgg 框架的应用生命周期机制及其在项目中的实现。
|
||||||
|
|
||||||
|
## 生命周期流程图
|
||||||
|
|
||||||
|
```
|
||||||
|
┌─────────────┐
|
||||||
|
│ new │ 创建 ElectronEgg 实例
|
||||||
|
└──────┬──────┘
|
||||||
|
│
|
||||||
|
┌──────▼──────┐
|
||||||
|
│ ready │ core app 加载完成(ee-core 框架初始化)
|
||||||
|
└──────┬──────┘
|
||||||
|
│
|
||||||
|
┌──────▼─────────────┐
|
||||||
|
│ electronAppReady │ Electron app 加载完成
|
||||||
|
└──────┬─────────────┘
|
||||||
|
│
|
||||||
|
├─────────────────┐
|
||||||
|
│ │
|
||||||
|
┌──────▼──────┐ ┌─────▼────────┐
|
||||||
|
│ mainWindow │ │ windowReady │ 主窗口创建完成
|
||||||
|
└──────┬──────┘ └─────▲────────┘
|
||||||
|
│ │
|
||||||
|
└─────────────────┘
|
||||||
|
│
|
||||||
|
┌──────▼──────┐
|
||||||
|
│ running │ 应用运行中
|
||||||
|
└──────┬──────┘
|
||||||
|
│
|
||||||
|
┌──────▼──────┐
|
||||||
|
│beforeClose │ 退出之前触发
|
||||||
|
└──────┬──────┘
|
||||||
|
│
|
||||||
|
┌──────▼──────┐
|
||||||
|
│ quit │ 应用退出
|
||||||
|
└─────────────┘
|
||||||
|
```
|
||||||
|
|
||||||
|
## 生命周期钩子详解
|
||||||
|
|
||||||
|
### 1. new - 实例创建
|
||||||
|
|
||||||
|
**触发时机**:调用 `new ElectronEgg()` 时
|
||||||
|
|
||||||
|
**实现位置**:[electron/main.js](electron/main.js#L6)
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
const { ElectronEgg } = require('ee-core');
|
||||||
|
const app = new ElectronEgg();
|
||||||
|
```
|
||||||
|
|
||||||
|
**作用**:
|
||||||
|
- 创建 ElectronEgg 应用实例
|
||||||
|
- 初始化框架核心模块
|
||||||
|
- 准备生命周期管理器
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### 2. ready - 核心应用就绪
|
||||||
|
|
||||||
|
**触发时机**:ee-core 框架加载完成,Electron app 启动之前
|
||||||
|
|
||||||
|
**实现位置**:
|
||||||
|
- 注册:[electron/main.js](electron/main.js#L10)
|
||||||
|
- 实现:[electron/preload/lifecycle.js](electron/preload/lifecycle.js#L12-L14)
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
// 注册
|
||||||
|
app.register("ready", life.ready);
|
||||||
|
|
||||||
|
// 实现
|
||||||
|
async ready() {
|
||||||
|
logger.info('[lifecycle] ready');
|
||||||
|
// 在这里可以做:
|
||||||
|
// - 初始化数据库连接
|
||||||
|
// - 加载配置文件
|
||||||
|
// - 初始化全局变量
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
**适用场景**:
|
||||||
|
- ✅ 初始化数据库连接
|
||||||
|
- ✅ 加载应用配置
|
||||||
|
- ✅ 注册全局服务
|
||||||
|
- ✅ 初始化日志系统
|
||||||
|
- ❌ 不能操作窗口(窗口还未创建)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### 3. electronAppReady - Electron 应用就绪
|
||||||
|
|
||||||
|
**触发时机**:Electron 的 `app.ready` 事件触发后,主窗口创建之前
|
||||||
|
|
||||||
|
**实现位置**:
|
||||||
|
- 注册:[electron/main.js](electron/main.js#L11)
|
||||||
|
- 实现:[electron/preload/lifecycle.js](electron/preload/lifecycle.js#L19-L21)
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
// 注册
|
||||||
|
app.register("electron-app-ready", life.electronAppReady);
|
||||||
|
|
||||||
|
// 实现
|
||||||
|
async electronAppReady() {
|
||||||
|
logger.info('[lifecycle] electron-app-ready');
|
||||||
|
// 在这里可以做:
|
||||||
|
// - 注册全局快捷键
|
||||||
|
// - 设置应用菜单
|
||||||
|
// - 初始化托盘图标
|
||||||
|
// - 注册协议处理
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
**适用场景**:
|
||||||
|
- ✅ 注册全局快捷键 (globalShortcut)
|
||||||
|
- ✅ 创建应用菜单 (Menu)
|
||||||
|
- ✅ 创建系统托盘 (Tray)
|
||||||
|
- ✅ 注册自定义协议 (protocol)
|
||||||
|
- ⚠️ 可以创建窗口,但通常在框架内部自动创建
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### 4. mainWindow - 主窗口创建
|
||||||
|
|
||||||
|
**触发时机**:框架创建主窗口时(内部流程,不需要手动注册)
|
||||||
|
|
||||||
|
**说明**:
|
||||||
|
- 这是框架内部自动执行的步骤
|
||||||
|
- 根据 `electron/config/config.*.js` 中的 `windowsOption` 配置创建窗口
|
||||||
|
- 窗口创建完成后会触发 `windowReady` 钩子
|
||||||
|
|
||||||
|
**配置示例**:
|
||||||
|
```javascript
|
||||||
|
// electron/config/config.default.js
|
||||||
|
windowsOption: {
|
||||||
|
width: 1200,
|
||||||
|
height: 800,
|
||||||
|
show: false, // 设置为 false 可实现无白屏启动
|
||||||
|
webPreferences: {
|
||||||
|
contextIsolation: false,
|
||||||
|
nodeIntegration: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### 5. windowReady - 窗口就绪
|
||||||
|
|
||||||
|
**触发时机**:主窗口创建完成,页面加载完毕
|
||||||
|
|
||||||
|
**实现位置**:
|
||||||
|
- 注册:[electron/main.js](electron/main.js#L12)
|
||||||
|
- 实现:[electron/preload/lifecycle.js](electron/preload/lifecycle.js#L26-L37)
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
// 注册
|
||||||
|
app.register("window-ready", life.windowReady);
|
||||||
|
|
||||||
|
// 实现
|
||||||
|
async windowReady() {
|
||||||
|
logger.info('[lifecycle] window-ready');
|
||||||
|
|
||||||
|
// 延迟显示窗口,避免白屏
|
||||||
|
const { windowsOption } = getConfig();
|
||||||
|
if (windowsOption.show == false) {
|
||||||
|
const win = getMainWindow();
|
||||||
|
win.once('ready-to-show', () => {
|
||||||
|
win.show(); // 显示窗口
|
||||||
|
win.focus(); // 聚焦窗口
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 在这里可以做:
|
||||||
|
// - 向渲染进程发送初始化数据
|
||||||
|
// - 检查更新
|
||||||
|
// - 加载用户配置
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
**适用场景**:
|
||||||
|
- ✅ 操作主窗口 (show/hide/maximize 等)
|
||||||
|
- ✅ 向渲染进程发送消息
|
||||||
|
- ✅ 执行自动更新检查
|
||||||
|
- ✅ 加载用户数据并同步到前端
|
||||||
|
- ✅ 实现无白屏启动(配合 `show: false`)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### 6. running - 应用运行中
|
||||||
|
|
||||||
|
**触发时机**:窗口显示后,应用正常运行期间
|
||||||
|
|
||||||
|
**说明**:
|
||||||
|
- 这不是一个独立的生命周期钩子
|
||||||
|
- 表示应用的正常运行状态
|
||||||
|
- 此时所有功能都可用
|
||||||
|
|
||||||
|
**可用操作**:
|
||||||
|
- IPC 通信(前后端交互)
|
||||||
|
- 业务逻辑处理
|
||||||
|
- 数据库操作
|
||||||
|
- 网络请求
|
||||||
|
- 文件系统操作
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### 7. beforeClose - 关闭前钩子
|
||||||
|
|
||||||
|
**触发时机**:用户点击关闭按钮或调用 `app.quit()` 之前
|
||||||
|
|
||||||
|
**实现位置**:
|
||||||
|
- 注册:[electron/main.js](electron/main.js#L13)
|
||||||
|
- 实现:[electron/preload/lifecycle.js](electron/preload/lifecycle.js#L42-L44)
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
// 注册
|
||||||
|
app.register("before-close", life.beforeClose);
|
||||||
|
|
||||||
|
// 实现
|
||||||
|
async beforeClose() {
|
||||||
|
logger.info('[lifecycle] before-close');
|
||||||
|
// 在这里可以做:
|
||||||
|
// - 保存用户数据
|
||||||
|
// - 关闭数据库连接
|
||||||
|
// - 清理临时文件
|
||||||
|
// - 释放系统资源
|
||||||
|
// - 确认是否退出
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
**适用场景**:
|
||||||
|
- ✅ 保存应用状态
|
||||||
|
- ✅ 关闭数据库连接
|
||||||
|
- ✅ 清理临时资源
|
||||||
|
- ✅ 询问用户是否确认退出
|
||||||
|
- ✅ 上传日志或统计数据
|
||||||
|
|
||||||
|
**阻止关闭示例**:
|
||||||
|
```javascript
|
||||||
|
async beforeClose(args, event) {
|
||||||
|
const { dialog } = require('electron');
|
||||||
|
const result = await dialog.showMessageBox({
|
||||||
|
type: 'question',
|
||||||
|
buttons: ['取消', '退出'],
|
||||||
|
message: '确定要退出应用吗?'
|
||||||
|
});
|
||||||
|
|
||||||
|
if (result.response === 0) {
|
||||||
|
// 阻止关闭
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 允许关闭
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### 8. quit - 应用退出
|
||||||
|
|
||||||
|
**触发时机**:`beforeClose` 完成后,应用进程终止
|
||||||
|
|
||||||
|
**说明**:
|
||||||
|
- 这是最终状态,不可逆
|
||||||
|
- 所有资源清理应在 `beforeClose` 中完成
|
||||||
|
- 退出后进程结束,无法执行代码
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 额外生命周期:preload
|
||||||
|
|
||||||
|
### preload - 预加载模块
|
||||||
|
|
||||||
|
**触发时机**:应用启动时,在所有其他钩子之前
|
||||||
|
|
||||||
|
**实现位置**:
|
||||||
|
- 注册:[electron/main.js](electron/main.js#L16)
|
||||||
|
- 实现:[electron/preload/index.js](electron/preload/index.js#L7-L9)
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
// 注册
|
||||||
|
app.register("preload", preload);
|
||||||
|
|
||||||
|
// 实现
|
||||||
|
function preload() {
|
||||||
|
logger.info('[preload] load 1');
|
||||||
|
// 在这里可以做:
|
||||||
|
// - 加载环境变量
|
||||||
|
// - 注册原生模块
|
||||||
|
// - 设置全局异常处理
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
**适用场景**:
|
||||||
|
- ✅ 加载环境变量
|
||||||
|
- ✅ 注册 Node.js 原生模块
|
||||||
|
- ✅ 设置全局错误处理
|
||||||
|
- ✅ 初始化第三方 SDK
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 实际开发示例
|
||||||
|
|
||||||
|
### 示例 1:数据库初始化
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
// electron/preload/lifecycle.js
|
||||||
|
const Database = require('better-sqlite3');
|
||||||
|
let db;
|
||||||
|
|
||||||
|
class Lifecycle {
|
||||||
|
async ready() {
|
||||||
|
// 在 ready 钩子中初始化数据库
|
||||||
|
const path = require('path');
|
||||||
|
const dbPath = path.join(app.getPath('userData'), 'app.db');
|
||||||
|
db = new Database(dbPath);
|
||||||
|
logger.info('[lifecycle] database initialized');
|
||||||
|
}
|
||||||
|
|
||||||
|
async beforeClose() {
|
||||||
|
// 在关闭前关闭数据库连接
|
||||||
|
if (db) {
|
||||||
|
db.close();
|
||||||
|
logger.info('[lifecycle] database closed');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### 示例 2:自动更新检查
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
// electron/preload/lifecycle.js
|
||||||
|
const { autoUpdater } = require('electron-updater');
|
||||||
|
|
||||||
|
class Lifecycle {
|
||||||
|
async windowReady() {
|
||||||
|
// 窗口就绪后检查更新
|
||||||
|
const { getMainWindow } = require('ee-core/electron');
|
||||||
|
const win = getMainWindow();
|
||||||
|
|
||||||
|
autoUpdater.checkForUpdates();
|
||||||
|
|
||||||
|
autoUpdater.on('update-available', () => {
|
||||||
|
win.webContents.send('update-available');
|
||||||
|
});
|
||||||
|
|
||||||
|
logger.info('[lifecycle] update check started');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### 示例 3:托盘图标
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
// electron/preload/lifecycle.js
|
||||||
|
const { Tray, Menu } = require('electron');
|
||||||
|
let tray;
|
||||||
|
|
||||||
|
class Lifecycle {
|
||||||
|
async electronAppReady() {
|
||||||
|
// 在 Electron 就绪后创建托盘
|
||||||
|
const path = require('path');
|
||||||
|
const iconPath = path.join(__dirname, '../../public/images/tray-icon.png');
|
||||||
|
|
||||||
|
tray = new Tray(iconPath);
|
||||||
|
const contextMenu = Menu.buildFromTemplate([
|
||||||
|
{ label: '打开主窗口', click: () => {
|
||||||
|
const { getMainWindow } = require('ee-core/electron');
|
||||||
|
getMainWindow().show();
|
||||||
|
}},
|
||||||
|
{ label: '退出', click: () => {
|
||||||
|
const { app } = require('electron');
|
||||||
|
app.quit();
|
||||||
|
}}
|
||||||
|
]);
|
||||||
|
|
||||||
|
tray.setContextMenu(contextMenu);
|
||||||
|
logger.info('[lifecycle] tray created');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### 示例 4:无白屏启动
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
// electron/config/config.default.js
|
||||||
|
windowsOption: {
|
||||||
|
width: 1200,
|
||||||
|
height: 800,
|
||||||
|
show: false, // 关键配置:初始不显示
|
||||||
|
backgroundColor: '#ffffff'
|
||||||
|
}
|
||||||
|
|
||||||
|
// electron/preload/lifecycle.js
|
||||||
|
class Lifecycle {
|
||||||
|
async windowReady() {
|
||||||
|
// 页面加载完成后再显示,避免白屏
|
||||||
|
const { getMainWindow } = require('ee-core/electron');
|
||||||
|
const win = getMainWindow();
|
||||||
|
|
||||||
|
win.once('ready-to-show', () => {
|
||||||
|
win.show();
|
||||||
|
win.focus();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 生命周期执行顺序总结
|
||||||
|
|
||||||
|
```
|
||||||
|
1. preload() # 预加载模块
|
||||||
|
2. new ElectronEgg() # 创建应用实例
|
||||||
|
3. ready() # 核心框架就绪
|
||||||
|
4. electronAppReady() # Electron 就绪
|
||||||
|
5. [创建主窗口] # 框架内部创建窗口
|
||||||
|
6. windowReady() # 窗口就绪
|
||||||
|
7. [应用运行中] # 正常运行状态
|
||||||
|
8. beforeClose() # 关闭前钩子
|
||||||
|
9. [应用退出] # 进程结束
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 注意事项
|
||||||
|
|
||||||
|
1. **异步支持**:所有生命周期钩子都支持 `async/await`,可以执行异步操作
|
||||||
|
|
||||||
|
2. **错误处理**:建议在每个钩子中添加 try-catch 错误处理
|
||||||
|
|
||||||
|
3. **顺序依赖**:不要在早期钩子中访问尚未初始化的资源(如在 `ready` 中操作窗口)
|
||||||
|
|
||||||
|
4. **性能优化**:避免在钩子中执行耗时操作,会阻塞应用启动
|
||||||
|
|
||||||
|
5. **资源清理**:在 `beforeClose` 中务必清理所有资源,避免内存泄漏
|
||||||
|
|
||||||
|
6. **日志记录**:建议在每个钩子中记录日志,方便排查问题
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 相关文件
|
||||||
|
|
||||||
|
- 生命周期注册:[electron/main.js](electron/main.js)
|
||||||
|
- 生命周期实现:[electron/preload/lifecycle.js](electron/preload/lifecycle.js)
|
||||||
|
- 预加载模块:[electron/preload/index.js](electron/preload/index.js)
|
||||||
|
- 窗口配置:[electron/config/config.default.js](electron/config/config.default.js)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 参考资源
|
||||||
|
|
||||||
|
- ElectronEgg 官方文档:https://www.kaka996.com/pages/987b1c/
|
||||||
|
- Electron 官方文档:https://www.electronjs.org/zh/docs/latest/
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
#### 基础配置
|
|
||||||
主进程的配置文件在./config文件夹下
|
|
||||||
```shell
|
|
||||||
# 说明
|
|
||||||
bin.js // 开发配置
|
|
||||||
config.default.js // 默认配置文件,开发环境和生产环境都会加载
|
|
||||||
config.local.js // 开发环境配置文件,追加和覆盖default配置文件
|
|
||||||
config.prod.js // 生产环境配置文件,追加和覆盖default配置文件
|
|
||||||
nodemon.json // 开发环境,代码(监控)热加载
|
|
||||||
builder.json // 打包配置
|
|
||||||
```
|
|
||||||
@@ -1,170 +0,0 @@
|
|||||||
const { app: electronApp } = require('electron');
|
|
||||||
const { autoUpdater } = require("electron-updater");
|
|
||||||
const is = require('ee-core/utils/is');
|
|
||||||
const Log = require('ee-core/log');
|
|
||||||
const Conf = require('ee-core/config');
|
|
||||||
const CoreWindow = require('ee-core/electron/window');
|
|
||||||
const Electron = require('ee-core/electron');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 自动升级插件
|
|
||||||
* @class
|
|
||||||
*/
|
|
||||||
class AutoUpdaterAddon {
|
|
||||||
|
|
||||||
constructor() {
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 创建
|
|
||||||
*/
|
|
||||||
create () {
|
|
||||||
Log.info('[addon:autoUpdater] load');
|
|
||||||
const cfg = Conf.getValue('addons.autoUpdater');
|
|
||||||
if ((is.windows() && cfg.windows)
|
|
||||||
|| (is.macOS() && cfg.macOS)
|
|
||||||
|| (is.linux() && cfg.linux))
|
|
||||||
{
|
|
||||||
// continue
|
|
||||||
} else {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// 是否检查更新
|
|
||||||
if (cfg.force) {
|
|
||||||
this.checkUpdate();
|
|
||||||
}
|
|
||||||
|
|
||||||
const status = {
|
|
||||||
error: -1,
|
|
||||||
available: 1,
|
|
||||||
noAvailable: 2,
|
|
||||||
downloading: 3,
|
|
||||||
downloaded: 4,
|
|
||||||
}
|
|
||||||
|
|
||||||
const version = electronApp.getVersion();
|
|
||||||
Log.info('[addon:autoUpdater] current version: ', version);
|
|
||||||
|
|
||||||
// 设置下载服务器地址
|
|
||||||
let server = cfg.options.url;
|
|
||||||
let lastChar = server.substring(server.length - 1);
|
|
||||||
server = lastChar === '/' ? server : server + "/";
|
|
||||||
//Log.info('[addon:autoUpdater] server: ', server);
|
|
||||||
cfg.options.url = server;
|
|
||||||
|
|
||||||
// 是否后台自动下载
|
|
||||||
autoUpdater.autoDownload = cfg.force ? true : false;
|
|
||||||
|
|
||||||
try {
|
|
||||||
autoUpdater.setFeedURL(cfg.options);
|
|
||||||
} catch (error) {
|
|
||||||
Log.error('[addon:autoUpdater] setFeedURL error : ', error);
|
|
||||||
}
|
|
||||||
|
|
||||||
autoUpdater.on('checking-for-update', () => {
|
|
||||||
//sendStatusToWindow('正在检查更新...');
|
|
||||||
})
|
|
||||||
autoUpdater.on('update-available', (info) => {
|
|
||||||
info.status = status.available;
|
|
||||||
info.desc = '有可用更新';
|
|
||||||
this.sendStatusToWindow(info);
|
|
||||||
})
|
|
||||||
autoUpdater.on('update-not-available', (info) => {
|
|
||||||
info.status = status.noAvailable;
|
|
||||||
info.desc = '没有可用更新';
|
|
||||||
this.sendStatusToWindow(info);
|
|
||||||
})
|
|
||||||
autoUpdater.on('error', (err) => {
|
|
||||||
let info = {
|
|
||||||
status: status.error,
|
|
||||||
desc: err
|
|
||||||
}
|
|
||||||
this.sendStatusToWindow(info);
|
|
||||||
})
|
|
||||||
autoUpdater.on('download-progress', (progressObj) => {
|
|
||||||
let percentNumber = parseInt(progressObj.percent);
|
|
||||||
let totalSize = this.bytesChange(progressObj.total);
|
|
||||||
let transferredSize = this.bytesChange(progressObj.transferred);
|
|
||||||
let text = '已下载 ' + percentNumber + '%';
|
|
||||||
text = text + ' (' + transferredSize + "/" + totalSize + ')';
|
|
||||||
|
|
||||||
let info = {
|
|
||||||
status: status.downloading,
|
|
||||||
desc: text,
|
|
||||||
percentNumber: percentNumber,
|
|
||||||
totalSize: totalSize,
|
|
||||||
transferredSize: transferredSize
|
|
||||||
}
|
|
||||||
Log.info('[addon:autoUpdater] progress: ', text);
|
|
||||||
this.sendStatusToWindow(info);
|
|
||||||
})
|
|
||||||
autoUpdater.on('update-downloaded', (info) => {
|
|
||||||
info.status = status.downloaded;
|
|
||||||
info.desc = '下载完成';
|
|
||||||
this.sendStatusToWindow(info);
|
|
||||||
|
|
||||||
// 托盘插件默认会阻止窗口关闭,这里设置允许关闭窗口
|
|
||||||
Electron.extra.closeWindow = true;
|
|
||||||
|
|
||||||
autoUpdater.quitAndInstall();
|
|
||||||
// const mainWindow = CoreWindow.getMainWindow();
|
|
||||||
// if (mainWindow) {
|
|
||||||
// mainWindow.destroy()
|
|
||||||
// }
|
|
||||||
// electronApp.appQuit()
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 检查更新
|
|
||||||
*/
|
|
||||||
checkUpdate () {
|
|
||||||
autoUpdater.checkForUpdates();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 下载更新
|
|
||||||
*/
|
|
||||||
download () {
|
|
||||||
autoUpdater.downloadUpdate();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 向前端发消息
|
|
||||||
*/
|
|
||||||
sendStatusToWindow(content = {}) {
|
|
||||||
const textJson = JSON.stringify(content);
|
|
||||||
const channel = 'app.updater';
|
|
||||||
const win = CoreWindow.getMainWindow();
|
|
||||||
win.webContents.send(channel, textJson);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 单位转换
|
|
||||||
*/
|
|
||||||
bytesChange (limit) {
|
|
||||||
let size = "";
|
|
||||||
if(limit < 0.1 * 1024){
|
|
||||||
size = limit.toFixed(2) + "B";
|
|
||||||
}else if(limit < 0.1 * 1024 * 1024){
|
|
||||||
size = (limit/1024).toFixed(2) + "KB";
|
|
||||||
}else if(limit < 0.1 * 1024 * 1024 * 1024){
|
|
||||||
size = (limit/(1024 * 1024)).toFixed(2) + "MB";
|
|
||||||
}else{
|
|
||||||
size = (limit/(1024 * 1024 * 1024)).toFixed(2) + "GB";
|
|
||||||
}
|
|
||||||
|
|
||||||
let sizeStr = size + "";
|
|
||||||
let index = sizeStr.indexOf(".");
|
|
||||||
let dou = sizeStr.substring(index + 1 , index + 3);
|
|
||||||
if(dou == "00"){
|
|
||||||
return sizeStr.substring(0, index) + sizeStr.substring(index + 3, index + 5);
|
|
||||||
}
|
|
||||||
|
|
||||||
return size;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
AutoUpdaterAddon.toString = () => '[class AutoUpdaterAddon]';
|
|
||||||
module.exports = AutoUpdaterAddon;
|
|
||||||
@@ -1,67 +0,0 @@
|
|||||||
const { app: electronApp } = require('electron');
|
|
||||||
const Log = require('ee-core/log');
|
|
||||||
const Conf = require('ee-core/config');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 唤醒插件
|
|
||||||
* @class
|
|
||||||
*/
|
|
||||||
class AwakenAddon {
|
|
||||||
|
|
||||||
constructor() {
|
|
||||||
this.protocol = '';
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 创建
|
|
||||||
*/
|
|
||||||
create () {
|
|
||||||
Log.info('[addon:awaken] load');
|
|
||||||
|
|
||||||
const cfg = Conf.getValue('addons.awaken');
|
|
||||||
this.protocol = cfg.protocol;
|
|
||||||
|
|
||||||
electronApp.setAsDefaultProtocolClient(this.protocol);
|
|
||||||
|
|
||||||
this.handleArgv(process.argv);
|
|
||||||
electronApp.on('second-instance', (event, argv) => {
|
|
||||||
if (process.platform === 'win32') {
|
|
||||||
this.handleArgv(argv)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
// 仅用于macOS
|
|
||||||
electronApp.on('open-url', (event, urlStr) => {
|
|
||||||
this.handleUrl(urlStr)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 参数处理
|
|
||||||
*/
|
|
||||||
handleArgv(argv) {
|
|
||||||
const offset = electronApp.isPackaged ? 1 : 2;
|
|
||||||
const url = argv.find((arg, i) => i >= offset && arg.startsWith(this.protocol));
|
|
||||||
this.handleUrl(url)
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* url解析
|
|
||||||
*/
|
|
||||||
handleUrl(awakeUrlStr) {
|
|
||||||
if (!awakeUrlStr || awakeUrlStr.length === 0) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
const {hostname, pathname, search} = new URL(awakeUrlStr);
|
|
||||||
let awakeUrlInfo = {
|
|
||||||
urlStr: awakeUrlStr,
|
|
||||||
urlHost: hostname,
|
|
||||||
urlPath: pathname,
|
|
||||||
urlParams: search && search.slice(1)
|
|
||||||
}
|
|
||||||
Log.info('[addon:awaken] awakeUrlInfo:', awakeUrlInfo);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
AwakenAddon.toString = () => '[class AwakenAddon]';
|
|
||||||
module.exports = AwakenAddon;
|
|
||||||
@@ -1,94 +0,0 @@
|
|||||||
const { app, session } = require('electron');
|
|
||||||
const _ = require('lodash');
|
|
||||||
const fs = require('fs');
|
|
||||||
const path = require('path');
|
|
||||||
const Log = require('ee-core/log');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 扩展插件 (electron自身对该功能并不完全支持,官方也不建议使用)
|
|
||||||
* @class
|
|
||||||
*/
|
|
||||||
class ChromeExtensionAddon {
|
|
||||||
|
|
||||||
constructor() {
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 创建
|
|
||||||
*/
|
|
||||||
async create () {
|
|
||||||
Log.info('[addon:chromeExtension] load');
|
|
||||||
|
|
||||||
const extensionIds = this.getAllIds();
|
|
||||||
for (let i = 0; i < extensionIds.length; i++) {
|
|
||||||
await this.load(extensionIds[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取扩展id列表(crx解压后的目录名,即是该扩展的id)
|
|
||||||
*/
|
|
||||||
getAllIds () {
|
|
||||||
const extendsionDir = this.getDirectory();
|
|
||||||
const ids = this.getDirs(extendsionDir);
|
|
||||||
|
|
||||||
return ids;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 扩展所在目录
|
|
||||||
*/
|
|
||||||
getDirectory () {
|
|
||||||
let extensionDirPath = '';
|
|
||||||
let variablePath = 'build'; // 打包前路径
|
|
||||||
if (app.isPackaged) {
|
|
||||||
variablePath = '..'; // 打包后路径
|
|
||||||
}
|
|
||||||
extensionDirPath = path.join(app.getAppPath(), variablePath, "extraResources", "chromeExtension");
|
|
||||||
|
|
||||||
return extensionDirPath;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 加载扩展
|
|
||||||
*/
|
|
||||||
async load (extensionId = '') {
|
|
||||||
if (_.isEmpty(extensionId)) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
const extensionPath = path.join(this.getDirectory(), extensionId);
|
|
||||||
Log.info('[addon:chromeExtension] extensionPath:', extensionPath);
|
|
||||||
await session.defaultSession.loadExtension(extensionPath, { allowFileAccess: true });
|
|
||||||
} catch (e) {
|
|
||||||
Log.info('[addon:chromeExtension] load extension error extensionId:%s, errorInfo:%s', extensionId, e.toString());
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取目录下所有文件夹
|
|
||||||
*/
|
|
||||||
getDirs(dir) {
|
|
||||||
if (!dir) {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
const components = [];
|
|
||||||
const files = fs.readdirSync(dir);
|
|
||||||
files.forEach(function(item, index) {
|
|
||||||
const stat = fs.lstatSync(dir + '/' + item);
|
|
||||||
if (stat.isDirectory() === true) {
|
|
||||||
components.push(item);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return components;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
ChromeExtensionAddon.toString = () => '[class ChromeExtensionAddon]';
|
|
||||||
module.exports = ChromeExtensionAddon;
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
const Log = require('ee-core/log');
|
|
||||||
const EE = require('ee-core/ee');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 安全插件
|
|
||||||
* @class
|
|
||||||
*/
|
|
||||||
class SecurityAddon {
|
|
||||||
|
|
||||||
constructor() {
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 创建
|
|
||||||
*/
|
|
||||||
create () {
|
|
||||||
Log.info('[addon:security] load');
|
|
||||||
const { CoreApp } = EE;
|
|
||||||
const runWithDebug = process.argv.find(function(e){
|
|
||||||
let isHasDebug = e.includes("--inspect") || e.includes("--inspect-brk") || e.includes("--remote-debugging-port");
|
|
||||||
return isHasDebug;
|
|
||||||
})
|
|
||||||
|
|
||||||
// 不允许远程调试
|
|
||||||
if (runWithDebug) {
|
|
||||||
Log.error('[error] Remote debugging is not allowed, runWithDebug:', runWithDebug);
|
|
||||||
CoreApp.appQuit();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
SecurityAddon.toString = () => '[class SecurityAddon]';
|
|
||||||
module.exports = SecurityAddon;
|
|
||||||
@@ -1,72 +0,0 @@
|
|||||||
const { Tray, Menu } = require('electron');
|
|
||||||
const path = require('path');
|
|
||||||
const Ps = require('ee-core/ps');
|
|
||||||
const Log = require('ee-core/log');
|
|
||||||
const Electron = require('ee-core/electron');
|
|
||||||
const CoreWindow = require('ee-core/electron/window');
|
|
||||||
const Conf = require('ee-core/config');
|
|
||||||
const EE = require('ee-core/ee');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 托盘插件
|
|
||||||
* @class
|
|
||||||
*/
|
|
||||||
class TrayAddon {
|
|
||||||
|
|
||||||
constructor() {
|
|
||||||
this.tray = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 创建托盘
|
|
||||||
*/
|
|
||||||
create () {
|
|
||||||
// 开发环境,代码热更新开启时,会导致托盘中有残影
|
|
||||||
if (Ps.isDev() && Ps.isHotReload()) return;
|
|
||||||
|
|
||||||
Log.info('[addon:tray] load');
|
|
||||||
const { CoreApp } = EE;
|
|
||||||
const cfg = Conf.getValue('addons.tray');
|
|
||||||
const mainWindow = CoreWindow.getMainWindow();
|
|
||||||
|
|
||||||
// 托盘图标
|
|
||||||
let iconPath = path.join(Ps.getHomeDir(), cfg.icon);
|
|
||||||
|
|
||||||
// 托盘菜单功能列表
|
|
||||||
let trayMenuTemplate = [
|
|
||||||
{
|
|
||||||
label: '显示',
|
|
||||||
click: function () {
|
|
||||||
mainWindow.show();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: '退出',
|
|
||||||
click: function () {
|
|
||||||
CoreApp.appQuit();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
// 点击关闭,最小化到托盘
|
|
||||||
mainWindow.on('close', (event) => {
|
|
||||||
if (Electron.extra.closeWindow == true) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
mainWindow.hide();
|
|
||||||
event.preventDefault();
|
|
||||||
});
|
|
||||||
|
|
||||||
// 实例化托盘
|
|
||||||
this.tray = new Tray(iconPath);
|
|
||||||
this.tray.setToolTip(cfg.title);
|
|
||||||
const contextMenu = Menu.buildFromTemplate(trayMenuTemplate);
|
|
||||||
this.tray.setContextMenu(contextMenu);
|
|
||||||
this.tray.on('double-click', () => {
|
|
||||||
mainWindow.show()
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
TrayAddon.toString = () => '[class TrayAddon]';
|
|
||||||
module.exports = TrayAddon;
|
|
||||||
@@ -1,108 +0,0 @@
|
|||||||
/**
|
|
||||||
* ee-bin 配置
|
|
||||||
* 仅适用于开发环境
|
|
||||||
*/
|
|
||||||
module.exports = {
|
|
||||||
/**
|
|
||||||
* development serve ("frontend" "electron" )
|
|
||||||
* ee-bin dev
|
|
||||||
*/
|
|
||||||
dev: {
|
|
||||||
frontend: {
|
|
||||||
directory: './frontend',
|
|
||||||
cmd: 'npm',
|
|
||||||
args: ['run', 'dev'],
|
|
||||||
protocol: 'http://',
|
|
||||||
hostname: 'localhost',
|
|
||||||
port: 18091,
|
|
||||||
indexPath: 'index.html'
|
|
||||||
},
|
|
||||||
electron: {
|
|
||||||
directory: './',
|
|
||||||
cmd: 'electron',
|
|
||||||
args: ['.', '--env=local', '--color=always'], // --env: local|prod; '--color=always' 控制台颜色
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 构建
|
|
||||||
* ee-bin build
|
|
||||||
*/
|
|
||||||
build: {
|
|
||||||
frontend: {
|
|
||||||
directory: './frontend',
|
|
||||||
cmd: 'npm',
|
|
||||||
args: ['run', 'build'],
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 移动资源
|
|
||||||
* ee-bin move
|
|
||||||
*/
|
|
||||||
move: {
|
|
||||||
frontend_dist: {
|
|
||||||
dist: './frontend/dist',
|
|
||||||
target: './public/dist'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 预发布模式(prod)
|
|
||||||
* ee-bin start
|
|
||||||
*/
|
|
||||||
start: {
|
|
||||||
directory: './',
|
|
||||||
cmd: 'electron',
|
|
||||||
args: ['.', '--env=prod']
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 加密
|
|
||||||
*/
|
|
||||||
encrypt: {
|
|
||||||
// confusion - 压缩混淆加密
|
|
||||||
// bytecode - 字节码加密
|
|
||||||
// strict - 先混淆加密,然后字节码加密
|
|
||||||
type: 'confusion',
|
|
||||||
// 文件匹配
|
|
||||||
// ! 符号开头的意思是过滤
|
|
||||||
files: [
|
|
||||||
'electron/**/*.(js|json)',
|
|
||||||
'!electron/config/encrypt.js',
|
|
||||||
'!electron/config/nodemon.json',
|
|
||||||
'!electron/config/builder.json',
|
|
||||||
'!electron/config/bin.json',
|
|
||||||
],
|
|
||||||
// 需要加密的文件后缀,暂时只支持js
|
|
||||||
fileExt: ['.js'],
|
|
||||||
// 混淆加密配置
|
|
||||||
confusionOptions: {
|
|
||||||
// 压缩成一行
|
|
||||||
compact: true,
|
|
||||||
// 删除字符串文字并将其放置在一个特殊数组中
|
|
||||||
stringArray: true,
|
|
||||||
// 对stringArray的所有字符串文字进行编码,值:'none' | 'base64' | 'rc4'
|
|
||||||
stringArrayEncoding: ['none'],
|
|
||||||
// 注入死代码,注:影响性能
|
|
||||||
deadCodeInjection: false,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 执行自定义命令
|
|
||||||
* ee-bin exec
|
|
||||||
*/
|
|
||||||
exec: {
|
|
||||||
node_v: {
|
|
||||||
directory: './',
|
|
||||||
cmd: 'node',
|
|
||||||
args: ['-v'],
|
|
||||||
},
|
|
||||||
npm_v: {
|
|
||||||
directory: './',
|
|
||||||
cmd: 'npm',
|
|
||||||
args: ['-v'],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
|
||||||
@@ -1,185 +1,71 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
|
const {getBaseDir} = require('ee-core/ps');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 默认配置
|
* 默认配置
|
||||||
*/
|
*/
|
||||||
module.exports = (appInfo) => {
|
module.exports = () => {
|
||||||
|
return {
|
||||||
const config = {};
|
openDevTools: false,
|
||||||
|
singleLock: true,
|
||||||
/**
|
windowsOption: {
|
||||||
* 开发者工具
|
title: 'NPQS9100-自动检测平台',
|
||||||
*/
|
menuBarVisible: false,
|
||||||
config.openDevTools = false;
|
width: 1920,
|
||||||
|
height: 1000,
|
||||||
/**
|
minWidth: 1024,
|
||||||
* 应用程序顶部菜单
|
minHeight: 640,
|
||||||
*/
|
webPreferences: {
|
||||||
config.openAppMenu = true;
|
//webSecurity: false,
|
||||||
|
contextIsolation: false, // false -> 可在渲染进程中使用electron的api,true->需要bridge.js(contextBridge)
|
||||||
/**
|
nodeIntegration: true,
|
||||||
* 1.507
|
//preload: path.join(getElectronDir(), 'preload', 'bridge.js'),
|
||||||
* 主窗口
|
},
|
||||||
*/
|
frame: true,
|
||||||
config.windowsOption = {
|
show: true,
|
||||||
title: '自动检测平台',
|
icon: path.join(getBaseDir(), 'public', 'images', 'logo-32.png'),
|
||||||
width: 1920 /1.5,
|
},
|
||||||
height: 1080 /1.2,
|
logger: {
|
||||||
minWidth: 1920 /1.5,
|
level: 'INFO',
|
||||||
minHeight: 1080 /1.2,
|
outputJSON: false,
|
||||||
webPreferences: {
|
appLogName: '9100.log',
|
||||||
//webSecurity: false,
|
coreLogName: '9100-core.log',
|
||||||
contextIsolation: false, // false -> 可在渲染进程中使用electron的api,true->需要bridge.js(contextBridge)
|
errorLogName: '9100-error.log'
|
||||||
nodeIntegration: true,
|
},
|
||||||
//preload: path.join(appInfo.baseDir, 'preload', 'bridge.js'),
|
// 远程web地址
|
||||||
},
|
remote: {
|
||||||
frame: true,
|
enable: false,
|
||||||
show: false,
|
url: ''
|
||||||
icon: path.join(appInfo.home, 'public', 'images', 'logo-32.png'),
|
},
|
||||||
};
|
socketServer: {
|
||||||
|
enable: false,
|
||||||
/**
|
port: 7070,
|
||||||
* ee框架日志
|
path: "/socket.io/",
|
||||||
*/
|
connectTimeout: 45000,
|
||||||
config.logger = {
|
pingTimeout: 30000,
|
||||||
encoding: 'utf8',
|
pingInterval: 25000,
|
||||||
level: 'INFO',
|
maxHttpBufferSize: 1e8,
|
||||||
outputJSON: false,
|
transports: ["polling", "websocket"],
|
||||||
buffer: true,
|
cors: {
|
||||||
enablePerformanceTimer: false,
|
origin: true,
|
||||||
rotator: 'day',
|
},
|
||||||
appLogName: 'pqs9100.log',
|
channel: 'socket-channel'
|
||||||
coreLogName: 'pqs9100-core.log',
|
},
|
||||||
errorLogName: 'pqs9100-error.log'
|
httpServer: {
|
||||||
}
|
enable: false,
|
||||||
|
https: {
|
||||||
/**
|
enable: false,
|
||||||
* 远程模式-web地址
|
key: '/public/ssl/localhost+1.key',
|
||||||
*/
|
cert: '/public/ssl/localhost+1.pem'
|
||||||
config.remoteUrl = {
|
},
|
||||||
enable: false,
|
host: '127.0.0.1',
|
||||||
url: 'http://electron-egg.kaka996.com/'
|
port: 7071,
|
||||||
};
|
},
|
||||||
|
mainServer: {
|
||||||
/**
|
indexPath: '/public/dist/index.html',
|
||||||
* 内置socket服务
|
channelSeparator: '/',
|
||||||
*/
|
}
|
||||||
config.socketServer = {
|
|
||||||
enable: false, // 是否开启
|
|
||||||
port: 7070,// 默认端口
|
|
||||||
path: "/socket.io/", // 默认路径名称
|
|
||||||
connectTimeout: 45000, // 客户端连接超时时间
|
|
||||||
pingTimeout: 30000, // 心跳检测超时时间
|
|
||||||
pingInterval: 25000, // 心跳检测间隔时间
|
|
||||||
maxHttpBufferSize: 1e8, // 每条消息的数据最大值
|
|
||||||
transports: ["polling", "websocket"], // http轮询和websocket
|
|
||||||
cors: {
|
|
||||||
origin: true, // http协议时,需要设置允许跨域
|
|
||||||
},
|
|
||||||
channel: 'c1' // 默认频道c1,可以自定义
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 内置http服务
|
|
||||||
*/
|
|
||||||
config.httpServer = {
|
|
||||||
enable: false,
|
|
||||||
https: {
|
|
||||||
enable: false,
|
|
||||||
key: '/public/ssl/localhost+1.key',
|
|
||||||
cert: '/public/ssl/localhost+1.pem'
|
|
||||||
},
|
|
||||||
host: '127.0.0.1',
|
|
||||||
port: 7071,
|
|
||||||
cors: {
|
|
||||||
origin: "*" // 默认允许跨域
|
|
||||||
},
|
|
||||||
body: {
|
|
||||||
multipart: true,
|
|
||||||
formidable: {
|
|
||||||
keepExtensions: true
|
|
||||||
}
|
|
||||||
},
|
|
||||||
filterRequest: {
|
|
||||||
uris: [
|
|
||||||
'favicon.ico' // 默认过滤的uri favicon.ico
|
|
||||||
],
|
|
||||||
returnData: ''
|
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 主进程
|
|
||||||
*/
|
|
||||||
config.mainServer = {
|
|
||||||
protocol: 'file://',
|
|
||||||
indexPath: '/public/dist/index.html',
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 硬件加速
|
|
||||||
*/
|
|
||||||
config.hardGpu = {
|
|
||||||
enable: true
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 异常捕获
|
|
||||||
*/
|
|
||||||
config.exception = {
|
|
||||||
mainExit: false, // 主进程退出时是否捕获异常
|
|
||||||
childExit: true,
|
|
||||||
rendererExit: true,
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* jobs
|
|
||||||
*/
|
|
||||||
config.jobs = {
|
|
||||||
messageLog: true // 是否打印进程间通信的消息log
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 插件功能
|
|
||||||
* @param window 官方内置插件
|
|
||||||
* @param tray 托盘插件
|
|
||||||
* @param security 安全插件
|
|
||||||
* @param awaken 唤醒插件
|
|
||||||
* @param autoUpdater 自动升级插件
|
|
||||||
*/
|
|
||||||
config.addons = {
|
|
||||||
window: {
|
|
||||||
enable: true,
|
|
||||||
},
|
|
||||||
tray: {
|
|
||||||
enable: true,
|
|
||||||
title: '自动检测平台',
|
|
||||||
icon: '/public/images/tray.png'
|
|
||||||
},
|
|
||||||
security: {
|
|
||||||
enable: true,
|
|
||||||
},
|
|
||||||
awaken: {
|
|
||||||
enable: true,
|
|
||||||
protocol: 'ee',
|
|
||||||
args: []
|
|
||||||
},
|
|
||||||
autoUpdater: {
|
|
||||||
enable: true,
|
|
||||||
windows: false,
|
|
||||||
macOS: false,
|
|
||||||
linux: false,
|
|
||||||
options: {
|
|
||||||
provider: 'generic',
|
|
||||||
url: 'http://kodo.qiniu.com/'
|
|
||||||
},
|
|
||||||
force: false,
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
return {
|
|
||||||
...config
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,31 +1,13 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 开发环境配置,覆盖 config.default.js
|
* Development environment configuration, coverage config.default.js
|
||||||
*/
|
*/
|
||||||
module.exports = (appInfo) => {
|
module.exports = () => {
|
||||||
const config = {};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 开发者工具
|
|
||||||
*/
|
|
||||||
config.openDevTools = {
|
|
||||||
mode: 'undocked'
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 应用程序顶部菜单
|
|
||||||
*/
|
|
||||||
config.openAppMenu = false;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* jobs
|
|
||||||
*/
|
|
||||||
config.jobs = {
|
|
||||||
messageLog: true
|
|
||||||
};
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...config
|
openDevTools: false,
|
||||||
|
jobs: {
|
||||||
|
messageLog: false
|
||||||
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,29 +1,10 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 生产环境配置,覆盖 config.default.js
|
* coverage config.default.js
|
||||||
*/
|
*/
|
||||||
module.exports = (appInfo) => {
|
module.exports = () => {
|
||||||
const config = {};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 开发者工具
|
|
||||||
*/
|
|
||||||
config.openDevTools = false;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 应用程序顶部菜单
|
|
||||||
*/
|
|
||||||
config.openAppMenu = false;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* jobs
|
|
||||||
*/
|
|
||||||
config.jobs = {
|
|
||||||
messageLog: false
|
|
||||||
};
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...config
|
openDevTools: false,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,13 +0,0 @@
|
|||||||
{
|
|
||||||
"watch": [
|
|
||||||
"electron/",
|
|
||||||
"main.js"
|
|
||||||
],
|
|
||||||
"ignore": [],
|
|
||||||
"ext": "js,json",
|
|
||||||
"verbose": true,
|
|
||||||
"exec": "electron . --env=local --hot-reload=1",
|
|
||||||
"restartable": "hr",
|
|
||||||
"colours": true,
|
|
||||||
"events": {}
|
|
||||||
}
|
|
||||||
@@ -1,19 +1,13 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const { Controller } = require('ee-core');
|
const { logger } = require('ee-core/log');
|
||||||
const Log = require('ee-core/log');
|
const { exampleService } = require('../service/example');
|
||||||
const Services = require('ee-core/services');
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* example
|
* example
|
||||||
* @class
|
* @class
|
||||||
*/
|
*/
|
||||||
class ExampleController extends Controller {
|
class ExampleController {
|
||||||
|
|
||||||
constructor(ctx) {
|
|
||||||
super(ctx);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 所有方法接收两个参数
|
* 所有方法接收两个参数
|
||||||
@@ -25,12 +19,12 @@ class ExampleController extends Controller {
|
|||||||
* test
|
* test
|
||||||
*/
|
*/
|
||||||
async test () {
|
async test () {
|
||||||
const result = await Services.get('example').test('electron');
|
const result = await exampleService.test('electron');
|
||||||
Log.info('service result:', result);
|
logger.info('service result:', result);
|
||||||
|
|
||||||
return 'hello electron-egg';
|
return 'hello electron-egg';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ExampleController.toString = () => '[class ExampleController]';
|
ExampleController.toString = () => '[class ExampleController]';
|
||||||
|
|
||||||
module.exports = ExampleController;
|
module.exports = ExampleController;
|
||||||
@@ -1,50 +0,0 @@
|
|||||||
const { Application } = require('ee-core');
|
|
||||||
|
|
||||||
class Index extends Application {
|
|
||||||
|
|
||||||
constructor() {
|
|
||||||
super();
|
|
||||||
// this === eeApp;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* core app have been loaded
|
|
||||||
*/
|
|
||||||
async ready () {
|
|
||||||
// do some things
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* electron app ready
|
|
||||||
*/
|
|
||||||
async electronAppReady () {
|
|
||||||
// do some things
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* main window have been loaded
|
|
||||||
*/
|
|
||||||
async windowReady () {
|
|
||||||
// do some things
|
|
||||||
// 延迟加载,无白屏
|
|
||||||
const winOpt = this.config.windowsOption;
|
|
||||||
if (winOpt.show == false) {
|
|
||||||
const win = this.electron.mainWindow;
|
|
||||||
win.once('ready-to-show', () => {
|
|
||||||
win.show();
|
|
||||||
win.focus();
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* before app close
|
|
||||||
*/
|
|
||||||
async beforeClose () {
|
|
||||||
// do some things
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Index.toString = () => '[class Index]';
|
|
||||||
module.exports = Index;
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
const Log = require('ee-core/log');
|
|
||||||
|
|
||||||
exports.welcome = function () {
|
|
||||||
Log.info('[child-process] [jobs/example/hello] welcome ! ');
|
|
||||||
}
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
const Job = require('ee-core/jobs/baseJobClass');
|
|
||||||
const Log = require('ee-core/log');
|
|
||||||
const Ps = require('ee-core/ps');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* example - TimerJob
|
|
||||||
* @class
|
|
||||||
*/
|
|
||||||
class TimerJob extends Job {
|
|
||||||
|
|
||||||
constructor(params) {
|
|
||||||
super();
|
|
||||||
this.params = params;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* handle()方法是必要的,且会被自动调用
|
|
||||||
*/
|
|
||||||
async handle () {
|
|
||||||
Log.info("[child-process] TimerJob params: ", this.params);
|
|
||||||
|
|
||||||
if (Ps.isChildJob()) {
|
|
||||||
Ps.exit();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
TimerJob.toString = () => '[class TimerJob]';
|
|
||||||
module.exports = TimerJob;
|
|
||||||
19
electron/main.js
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
const { ElectronEgg } = require('ee-core');
|
||||||
|
const { Lifecycle } = require('./preload/lifecycle');
|
||||||
|
const { preload } = require('./preload');
|
||||||
|
|
||||||
|
// new app
|
||||||
|
const app = new ElectronEgg();
|
||||||
|
|
||||||
|
// register lifecycle
|
||||||
|
const life = new Lifecycle();
|
||||||
|
app.register("ready", life.ready);
|
||||||
|
app.register("electron-app-ready", life.electronAppReady);
|
||||||
|
app.register("window-ready", life.windowReady);
|
||||||
|
app.register("before-close", life.beforeClose);
|
||||||
|
|
||||||
|
// register preload
|
||||||
|
app.register("preload", preload);
|
||||||
|
|
||||||
|
// run
|
||||||
|
app.run();
|
||||||
@@ -1,14 +1,16 @@
|
|||||||
/*************************************************
|
/*************************************************
|
||||||
** preload为预加载模块,该文件将会在程序启动时加载 **
|
** preload为预加载模块,该文件将会在程序启动时加载 **
|
||||||
*************************************************/
|
*************************************************/
|
||||||
const Addon = require('ee-core/addon');
|
|
||||||
|
|
||||||
/**
|
const { logger } = require('ee-core/log');
|
||||||
* 预加载模块入口
|
|
||||||
*/
|
|
||||||
module.exports = async () => {
|
|
||||||
|
|
||||||
// 示例功能模块,可选择性使用和修改
|
function preload() {
|
||||||
Addon.get('tray').create();
|
logger.info('[preload] load 1');
|
||||||
Addon.get('security').create();
|
}
|
||||||
}
|
|
||||||
|
/**
|
||||||
|
* 预加载模块入口
|
||||||
|
*/
|
||||||
|
module.exports = {
|
||||||
|
preload
|
||||||
|
}
|
||||||
58
electron/preload/lifecycle.js
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
const { logger } = require('ee-core/log');
|
||||||
|
const { getConfig } = require('ee-core/config');
|
||||||
|
const { getMainWindow } = require('ee-core/electron');
|
||||||
|
|
||||||
|
class Lifecycle {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* core app have been loaded
|
||||||
|
*/
|
||||||
|
async ready() {
|
||||||
|
logger.info('[lifecycle] ready');
|
||||||
|
// 在这里可以做:
|
||||||
|
// - 初始化数据库连接
|
||||||
|
// - 加载配置文件
|
||||||
|
// - 初始化全局变量
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* electron app ready
|
||||||
|
*/
|
||||||
|
async electronAppReady() {
|
||||||
|
logger.info('[lifecycle] electron-app-ready');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* main window have been loaded
|
||||||
|
*/
|
||||||
|
async windowReady() {
|
||||||
|
logger.info('[lifecycle] window-ready');
|
||||||
|
|
||||||
|
// 延迟加载,无白屏
|
||||||
|
const win = getMainWindow();
|
||||||
|
const { windowsOption } = getConfig();
|
||||||
|
if (windowsOption.show == false) {
|
||||||
|
win.once('ready-to-show', () => {
|
||||||
|
win.show();
|
||||||
|
win.focus();
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
win.show();
|
||||||
|
win.focus();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* before app close
|
||||||
|
*/
|
||||||
|
async beforeClose() {
|
||||||
|
logger.info('[lifecycle] before-close');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Lifecycle.toString = () => '[class Lifecycle]';
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
Lifecycle
|
||||||
|
};
|
||||||
@@ -1,16 +1,12 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const { Service } = require('ee-core');
|
const { logger } = require('ee-core/log');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 示例服务(service层为单例)
|
* 示例服务
|
||||||
* @class
|
* @class
|
||||||
*/
|
*/
|
||||||
class ExampleService extends Service {
|
class ExampleService {
|
||||||
|
|
||||||
constructor(ctx) {
|
|
||||||
super(ctx);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* test
|
* test
|
||||||
@@ -21,9 +17,14 @@ class ExampleService extends Service {
|
|||||||
params: args
|
params: args
|
||||||
}
|
}
|
||||||
|
|
||||||
|
logger.info('ExampleService obj:', obj);
|
||||||
|
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ExampleService.toString = () => '[class ExampleService]';
|
ExampleService.toString = () => '[class ExampleService]';
|
||||||
module.exports = ExampleService;
|
|
||||||
|
module.exports = {
|
||||||
|
ExampleService,
|
||||||
|
exampleService: new ExampleService()
|
||||||
|
};
|
||||||
@@ -20,6 +20,8 @@ VITE_API_URL=/api
|
|||||||
# 开发环境跨域代理,支持配置多个
|
# 开发环境跨域代理,支持配置多个
|
||||||
|
|
||||||
#VITE_PROXY=[["/api","http://127.0.0.1:18092/"]]
|
#VITE_PROXY=[["/api","http://127.0.0.1:18092/"]]
|
||||||
VITE_PROXY=[["/api","http://192.168.1.124:18092/"]]
|
VITE_PROXY=[["/api","http://192.168.1.125:18092/"]]
|
||||||
#VITE_PROXY=[["/api","http://192.168.1.125:18092/"]]
|
#VITE_PROXY=[["/api","http://192.168.1.125:18092/"]]
|
||||||
# VITE_PROXY=[["/api","http://192.168.1.138:8080/"]]张文
|
# VITE_PROXY=[["/api","http://192.168.1.138:8080/"]]张文
|
||||||
|
# 开启激活验证
|
||||||
|
VITE_ACTIVATE_OPEN=false
|
||||||
@@ -24,3 +24,5 @@ VITE_PWA=true
|
|||||||
# 线上环境接口地址
|
# 线上环境接口地址
|
||||||
#VITE_API_URL="/api" # 打包时用
|
#VITE_API_URL="/api" # 打包时用
|
||||||
VITE_API_URL="http://192.168.1.125:18092/"
|
VITE_API_URL="http://192.168.1.125:18092/"
|
||||||
|
# 开启激活验证
|
||||||
|
VITE_ACTIVATE_OPEN=false
|
||||||
@@ -6,7 +6,6 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import autofit from 'autofit.js'
|
|
||||||
import { useI18n } from 'vue-i18n'
|
import { useI18n } from 'vue-i18n'
|
||||||
import { getBrowserLang } from '@/utils'
|
import { getBrowserLang } from '@/utils'
|
||||||
import { useTheme } from '@/hooks/useTheme'
|
import { useTheme } from '@/hooks/useTheme'
|
||||||
@@ -32,16 +31,14 @@ onMounted(() => {
|
|||||||
const language = globalStore.language ?? getBrowserLang()
|
const language = globalStore.language ?? getBrowserLang()
|
||||||
i18n.locale.value = language
|
i18n.locale.value = language
|
||||||
globalStore.setGlobalState('language', language as LanguageType)
|
globalStore.setGlobalState('language', language as LanguageType)
|
||||||
// 自动适配
|
// 移除 autofit,使用 CSS 自适应
|
||||||
autofit.init({
|
// autofit.init({
|
||||||
el: '#app',
|
// el: '#app',
|
||||||
//dh: 720 * 1,
|
// dw: 1440,
|
||||||
//dw: 1280 * 1.2,
|
// dh: 900,
|
||||||
dw: 1920 / 1.5,
|
// resize: true,
|
||||||
dh: 1080 / 1.2,
|
// limit: 0.1
|
||||||
resize: true,
|
// })
|
||||||
limit: 0.1
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
|
|
||||||
// element language
|
// element language
|
||||||
@@ -59,4 +56,10 @@ const buttonConfig = reactive({ autoInsertSpace: false })
|
|||||||
|
|
||||||
document.getElementById('loadingPage')?.remove()
|
document.getElementById('loadingPage')?.remove()
|
||||||
</script>
|
</script>
|
||||||
<style scoped></style>
|
<style scoped>
|
||||||
|
#app {
|
||||||
|
width: 100vw;
|
||||||
|
height: 100vh;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|||||||
14
frontend/src/api/activate/index.ts
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
import http from '@/api'
|
||||||
|
import type { Activate } from '@/api/activate/interface'
|
||||||
|
|
||||||
|
export const generateApplicationCode = (params: Activate.ApplicationCodePlaintext) => {
|
||||||
|
return http.post(`/activate/generateApplicationCode`, params)
|
||||||
|
}
|
||||||
|
|
||||||
|
export const verifyActivationCode = (activationCode: string) => {
|
||||||
|
return http.post(`/activate/verifyActivationCode`, { activationCode })
|
||||||
|
}
|
||||||
|
|
||||||
|
export const getLicense = () => {
|
||||||
|
return http.post(`/activate/getLicense`)
|
||||||
|
}
|
||||||
55
frontend/src/api/activate/interface/index.ts
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
//激活模块
|
||||||
|
export namespace Activate {
|
||||||
|
|
||||||
|
export interface ApplicationModule {
|
||||||
|
/**
|
||||||
|
* 是否申请 1是 0否
|
||||||
|
*/
|
||||||
|
apply: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ActivateModule extends ApplicationModule {
|
||||||
|
/**
|
||||||
|
* 是否永久 1是 0否
|
||||||
|
*/
|
||||||
|
permanently: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ApplicationCodePlaintext {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 模拟式模块
|
||||||
|
*/
|
||||||
|
simulate: ApplicationModule;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数字式模块
|
||||||
|
*/
|
||||||
|
digital: ApplicationModule;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 比对式模块
|
||||||
|
*/
|
||||||
|
contrast: ApplicationModule;
|
||||||
|
}
|
||||||
|
export interface ActivationCodePlaintext {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 模拟式模块
|
||||||
|
*/
|
||||||
|
simulate: ActivateModule;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数字式模块
|
||||||
|
*/
|
||||||
|
digital: ActivateModule;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 比对式模块
|
||||||
|
*/
|
||||||
|
contrast: ActivateModule;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -93,7 +93,7 @@ class RequestHttp {
|
|||||||
}
|
}
|
||||||
// 登陆失效
|
// 登陆失效
|
||||||
if (data.code === ResultEnum.OVERDUE) {
|
if (data.code === ResultEnum.OVERDUE) {
|
||||||
console.log('登陆失效')
|
//console.log('登陆失效')
|
||||||
userStore.setAccessToken('')
|
userStore.setAccessToken('')
|
||||||
userStore.setRefreshToken('')
|
userStore.setRefreshToken('')
|
||||||
userStore.setIsRefreshToken(false)
|
userStore.setIsRefreshToken(false)
|
||||||
@@ -142,7 +142,7 @@ class RequestHttp {
|
|||||||
async (error: AxiosError) => {
|
async (error: AxiosError) => {
|
||||||
const { response } = error
|
const { response } = error
|
||||||
tryHideFullScreenLoading()
|
tryHideFullScreenLoading()
|
||||||
console.log('error', error.message)
|
//console.log('error', error.message)
|
||||||
// 请求超时 && 网络错误单独判断,没有 response
|
// 请求超时 && 网络错误单独判断,没有 response
|
||||||
if (error.message.indexOf('timeout') !== -1) ElMessage.error('请求超时!请您稍后重试')
|
if (error.message.indexOf('timeout') !== -1) ElMessage.error('请求超时!请您稍后重试')
|
||||||
if (error.message.indexOf('Network Error') !== -1) ElMessage.error('网络错误!请您稍后重试')
|
if (error.message.indexOf('Network Error') !== -1) ElMessage.error('网络错误!请您稍后重试')
|
||||||
@@ -228,7 +228,7 @@ class RequestHttp {
|
|||||||
|
|
||||||
// 设置默认的Authorization头部
|
// 设置默认的Authorization头部
|
||||||
eventSource.addEventListener('open', function () {
|
eventSource.addEventListener('open', function () {
|
||||||
console.log('SSE连接已建立')
|
//console.log('SSE连接已建立')
|
||||||
})
|
})
|
||||||
// 添加错误处理
|
// 添加错误处理
|
||||||
eventSource.addEventListener('error', function (err) {
|
eventSource.addEventListener('error', function (err) {
|
||||||
|
|||||||
@@ -112,7 +112,7 @@ const uploadExcel = async (param: UploadRequestOptions) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function handleImportResponse(res: any) {
|
async function handleImportResponse(res: any) {
|
||||||
console.log(res)
|
|
||||||
|
|
||||||
if (res.type === 'application/json') {
|
if (res.type === 'application/json') {
|
||||||
const fileReader = new FileReader()
|
const fileReader = new FileReader()
|
||||||
@@ -129,7 +129,7 @@ async function handleImportResponse(res: any) {
|
|||||||
}
|
}
|
||||||
emit('result', jsonData.data)
|
emit('result', jsonData.data)
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log(err)
|
//console.log(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fileReader.readAsText(res)
|
fileReader.readAsText(res)
|
||||||
|
|||||||
@@ -181,7 +181,7 @@ const initSSE = () => {
|
|||||||
eventSource.value = http.sse('/sse/createSse')
|
eventSource.value = http.sse('/sse/createSse')
|
||||||
|
|
||||||
eventSource.value.onmessage = event => {
|
eventSource.value.onmessage = event => {
|
||||||
console.log('收到消息内容是:', event.data)
|
// console.log('收到消息内容是:', event.data)
|
||||||
const res = JSON.parse(event.data)
|
const res = JSON.parse(event.data)
|
||||||
progressData.value.percentage = res.data
|
progressData.value.percentage = res.data
|
||||||
progressData.value.message = res.message
|
progressData.value.message = res.message
|
||||||
@@ -210,7 +210,7 @@ const closeEventSource = () => {
|
|||||||
if (eventSource.value) {
|
if (eventSource.value) {
|
||||||
eventSource.value.close()
|
eventSource.value.close()
|
||||||
eventSource.value = null
|
eventSource.value = null
|
||||||
console.log('SSE连接已关闭')
|
// console.log('SSE连接已关闭')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 监听 dialogVisible 的变化,确保在对话框关闭时清理资源
|
// 监听 dialogVisible 的变化,确保在对话框关闭时清理资源
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ const auth: Directive = {
|
|||||||
} else {
|
} else {
|
||||||
currentPageRoles = authStore.authButtonListGet[authStore.routeName] ?? []
|
currentPageRoles = authStore.authButtonListGet[authStore.routeName] ?? []
|
||||||
}
|
}
|
||||||
console.log('currentPageRoles', currentPageRoles)
|
//console.log('currentPageRoles', currentPageRoles)
|
||||||
if (value instanceof Array && value.length) {
|
if (value instanceof Array && value.length) {
|
||||||
const hasPermission = value.every(item => currentPageRoles.includes(item))
|
const hasPermission = value.every(item => currentPageRoles.includes(item))
|
||||||
if (!hasPermission) el.remove()
|
if (!hasPermission) el.remove()
|
||||||
|
|||||||
@@ -1,24 +1,21 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="footer flx-align-center pl10">
|
<div class="footer flx-align-center pl10">
|
||||||
<el-dropdown>
|
<el-dropdown>
|
||||||
<!-- <span class="el-dropdown-link">
|
|
||||||
{{ title }}
|
|
||||||
<el-icon class="el-icon--right">
|
|
||||||
<arrow-down />
|
|
||||||
</el-icon>
|
|
||||||
</span> -->
|
|
||||||
<!-- <el-button dictType="primary"> -->
|
|
||||||
<div class="change_mode">
|
<div class="change_mode">
|
||||||
{{ title }}
|
{{ title }}
|
||||||
<el-icon class="el-icon--right change_mode_down"><arrow-down /></el-icon>
|
<el-icon class="el-icon--right change_mode_down"><arrow-down /></el-icon>
|
||||||
<el-icon class="el-icon--right change_mode_up"><arrow-up /></el-icon>
|
<el-icon class="el-icon--right change_mode_up"><arrow-up /></el-icon>
|
||||||
</div>
|
</div>
|
||||||
<!-- </el-button> -->
|
|
||||||
<template #dropdown>
|
<template #dropdown>
|
||||||
<el-dropdown-menu>
|
<el-dropdown-menu>
|
||||||
<el-dropdown-item @click="handelOpen('模拟式')">模拟式模块</el-dropdown-item>
|
<el-dropdown-item
|
||||||
<el-dropdown-item @click="handelOpen('数字式')">数字式模块</el-dropdown-item>
|
v-for="item in modeList"
|
||||||
<el-dropdown-item @click="handelOpen('比对式')">比对式模块</el-dropdown-item>
|
:key="item.key"
|
||||||
|
:disabled="!item.activated"
|
||||||
|
@click="handelOpen(item.code, item.key)"
|
||||||
|
>
|
||||||
|
{{ item.name }}
|
||||||
|
</el-dropdown-item>
|
||||||
</el-dropdown-menu>
|
</el-dropdown-menu>
|
||||||
</template>
|
</template>
|
||||||
</el-dropdown>
|
</el-dropdown>
|
||||||
@@ -31,26 +28,52 @@
|
|||||||
import { computed } from 'vue'
|
import { computed } from 'vue'
|
||||||
import { useAuthStore } from '@/stores/modules/auth'
|
import { useAuthStore } from '@/stores/modules/auth'
|
||||||
import { useModeStore } from '@/stores/modules/mode' // 引入模式 store
|
import { useModeStore } from '@/stores/modules/mode' // 引入模式 store
|
||||||
import { useRouter } from 'vue-router'
|
|
||||||
|
|
||||||
const router = useRouter()
|
|
||||||
const authStore = useAuthStore()
|
const authStore = useAuthStore()
|
||||||
const modeStore = useModeStore()
|
const modeStore = useModeStore()
|
||||||
|
|
||||||
const title = computed(() => {
|
const title = computed(() => {
|
||||||
return modeStore.currentMode === '' ? '模拟式模块' : modeStore.currentMode + '模块'
|
return modeStore.currentMode === '' ? '选择模块' : modeStore.currentMode + '模块'
|
||||||
})
|
})
|
||||||
|
const activateInfo = authStore.activateInfo
|
||||||
const handelOpen = async (item: string) => {
|
const isActivateOpen = import.meta.env.VITE_ACTIVATE_OPEN
|
||||||
|
const modeList = [
|
||||||
|
{
|
||||||
|
name: '模拟式模块',
|
||||||
|
code: '模拟式',
|
||||||
|
key: 'simulate',
|
||||||
|
activated:
|
||||||
|
isActivateOpen === 'true'
|
||||||
|
? activateInfo.simulate.apply === 1 && activateInfo.simulate.permanently === 1
|
||||||
|
: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: '数字式模块',
|
||||||
|
code: '数字式',
|
||||||
|
key: 'digital',
|
||||||
|
activated:
|
||||||
|
isActivateOpen === 'true'
|
||||||
|
? activateInfo.digital.apply === 1 && activateInfo.digital.permanently === 1
|
||||||
|
: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: '比对式模块',
|
||||||
|
code: '比对式',
|
||||||
|
key: 'contrast',
|
||||||
|
activated:
|
||||||
|
isActivateOpen === 'true'
|
||||||
|
? activateInfo.contrast.apply === 1 && activateInfo.contrast.permanently === 1
|
||||||
|
: true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
const handelOpen = async (item: string, key: string) => {
|
||||||
|
if (isActivateOpen === 'true' && (activateInfo[key].apply !== 1 || activateInfo[key].permanently !== 1)) {
|
||||||
|
ElMessage.warning(`${item}模块未激活`)
|
||||||
|
return
|
||||||
|
}
|
||||||
await authStore.setShowMenu()
|
await authStore.setShowMenu()
|
||||||
modeStore.setCurrentMode(item) // 将模式code存入 store
|
modeStore.setCurrentMode(item) // 将模式code存入 store
|
||||||
|
|
||||||
//if (router.currentRoute.value.path === '/home/index') {
|
|
||||||
// 强制刷新页面
|
// 强制刷新页面
|
||||||
window.location.reload()
|
window.location.reload()
|
||||||
//} else {
|
|
||||||
// router.push({ path: '/home/index' });
|
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
|
|||||||
@@ -1,218 +1,212 @@
|
|||||||
<template>
|
<template>
|
||||||
<!-- <div class="userInfo">-->
|
<!-- <div class="userInfo">-->
|
||||||
<!-- <div class="icon">-->
|
<!-- <div class="icon">-->
|
||||||
<!-- <Avatar/>-->
|
<!-- <Avatar/>-->
|
||||||
<!-- </div>-->
|
<!-- </div>-->
|
||||||
<!-- <div class="username">-->
|
<!-- <div class="username">-->
|
||||||
<!-- {{ username }}-->
|
<!-- {{ username }}-->
|
||||||
<!-- </div>-->
|
<!-- </div>-->
|
||||||
<!-- </div>-->
|
<!-- </div>-->
|
||||||
<el-dropdown trigger="click">
|
<el-dropdown trigger="click">
|
||||||
<div class="userInfo">
|
<div class="userInfo">
|
||||||
<div class="icon">
|
<div class="icon">
|
||||||
<Avatar />
|
<Avatar />
|
||||||
</div>
|
</div>
|
||||||
<div class="username">
|
<div class="username">
|
||||||
{{ username }}
|
{{ username }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<template #dropdown>
|
<template #dropdown>
|
||||||
<el-dropdown-menu>
|
<el-dropdown-menu>
|
||||||
<el-dropdown-item @click="openDialog('themeRef')">
|
<el-dropdown-item @click="openDialog('themeRef')">
|
||||||
<el-icon><Sunny /></el-icon>{{ t("header.changeTheme") }}
|
<el-icon><Sunny /></el-icon>
|
||||||
</el-dropdown-item>
|
{{ t('header.changeTheme') }}
|
||||||
<el-dropdown-item @click="openDialog('infoRef')">
|
</el-dropdown-item>
|
||||||
<el-icon><User /></el-icon>{{ t("header.personalData") }}
|
<el-dropdown-item @click="openDialog('infoRef')">
|
||||||
</el-dropdown-item>
|
<el-icon><User /></el-icon>
|
||||||
<el-dropdown-item @click="openDialog('passwordRef')">
|
{{ t('header.personalData') }}
|
||||||
<el-icon><Edit /></el-icon>{{ t("header.changePassword") }}
|
</el-dropdown-item>
|
||||||
</el-dropdown-item>
|
<el-dropdown-item @click="openDialog('passwordRef')">
|
||||||
<el-dropdown-item @click="changeMode">
|
<el-icon><Edit /></el-icon>
|
||||||
<el-icon><Switch /></el-icon>{{ t("header.changeMode") }}
|
{{ t('header.changePassword') }}
|
||||||
</el-dropdown-item>
|
</el-dropdown-item>
|
||||||
<el-dropdown-item @click="openDialog('versionRegisterRef')">
|
<el-dropdown-item @click="changeMode" v-if="authStore.showMenuFlag">
|
||||||
<el-icon><SetUp /></el-icon>{{ t("header.versionRegister") }}
|
<el-icon><Switch /></el-icon>
|
||||||
</el-dropdown-item>
|
{{ t('header.changeMode') }}
|
||||||
<el-dropdown trigger="hover" placement="left-start" v-if="userStore.userInfo.loginName == 'root'">
|
</el-dropdown-item>
|
||||||
<div class="custom-dropdown-trigger">
|
<el-dropdown-item @click="openDialog('versionRegisterRef')">
|
||||||
<el-icon><Tools /></el-icon>
|
<el-icon><SetUp /></el-icon>
|
||||||
<span>{{ t("header.changeScene") }}</span>
|
{{ t('header.versionRegister') }}
|
||||||
</div>
|
</el-dropdown-item>
|
||||||
<template #dropdown>
|
<el-dropdown trigger="hover" placement="left-start" v-if="userStore.userInfo.loginName == 'root'">
|
||||||
<el-dropdown-menu>
|
<div class="custom-dropdown-trigger">
|
||||||
<el-dropdown-item
|
<el-icon><Tools /></el-icon>
|
||||||
v-for="item in dictStore.getDictData('app_scene')"
|
<span>{{ t('header.changeScene') }}</span>
|
||||||
:key="item.value"
|
</div>
|
||||||
:class="{
|
<template #dropdown>
|
||||||
'custom-dropdown-item': true,
|
<el-dropdown-menu>
|
||||||
active: item.value === appSceneStore.currentScene
|
<el-dropdown-item
|
||||||
}"
|
v-for="item in dictStore.getDictData('app_scene')"
|
||||||
@click="changeScene(item.value?? '')"
|
:key="item.value"
|
||||||
:disabled = "item.value === appSceneStore.currentScene"
|
:class="{
|
||||||
>
|
'custom-dropdown-item': true,
|
||||||
{{ item.name }}
|
active: item.value === appSceneStore.currentScene
|
||||||
</el-dropdown-item>
|
}"
|
||||||
|
@click="changeScene(item.value ?? '')"
|
||||||
|
:disabled="item.value === appSceneStore.currentScene"
|
||||||
|
>
|
||||||
|
{{ item.name }}
|
||||||
|
</el-dropdown-item>
|
||||||
|
</el-dropdown-menu>
|
||||||
|
</template>
|
||||||
|
</el-dropdown>
|
||||||
</el-dropdown-menu>
|
</el-dropdown-menu>
|
||||||
</template>
|
</template>
|
||||||
</el-dropdown>
|
</el-dropdown>
|
||||||
</el-dropdown-menu>
|
<div class="avatar">
|
||||||
</template>
|
<img src="@/assets/icons/out_login.svg" alt="avatar" @click="logout" />
|
||||||
</el-dropdown>
|
</div>
|
||||||
<div class="avatar">
|
<!-- infoDialog -->
|
||||||
<img src="@/assets/icons/out_login.svg" alt="avatar" @click="logout" />
|
<InfoDialog ref="infoRef"></InfoDialog>
|
||||||
</div>
|
<!-- passwordDialog -->
|
||||||
<!-- infoDialog -->
|
<PasswordDialog ref="passwordRef"></PasswordDialog>
|
||||||
<InfoDialog ref="infoRef"></InfoDialog>
|
<!-- versionRegisterDialog -->
|
||||||
<!-- passwordDialog -->
|
<VersionDialog ref="versionRegisterRef"></VersionDialog>
|
||||||
<PasswordDialog ref="passwordRef"></PasswordDialog>
|
|
||||||
<!-- versionRegisterDialog -->
|
|
||||||
<VersionDialog ref="versionRegisterRef"></VersionDialog>
|
|
||||||
<!-- ThemeDialog -->
|
<!-- ThemeDialog -->
|
||||||
<ThemeDialog ref="themeRef"></ThemeDialog>
|
<ThemeDialog ref="themeRef"></ThemeDialog>
|
||||||
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref } from "vue";
|
import { computed, ref } from 'vue'
|
||||||
import { LOGIN_URL } from "@/config";
|
import { LOGIN_URL } from '@/config'
|
||||||
import { useRouter } from "vue-router";
|
import { useRouter } from 'vue-router'
|
||||||
import { logoutApi } from "@/api/user/login";
|
import { logoutApi } from '@/api/user/login'
|
||||||
import { useUserStore } from "@/stores/modules/user";
|
import { useUserStore } from '@/stores/modules/user'
|
||||||
import { ElMessageBox, ElMessage, CHANGE_EVENT } from "element-plus";
|
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||||
import InfoDialog from "./InfoDialog.vue";
|
import InfoDialog from './InfoDialog.vue'
|
||||||
import PasswordDialog from "./PasswordDialog.vue";
|
import PasswordDialog from './PasswordDialog.vue'
|
||||||
import ThemeDialog from "./ThemeDialog.vue";
|
import ThemeDialog from './ThemeDialog.vue'
|
||||||
import VersionDialog from "@/views/system/versionRegister/index.vue";
|
import VersionDialog from '@/views/system/versionRegister/index.vue'
|
||||||
import { computed } from "vue";
|
import { Avatar, Sunny, Switch, Tools } from '@element-plus/icons-vue'
|
||||||
import { ArrowLeft, Avatar, Delete, Document, Sunny, Switch ,Tools} from "@element-plus/icons-vue";
|
import { useAuthStore } from '@/stores/modules/auth'
|
||||||
import AssemblySize from "./components/AssemblySize.vue";
|
import { useDictStore } from '@/stores/modules/dict'
|
||||||
import Language from "./components/Language.vue";
|
import { useAppSceneStore, useModeStore } from '@/stores/modules/mode'
|
||||||
import SearchMenu from "./components/SearchMenu.vue";
|
import { useTheme } from '@/hooks/useTheme'
|
||||||
import ThemeSetting from "./components/ThemeSetting.vue";
|
import { useI18n } from 'vue-i18n'
|
||||||
import Message from "./components/Message.vue";
|
import { updateScene } from '@/api/system/base/index'
|
||||||
import Fullscreen from "./components/Fullscreen.vue";
|
|
||||||
import { useAuthStore } from "@/stores/modules/auth";
|
|
||||||
import {useDictStore} from "@/stores/modules/dict";
|
|
||||||
import { useModeStore,useAppSceneStore } from "@/stores/modules/mode";
|
|
||||||
const userStore = useUserStore();
|
|
||||||
const dictStore = useDictStore();
|
|
||||||
const username = computed(() => userStore.userInfo.name);
|
|
||||||
|
|
||||||
const router = useRouter();
|
const userStore = useUserStore()
|
||||||
const authStore = useAuthStore();
|
const dictStore = useDictStore()
|
||||||
const modeStore = useModeStore();
|
const username = computed(() => userStore.userInfo.name)
|
||||||
const AppSceneStore = useAppSceneStore();
|
|
||||||
import { useTheme } from "@/hooks/useTheme";
|
|
||||||
import { useI18n } from "vue-i18n";
|
|
||||||
import {updateScene} from '@/api/system/base/index'
|
|
||||||
|
|
||||||
|
const router = useRouter()
|
||||||
|
const authStore = useAuthStore()
|
||||||
|
const modeStore = useModeStore()
|
||||||
|
const AppSceneStore = useAppSceneStore()
|
||||||
|
|
||||||
const { changePrimary} = useTheme();
|
const { changePrimary } = useTheme()
|
||||||
|
|
||||||
// 初始化 i18n
|
// 初始化 i18n
|
||||||
const { t } = useI18n(); // 使用 t 方法替代 $t
|
const { t } = useI18n() // 使用 t 方法替代 $t
|
||||||
|
|
||||||
// 退出登录
|
// 退出登录
|
||||||
const logout = () => {
|
const logout = () => {
|
||||||
ElMessageBox.confirm("您是否确认退出登录?", "温馨提示", {
|
ElMessageBox.confirm('您是否确认退出登录?', '温馨提示', {
|
||||||
confirmButtonText: "确定",
|
confirmButtonText: '确定',
|
||||||
cancelButtonText: "取消",
|
cancelButtonText: '取消',
|
||||||
type: "warning",
|
type: 'warning'
|
||||||
}).then(async () => {
|
}).then(async () => {
|
||||||
// 1.执行退出登录接口
|
// 1.执行退出登录接口
|
||||||
await logoutApi();
|
await logoutApi()
|
||||||
// 2.清除 Token
|
// 2.清除 Token
|
||||||
userStore.setAccessToken("");
|
userStore.setAccessToken('')
|
||||||
userStore.setRefreshToken("");
|
userStore.setRefreshToken('')
|
||||||
userStore.setExp(0)
|
userStore.setExp(0)
|
||||||
userStore.setUserInfo({id: "", name: ""});
|
userStore.setUserInfo({ id: '', name: '' })
|
||||||
userStore.setIsRefreshToken(false)
|
userStore.setIsRefreshToken(false)
|
||||||
dictStore.setDictData([]);
|
dictStore.setDictData([])
|
||||||
modeStore.setCurrentMode('');
|
modeStore.setCurrentMode('')
|
||||||
AppSceneStore.setCurrentMode('');
|
AppSceneStore.setCurrentMode('')
|
||||||
// 3.重定向到登陆页
|
// 3.重定向到登陆页
|
||||||
router.replace(LOGIN_URL);
|
ElMessage.success('退出登录成功!')
|
||||||
ElMessage.success("退出登录成功!");
|
//重置菜单/导航栏权限
|
||||||
//重置菜单/导航栏权限
|
await authStore.resetAuthStore()
|
||||||
authStore.resetAuthStore();
|
await router.push(LOGIN_URL)
|
||||||
});
|
})
|
||||||
};
|
}
|
||||||
|
|
||||||
// 打开修改密码和个人信息弹窗
|
// 打开修改密码和个人信息弹窗
|
||||||
const infoRef = ref<InstanceType<typeof InfoDialog> | null>(null);
|
const infoRef = ref<InstanceType<typeof InfoDialog> | null>(null)
|
||||||
const passwordRef = ref<InstanceType<typeof PasswordDialog> | null>(null);
|
const passwordRef = ref<InstanceType<typeof PasswordDialog> | null>(null)
|
||||||
const versionRegisterRef = ref<InstanceType<typeof VersionDialog> | null>(null);
|
const versionRegisterRef = ref<InstanceType<typeof VersionDialog> | null>(null)
|
||||||
const themeRef = ref<InstanceType<typeof ThemeDialog> | null>(null);
|
const themeRef = ref<InstanceType<typeof ThemeDialog> | null>(null)
|
||||||
const openDialog = (ref: string) => {
|
const openDialog = (ref: string) => {
|
||||||
if (ref == "infoRef") infoRef.value?.openDialog();
|
if (ref == 'infoRef') infoRef.value?.openDialog()
|
||||||
if (ref == "passwordRef") passwordRef.value?.openDialog();
|
if (ref == 'passwordRef') passwordRef.value?.openDialog()
|
||||||
if (ref == "versionRegisterRef") versionRegisterRef.value?.openDialog();
|
if (ref == 'versionRegisterRef') versionRegisterRef.value?.openDialog()
|
||||||
if (ref == "themeRef") themeRef.value?.openDialog();
|
if (ref == 'themeRef') themeRef.value?.openDialog()
|
||||||
|
}
|
||||||
|
|
||||||
};
|
const appSceneStore = useAppSceneStore()
|
||||||
|
|
||||||
|
|
||||||
const appSceneStore = useAppSceneStore();
|
|
||||||
|
|
||||||
const changeScene = async (value: string) => {
|
const changeScene = async (value: string) => {
|
||||||
appSceneStore.setCurrentMode(value);
|
appSceneStore.setCurrentMode(value)
|
||||||
await updateScene({scene :dictStore.getDictData('app_scene').find(item => item.value == value)?.id});
|
await updateScene({ scene: dictStore.getDictData('app_scene').find(item => item.value == value)?.id })
|
||||||
// 强制刷新页面
|
// 强制刷新页面
|
||||||
window.location.reload();
|
window.location.reload()
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
//模式切换
|
//模式切换
|
||||||
const changeMode = () => {
|
const changeMode = () => {
|
||||||
authStore.changeModel();
|
authStore.changeModel()
|
||||||
};
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
.userInfo {
|
.userInfo {
|
||||||
min-width: 80px;
|
min-width: 80px;
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: flex-start;
|
justify-content: flex-start;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
.icon {
|
.icon {
|
||||||
width: 18px;
|
width: 18px;
|
||||||
height: 18px;
|
height: 18px;
|
||||||
color: #fff !important;
|
color: #fff !important;
|
||||||
}
|
}
|
||||||
.username {
|
.username {
|
||||||
color: #fff;
|
color: #fff;
|
||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
margin-left: 10px;
|
margin-left: 10px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.avatar {
|
.avatar {
|
||||||
width: 40px;
|
width: 40px;
|
||||||
height: 40px;
|
height: 40px;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: flex-end;
|
justify-content: flex-end;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
// border-radius: 50%;
|
// border-radius: 50%;
|
||||||
img {
|
img {
|
||||||
// width: 100%;
|
// width: 100%;
|
||||||
// height: 100%;
|
// height: 100%;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.custom-dropdown-trigger {
|
.custom-dropdown-trigger {
|
||||||
padding: 8px 15px;
|
padding: 8px 15px;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 8px;
|
gap: 8px;
|
||||||
}
|
}
|
||||||
|
|
||||||
:deep(.el-dropdown-menu__item.custom-dropdown-item.active),
|
:deep(.el-dropdown-menu__item.custom-dropdown-item.active),
|
||||||
:deep(.el-dropdown-menu__item.custom-dropdown-item.active:hover) {
|
:deep(.el-dropdown-menu__item.custom-dropdown-item.active:hover) {
|
||||||
background-color: var(--el-color-primary-light-9) !important;
|
background-color: var(--el-color-primary-light-9) !important;
|
||||||
color: var(--el-color-primary)
|
color: var(--el-color-primary);
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -3,14 +3,14 @@ import { useUserStore } from '@/stores/modules/user'
|
|||||||
import { useAuthStore } from '@/stores/modules/auth'
|
import { useAuthStore } from '@/stores/modules/auth'
|
||||||
import { LOGIN_URL, ROUTER_WHITE_LIST } from '@/config'
|
import { LOGIN_URL, ROUTER_WHITE_LIST } from '@/config'
|
||||||
import { initDynamicRouter } from '@/routers/modules/dynamicRouter'
|
import { initDynamicRouter } from '@/routers/modules/dynamicRouter'
|
||||||
import { staticRouter, errorRouter } from '@/routers/modules/staticRouter'
|
import { staticRouter } from '@/routers/modules/staticRouter'
|
||||||
import NProgress from '@/config/nprogress'
|
import NProgress from '@/config/nprogress'
|
||||||
|
|
||||||
const mode = import.meta.env.VITE_ROUTER_MODE
|
const mode = import.meta.env.VITE_ROUTER_MODE
|
||||||
|
|
||||||
const routerMode = {
|
const routerMode = {
|
||||||
hash: () => createWebHashHistory(),
|
hash: () => createWebHashHistory(),
|
||||||
history: () => createWebHistory(),
|
history: () => createWebHistory()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -30,76 +30,80 @@ const routerMode = {
|
|||||||
* @param meta.isKeepAlive ==> 当前路由是否缓存
|
* @param meta.isKeepAlive ==> 当前路由是否缓存
|
||||||
* */
|
* */
|
||||||
const router = createRouter({
|
const router = createRouter({
|
||||||
|
history: routerMode[mode](),
|
||||||
history: routerMode[mode](),
|
routes: [...staticRouter],
|
||||||
routes: [...staticRouter],
|
// 不区分路由大小写,非严格模式下提供了更宽松的路径匹配
|
||||||
// 不区分路由大小写,非严格模式下提供了更宽松的路径匹配
|
strict: false,
|
||||||
strict: false,
|
// 页面刷新时,滚动条位置还原
|
||||||
// 页面刷新时,滚动条位置还原
|
scrollBehavior: () => ({ left: 0, top: 0 })
|
||||||
scrollBehavior: () => ({ left: 0, top: 0 }),
|
|
||||||
})
|
})
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description 路由拦截 beforeEach
|
* @description 路由拦截 beforeEach
|
||||||
* */
|
* */
|
||||||
router.beforeEach(async (to, from, next) => {
|
router.beforeEach(async (to, from, next) => {
|
||||||
const userStore = useUserStore()
|
const userStore = useUserStore()
|
||||||
const authStore = useAuthStore()
|
const authStore = useAuthStore()
|
||||||
// 1.NProgress 开始
|
// 1.NProgress 开始
|
||||||
NProgress.start()
|
NProgress.start()
|
||||||
// 2.动态设置标题
|
// 2.动态设置标题
|
||||||
const title = import.meta.env.VITE_GLOB_APP_TITLE
|
const title = import.meta.env.VITE_GLOB_APP_TITLE
|
||||||
document.title = to.meta.title ? `${to.meta.title} - ${title}` : title
|
document.title = to.meta.title ? `${to.meta.title} - ${title}` : title
|
||||||
|
|
||||||
// 3.判断是访问登陆页,有 Token 就在当前页面,没有 Token 重置路由到登陆页
|
// 3.判断是访问登陆页,有 Token 就在当前页面,没有 Token 重置路由到登陆页
|
||||||
if (to.path.toLocaleLowerCase() === LOGIN_URL) {
|
if (to.path.toLocaleLowerCase() === LOGIN_URL) {
|
||||||
if (userStore.accessToken) return next(from.fullPath)
|
if (userStore.accessToken) return next(from.fullPath)
|
||||||
resetRouter()
|
resetRouter()
|
||||||
return next()
|
return next()
|
||||||
}
|
}
|
||||||
|
|
||||||
// 4.判断访问页面是否在路由白名单地址(静态路由)中,如果存在直接放行
|
// 4.判断访问页面是否在路由白名单地址(静态路由)中,如果存在直接放行
|
||||||
if (ROUTER_WHITE_LIST.includes(to.path)) return next()
|
if (ROUTER_WHITE_LIST.includes(to.path)) return next()
|
||||||
|
|
||||||
// 5.判断是否有 Token,没有重定向到 login 页面
|
// 5.判断是否有 Token,没有重定向到 login 页面
|
||||||
if (!userStore.accessToken) return next({ path: LOGIN_URL, replace: true })
|
if (!userStore.accessToken) return next({ path: LOGIN_URL, replace: true })
|
||||||
|
|
||||||
// 6.如果没有菜单列表,就重新请求菜单列表并添加动态路由
|
// 6.如果没有菜单列表,就重新请求菜单列表并添加动态路由
|
||||||
if (!authStore.authMenuListGet.length) {
|
if (!authStore.authMenuListGet.length) {
|
||||||
await initDynamicRouter()
|
await initDynamicRouter()
|
||||||
return next({ ...to, replace: true })
|
return next({ ...to, replace: true })
|
||||||
}
|
}
|
||||||
|
|
||||||
// 7.存储 routerName 做按钮权限筛选
|
// 7.存储 routerName 做按钮权限筛选
|
||||||
authStore.setRouteName(to.name as string)
|
await authStore.setRouteName(to.name as string)
|
||||||
// 8.正常访问页面
|
// 8. 当前页面是否有激活信息,没有就刷新
|
||||||
next()
|
const activateInfo = authStore.activateInfo
|
||||||
|
if (!Object.keys(activateInfo).length) {
|
||||||
|
await authStore.setActivateInfo()
|
||||||
|
}
|
||||||
|
// 9.正常访问页面
|
||||||
|
next()
|
||||||
})
|
})
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description 重置路由
|
* @description 重置路由
|
||||||
* */
|
* */
|
||||||
export const resetRouter = () => {
|
export const resetRouter = () => {
|
||||||
const authStore = useAuthStore()
|
const authStore = useAuthStore()
|
||||||
authStore.flatMenuListGet.forEach(route => {
|
authStore.flatMenuListGet.forEach(route => {
|
||||||
const { name } = route
|
const { name } = route
|
||||||
if (name && router.hasRoute(name)) router.removeRoute(name)
|
if (name && router.hasRoute(name)) router.removeRoute(name)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description 路由跳转错误
|
* @description 路由跳转错误
|
||||||
* */
|
* */
|
||||||
router.onError(error => {
|
router.onError(error => {
|
||||||
NProgress.done()
|
NProgress.done()
|
||||||
//console.warn('路由错误', error.message)
|
//console.warn('路由错误', error.message)
|
||||||
})
|
})
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description 路由跳转结束
|
* @description 路由跳转结束
|
||||||
* */
|
* */
|
||||||
router.afterEach(() => {
|
router.afterEach(() => {
|
||||||
NProgress.done()
|
NProgress.done()
|
||||||
})
|
})
|
||||||
|
|
||||||
export default router
|
export default router
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { RouteRecordRaw } from 'vue-router'
|
import { type RouteRecordRaw } from 'vue-router'
|
||||||
import { HOME_URL, LOGIN_URL } from '@/config'
|
import { HOME_URL, LOGIN_URL } from '@/config'
|
||||||
|
|
||||||
export const Layout = () => import('@/layouts/index.vue')
|
export const Layout = () => import('@/layouts/index.vue')
|
||||||
/**
|
/**
|
||||||
* staticRouter (静态路由)
|
* staticRouter (静态路由)
|
||||||
|
|||||||
@@ -1,89 +1,89 @@
|
|||||||
import { defineStore } from "pinia";
|
import { defineStore } from 'pinia'
|
||||||
import { AuthState } from "@/stores/interface";
|
import { AuthState } from '@/stores/interface'
|
||||||
import { getAuthButtonListApi, getAuthMenuListApi } from "@/api/user/login";
|
import { getAuthButtonListApi, getAuthMenuListApi } from '@/api/user/login'
|
||||||
import {
|
import { getAllBreadcrumbList, getFlatMenuList, getShowMenuList } from '@/utils'
|
||||||
getFlatMenuList,
|
import { useRouter } from 'vue-router'
|
||||||
getShowMenuList,
|
import { AUTH_STORE_KEY } from '@/stores/constant'
|
||||||
getAllBreadcrumbList,
|
import { useModeStore } from '@/stores/modules/mode'
|
||||||
} from "@/utils";
|
import { getLicense } from '@/api/activate'
|
||||||
import { useRouter } from "vue-router";
|
import type { Activate } from '@/api/activate/interface'
|
||||||
import { AUTH_STORE_KEY } from "@/stores/constant";
|
|
||||||
import {useModeStore} from '@/stores/modules/mode'
|
|
||||||
|
|
||||||
|
|
||||||
export const useAuthStore = defineStore({
|
export const useAuthStore = defineStore({
|
||||||
id: AUTH_STORE_KEY,
|
id: AUTH_STORE_KEY,
|
||||||
state: (): AuthState => ({
|
state: (): AuthState => ({
|
||||||
// 按钮权限列表
|
// 按钮权限列表
|
||||||
authButtonList: {},
|
authButtonList: {},
|
||||||
// 菜单权限列表
|
// 菜单权限列表
|
||||||
authMenuList: [],
|
authMenuList: [],
|
||||||
// 当前页面的 router name,用来做按钮权限筛选
|
// 当前页面的 router name,用来做按钮权限筛选
|
||||||
routeName: "",
|
routeName: '',
|
||||||
//登录不显示菜单栏和导航栏,点击进入测试的时候显示
|
//登录不显示菜单栏和导航栏,点击进入测试的时候显示
|
||||||
showMenuFlag: JSON.parse(localStorage.getItem("showMenuFlag")),
|
showMenuFlag: JSON.parse(localStorage.getItem('showMenuFlag') as string),
|
||||||
router: useRouter(),
|
router: useRouter(),
|
||||||
}),
|
activateInfo: {}
|
||||||
getters: {
|
}),
|
||||||
// 按钮权限列表
|
getters: {
|
||||||
authButtonListGet: (state) => state.authButtonList,
|
// 按钮权限列表
|
||||||
// 菜单权限列表 ==> 这里的菜单没有经过任何处理
|
authButtonListGet: state => state.authButtonList,
|
||||||
authMenuListGet: (state) => state.authMenuList,
|
// 菜单权限列表 ==> 这里的菜单没有经过任何处理
|
||||||
// 菜单权限列表 ==> 左侧菜单栏渲染,需要剔除 isHide == true
|
authMenuListGet: state => state.authMenuList,
|
||||||
showMenuListGet: (state) => getShowMenuList(state.authMenuList),
|
// 菜单权限列表 ==> 左侧菜单栏渲染,需要剔除 isHide == true
|
||||||
// 菜单权限列表 ==> 扁平化之后的一维数组菜单,主要用来添加动态路由
|
showMenuListGet: state => getShowMenuList(state.authMenuList),
|
||||||
flatMenuListGet: (state) => getFlatMenuList(state.authMenuList),
|
// 菜单权限列表 ==> 扁平化之后的一维数组菜单,主要用来添加动态路由
|
||||||
// 递归处理后的所有面包屑导航列表
|
flatMenuListGet: state => getFlatMenuList(state.authMenuList),
|
||||||
breadcrumbListGet: (state) => getAllBreadcrumbList(state.authMenuList),
|
// 递归处理后的所有面包屑导航列表
|
||||||
//是否显示菜单和导航栏
|
breadcrumbListGet: state => getAllBreadcrumbList(state.authMenuList),
|
||||||
showMenuFlagGet: (state) => state.showMenuFlag,
|
//是否显示菜单和导航栏
|
||||||
},
|
showMenuFlagGet: state => state.showMenuFlag,
|
||||||
actions: {
|
// 获取激活信息
|
||||||
// Get AuthButtonList
|
activateInfoGet: state => state.activateInfo
|
||||||
async getAuthButtonList() {
|
|
||||||
const { data } = await getAuthButtonListApi();
|
|
||||||
this.authButtonList = data;
|
|
||||||
},
|
},
|
||||||
// Get AuthMenuList
|
actions: {
|
||||||
async getAuthMenuList() {
|
// Get AuthButtonList
|
||||||
const modeStore = useModeStore()
|
async getAuthButtonList() {
|
||||||
|
const { data } = await getAuthButtonListApi()
|
||||||
|
this.authButtonList = data
|
||||||
|
},
|
||||||
|
// Get AuthMenuList
|
||||||
|
async getAuthMenuList() {
|
||||||
|
const modeStore = useModeStore()
|
||||||
|
|
||||||
const { data: menuData } = await getAuthMenuListApi();
|
const { data: menuData } = await getAuthMenuListApi()
|
||||||
// 根据不同模式过滤菜单
|
// 根据不同模式过滤菜单
|
||||||
const filteredMenu = modeStore.currentMode === '比对式'
|
const filteredMenu =
|
||||||
? filterMenuByExcludedNames(menuData, ['testSource', 'testScript', 'controlSource'])
|
modeStore.currentMode === '比对式'
|
||||||
: filterMenuByExcludedNames(menuData, ['standardDevice']);
|
? filterMenuByExcludedNames(menuData, ['testSource', 'testScript', 'controlSource'])
|
||||||
|
: filterMenuByExcludedNames(menuData, ['standardDevice'])
|
||||||
this.authMenuList = filteredMenu;
|
|
||||||
|
|
||||||
},
|
|
||||||
// Set RouteName
|
|
||||||
async setRouteName(name: string) {
|
|
||||||
this.routeName = name;
|
|
||||||
},
|
|
||||||
//重置权限
|
|
||||||
async resetAuthStore() {
|
|
||||||
this.showMenuFlag = false;
|
|
||||||
localStorage.removeItem("showMenuFlag");
|
|
||||||
},
|
|
||||||
//修改判断菜单栏/导航栏显示条件
|
|
||||||
async setShowMenu() {
|
|
||||||
this.showMenuFlag = true;
|
|
||||||
localStorage.setItem("showMenuFlag", true);
|
|
||||||
},
|
|
||||||
//更改模式
|
|
||||||
async changeModel() {
|
|
||||||
this.showMenuFlag = !this.showMenuFlag;
|
|
||||||
if (this.showMenuFlag) {
|
|
||||||
localStorage.setItem("showMenuFlag", true);
|
|
||||||
} else {
|
|
||||||
localStorage.removeItem("showMenuFlag");
|
|
||||||
}
|
|
||||||
this.router.push({ path: "/home/index" });
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
|
this.authMenuList = filteredMenu
|
||||||
|
},
|
||||||
|
// Set RouteName
|
||||||
|
async setRouteName(name: string) {
|
||||||
|
this.routeName = name
|
||||||
|
},
|
||||||
|
//重置权限
|
||||||
|
async resetAuthStore() {
|
||||||
|
this.showMenuFlag = false
|
||||||
|
localStorage.removeItem('showMenuFlag')
|
||||||
|
},
|
||||||
|
//修改判断菜单栏/导航栏显示条件
|
||||||
|
async setShowMenu() {
|
||||||
|
this.showMenuFlag = true
|
||||||
|
localStorage.setItem('showMenuFlag', 'true')
|
||||||
|
},
|
||||||
|
//更改模式
|
||||||
|
async changeModel() {
|
||||||
|
this.showMenuFlag = false
|
||||||
|
localStorage.removeItem('showMenuFlag')
|
||||||
|
this.router.push({ path: '/home/index' })
|
||||||
|
},
|
||||||
|
async setActivateInfo() {
|
||||||
|
const license_result = await getLicense()
|
||||||
|
const licenseData = license_result.data as unknown as Activate.ActivationCodePlaintext
|
||||||
|
this.activateInfo = licenseData
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通用菜单过滤函数
|
* 通用菜单过滤函数
|
||||||
@@ -92,12 +92,12 @@ export const useAuthStore = defineStore({
|
|||||||
* @returns 过滤后的菜单列表
|
* @returns 过滤后的菜单列表
|
||||||
*/
|
*/
|
||||||
function filterMenuByExcludedNames(menuList: any[], excludedNames: string[]): any[] {
|
function filterMenuByExcludedNames(menuList: any[], excludedNames: string[]): any[] {
|
||||||
return menuList.filter(menu => {
|
return menuList.filter(menu => {
|
||||||
// 如果当前项有 children,递归处理子项
|
// 如果当前项有 children,递归处理子项
|
||||||
if (menu.children && menu.children.length > 0) {
|
if (menu.children && menu.children.length > 0) {
|
||||||
menu.children = filterMenuByExcludedNames(menu.children, excludedNames);
|
menu.children = filterMenuByExcludedNames(menu.children, excludedNames)
|
||||||
}
|
}
|
||||||
// 过滤掉在排除列表中的菜单项
|
// 过滤掉在排除列表中的菜单项
|
||||||
return !excludedNames.includes(menu.name);
|
return !excludedNames.includes(menu.name)
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -342,6 +342,17 @@
|
|||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
padding: 10px 15px;
|
padding: 10px 15px;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// 隐藏滚动条的CSS
|
||||||
|
scrollbar-width: none; /* Firefox */
|
||||||
|
-ms-overflow-style: none; /* IE 10+ */
|
||||||
|
|
||||||
|
&::-webkit-scrollbar {
|
||||||
|
width: 0px;
|
||||||
|
background: transparent; /* Chrome Safari */
|
||||||
|
}
|
||||||
|
|
||||||
//设置dialog内部form样式
|
//设置dialog内部form样式
|
||||||
.el-form {
|
.el-form {
|
||||||
.el-form-item {
|
.el-form-item {
|
||||||
@@ -379,6 +390,8 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//全局el-form-item间距
|
//全局el-form-item间距
|
||||||
.el-form-item {
|
.el-form-item {
|
||||||
margin-right: 10px !important;
|
margin-right: 10px !important;
|
||||||
|
|||||||
@@ -1,17 +1,23 @@
|
|||||||
export const dialogSmall = {
|
export const dialogSmall = {
|
||||||
width:'500px',
|
width:'26vw',
|
||||||
|
maxWidth:'500px',
|
||||||
|
minWidth:'300px',
|
||||||
closeOnClickModal:false,
|
closeOnClickModal:false,
|
||||||
draggable:true,
|
draggable:true,
|
||||||
class:'dialog-small'
|
class:'dialog-small'
|
||||||
}
|
}
|
||||||
export const dialogMiddle = {
|
export const dialogMiddle = {
|
||||||
width:'800px',
|
width:'42vw',
|
||||||
|
maxWidth:'800px',
|
||||||
|
minWidth:'600px',
|
||||||
closeOnClickModal:false,
|
closeOnClickModal:false,
|
||||||
draggable:true,
|
draggable:true,
|
||||||
class:'dialog-middle'
|
class:'dialog-middle'
|
||||||
}
|
}
|
||||||
export const dialogBig = {
|
export const dialogBig = {
|
||||||
width:'1200px',
|
width:'62vw',
|
||||||
|
maxWidth:'1200px',
|
||||||
|
minWidth:'800px',
|
||||||
closeOnClickModal:false,
|
closeOnClickModal:false,
|
||||||
draggable:true,
|
draggable:true,
|
||||||
class:'dialog-big',
|
class:'dialog-big',
|
||||||
|
|||||||
@@ -1,31 +0,0 @@
|
|||||||
const Renderer =
|
|
||||||
(window.require && window.require('electron')) || window.electron || {}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ipc
|
|
||||||
* 官方api说明:https://www.electronjs.org/zh/docs/latest/api/ipc-renderer
|
|
||||||
*
|
|
||||||
* 属性/方法
|
|
||||||
* ipc.invoke(channel, param) - 发送异步消息(invoke/handle 模型)
|
|
||||||
* ipc.sendSync(channel, param) - 发送同步消息(send/on 模型)
|
|
||||||
* ipc.on(channel, listener) - 监听 channel, 当新消息到达,调用 listener
|
|
||||||
* ipc.once(channel, listener) - 添加一次性 listener 函数
|
|
||||||
* ipc.removeListener(channel, listener) - 为特定的 channel 从监听队列中删除特定的 listener 监听者
|
|
||||||
* ipc.removeAllListeners(channel) - 移除所有的监听器,当指定 channel 时只移除与其相关的所有监听器
|
|
||||||
* ipc.send(channel, ...args) - 通过channel向主进程发送异步消息
|
|
||||||
* ipc.postMessage(channel, message, [transfer]) - 发送消息到主进程
|
|
||||||
* ipc.sendTo(webContentsId, channel, ...args) - 通过 channel 发送消息到带有 webContentsId 的窗口
|
|
||||||
* ipc.sendToHost(channel, ...args) - 消息会被发送到 host 页面上的 <webview> 元素
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ipc
|
|
||||||
*/
|
|
||||||
const ipc = Renderer.ipcRenderer || undefined
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 是否为EE环境
|
|
||||||
*/
|
|
||||||
const isEE = ipc ? true : false
|
|
||||||
|
|
||||||
export { Renderer, ipc, isEE }
|
|
||||||
119
frontend/src/utils/ipcRenderer.ts
Normal file
@@ -0,0 +1,119 @@
|
|||||||
|
/**
|
||||||
|
* Electron IPC Renderer 类型定义
|
||||||
|
*/
|
||||||
|
|
||||||
|
interface IpcRenderer {
|
||||||
|
/**
|
||||||
|
* 发送异步消息(invoke/handle 模型)
|
||||||
|
* @param channel 通道名称
|
||||||
|
* @param param 传递的参数
|
||||||
|
* @returns Promise<T> 返回结果
|
||||||
|
*/
|
||||||
|
invoke<T = any>(channel: string, param?: any): Promise<T>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发送同步消息(send/on 模型)
|
||||||
|
* @param channel 通道名称
|
||||||
|
* @param param 传递的参数
|
||||||
|
* @returns 返回结果
|
||||||
|
*/
|
||||||
|
sendSync(channel: string, param?: any): any;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 监听 channel,当新消息到达,调用 listener
|
||||||
|
* @param channel 通道名称
|
||||||
|
* @param listener 监听器函数
|
||||||
|
*/
|
||||||
|
on(channel: string, listener: (event: any, ...args: any[]) => void): void;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加一次性 listener 函数
|
||||||
|
* @param channel 通道名称
|
||||||
|
* @param listener 监听器函数
|
||||||
|
*/
|
||||||
|
once(channel: string, listener: (event: any, ...args: any[]) => void): void;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 为特定的 channel 从监听队列中删除特定的 listener 监听者
|
||||||
|
* @param channel 通道名称
|
||||||
|
* @param listener 要移除的监听器函数
|
||||||
|
*/
|
||||||
|
removeListener(channel: string, listener: (event: any, ...args: any[]) => void): void;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 移除所有的监听器,当指定 channel 时只移除与其相关的所有监听器
|
||||||
|
* @param channel 通道名称(可选)
|
||||||
|
*/
|
||||||
|
removeAllListeners(channel?: string): void;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过 channel 向主进程发送异步消息
|
||||||
|
* @param channel 通道名称
|
||||||
|
* @param args 传递的参数
|
||||||
|
*/
|
||||||
|
send(channel: string, ...args: any[]): void;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发送消息到主进程
|
||||||
|
* @param channel 通道名称
|
||||||
|
* @param message 消息内容
|
||||||
|
* @param transfer 传输对象(可选)
|
||||||
|
*/
|
||||||
|
postMessage(channel: string, message: any, transfer?: MessagePort[]): void;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过 channel 发送消息到带有 webContentsId 的窗口
|
||||||
|
* @param webContentsId 目标窗口的 ID
|
||||||
|
* @param channel 通道名称
|
||||||
|
* @param args 传递的参数
|
||||||
|
*/
|
||||||
|
sendTo(webContentsId: number, channel: string, ...args: any[]): void;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 消息会被发送到 host 页面上的 <webview> 元素
|
||||||
|
* @param channel 通道名称
|
||||||
|
* @param args 传递的参数
|
||||||
|
*/
|
||||||
|
sendToHost(channel: string, ...args: any[]): void;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Electron {
|
||||||
|
ipcRenderer?: IpcRenderer;
|
||||||
|
}
|
||||||
|
|
||||||
|
const Renderer = (window.require && window.require('electron')) || (window as any).electron || {};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ipc
|
||||||
|
* 官方api说明:https://www.electronjs.org/zh/docs/latest/api/ipc-renderer
|
||||||
|
*
|
||||||
|
* 属性/方法
|
||||||
|
* ipc.invoke(channel, param) - 发送异步消息(invoke/handle 模型)
|
||||||
|
* ipc.sendSync(channel, param) - 发送同步消息(send/on 模型)
|
||||||
|
* ipc.on(channel, listener) - 监听 channel, 当新消息到达,调用 listener
|
||||||
|
* ipc.once(channel, listener) - 添加一次性 listener 函数
|
||||||
|
* ipc.removeListener(channel, listener) - 为特定的 channel 从监听队列中删除特定的 listener 监听者
|
||||||
|
* ipc.removeAllListeners(channel) - 移除所有的监听器,当指定 channel 时只移除与其相关的所有监听器
|
||||||
|
* ipc.send(channel, ...args) - 通过channel向主进程发送异步消息
|
||||||
|
* ipc.postMessage(channel, message, [transfer]) - 发送消息到主进程
|
||||||
|
* ipc.sendTo(webContentsId, channel, ...args) - 通过 channel 发送消息到带有 webContentsId 的窗口
|
||||||
|
* ipc.sendToHost(channel, ...args) - 消息会被发送到 host 页面上的 <webview> 元素
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ipc
|
||||||
|
*/
|
||||||
|
const ipc: IpcRenderer | undefined = Renderer.ipcRenderer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否为EE环境
|
||||||
|
*/
|
||||||
|
const isEE: boolean = ipc ? true : false;
|
||||||
|
|
||||||
|
export {
|
||||||
|
type IpcRenderer,
|
||||||
|
type Electron,
|
||||||
|
Renderer,
|
||||||
|
ipc,
|
||||||
|
isEE
|
||||||
|
};
|
||||||
@@ -190,8 +190,8 @@ export default class SocketService {
|
|||||||
* WebSocket连接配置
|
* WebSocket连接配置
|
||||||
*/
|
*/
|
||||||
private config: SocketConfig = {
|
private config: SocketConfig = {
|
||||||
// url: 'ws://127.0.0.1:7777/hello',
|
url: 'ws://127.0.0.1:7777/hello',
|
||||||
url: 'ws://192.168.1.124:7777/hello',
|
// url: 'ws://192.168.1.124:7777/hello',
|
||||||
heartbeatInterval: 9000, // 9秒心跳间隔
|
heartbeatInterval: 9000, // 9秒心跳间隔
|
||||||
reconnectDelay: 5000, // 5秒重连延迟
|
reconnectDelay: 5000, // 5秒重连延迟
|
||||||
maxReconnectAttempts: 5, // 最多重连5次
|
maxReconnectAttempts: 5, // 最多重连5次
|
||||||
@@ -246,13 +246,13 @@ export default class SocketService {
|
|||||||
public connect(): Promise<void> | void {
|
public connect(): Promise<void> | void {
|
||||||
// 检查浏览器支持
|
// 检查浏览器支持
|
||||||
if (!window.WebSocket) {
|
if (!window.WebSocket) {
|
||||||
console.log('您的浏览器不支持WebSocket');
|
// console.log('您的浏览器不支持WebSocket');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 防止重复连接
|
// 防止重复连接
|
||||||
if (this.connectionStatus === ConnectionStatus.CONNECTING || this.connected) {
|
if (this.connectionStatus === ConnectionStatus.CONNECTING || this.connected) {
|
||||||
console.warn('WebSocket已连接或正在连接中');
|
// console.warn('WebSocket已连接或正在连接中');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -263,7 +263,7 @@ export default class SocketService {
|
|||||||
this.setupEventHandlersLegacy();
|
this.setupEventHandlersLegacy();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
this.connectionStatus = ConnectionStatus.ERROR;
|
this.connectionStatus = ConnectionStatus.ERROR;
|
||||||
console.error('WebSocket连接失败:', error);
|
//console.error('WebSocket连接失败:', error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -276,14 +276,14 @@ export default class SocketService {
|
|||||||
// 检查浏览器支持
|
// 检查浏览器支持
|
||||||
if (!window.WebSocket) {
|
if (!window.WebSocket) {
|
||||||
const error = '您的浏览器不支持WebSocket';
|
const error = '您的浏览器不支持WebSocket';
|
||||||
console.error(error);
|
//console.error(error);
|
||||||
reject(new Error(error));
|
reject(new Error(error));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 防止重复连接
|
// 防止重复连接
|
||||||
if (this.connectionStatus === ConnectionStatus.CONNECTING || this.connected) {
|
if (this.connectionStatus === ConnectionStatus.CONNECTING || this.connected) {
|
||||||
console.warn('WebSocket已连接或正在连接中');
|
//console.warn('WebSocket已连接或正在连接中');
|
||||||
resolve();
|
resolve();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -307,11 +307,11 @@ export default class SocketService {
|
|||||||
*/
|
*/
|
||||||
public registerCallBack<T = any>(messageType: string, callback: CallbackFunction<T>): void {
|
public registerCallBack<T = any>(messageType: string, callback: CallbackFunction<T>): void {
|
||||||
if (!messageType || typeof callback !== 'function') {
|
if (!messageType || typeof callback !== 'function') {
|
||||||
console.error('注册回调函数参数无效');
|
//console.error('注册回调函数参数无效');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.callBackMapping[messageType] = callback;
|
this.callBackMapping[messageType] = callback;
|
||||||
console.log(`注册消息处理器: ${messageType}`);
|
// console.log(`注册消息处理器: ${messageType}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -321,7 +321,7 @@ export default class SocketService {
|
|||||||
public unRegisterCallBack(messageType: string): void {
|
public unRegisterCallBack(messageType: string): void {
|
||||||
if (this.callBackMapping[messageType]) {
|
if (this.callBackMapping[messageType]) {
|
||||||
delete this.callBackMapping[messageType];
|
delete this.callBackMapping[messageType];
|
||||||
console.log(`注销消息处理器: ${messageType}`);
|
//console.log(`注销消息处理器: ${messageType}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -354,10 +354,10 @@ export default class SocketService {
|
|||||||
const message = typeof data === 'string' ? data : JSON.stringify(data);
|
const message = typeof data === 'string' ? data : JSON.stringify(data);
|
||||||
this.ws.send(message);
|
this.ws.send(message);
|
||||||
|
|
||||||
console.log('发送消息:', message);
|
//console.log('发送消息:', message);
|
||||||
resolve();
|
resolve();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('发送消息失败:', error);
|
//console.error('发送消息失败:', error);
|
||||||
reject(error);
|
reject(error);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -367,7 +367,7 @@ export default class SocketService {
|
|||||||
* 关闭WebSocket连接
|
* 关闭WebSocket连接
|
||||||
*/
|
*/
|
||||||
public closeWs(): void {
|
public closeWs(): void {
|
||||||
console.log('正在关闭WebSocket连接...');
|
//console.log('正在关闭WebSocket连接...');
|
||||||
|
|
||||||
// 清理心跳
|
// 清理心跳
|
||||||
this.clearHeartbeat();
|
this.clearHeartbeat();
|
||||||
@@ -383,7 +383,7 @@ export default class SocketService {
|
|||||||
this.connectRetryCount = 0;
|
this.connectRetryCount = 0;
|
||||||
this.sendRetryCount = 0;
|
this.sendRetryCount = 0;
|
||||||
|
|
||||||
console.log('WebSocket连接已关闭');
|
//console.log('WebSocket连接已关闭');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -447,7 +447,7 @@ export default class SocketService {
|
|||||||
// 连接成功事件
|
// 连接成功事件
|
||||||
this.ws.onopen = () => {
|
this.ws.onopen = () => {
|
||||||
ElMessage.success("WebSocket连接服务端成功");
|
ElMessage.success("WebSocket连接服务端成功");
|
||||||
console.log('WebSocket连接成功');
|
// console.log('WebSocket连接成功');
|
||||||
this.connectionStatus = ConnectionStatus.CONNECTED;
|
this.connectionStatus = ConnectionStatus.CONNECTED;
|
||||||
this.connectRetryCount = 0;
|
this.connectRetryCount = 0;
|
||||||
this.startHeartbeat();
|
this.startHeartbeat();
|
||||||
@@ -456,7 +456,7 @@ export default class SocketService {
|
|||||||
|
|
||||||
// 连接关闭事件
|
// 连接关闭事件
|
||||||
this.ws.onclose = (event: CloseEvent) => {
|
this.ws.onclose = (event: CloseEvent) => {
|
||||||
console.log('WebSocket连接关闭', event.code, event.reason);
|
//console.log('WebSocket连接关闭', event.code, event.reason);
|
||||||
this.connectionStatus = ConnectionStatus.DISCONNECTED;
|
this.connectionStatus = ConnectionStatus.DISCONNECTED;
|
||||||
this.clearHeartbeat();
|
this.clearHeartbeat();
|
||||||
|
|
||||||
@@ -489,7 +489,7 @@ export default class SocketService {
|
|||||||
// 连接成功事件
|
// 连接成功事件
|
||||||
this.ws.onopen = () => {
|
this.ws.onopen = () => {
|
||||||
ElMessage.success("webSocket连接服务端成功了");
|
ElMessage.success("webSocket连接服务端成功了");
|
||||||
console.log('连接服务端成功了');
|
// console.log('连接服务端成功了');
|
||||||
this.connectionStatus = ConnectionStatus.CONNECTED;
|
this.connectionStatus = ConnectionStatus.CONNECTED;
|
||||||
this.connectRetryCount = 0;
|
this.connectRetryCount = 0;
|
||||||
this.startHeartbeat();
|
this.startHeartbeat();
|
||||||
@@ -497,7 +497,7 @@ export default class SocketService {
|
|||||||
|
|
||||||
// 连接关闭事件
|
// 连接关闭事件
|
||||||
this.ws.onclose = (event: CloseEvent) => {
|
this.ws.onclose = (event: CloseEvent) => {
|
||||||
console.log('连接webSocket服务端关闭');
|
// console.log('连接webSocket服务端关闭');
|
||||||
this.connectionStatus = ConnectionStatus.DISCONNECTED;
|
this.connectionStatus = ConnectionStatus.DISCONNECTED;
|
||||||
this.clearHeartbeat();
|
this.clearHeartbeat();
|
||||||
|
|
||||||
@@ -530,7 +530,7 @@ export default class SocketService {
|
|||||||
|
|
||||||
// 心跳响应处理
|
// 心跳响应处理
|
||||||
if (event.data === 'over') {
|
if (event.data === 'over') {
|
||||||
console.log(`${new Date().toLocaleTimeString()} - 收到心跳响应`);
|
// console.log(`${new Date().toLocaleTimeString()} - 收到心跳响应`);
|
||||||
this.lastResponseHeartTime = Date.now();
|
this.lastResponseHeartTime = Date.now();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -553,7 +553,7 @@ export default class SocketService {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// 非JSON格式的消息,作为普通文本处理
|
// 非JSON格式的消息,作为普通文本处理
|
||||||
console.log('收到非JSON格式消息:', event.data);
|
// console.log('收到非JSON格式消息:', event.data);
|
||||||
// 可以添加文本消息的处理逻辑
|
// 可以添加文本消息的处理逻辑
|
||||||
if (this.callBackMapping['text']) {
|
if (this.callBackMapping['text']) {
|
||||||
this.callBackMapping['text']({
|
this.callBackMapping['text']({
|
||||||
@@ -587,7 +587,7 @@ export default class SocketService {
|
|||||||
|
|
||||||
const delay = this.config.reconnectDelay! * this.connectRetryCount;
|
const delay = this.config.reconnectDelay! * this.connectRetryCount;
|
||||||
|
|
||||||
console.log(`尝试第${this.connectRetryCount}次重连,${delay}ms后开始...`);
|
// console.log(`尝试第${this.connectRetryCount}次重连,${delay}ms后开始...`);
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
try {
|
try {
|
||||||
@@ -674,7 +674,7 @@ export default class SocketService {
|
|||||||
*/
|
*/
|
||||||
private sendHeartbeat(): void {
|
private sendHeartbeat(): void {
|
||||||
if (this.connected && this.ws) {
|
if (this.connected && this.ws) {
|
||||||
console.log(`${new Date().toLocaleTimeString()} - 发送心跳消息`);
|
// console.log(`${new Date().toLocaleTimeString()} - 发送心跳消息`);
|
||||||
this.ws.send('alive');
|
this.ws.send('alive');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -124,23 +124,25 @@ let dialogTitle = computed(() => {
|
|||||||
const formRuleRef = ref<FormInstance>()
|
const formRuleRef = ref<FormInstance>()
|
||||||
const rules: Ref<Record<string, Array<FormItemRule>>> = ref({
|
const rules: Ref<Record<string, Array<FormItemRule>>> = ref({
|
||||||
name: [{ required: true, trigger: 'blur', message: '菜单名称必填!' }],
|
name: [{ required: true, trigger: 'blur', message: '菜单名称必填!' }],
|
||||||
code: [{ required: true, trigger: 'blur', message: '编码必填!' }]
|
code: [{ required: true, trigger: 'blur', message: '编码必填!' }],
|
||||||
|
path : [{ required: true, trigger: 'blur', message: '路由地址必填!' }],
|
||||||
|
component :[{ required: true, trigger: 'blur', message: '组件地址必填!' }]
|
||||||
})
|
})
|
||||||
|
|
||||||
watch(
|
// watch(
|
||||||
() => formContent.value.type,
|
// () => formContent.value.type,
|
||||||
newVal => {
|
// newVal => {
|
||||||
if (newVal === 1) {
|
// if (newVal === 1) {
|
||||||
// 选择按钮时,路由地址和组件地址无需校验
|
// // 选择按钮时,路由地址和组件地址无需校验
|
||||||
rules.value.path = []
|
// rules.value.path = []
|
||||||
rules.value.component = []
|
// rules.value.component = []
|
||||||
} else {
|
// } else {
|
||||||
// 其他情况下,路由地址和组件地址需要校验
|
// // 其他情况下,路由地址和组件地址需要校验
|
||||||
rules.value.path = [{ required: true, trigger: 'blur', message: '路由地址必填!' }]
|
// rules.value.path = [{ required: true, trigger: 'blur', message: '路由地址必填!' }]
|
||||||
rules.value.component = [{ required: true, trigger: 'blur', message: '组件地址必填!' }]
|
// rules.value.component = [{ required: true, trigger: 'blur', message: '组件地址必填!' }]
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
)
|
// )
|
||||||
|
|
||||||
// 关闭弹窗
|
// 关闭弹窗
|
||||||
const close = () => {
|
const close = () => {
|
||||||
@@ -196,12 +198,12 @@ const save = () => {
|
|||||||
const open = async (sign: string, data: Function.ResFunction) => {
|
const open = async (sign: string, data: Function.ResFunction) => {
|
||||||
// 重置表单
|
// 重置表单
|
||||||
dialogFormRef.value?.resetFields()
|
dialogFormRef.value?.resetFields()
|
||||||
|
// 清空表单校验
|
||||||
|
dialogFormRef.value?.clearValidate()
|
||||||
const response = await getFunctionListNoButton()
|
const response = await getFunctionListNoButton()
|
||||||
functionList.value = response.data as unknown as Function.ResFunction[]
|
functionList.value = response.data as unknown as Function.ResFunction[]
|
||||||
titleType.value = sign
|
titleType.value = sign
|
||||||
dialogVisible.value = true
|
dialogVisible.value = true
|
||||||
rules.value.path = [{ required: true, trigger: 'blur', message: '路由地址必填!' }]
|
|
||||||
rules.value.component = [{ required: true, trigger: 'blur', message: '组件地址必填!' }]
|
|
||||||
|
|
||||||
if (formContent.value.pid === '0') {
|
if (formContent.value.pid === '0') {
|
||||||
formContent.value.pid = ''
|
formContent.value.pid = ''
|
||||||
|
|||||||
@@ -158,7 +158,6 @@ const handleConnectEnd = (params: any) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const handleConnect = (params: any) => {
|
const handleConnect = (params: any) => {
|
||||||
console.log('连接信息:', params)
|
|
||||||
const sourceNode = nodes.value.find(node => node.id === params.source)
|
const sourceNode = nodes.value.find(node => node.id === params.source)
|
||||||
const targetNode = nodes.value.find(node => node.id === params.target)
|
const targetNode = nodes.value.find(node => node.id === params.target)
|
||||||
|
|
||||||
@@ -207,7 +206,6 @@ const devIds = ref<string[]>()
|
|||||||
const standardDevIds = ref<string[]>()
|
const standardDevIds = ref<string[]>()
|
||||||
|
|
||||||
const open = async () => {
|
const open = async () => {
|
||||||
console.log('开始打开通道配对')
|
|
||||||
edges.value = []
|
edges.value = []
|
||||||
devIds.value = prop.devIdList.map(d => d.id)
|
devIds.value = prop.devIdList.map(d => d.id)
|
||||||
standardDevIds.value = prop.pqStandardDevList.map(d => d.id)
|
standardDevIds.value = prop.pqStandardDevList.map(d => d.id)
|
||||||
@@ -373,6 +371,7 @@ const createNodes = (device: Device.ResPqDev[], standardDev: StandardDevice.ResP
|
|||||||
const outputChannelX = 1050
|
const outputChannelX = 1050
|
||||||
const standardWidth = 1170
|
const standardWidth = 1170
|
||||||
|
|
||||||
|
|
||||||
// 添加被检通道
|
// 添加被检通道
|
||||||
// let currentYPosition = 50; // 初始Y位置
|
// let currentYPosition = 50; // 初始Y位置
|
||||||
let actualChannelsTotalLength = 0;
|
let actualChannelsTotalLength = 0;
|
||||||
@@ -386,7 +385,7 @@ const createNodes = (device: Device.ResPqDev[], standardDev: StandardDevice.ResP
|
|||||||
|
|
||||||
let currentYPosition = (vueFlowElement.value - 60 * actualChannelsTotalLength) / 2; // 初始Y位置
|
let currentYPosition = (vueFlowElement.value - 60 * actualChannelsTotalLength) / 2; // 初始Y位置
|
||||||
const deviceSpacing = 30; // 设备间的垂直间距
|
const deviceSpacing = 30; // 设备间的垂直间距
|
||||||
|
console.log('currentYPosition', currentYPosition)
|
||||||
Object.entries(channelCounts).forEach(([deviceId, count]) => {
|
Object.entries(channelCounts).forEach(([deviceId, count]) => {
|
||||||
// 从deviceMonitor中获取实际通道信息
|
// 从deviceMonitor中获取实际通道信息
|
||||||
let actualChannels = []; // 存储实际的通道号
|
let actualChannels = []; // 存储实际的通道号
|
||||||
@@ -462,8 +461,6 @@ const createNodes = (device: Device.ResPqDev[], standardDev: StandardDevice.ResP
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 添加被检设备
|
// 添加被检设备
|
||||||
// let deviceCurrentYPosition = 50; // 与通道计算保持一致的初始位置
|
// let deviceCurrentYPosition = 50; // 与通道计算保持一致的初始位置
|
||||||
let deviceCurrentYPosition = (vueFlowElement.value - 60 * actualChannelsTotalLength) / 2; // 与通道计算保持一致的初始位置
|
let deviceCurrentYPosition = (vueFlowElement.value - 60 * actualChannelsTotalLength) / 2; // 与通道计算保持一致的初始位置
|
||||||
@@ -502,10 +499,6 @@ const createNodes = (device: Device.ResPqDev[], standardDev: StandardDevice.ResP
|
|||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 添加标准设备
|
// 添加标准设备
|
||||||
// let standardDeviceCurrentYPosition = 50; // 与标准通道计算保持一致的初始位置
|
// let standardDeviceCurrentYPosition = 50; // 与标准通道计算保持一致的初始位置
|
||||||
let standardDeviceCurrentYPosition = (vueFlowElement.value - 60 * totalCount) / 2; // 与标准通道计算保持一致的初始位置
|
let standardDeviceCurrentYPosition = (vueFlowElement.value - 60 * totalCount) / 2; // 与标准通道计算保持一致的初始位置
|
||||||
@@ -554,4 +547,11 @@ defineExpose({ open, handleNext })
|
|||||||
.vue-flow__node.no-handle-node .vue-flow__handle {
|
.vue-flow__node.no-handle-node .vue-flow__handle {
|
||||||
display: none !important;
|
display: none !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* 放大连线点 */
|
||||||
|
.vue-flow__handle {
|
||||||
|
width: 12px !important; /* 原来默认是 6px */
|
||||||
|
height: 12px !important; /* 原来默认是 6px */
|
||||||
|
background-color: #3b82f6 !important; /* 更明显的颜色 */
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -485,7 +485,7 @@ const getResults = async (code: any) => {
|
|||||||
|
|
||||||
// 判断是否为录波数据请求
|
// 判断是否为录波数据请求
|
||||||
const isWaveDataRequest = code === 'wave_data' || isWaveData.value
|
const isWaveDataRequest = code === 'wave_data' || isWaveData.value
|
||||||
console.log('isWaveDataRequest:', rowList.value.scriptType)
|
|
||||||
getContrastResult({
|
getContrastResult({
|
||||||
planId: checkStore.plan.id,
|
planId: checkStore.plan.id,
|
||||||
scriptType: rowList.value.scriptType,
|
scriptType: rowList.value.scriptType,
|
||||||
|
|||||||
@@ -266,8 +266,26 @@ watch(webMsgSend, function (newValue, oldValue) {
|
|||||||
step1.value = 'success'
|
step1.value = 'success'
|
||||||
step2.value = 'process'
|
step2.value = 'process'
|
||||||
}
|
}
|
||||||
|
if(newValue.code == 10550){
|
||||||
|
step1InitLog.value = [{
|
||||||
|
type: 'error',
|
||||||
|
log: '设备通讯校验时,设备连接异常!',
|
||||||
|
}];
|
||||||
|
step1.value = 'error'
|
||||||
|
ts.value = 'error'
|
||||||
|
step5.value = 'error'
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'record_wave_step1':
|
case 'record_wave_step1':
|
||||||
|
if(newValue.code == 10550){
|
||||||
|
step1InitLog.value = [{
|
||||||
|
type: 'error',
|
||||||
|
log: '录波校验时,设备连接异常!',
|
||||||
|
}];
|
||||||
|
step1.value = 'error'
|
||||||
|
ts.value = 'error'
|
||||||
|
step5.value = 'error'
|
||||||
|
}
|
||||||
if (newValue.code == 25002) { //某一路录波校验失败
|
if (newValue.code == 25002) { //某一路录波校验失败
|
||||||
step1InitLog.value.push({
|
step1InitLog.value.push({
|
||||||
type: 'error',
|
type: 'error',
|
||||||
@@ -293,6 +311,15 @@ watch(webMsgSend, function (newValue, oldValue) {
|
|||||||
log: '正在进行模型一致性校验.....',
|
log: '正在进行模型一致性校验.....',
|
||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
|
if(newValue.code == 10550){
|
||||||
|
step2InitLog.value = [{
|
||||||
|
type: 'error',
|
||||||
|
log: '模型一致性校验时,设备连接异常!',
|
||||||
|
}];
|
||||||
|
step2.value = 'error'
|
||||||
|
ts.value = 'error'
|
||||||
|
step5.value = 'error'
|
||||||
|
}
|
||||||
if (newValue.code == 25002) { //单个监测点失败
|
if (newValue.code == 25002) { //单个监测点失败
|
||||||
step2InitLog.value.push({
|
step2InitLog.value.push({
|
||||||
type: 'error',
|
type: 'error',
|
||||||
@@ -324,6 +351,15 @@ watch(webMsgSend, function (newValue, oldValue) {
|
|||||||
log: '正在进行数据对齐检验.....',
|
log: '正在进行数据对齐检验.....',
|
||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
|
if(newValue.code == 10550){
|
||||||
|
step3InitLog.value = [{
|
||||||
|
type: 'error',
|
||||||
|
log: '实时数据对齐时,设备连接异常!',
|
||||||
|
}];
|
||||||
|
step3.value = 'error'
|
||||||
|
ts.value = 'error'
|
||||||
|
step5.value = 'error'
|
||||||
|
}
|
||||||
if (newValue.code == 25002) { //单个监测点失败
|
if (newValue.code == 25002) { //单个监测点失败
|
||||||
|
|
||||||
step3InitLog.value.push({
|
step3InitLog.value.push({
|
||||||
@@ -361,6 +397,15 @@ watch(webMsgSend, function (newValue, oldValue) {
|
|||||||
log: '正在进行相序性检.....',
|
log: '正在进行相序性检.....',
|
||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
|
if(newValue.code == 10550){
|
||||||
|
step4InitLog.value = [{
|
||||||
|
type: 'error',
|
||||||
|
log: '相序校验时,设备连接异常!',
|
||||||
|
}];
|
||||||
|
step4.value = 'error'
|
||||||
|
ts.value = 'error'
|
||||||
|
step5.value = 'error'
|
||||||
|
}
|
||||||
if (newValue.code == 25002) {
|
if (newValue.code == 25002) {
|
||||||
step4InitLog.value.push({
|
step4InitLog.value.push({
|
||||||
type: 'error',
|
type: 'error',
|
||||||
|
|||||||
@@ -304,7 +304,7 @@ watch(
|
|||||||
setLogList('error', newValue.data)
|
setLogList('error', newValue.data)
|
||||||
break
|
break
|
||||||
case 25003:
|
case 25003:
|
||||||
ElMessageBox.alert('录波对齐失败!', {
|
ElMessageBox.alert('录波数据异常!', {
|
||||||
confirmButtonText: '确定',
|
confirmButtonText: '确定',
|
||||||
type: 'error'
|
type: 'error'
|
||||||
})
|
})
|
||||||
@@ -353,7 +353,70 @@ watch(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
|
case 'flicker_data_check':
|
||||||
|
switch (newValue.code) {
|
||||||
|
case 25002:
|
||||||
|
setLogList('error', newValue.data)
|
||||||
|
break
|
||||||
|
case 25003:
|
||||||
|
ElMessageBox.alert('闪变收集失败!', {
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
type: 'error'
|
||||||
|
})
|
||||||
|
stopTimeCount()
|
||||||
|
break
|
||||||
|
case 25001: {
|
||||||
|
// 当录波校验完成时,更新录波项目的按钮状态
|
||||||
|
setLogList('info', '闪变校验完成!')
|
||||||
|
// 解析返回的数据
|
||||||
|
const waveData = JSON.parse(newValue.data)
|
||||||
|
// 找到录波项目并更新其状态
|
||||||
|
const waveResultItem = checkResult.find(item => item.scriptName === '闪变')
|
||||||
|
if (waveResultItem) {
|
||||||
|
// 根据返回的chnResult更新各个设备的通道状态
|
||||||
|
waveResultItem.devices.forEach(device => {
|
||||||
|
const deviceData = waveData.find((d: any) => d.deviceId === device.deviceId)
|
||||||
|
if (deviceData) {
|
||||||
|
// 根据实际返回的chnResult更新状态
|
||||||
|
deviceData.chnResult.forEach((result: number, index: number) => {
|
||||||
|
// 创建数字到枚举的映射
|
||||||
|
const resultMap: { [key: number]: CheckData.ChnCheckResultEnum } = {
|
||||||
|
1: CheckData.ChnCheckResultEnum.SUCCESS,
|
||||||
|
2: CheckData.ChnCheckResultEnum.FAIL,
|
||||||
|
3: CheckData.ChnCheckResultEnum.TIMEOUT,
|
||||||
|
4: CheckData.ChnCheckResultEnum.ERRORDATA,
|
||||||
|
5: CheckData.ChnCheckResultEnum.NOT_PART_IN_ERROR
|
||||||
|
}
|
||||||
|
|
||||||
|
// 使用映射关系设置状态,如果没有对应的映射则设为UNKNOWN
|
||||||
|
device.chnResult[index] = resultMap[result] || CheckData.ChnCheckResultEnum.UNKNOWN
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
// 触发响应式更新
|
||||||
|
checkResult.splice(0, 0)
|
||||||
|
stopTimeCount()
|
||||||
|
updatePercentage()
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break
|
||||||
|
case 'QUIT_FUNEND$01':{
|
||||||
|
ElMessageBox.alert(newValue.data, '检测失败', {
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
type: 'error'
|
||||||
|
})
|
||||||
|
// 设置闪变项目为Unkonown 状态
|
||||||
|
const flickerResultItem = checkResult.find(item => item.code === 'F')
|
||||||
|
if (flickerResultItem) {
|
||||||
|
flickerResultItem.devices.forEach(device => {
|
||||||
|
device.chnResult.fill(CheckData.ChnCheckResultEnum.UNKNOWN)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
stopTimeCount()
|
||||||
|
break
|
||||||
|
}
|
||||||
case 'connect':
|
case 'connect':
|
||||||
switch (newValue.operateCode) {
|
switch (newValue.operateCode) {
|
||||||
case 'Contrast_Dev':
|
case 'Contrast_Dev':
|
||||||
@@ -396,7 +459,11 @@ watch(
|
|||||||
setLogList('error', '设备主动关闭连接!')
|
setLogList('error', '设备主动关闭连接!')
|
||||||
stopTimeCount()
|
stopTimeCount()
|
||||||
break
|
break
|
||||||
case 'yjc_xyjy' :
|
case 'yjc_xyjy' :
|
||||||
|
if(newValue.code == 10550){
|
||||||
|
setLogList('error', '协议校验时,设备连接异常!')
|
||||||
|
stopTimeCount()
|
||||||
|
}
|
||||||
if (newValue.code == 10552) {
|
if (newValue.code == 10552) {
|
||||||
ElMessageBox.alert('重复的初始化操作!', '检测失败', {
|
ElMessageBox.alert('重复的初始化操作!', '检测失败', {
|
||||||
confirmButtonText: '确定',
|
confirmButtonText: '确定',
|
||||||
@@ -406,13 +473,19 @@ watch(
|
|||||||
stopTimeCount()
|
stopTimeCount()
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'yjc_sbtxjy' :
|
case 'yjc_sbtxjy' :
|
||||||
ElMessageBox.alert('重复的初始化操作!', '检测失败', {
|
if(newValue.code == 10550){
|
||||||
confirmButtonText: '确定',
|
setLogList('error', '设备通讯校验时,设备连接异常!')
|
||||||
type: 'error',
|
stopTimeCount()
|
||||||
})
|
}
|
||||||
setLogList('error', '重复的初始化操作!')
|
if (newValue.code == 10552) {
|
||||||
stopTimeCount()
|
ElMessageBox.alert('重复的初始化操作!', '检测失败', {
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
type: 'error',
|
||||||
|
})
|
||||||
|
setLogList('error', '重复的初始化操作!')
|
||||||
|
stopTimeCount()
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (checkStore.selectTestItems.preTest == false && newValue.requestId != 'formal_real') {
|
if (checkStore.selectTestItems.preTest == false && newValue.requestId != 'formal_real') {
|
||||||
@@ -446,6 +519,12 @@ watch(
|
|||||||
stopTimeCount()
|
stopTimeCount()
|
||||||
if (newValue.requestId == 'YJC_xujy') setLogList('info', '初始化失败!')
|
if (newValue.requestId == 'YJC_xujy') setLogList('info', '初始化失败!')
|
||||||
break
|
break
|
||||||
|
case 10550:
|
||||||
|
setLogList('error', str +'时,设备连接异常!')
|
||||||
|
|
||||||
|
emit('update:testStatus', 'error')
|
||||||
|
stopTimeCount()
|
||||||
|
break
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -480,8 +559,9 @@ watch(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (newValue.code == 25007) {
|
if (newValue.code == 25007) {
|
||||||
|
|
||||||
// 设置闪变项目为LOADING状态
|
// 设置闪变项目为LOADING状态
|
||||||
const flickerResultItem = checkResult.find(item => item.code === 'flicker_data')
|
const flickerResultItem = checkResult.find(item => item.code === 'F')
|
||||||
|
|
||||||
if (flickerResultItem) {
|
if (flickerResultItem) {
|
||||||
flickerResultItem.devices.forEach(device => {
|
flickerResultItem.devices.forEach(device => {
|
||||||
@@ -506,13 +586,16 @@ watch(
|
|||||||
temp.devices = [...existingWaveItem.devices] // 保留已设置的devices
|
temp.devices = [...existingWaveItem.devices] // 保留已设置的devices
|
||||||
}
|
}
|
||||||
} // 特殊处理闪变项目 - 如果是25007消息且当前项目是闪变项目,则使用已设置的状态
|
} // 特殊处理闪变项目 - 如果是25007消息且当前项目是闪变项目,则使用已设置的状态
|
||||||
else if (newValue.code == 25007 && item.code === 'PST') {
|
else if (newValue.code == 25007 && item.code === 'F') {
|
||||||
const existingFlickerItem = checkResult.find(checkItem => checkItem.scriptType === 'PST')
|
|
||||||
|
const existingFlickerItem = checkResult.find(checkItem => checkItem.scriptName === '闪变')
|
||||||
|
|
||||||
if (existingFlickerItem) {
|
if (existingFlickerItem) {
|
||||||
temp.devices = [...existingFlickerItem.devices] // 保留已设置的devices
|
temp.devices = [...existingFlickerItem.devices] // 保留已设置的devices
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
// 找到message中所有scriptName与当前item.code匹配的项
|
// 找到message中所有scriptName与当前item.code匹配的项
|
||||||
const matchedDevices = message
|
const matchedDevices = message
|
||||||
.filter((msg: any) => msg.scriptName === item.code)
|
.filter((msg: any) => msg.scriptName === item.code)
|
||||||
@@ -526,7 +609,7 @@ watch(
|
|||||||
temp.devices.push(...matchedDevices)
|
temp.devices.push(...matchedDevices)
|
||||||
|
|
||||||
// 对于未匹配到的设备,也要添加占位符(特别是录波项目)
|
// 对于未匹配到的设备,也要添加占位符(特别是录波项目)
|
||||||
if (item.code === 'wave_data' || item.code === 'PST') {
|
if (item.code === 'wave_data' || item.code === 'F') {
|
||||||
deviceList.forEach(device => {
|
deviceList.forEach(device => {
|
||||||
const isDeviceExist = matchedDevices.some((matchedDevice: any) => matchedDevice.deviceId === device.deviceId)
|
const isDeviceExist = matchedDevices.some((matchedDevice: any) => matchedDevice.deviceId === device.deviceId)
|
||||||
if (!isDeviceExist) {
|
if (!isDeviceExist) {
|
||||||
@@ -535,7 +618,7 @@ watch(
|
|||||||
deviceId: device.deviceId,
|
deviceId: device.deviceId,
|
||||||
deviceName: device.deviceName,
|
deviceName: device.deviceName,
|
||||||
chnResult: new Array(checkStore.chnNumList.length).fill(
|
chnResult: new Array(checkStore.chnNumList.length).fill(
|
||||||
item.code === 'wave_data' ?
|
item.code === 'wave_data' || item.code === 'F' ?
|
||||||
CheckData.ChnCheckResultEnum.UNKNOWN :
|
CheckData.ChnCheckResultEnum.UNKNOWN :
|
||||||
CheckData.ChnCheckResultEnum.UNKNOWN
|
CheckData.ChnCheckResultEnum.UNKNOWN
|
||||||
)
|
)
|
||||||
@@ -561,12 +644,16 @@ watch(
|
|||||||
}
|
}
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
case 25003:
|
case 25003:
|
||||||
setLogList('error', '检测失败!')
|
setLogList('error', '检测失败!')
|
||||||
stopTimeCount()
|
stopTimeCount()
|
||||||
updatePercentage()
|
updatePercentage()
|
||||||
break
|
break
|
||||||
|
case 10550:
|
||||||
|
setLogList('error', '设备连接异常!')
|
||||||
|
stopTimeCount()
|
||||||
|
updatePercentage()
|
||||||
|
break
|
||||||
default:
|
default:
|
||||||
if (newValue.code != 10201) {
|
if (newValue.code != 10201) {
|
||||||
setLogList(newValue.code == 10200 ? 'info' : 'error', newValue.data)
|
setLogList(newValue.code == 10200 ? 'info' : 'error', newValue.data)
|
||||||
@@ -686,7 +773,7 @@ const initScriptData = async () => {
|
|||||||
// 保存脚本数据并设置总数
|
// 保存脚本数据并设置总数
|
||||||
scriptData.push(...temp)
|
scriptData.push(...temp)
|
||||||
checkTotal = scriptData.length
|
checkTotal = scriptData.length
|
||||||
console.log('shul',checkTotal)
|
|
||||||
}
|
}
|
||||||
// 初始化设备列表
|
// 初始化设备列表
|
||||||
const initDeviceList = () => {
|
const initDeviceList = () => {
|
||||||
@@ -696,7 +783,6 @@ const initDeviceList = () => {
|
|||||||
// 初始化检测结果 (详细到通道)
|
// 初始化检测结果 (详细到通道)
|
||||||
const initCheckResult = (defaultValue: CheckData.ChnCheckResultEnum) => {
|
const initCheckResult = (defaultValue: CheckData.ChnCheckResultEnum) => {
|
||||||
let result: CheckData.ScriptChnItem[] = []
|
let result: CheckData.ScriptChnItem[] = []
|
||||||
|
|
||||||
scriptData.forEach(item => {
|
scriptData.forEach(item => {
|
||||||
let temp: CheckData.ScriptChnItem = {
|
let temp: CheckData.ScriptChnItem = {
|
||||||
scriptType: item.id,
|
scriptType: item.id,
|
||||||
@@ -709,7 +795,7 @@ const initCheckResult = (defaultValue: CheckData.ChnCheckResultEnum) => {
|
|||||||
let tempChnResult: CheckData.ChnCheckResultEnum[] = []
|
let tempChnResult: CheckData.ChnCheckResultEnum[] = []
|
||||||
for (let j = 0; j < checkStore.chnNumList.length; j++) {
|
for (let j = 0; j < checkStore.chnNumList.length; j++) {
|
||||||
// 录波项目初始化为UNKNOWN状态,其他项目使用传入的默认值
|
// 录波项目初始化为UNKNOWN状态,其他项目使用传入的默认值
|
||||||
if ((item.code === 'wave_data' || item.code === 'PST')&& checkTotal > 1) {
|
if ((item.code === 'wave_data' || item.code === 'F')&& checkTotal > 1) {
|
||||||
tempChnResult.push(CheckData.ChnCheckResultEnum.UNKNOWN)
|
tempChnResult.push(CheckData.ChnCheckResultEnum.UNKNOWN)
|
||||||
} else {
|
} else {
|
||||||
tempChnResult.push(defaultValue)
|
tempChnResult.push(defaultValue)
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
<template>
|
<template>
|
||||||
<el-dialog
|
<el-dialog
|
||||||
:title="dialogTitle"
|
:title="dialogTitle"
|
||||||
width="1550px"
|
width="90vw"
|
||||||
|
:style="{ maxWidth: '1550px', minWidth: '800px' }"
|
||||||
:model-value="dialogVisible"
|
:model-value="dialogVisible"
|
||||||
:before-close="beforeClose"
|
:before-close="beforeClose"
|
||||||
@close="handleClose"
|
@close="handleClose"
|
||||||
@@ -374,7 +375,7 @@ const handleSubmitFast = async () => {
|
|||||||
})
|
})
|
||||||
preTestStatus.value = 'start'
|
preTestStatus.value = 'start'
|
||||||
if (checkStore.selectTestItems.test) {
|
if (checkStore.selectTestItems.test) {
|
||||||
console.log(111111)
|
|
||||||
|
|
||||||
testRef.value.initializeParameters()
|
testRef.value.initializeParameters()
|
||||||
testRef.value.showTestLog()
|
testRef.value.showTestLog()
|
||||||
@@ -413,12 +414,12 @@ const emit = defineEmits<{
|
|||||||
}>()
|
}>()
|
||||||
|
|
||||||
watch(preTestStatus, function (newValue, oldValue) {
|
watch(preTestStatus, function (newValue, oldValue) {
|
||||||
console.log('预检测状态', newValue, oldValue)
|
|
||||||
ActiveStatue.value = newValue
|
ActiveStatue.value = newValue
|
||||||
})
|
})
|
||||||
|
|
||||||
watch(TestStatus, function (newValue, oldValue) {
|
watch(TestStatus, function (newValue, oldValue) {
|
||||||
console.log('正式检测状态', newValue, oldValue)
|
|
||||||
|
|
||||||
ActiveStatue.value = newValue
|
ActiveStatue.value = newValue
|
||||||
})
|
})
|
||||||
@@ -431,13 +432,11 @@ watch(stepsActiveIndex, function (newValue, oldValue) {
|
|||||||
testRef.value.startTimeCount()
|
testRef.value.startTimeCount()
|
||||||
}, 500)
|
}, 500)
|
||||||
}
|
}
|
||||||
console.log('步骤索引', newValue, oldValue)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
watch(ActiveStatue, function (newValue, oldValue) {
|
watch(ActiveStatue, function (newValue, oldValue) {
|
||||||
console.log('当前步骤状态-----', newValue)
|
|
||||||
console.log('stepsActiveIndex-----', stepsActiveIndex.value)
|
|
||||||
console.log('stepsTotalNum----', stepsTotalNum.value)
|
|
||||||
if (newValue === 'error') {
|
if (newValue === 'error') {
|
||||||
stepsActiveIndex.value = stepsTotalNum.value + 1
|
stepsActiveIndex.value = stepsTotalNum.value + 1
|
||||||
nextStepText.value = '检测失败'
|
nextStepText.value = '检测失败'
|
||||||
@@ -466,7 +465,7 @@ watch(ActiveStatue, function (newValue, oldValue) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
const handleQuit = () => {
|
const handleQuit = () => {
|
||||||
console.log('handleQuit', ActiveStatue.value)
|
|
||||||
if (
|
if (
|
||||||
ActiveStatue.value !== 'success' &&
|
ActiveStatue.value !== 'success' &&
|
||||||
ActiveStatue.value !== 'waiting' &&
|
ActiveStatue.value !== 'waiting' &&
|
||||||
@@ -486,13 +485,13 @@ const handlePause = () => {
|
|||||||
testRef.value?.handlePause()
|
testRef.value?.handlePause()
|
||||||
}
|
}
|
||||||
const sendPause = () => {
|
const sendPause = () => {
|
||||||
console.log('发起暂停请求')
|
|
||||||
|
|
||||||
TestStatus.value = 'paused_ing'
|
TestStatus.value = 'paused_ing'
|
||||||
pauseTest()
|
pauseTest()
|
||||||
}
|
}
|
||||||
const sendResume = () => {
|
const sendResume = () => {
|
||||||
console.log('发起继续检测请求')
|
|
||||||
|
|
||||||
resumeTest({
|
resumeTest({
|
||||||
userPageId: JwtUtil.getLoginName(),
|
userPageId: JwtUtil.getLoginName(),
|
||||||
@@ -509,7 +508,7 @@ const sendResume = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const sendReCheck = () => {
|
const sendReCheck = () => {
|
||||||
console.log('发送重新检测指令')
|
|
||||||
startPreTest({
|
startPreTest({
|
||||||
userPageId: JwtUtil.getLoginName(),
|
userPageId: JwtUtil.getLoginName(),
|
||||||
devIds: checkStore.devices.map(item => item.deviceId),
|
devIds: checkStore.devices.map(item => item.deviceId),
|
||||||
@@ -524,7 +523,7 @@ const sendReCheck = () => {
|
|||||||
checkStore.selectTestItems.test
|
checkStore.selectTestItems.test
|
||||||
]
|
]
|
||||||
}).then(res => {
|
}).then(res => {
|
||||||
console.log(res)
|
|
||||||
if (res.code === 'A001014') {
|
if (res.code === 'A001014') {
|
||||||
ElMessageBox.alert('装置配置异常', '初始化失败', {
|
ElMessageBox.alert('装置配置异常', '初始化失败', {
|
||||||
confirmButtonText: '确定',
|
confirmButtonText: '确定',
|
||||||
@@ -558,17 +557,17 @@ const nextStep = () => {
|
|||||||
stepsActiveIndex.value++
|
stepsActiveIndex.value++
|
||||||
for (let selectTestItemsKey in checkStore.selectTestItems) {
|
for (let selectTestItemsKey in checkStore.selectTestItems) {
|
||||||
if (tempStep == 0 && checkStore.selectTestItems[selectTestItemsKey]) {
|
if (tempStep == 0 && checkStore.selectTestItems[selectTestItemsKey]) {
|
||||||
console.log('selectTestItemsKey1')
|
|
||||||
stepsActiveView.value = idx
|
stepsActiveView.value = idx
|
||||||
stepsActive.value = idx
|
stepsActive.value = idx
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (checkStore.selectTestItems[selectTestItemsKey] && tempStep != 0) {
|
if (checkStore.selectTestItems[selectTestItemsKey] && tempStep != 0) {
|
||||||
console.log('selectTestItemsKey2')
|
|
||||||
tempStep--
|
tempStep--
|
||||||
}
|
}
|
||||||
console.log('selectTestItemsKey3', idx)
|
|
||||||
idx++
|
idx++
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -258,7 +258,7 @@ const handleNodeClick = async (data: any) => {
|
|||||||
currentDesc.value = data.sourceDesc
|
currentDesc.value = data.sourceDesc
|
||||||
scriptType = data.scriptType ?? scriptType
|
scriptType = data.scriptType ?? scriptType
|
||||||
|
|
||||||
console.log('点击左侧树节点触发事件handleNodeClick', checkIndex.value)
|
|
||||||
if (checkIndex.value !== '') {
|
if (checkIndex.value !== '') {
|
||||||
await updateTableData()
|
await updateTableData()
|
||||||
activeTab.value = 'resultTab'
|
activeTab.value = 'resultTab'
|
||||||
@@ -267,7 +267,7 @@ const handleNodeClick = async (data: any) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const handleErrorSysChange = async () => {
|
const handleErrorSysChange = async () => {
|
||||||
console.log('切换误差体系', formContent.errorSysId)
|
|
||||||
changeErrorSystem({
|
changeErrorSystem({
|
||||||
planId: checkStore.plan.id,
|
planId: checkStore.plan.id,
|
||||||
scriptId: checkStore.plan.scriptId,
|
scriptId: checkStore.plan.scriptId,
|
||||||
@@ -303,7 +303,7 @@ watch(
|
|||||||
)
|
)
|
||||||
|
|
||||||
const handleChnNumChange = async () => {
|
const handleChnNumChange = async () => {
|
||||||
console.log('通道号', formContent.chnNum)
|
|
||||||
// 发起请求,查询该测试项的检测结果
|
// 发起请求,查询该测试项的检测结果
|
||||||
const { data: resTreeDataTemp }: { data: CheckData.TreeItem[] } = await getTreeData({
|
const { data: resTreeDataTemp }: { data: CheckData.TreeItem[] } = await getTreeData({
|
||||||
scriptId: checkStore.plan.scriptId,
|
scriptId: checkStore.plan.scriptId,
|
||||||
@@ -330,7 +330,7 @@ watch(currentCheckItem, (newVal, oldVal) => {
|
|||||||
if (newVal.length == 2) {
|
if (newVal.length == 2) {
|
||||||
key += '_' + newVal[1]
|
key += '_' + newVal[1]
|
||||||
}
|
}
|
||||||
console.log('当前检测项', key)
|
|
||||||
doCurrentCheckItemUpdate(key)
|
doCurrentCheckItemUpdate(key)
|
||||||
} else {
|
} else {
|
||||||
activeTab.value = 'resultTab'
|
activeTab.value = 'resultTab'
|
||||||
@@ -358,7 +358,7 @@ const defaultOperate = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const updateTableData = async () => {
|
const updateTableData = async () => {
|
||||||
console.log('左侧树被选中的叶子节点checkIndex', checkIndex.value)
|
|
||||||
if (checkIndex.value !== '') {
|
if (checkIndex.value !== '') {
|
||||||
checkListLevel.length = 0
|
checkListLevel.length = 0
|
||||||
checkResultData.length = 0
|
checkResultData.length = 0
|
||||||
@@ -618,7 +618,7 @@ const setCheckResultData = (data: CheckData.ResCheckResult | null) => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
Object.assign(checkResultData, result)
|
Object.assign(checkResultData, result)
|
||||||
console.log('检测结果', checkResultData)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const exportRawDataHandler = () => {
|
const exportRawDataHandler = () => {
|
||||||
@@ -661,7 +661,7 @@ const setRawData = (data: CheckData.RawDataItem[]) => {
|
|||||||
})
|
})
|
||||||
rawTableData.length = 0
|
rawTableData.length = 0
|
||||||
Object.assign(rawTableData, data)
|
Object.assign(rawTableData, data)
|
||||||
console.log('原始数据', rawTableData)
|
|
||||||
}
|
}
|
||||||
const dataToShow = (num: number): string => {
|
const dataToShow = (num: number): string => {
|
||||||
if (num == null || num == undefined) {
|
if (num == null || num == undefined) {
|
||||||
|
|||||||
@@ -155,7 +155,7 @@ const handleConnectEnd = (params: any) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const handleConnect = (params: any) => {
|
const handleConnect = (params: any) => {
|
||||||
console.log('连接信息:', params)
|
|
||||||
const sourceNode = nodes.value.find(node => node.id === params.source)
|
const sourceNode = nodes.value.find(node => node.id === params.source)
|
||||||
const targetNode = nodes.value.find(node => node.id === params.target)
|
const targetNode = nodes.value.find(node => node.id === params.target)
|
||||||
|
|
||||||
|
|||||||
@@ -233,8 +233,7 @@ watch(testStatus, function (newValue, oldValue) {
|
|||||||
* 3. 表格数据的实时更新
|
* 3. 表格数据的实时更新
|
||||||
*/
|
*/
|
||||||
watch(webMsgSend, function (newValue, oldValue) {
|
watch(webMsgSend, function (newValue, oldValue) {
|
||||||
console.log('webMsgSend---code', newValue.code)
|
|
||||||
console.log('webMsgSend---requestId', newValue.requestId)
|
|
||||||
|
|
||||||
// 只有在非等待状态下才处理WebSocket消息
|
// 只有在非等待状态下才处理WebSocket消息
|
||||||
if (testStatus.value !== 'waiting') {
|
if (testStatus.value !== 'waiting') {
|
||||||
@@ -325,8 +324,7 @@ watch(webMsgSend, function (newValue, oldValue) {
|
|||||||
TableInit();
|
TableInit();
|
||||||
} else {
|
} else {
|
||||||
// ==================== 特定业务消息处理 ====================
|
// ==================== 特定业务消息处理 ====================
|
||||||
console.log('显示东西code', newValue.code)
|
|
||||||
console.log('显示东西requestId', newValue.requestId)
|
|
||||||
switch (newValue.requestId) {
|
switch (newValue.requestId) {
|
||||||
// 处理源通讯校验相关消息
|
// 处理源通讯校验相关消息
|
||||||
case 'yjc_ytxjy':
|
case 'yjc_ytxjy':
|
||||||
@@ -443,7 +441,7 @@ watch(webMsgSend, function (newValue, oldValue) {
|
|||||||
break;
|
break;
|
||||||
// ★★★ 处理系数校准核心业务消息 ★★★
|
// ★★★ 处理系数校准核心业务消息 ★★★
|
||||||
case 'Coefficient_Check':
|
case 'Coefficient_Check':
|
||||||
console.log("Coefficient_Checkactive", active.value);
|
|
||||||
|
|
||||||
// ==================== 第1阶段:大电压/电流系数下装 ====================
|
// ==================== 第1阶段:大电压/电流系数下装 ====================
|
||||||
switch (newValue.operateCode) {
|
switch (newValue.operateCode) {
|
||||||
@@ -523,7 +521,7 @@ watch(webMsgSend, function (newValue, oldValue) {
|
|||||||
switch (newValue.operateCode) {
|
switch (newValue.operateCode) {
|
||||||
case 'DATA_CHNFACTOR$02':
|
case 'DATA_CHNFACTOR$02':
|
||||||
// 接收并更新表格中的系数校准数据
|
// 接收并更新表格中的系数校准数据
|
||||||
console.log('表格', name.value)
|
|
||||||
|
|
||||||
// 遍历所有设备,找到匹配的表格项并更新数据
|
// 遍历所有设备,找到匹配的表格项并更新数据
|
||||||
for (let i = 0; i < name.value.length; i++) {
|
for (let i = 0; i < name.value.length; i++) {
|
||||||
@@ -595,16 +593,15 @@ watch(webMsgSend, function (newValue, oldValue) {
|
|||||||
firstCoefficientVO.bI = newValue.data.bI;
|
firstCoefficientVO.bI = newValue.data.bI;
|
||||||
firstCoefficientVO.cI = newValue.data.cI;
|
firstCoefficientVO.cI = newValue.data.cI;
|
||||||
|
|
||||||
console.log(newValue.data.devName + '对象:', firstCoefficientVO);
|
|
||||||
activeIndex.value++; // 更新活跃索引
|
activeIndex.value++; // 更新活跃索引
|
||||||
} else {
|
} else {
|
||||||
console.log('未找到匹配的' + newValue.data.devName + '对象');
|
//console.log('未找到匹配的' + newValue.data.devName + '对象');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
console.log(newValue.data.devName + '数组为空');
|
//console.log(newValue.data.devName + '数组为空');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
console.log('未找到' + newValue.data.devName + '对应的数组');
|
//console.log('未找到' + newValue.data.devName + '对应的数组');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -655,7 +652,7 @@ watch(webMsgSend, function (newValue, oldValue) {
|
|||||||
* 通知父组件检测失败,重置相关状态
|
* 通知父组件检测失败,重置相关状态
|
||||||
*/
|
*/
|
||||||
const TableInit = () => {
|
const TableInit = () => {
|
||||||
console.log("出错系数检测",active.value);
|
|
||||||
// 通知父组件系数校准失败
|
// 通知父组件系数校准失败
|
||||||
emit('update:testStatus', 'error')
|
emit('update:testStatus', 'error')
|
||||||
}
|
}
|
||||||
@@ -667,7 +664,7 @@ const TableInit = () => {
|
|||||||
* @param desc 描述:'系数下装' | '系数校准'
|
* @param desc 描述:'系数下装' | '系数校准'
|
||||||
*/
|
*/
|
||||||
const tableLoading = (type: string, desc: string) => {
|
const tableLoading = (type: string, desc: string) => {
|
||||||
console.log('转动',channel.value)
|
|
||||||
|
|
||||||
// 遍历所有设备
|
// 遍历所有设备
|
||||||
for (let i = 0; i < channel.value.length; i++) {
|
for (let i = 0; i < channel.value.length; i++) {
|
||||||
@@ -688,7 +685,7 @@ const tableLoading = (type: string, desc: string) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
console.log('不转了')
|
//console.log('不转了')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -868,7 +865,7 @@ const handleSubmit = async () => {
|
|||||||
isButtonDisabled.value = true; // 禁用按钮,防止重复提交
|
isButtonDisabled.value = true; // 禁用按钮,防止重复提交
|
||||||
tableLoading('big', '系数下装') // 开启大幅值系数下装的加载动画
|
tableLoading('big', '系数下装') // 开启大幅值系数下装的加载动画
|
||||||
active.value++; // 步骤进度+1,进入第一个校准阶段
|
active.value++; // 步骤进度+1,进入第一个校准阶段
|
||||||
console.log('开始检测active.value', active.value)
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -389,7 +389,7 @@ watch(webMsgSend, function (newValue, oldValue) {
|
|||||||
ts.value = 'success'
|
ts.value = 'success'
|
||||||
}
|
}
|
||||||
activeIndex.value = 5
|
activeIndex.value = 5
|
||||||
console.log("@@@@", ts.value)
|
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ const resultData = ref([
|
|||||||
])
|
])
|
||||||
|
|
||||||
const handleClick = (row: any) => {
|
const handleClick = (row: any) => {
|
||||||
console.log(111)
|
|
||||||
DataCheckDialogVisible.value = true
|
DataCheckDialogVisible.value = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -468,14 +468,14 @@ const columns = reactive<ColumnProps<Device.ResPqDev>[]>([
|
|||||||
{
|
{
|
||||||
prop: 'recheckNum',
|
prop: 'recheckNum',
|
||||||
label: '检测次数',
|
label: '检测次数',
|
||||||
minWidth: 100,
|
minWidth: 110,
|
||||||
sortable: true,
|
sortable: true,
|
||||||
isShow: modeStore.currentMode != '比对式'
|
isShow: modeStore.currentMode != '比对式'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
prop: 'checkState',
|
prop: 'checkState',
|
||||||
label: '检测状态',
|
label: '检测状态',
|
||||||
minWidth: 100,
|
minWidth: 110,
|
||||||
sortable: true,
|
sortable: true,
|
||||||
isShow: checkStateShow,
|
isShow: checkStateShow,
|
||||||
render: scope => {
|
render: scope => {
|
||||||
@@ -485,7 +485,7 @@ const columns = reactive<ColumnProps<Device.ResPqDev>[]>([
|
|||||||
{
|
{
|
||||||
prop: 'checkResult',
|
prop: 'checkResult',
|
||||||
label: '检测结果',
|
label: '检测结果',
|
||||||
minWidth: 100,
|
minWidth: 110,
|
||||||
sortable: true,
|
sortable: true,
|
||||||
render: scope => {
|
render: scope => {
|
||||||
if (scope.row.checkResult === 0) {
|
if (scope.row.checkResult === 0) {
|
||||||
@@ -501,7 +501,7 @@ const columns = reactive<ColumnProps<Device.ResPqDev>[]>([
|
|||||||
{
|
{
|
||||||
prop: 'reportState',
|
prop: 'reportState',
|
||||||
label: '报告状态',
|
label: '报告状态',
|
||||||
minWidth: 100,
|
minWidth: 110,
|
||||||
sortable: true,
|
sortable: true,
|
||||||
render: scope => {
|
render: scope => {
|
||||||
if (scope.row.reportState === 0) {
|
if (scope.row.reportState === 0) {
|
||||||
@@ -519,7 +519,7 @@ const columns = reactive<ColumnProps<Device.ResPqDev>[]>([
|
|||||||
{
|
{
|
||||||
prop: 'factorCheckResult',
|
prop: 'factorCheckResult',
|
||||||
label: '系数校准结果',
|
label: '系数校准结果',
|
||||||
minWidth: 100,
|
minWidth: 140,
|
||||||
sortable: true,
|
sortable: true,
|
||||||
isShow: factorCheckShow.value && appSceneStore.currentScene === '1',
|
isShow: factorCheckShow.value && appSceneStore.currentScene === '1',
|
||||||
render: scope => {
|
render: scope => {
|
||||||
@@ -595,7 +595,7 @@ const handleRefresh = () => {
|
|||||||
|
|
||||||
// 表格排序
|
// 表格排序
|
||||||
const sortTable = ({ newIndex, oldIndex }: { newIndex?: number; oldIndex?: number }) => {
|
const sortTable = ({ newIndex, oldIndex }: { newIndex?: number; oldIndex?: number }) => {
|
||||||
console.log(newIndex, oldIndex) // 避免未使用参数警告
|
|
||||||
ElMessage.success('修改列表排序成功')
|
ElMessage.success('修改列表排序成功')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ interface User {
|
|||||||
address: string
|
address: string
|
||||||
}
|
}
|
||||||
const handleClick = (row:any) => {
|
const handleClick = (row:any) => {
|
||||||
console.log(111)
|
|
||||||
};
|
};
|
||||||
const tableRowClassName = ({
|
const tableRowClassName = ({
|
||||||
row,
|
row,
|
||||||
|
|||||||
@@ -303,7 +303,7 @@ let count = 0
|
|||||||
|
|
||||||
// 监听WebSocket消息变化,处理各种检测状态和错误
|
// 监听WebSocket消息变化,处理各种检测状态和错误
|
||||||
watch(webMsgSend, function(newValue, oldValue) {
|
watch(webMsgSend, function(newValue, oldValue) {
|
||||||
console.log('webMsgSend', newValue)
|
|
||||||
// 只在非等待状态下处理消息
|
// 只在非等待状态下处理消息
|
||||||
if (testStatus.value !== 'waiting') {
|
if (testStatus.value !== 'waiting') {
|
||||||
// 步骤4:正式检测阶段的消息处理
|
// 步骤4:正式检测阶段的消息处理
|
||||||
@@ -637,7 +637,7 @@ watch(webMsgSend, function(newValue, oldValue) {
|
|||||||
break
|
break
|
||||||
// 检测结束
|
// 检测结束
|
||||||
case 'Quit':
|
case 'Quit':
|
||||||
console.log('检测结束')
|
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1113,7 +1113,7 @@ const pauseSuccessCallback = () => {
|
|||||||
log: `${new Date().toLocaleString()}:暂停检测`,
|
log: `${new Date().toLocaleString()}:暂停检测`,
|
||||||
})
|
})
|
||||||
stopTimeCount()
|
stopTimeCount()
|
||||||
console.log('暂停中')
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1123,7 +1123,7 @@ const handleResumeTest = () => {
|
|||||||
startData.value = new Date()
|
startData.value = new Date()
|
||||||
testLogList.push({ type: 'info', log: `${new Date().toLocaleString()}:开始重新检测!` })
|
testLogList.push({ type: 'info', log: `${new Date().toLocaleString()}:开始重新检测!` })
|
||||||
resumeTimeCount()
|
resumeTimeCount()
|
||||||
console.log('开始继续检测')
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ========== 测试项索引管理函数 ==========
|
// ========== 测试项索引管理函数 ==========
|
||||||
|
|||||||
@@ -325,7 +325,7 @@ const handleSubmitFast = () => {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('handleSubmit', stepsActive.value, TestStatus.value)
|
|
||||||
|
|
||||||
// 根据当前激活的步骤执行对应的检测逻辑
|
// 根据当前激活的步骤执行对应的检测逻辑
|
||||||
switch (stepsActive.value) {
|
switch (stepsActive.value) {
|
||||||
@@ -442,28 +442,28 @@ const emit = defineEmits<{
|
|||||||
// ====================== 状态监听器 ======================
|
// ====================== 状态监听器 ======================
|
||||||
// 监听各个检测步骤的状态变化,并同步到总体状态
|
// 监听各个检测步骤的状态变化,并同步到总体状态
|
||||||
watch(preTestStatus, function (newValue, oldValue) {
|
watch(preTestStatus, function (newValue, oldValue) {
|
||||||
console.log('预检测状态变化:', newValue, oldValue)
|
|
||||||
ActiveStatue.value = newValue // 同步到总体状态
|
ActiveStatue.value = newValue // 同步到总体状态
|
||||||
})
|
})
|
||||||
|
|
||||||
watch(timeTestStatus, function (newValue, oldValue) {
|
watch(timeTestStatus, function (newValue, oldValue) {
|
||||||
console.log('守时检测状态变化:', newValue, oldValue)
|
|
||||||
ActiveStatue.value = newValue // 同步到总体状态
|
ActiveStatue.value = newValue // 同步到总体状态
|
||||||
})
|
})
|
||||||
|
|
||||||
watch(channelsTestStatus, function (newValue, oldValue) {
|
watch(channelsTestStatus, function (newValue, oldValue) {
|
||||||
console.log('系数校准状态变化:', newValue, oldValue)
|
|
||||||
ActiveStatue.value = newValue // 同步到总体状态
|
ActiveStatue.value = newValue // 同步到总体状态
|
||||||
})
|
})
|
||||||
|
|
||||||
watch(TestStatus, function (newValue, oldValue) {
|
watch(TestStatus, function (newValue, oldValue) {
|
||||||
console.log('正式检测状态变化:', newValue, oldValue)
|
|
||||||
ActiveStatue.value = newValue // 同步到总体状态
|
ActiveStatue.value = newValue // 同步到总体状态
|
||||||
})
|
})
|
||||||
|
|
||||||
// 监听总体状态变化,处理步骤切换和错误状态
|
// 监听总体状态变化,处理步骤切换和错误状态
|
||||||
watch(ActiveStatue, function (newValue, oldValue) {
|
watch(ActiveStatue, function (newValue, oldValue) {
|
||||||
console.log('总体状态变化:', newValue, oldValue)
|
|
||||||
|
|
||||||
// 处理错误状态
|
// 处理错误状态
|
||||||
if (newValue === 'error') {
|
if (newValue === 'error') {
|
||||||
@@ -474,21 +474,21 @@ watch(ActiveStatue, function (newValue, oldValue) {
|
|||||||
// 处理成功完成状态(已到达最后一个检测步骤)
|
// 处理成功完成状态(已到达最后一个检测步骤)
|
||||||
if (newValue === 'success' && stepsActiveIndex.value === stepsTotalNum.value - 1) {
|
if (newValue === 'success' && stepsActiveIndex.value === stepsTotalNum.value - 1) {
|
||||||
stepsActiveIndex.value += 2 // 跳到完成状态
|
stepsActiveIndex.value += 2 // 跳到完成状态
|
||||||
console.log('success')
|
|
||||||
nextStepText.value = '检测完成'
|
nextStepText.value = '检测完成'
|
||||||
}
|
}
|
||||||
|
|
||||||
// 处理连接超时状态
|
// 处理连接超时状态
|
||||||
if (newValue === 'connect_timeout') {
|
if (newValue === 'connect_timeout') {
|
||||||
stepsActiveIndex.value += 2 // 跳过当前步骤
|
stepsActiveIndex.value += 2 // 跳过当前步骤
|
||||||
console.log('connect_timeout')
|
|
||||||
nextStepText.value = '连接超时'
|
nextStepText.value = '连接超时'
|
||||||
}
|
}
|
||||||
|
|
||||||
// 处理暂停超时状态
|
// 处理暂停超时状态
|
||||||
if (newValue === 'pause_timeout') {
|
if (newValue === 'pause_timeout') {
|
||||||
stepsActiveIndex.value += 2 // 跳过当前步骤
|
stepsActiveIndex.value += 2 // 跳过当前步骤
|
||||||
console.log('pause_timeout')
|
|
||||||
nextStepText.value = '暂停超时'
|
nextStepText.value = '暂停超时'
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -504,7 +504,7 @@ watch(ActiveStatue, function (newValue, oldValue) {
|
|||||||
* 处理退出检测
|
* 处理退出检测
|
||||||
*/
|
*/
|
||||||
const handleQuit = () => {
|
const handleQuit = () => {
|
||||||
console.log('handleQuit', ActiveStatue.value)
|
|
||||||
|
|
||||||
// 可以直接关闭的安全状态:未检测、检测完成、检测失败或异常情况
|
// 可以直接关闭的安全状态:未检测、检测完成、检测失败或异常情况
|
||||||
const safeExitStates = [
|
const safeExitStates = [
|
||||||
@@ -543,7 +543,7 @@ const handlePause = () => {
|
|||||||
* 发送暂停指令
|
* 发送暂停指令
|
||||||
*/
|
*/
|
||||||
const sendPause = () => {
|
const sendPause = () => {
|
||||||
console.log('发起暂停请求')
|
|
||||||
|
|
||||||
TestStatus.value = 'paused_ing' // 设置为暂停中状态
|
TestStatus.value = 'paused_ing' // 设置为暂停中状态
|
||||||
pauseTest() // 调用暂停API
|
pauseTest() // 调用暂停API
|
||||||
@@ -553,7 +553,7 @@ const sendPause = () => {
|
|||||||
* 发送继续检测指令
|
* 发送继续检测指令
|
||||||
*/
|
*/
|
||||||
const sendResume = () => {
|
const sendResume = () => {
|
||||||
console.log('发起继续检测请求')
|
|
||||||
// 调用继续检测API
|
// 调用继续检测API
|
||||||
resumeTest({
|
resumeTest({
|
||||||
userPageId: JwtUtil.getLoginName(),
|
userPageId: JwtUtil.getLoginName(),
|
||||||
|
|||||||
@@ -268,7 +268,7 @@ function addMillisecondsToDate(dateString: string, millisecondsToAdd: number): D
|
|||||||
|
|
||||||
watch(activeIndex, function (newValue, oldValue) {
|
watch(activeIndex, function (newValue, oldValue) {
|
||||||
|
|
||||||
console.log(activeIndex.value,111,stepsIndex.value,222)
|
|
||||||
|
|
||||||
if (activeIndex.value === 1) {
|
if (activeIndex.value === 1) {
|
||||||
startTime.value = formatDateTime(new Date());
|
startTime.value = formatDateTime(new Date());
|
||||||
|
|||||||
@@ -1,96 +1,21 @@
|
|||||||
<template>
|
<template>
|
||||||
<!-- style=" height: calc(100vh - 120px) !important;" -->
|
<div class="homeView">
|
||||||
<div class="homeView">
|
<model v-if="!authStore.showMenuFlag"></model>
|
||||||
<model v-if="!authStore.showMenuFlag"></model>
|
<dashboard v-if="authStore.showMenuFlag"></dashboard>
|
||||||
<dashboard v-if="authStore.showMenuFlag"></dashboard>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- <div class="main">
|
|
||||||
<div class="main_container">
|
|
||||||
<div class="mode" v-for="(item, index) in modeList" :key="index">
|
|
||||||
<div class="mode_top">
|
|
||||||
<div class="mode_name">
|
|
||||||
<p>
|
|
||||||
{{ item.name }}
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
<div class="test_button">
|
|
||||||
<el-button
|
|
||||||
size="small"
|
|
||||||
dictType="primary"
|
|
||||||
@click="handelOpen(item.isActive)"
|
|
||||||
>进入检测</el-button
|
|
||||||
>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="mode_img">
|
|
||||||
<img :src="item.img" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div> -->
|
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { useRouter } from "vue-router";
|
import { useAuthStore } from '@/stores/modules/auth'
|
||||||
import { ElMessage } from "element-plus";
|
|
||||||
import { useAuthStore } from "@/stores/modules/auth";
|
|
||||||
|
|
||||||
import model from "./tabs/model.vue";
|
import model from './tabs/model.vue'
|
||||||
import dashboard from "./tabs/dashboard.vue";
|
import dashboard from './tabs/dashboard.vue'
|
||||||
import { onMounted, ref } from "vue";
|
|
||||||
// defineOptions({
|
|
||||||
// name: 'home'
|
|
||||||
// })
|
|
||||||
const authStore = useAuthStore();
|
|
||||||
|
|
||||||
const activeIndex = ref("1-1");
|
const authStore = useAuthStore()
|
||||||
const router = useRouter();
|
|
||||||
const modeList = [
|
|
||||||
{
|
|
||||||
name: "模拟式模式",
|
|
||||||
code:"模拟式",
|
|
||||||
img: new URL('/src/assets/images/dashboard/1.svg', import.meta.url).href,
|
|
||||||
isActive: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "数字式模式",
|
|
||||||
code:"数字式",
|
|
||||||
subName: "启用数字检测计划",
|
|
||||||
img: new URL('/src/assets/images/dashboard/2.svg', import.meta.url).href,
|
|
||||||
isActive: false,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "比对式模式",
|
|
||||||
code:"比对式",
|
|
||||||
subName: "启用比对式检测计划",
|
|
||||||
img: new URL('/src/assets/images/dashboard/3.svg', import.meta.url).href,
|
|
||||||
isActive: false,
|
|
||||||
},
|
|
||||||
];
|
|
||||||
const handelOpen = async (isActive: any) => {
|
|
||||||
await authStore.setShowMenu();
|
|
||||||
return;
|
|
||||||
// if (isActive) {
|
|
||||||
// router.push({ path: "/static" });
|
|
||||||
// } else {
|
|
||||||
// ElMessage({
|
|
||||||
// message: "当前模式未配置",
|
|
||||||
// type: "warning",
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
};
|
|
||||||
const handleSelect = (key: string, keyPath: string[]) => {
|
|
||||||
//console.log(key, keyPath);
|
|
||||||
};
|
|
||||||
onMounted(() => {
|
|
||||||
//console.log(111);
|
|
||||||
|
|
||||||
});
|
|
||||||
</script>
|
</script>
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
.homeView{
|
.homeView {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
// height: calc(100vh - 120px);
|
// height: calc(100vh - 120px);
|
||||||
height: 100%;
|
height: 100%;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -1,288 +1,264 @@
|
|||||||
<!-- 模式切换页面 -->
|
<!-- 模式切换页面 -->
|
||||||
<template>
|
<template>
|
||||||
<div class="main_container box">
|
<div class="main_container box">
|
||||||
<!-- :style="{
|
<el-carousel :interval="5000" type="card" style="width: 60%; margin-left: 20%; height: 70%">
|
||||||
height: authStore?.showMenuFlag
|
<el-carousel-item
|
||||||
? 'calc(100vh - 165px)'
|
class="mode"
|
||||||
: 'calc(100vh - 125px)',
|
:class="{ modeBG: index != 0 }"
|
||||||
}" -->
|
v-for="(item, index) in modeList"
|
||||||
|
:key="index"
|
||||||
|
>
|
||||||
|
<div class="mode_top">
|
||||||
|
<div class="mode_name">
|
||||||
|
{{ item.name }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<el-carousel :interval="5000" type="card" style="width: 60%;margin-left: 20%;height: 70%;">
|
<div class="mode_img">
|
||||||
<el-carousel-item class="mode" :class="{ modeBG: index != 0 }" v-for="(item, index) in modeList" :key="index">
|
<img :src="item.img" />
|
||||||
|
</div>
|
||||||
<div class="mode_top">
|
<div class="test_button">
|
||||||
<div class="mode_name">
|
<el-button size="large" type="primary" @click="handelOpen(item)" :disabled="!item.activated">
|
||||||
{{ item.name }}
|
进入检测
|
||||||
</div>
|
</el-button>
|
||||||
</div>
|
</div>
|
||||||
|
</el-carousel-item>
|
||||||
<div class="mode_img">
|
</el-carousel>
|
||||||
<img :src="item.img" />
|
</div>
|
||||||
</div>
|
|
||||||
<div class="test_button">
|
|
||||||
<el-button size="large" type="primary" @click="handelOpen(item)"
|
|
||||||
:disabled="item.isActive == false">进入检测</el-button>
|
|
||||||
</div>
|
|
||||||
</el-carousel-item>
|
|
||||||
</el-carousel>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<!-- <div class="mode" :class="{ modeBG: index != 0 }" v-for="(item, index) in modeList" :key="index">
|
|
||||||
<div class="mode_top">
|
|
||||||
<div class="mode_name">
|
|
||||||
<p>
|
|
||||||
{{ item.name }}
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
<div class="test_button">
|
|
||||||
<el-button size="small" type="primary" @click="handelOpen(item)"
|
|
||||||
:disabled="item.isActive == false">进入检测</el-button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="mode_img">
|
|
||||||
<img :src="item.img" />
|
|
||||||
</div>
|
|
||||||
</div> -->
|
|
||||||
</div>
|
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { useRouter } from "vue-router";
|
import { useAuthStore } from '@/stores/modules/auth'
|
||||||
import { ElMessage } from "element-plus";
|
import { useAppSceneStore, useModeStore } from '@/stores/modules/mode' // 引入模式 store
|
||||||
import { useAuthStore } from "@/stores/modules/auth";
|
import { getCurrentScene } from '@/api/user/login'
|
||||||
import { useModeStore, useAppSceneStore } from "@/stores/modules/mode"; // 引入模式 store
|
|
||||||
import { ref } from "vue";
|
const authStore = useAuthStore()
|
||||||
import {getCurrentScene} from "@/api/user/login";
|
const modeStore = useModeStore() // 使用模式 store
|
||||||
|
const AppSceneStore = useAppSceneStore()
|
||||||
|
const activateInfo = authStore.activateInfo
|
||||||
|
const isActivateOpen = import.meta.env.VITE_ACTIVATE_OPEN
|
||||||
|
|
||||||
const authStore = useAuthStore();
|
|
||||||
const modeStore = useModeStore(); // 使用模式 store
|
|
||||||
const AppSceneStore = useAppSceneStore();
|
|
||||||
const activeIndex = ref("1-1");
|
|
||||||
const router = useRouter();
|
|
||||||
const modeList = [
|
const modeList = [
|
||||||
{
|
{
|
||||||
name: "模拟式模块",
|
name: '模拟式模块',
|
||||||
code: "模拟式",
|
code: '模拟式',
|
||||||
subName: "未启用模拟式检测计划",
|
subName: '未启用模拟式检测计划',
|
||||||
img: new URL('/src/assets/images/dashboard/1.svg', import.meta.url).href,
|
img: new URL('/src/assets/images/dashboard/1.svg', import.meta.url).href,
|
||||||
isActive: true,
|
activated:
|
||||||
},
|
isActivateOpen === 'true'
|
||||||
{
|
? activateInfo.simulate.apply === 1 && activateInfo.simulate.permanently === 1
|
||||||
name: "数字式模块",
|
: true
|
||||||
code: "数字式",
|
},
|
||||||
subName: "启用数字检测计划",
|
{
|
||||||
img: new URL('/src/assets/images/dashboard/2.svg', import.meta.url).href,
|
name: '数字式模块',
|
||||||
isActive: true,
|
code: '数字式',
|
||||||
},
|
subName: '启用数字检测计划',
|
||||||
{
|
img: new URL('/src/assets/images/dashboard/2.svg', import.meta.url).href,
|
||||||
name: "比对式模块",
|
activated:
|
||||||
code: "比对式",
|
isActivateOpen === 'true'
|
||||||
subName: "启用比对式检测计划",
|
? activateInfo.digital.apply === 1 && activateInfo.digital.permanently === 1
|
||||||
img: new URL('/src/assets/images/dashboard/3.svg', import.meta.url).href,
|
: true
|
||||||
isActive: true,
|
},
|
||||||
},
|
{
|
||||||
];
|
name: '比对式模块',
|
||||||
|
code: '比对式',
|
||||||
|
subName: '启用比对式检测计划',
|
||||||
|
img: new URL('/src/assets/images/dashboard/3.svg', import.meta.url).href,
|
||||||
|
activated:
|
||||||
|
isActivateOpen === 'true'
|
||||||
|
? activateInfo.contrast.apply === 1 && activateInfo.contrast.permanently === 1
|
||||||
|
: true
|
||||||
|
}
|
||||||
|
]
|
||||||
const handelOpen = async (item: any) => {
|
const handelOpen = async (item: any) => {
|
||||||
modeStore.setCurrentMode(item.code); // 将模式code存入 store
|
if (!item.activated) {
|
||||||
const {data:scene} = await getCurrentScene(); // 获取当前场景
|
ElMessage.warning(`${item.name}未激活`)
|
||||||
// AppSceneStore.setCurrentMode(scene+'');//0:省级平台,1:设备出厂,2:研发自测
|
return
|
||||||
AppSceneStore.setCurrentMode(scene+'');//0:省级平台,1:设备出厂,2:研发自测
|
}
|
||||||
await authStore.setShowMenu();
|
modeStore.setCurrentMode(item.code) // 将模式code存入 store
|
||||||
await authStore.getAuthMenuList();
|
const { data: scene } = await getCurrentScene() // 获取当前场景
|
||||||
return;
|
AppSceneStore.setCurrentMode(scene + '') //0:省级平台,1:设备出厂,2:研发自测
|
||||||
// if (isActive) {
|
await authStore.setShowMenu()
|
||||||
// router.push({ path: "/static" });
|
await authStore.getAuthMenuList()
|
||||||
// } else {
|
return
|
||||||
// ElMessage({
|
}
|
||||||
// message: "当前模式未配置",
|
|
||||||
// type: "warning",
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
};
|
|
||||||
const handleSelect = (key: string, keyPath: string[]) => {
|
const handleSelect = (key: string, keyPath: string[]) => {
|
||||||
console.log(key, keyPath);
|
|
||||||
};
|
}
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
console.log();
|
|
||||||
});
|
})
|
||||||
</script>
|
</script>
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
.box {
|
.box {
|
||||||
background: #ededed;
|
background: #ededed;
|
||||||
// background-image: url("/src/assets/images/dashboard/DT.jpg");
|
// background-image: url("/src/assets/images/dashboard/DT.jpg");
|
||||||
// /* 背景图垂直、水平均居中 */
|
// /* 背景图垂直、水平均居中 */
|
||||||
// // background-position: center center;
|
// // background-position: center center;
|
||||||
// /* 背景图不平铺 */
|
// /* 背景图不平铺 */
|
||||||
// background-repeat: no-repeat;
|
// background-repeat: no-repeat;
|
||||||
// /* 当内容高度大于图片高度时,背景图像的位置相对于viewport固定 */
|
// /* 当内容高度大于图片高度时,背景图像的位置相对于viewport固定 */
|
||||||
// background-attachment: fixed;
|
// background-attachment: fixed;
|
||||||
// /* 让背景图基于容器大小伸缩 */
|
// /* 让背景图基于容器大小伸缩 */
|
||||||
// background-size: cover;
|
// background-size: cover;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.main_container {
|
.main_container {
|
||||||
|
width: 100%;
|
||||||
|
// height: calc(100vh - 165px);
|
||||||
|
height: 100%;
|
||||||
|
// overflow-y: auto;
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
align-items: center;
|
||||||
|
|
||||||
width: 100%;
|
.mode {
|
||||||
// height: calc(100vh - 165px);
|
height: 99.5% !important;
|
||||||
height: 100%;
|
border: 1px solid #eee;
|
||||||
// overflow-y: auto;
|
border-radius: 6px;
|
||||||
display: flex;
|
background: linear-gradient(
|
||||||
justify-content: space-between;
|
180deg,
|
||||||
flex-wrap: wrap;
|
rgba(0, 153, 255, 1) 0%,
|
||||||
align-items: center;
|
rgba(0, 153, 255, 1) 0%,
|
||||||
|
rgba(0, 102, 255, 1) 65%,
|
||||||
|
rgba(0, 51, 255, 1) 100%,
|
||||||
|
rgba(0, 51, 255, 1) 100%
|
||||||
|
);
|
||||||
|
|
||||||
.mode {
|
position: absolute;
|
||||||
|
|
||||||
height: 99.5% !important;
|
// padding: 40px 0;
|
||||||
border: 1px solid #eee;
|
.mode_top {
|
||||||
border-radius: 6px;
|
width: 100%;
|
||||||
background: linear-gradient(180deg,
|
height: 40px;
|
||||||
rgba(0, 153, 255, 1) 0%,
|
display: flex;
|
||||||
rgba(0, 153, 255, 1) 0%,
|
justify-content: center;
|
||||||
rgba(0, 102, 255, 1) 65%,
|
align-items: center;
|
||||||
rgba(0, 51, 255, 1) 100%,
|
background: #008aff;
|
||||||
rgba(0, 51, 255, 1) 100%);
|
border-radius: 6px 6px 0 0;
|
||||||
|
|
||||||
position: absolute;
|
.mode_name {
|
||||||
|
width: 100%;
|
||||||
|
height: 40px;
|
||||||
|
font-family: '微软雅黑 Bold', '微软雅黑', '微软雅黑', sans-serif;
|
||||||
|
font-weight: 700;
|
||||||
|
font-style: normal;
|
||||||
|
font-size: 20px;
|
||||||
|
color: #ffffff;
|
||||||
|
text-align: center;
|
||||||
|
line-height: 40px;
|
||||||
|
padding-left: 10px;
|
||||||
|
// margin-top: 20px;
|
||||||
|
|
||||||
|
.mode_subName {
|
||||||
|
font-family: '微软雅黑', sans-serif;
|
||||||
|
font-weight: 400;
|
||||||
|
font-style: normal;
|
||||||
|
font-size: 12px;
|
||||||
|
color: #ffffff;
|
||||||
|
line-height: 40px;
|
||||||
|
text-align: center;
|
||||||
|
padding: 5px 0 0 10px;
|
||||||
|
// margin-top: 10px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// padding: 40px 0;
|
.test_button {
|
||||||
.mode_top {
|
display: flex;
|
||||||
width: 100%;
|
text-align: center;
|
||||||
height: 40px;
|
width: 100%;
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: center;
|
align-items: center;
|
||||||
align-items: center;
|
justify-content: flex-end;
|
||||||
background: #008aff;
|
padding-right: 5px;
|
||||||
border-radius: 6px 6px 0 0;
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.mode_name {
|
.mode_img {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 40px;
|
height: auto;
|
||||||
font-family: "微软雅黑 Bold", "微软雅黑", "微软雅黑", sans-serif;
|
display: flex;
|
||||||
font-weight: 700;
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
// padding: 30px 0 50px;
|
||||||
|
margin-top: 100px;
|
||||||
|
// margin-bottom: 100px;
|
||||||
|
|
||||||
|
img:nth-child(1) {
|
||||||
|
width: 60%;
|
||||||
|
height: auto;
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
img:nth-child(2) {
|
||||||
|
width: 70%;
|
||||||
|
height: auto;
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
img:nth-child(3) {
|
||||||
|
width: 60%;
|
||||||
|
height: auto;
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.mode_test {
|
||||||
|
width: 100%;
|
||||||
|
height: 40px;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
|
||||||
|
.test_button:hover {
|
||||||
|
background: rgba(0, 0, 0, 0.2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.test_button {
|
||||||
|
position: absolute;
|
||||||
|
bottom: 30px;
|
||||||
|
left: 50%;
|
||||||
|
transform: translateX(-50%);
|
||||||
|
border-radius: 5px;
|
||||||
|
font-family: '微软雅黑', sans-serif;
|
||||||
|
font-weight: 400;
|
||||||
font-style: normal;
|
font-style: normal;
|
||||||
font-size: 20px;
|
color: #fff;
|
||||||
color: #ffffff;
|
|
||||||
text-align: center;
|
text-align: center;
|
||||||
line-height: 40px;
|
line-height: 40px;
|
||||||
padding-left: 10px;
|
cursor: pointer;
|
||||||
// margin-top: 20px;
|
}
|
||||||
|
|
||||||
.mode_subName {
|
.mode:nth-child(3n + 3) {
|
||||||
font-family: "微软雅黑", sans-serif;
|
background: linear-gradient(
|
||||||
font-weight: 400;
|
180deg,
|
||||||
font-style: normal;
|
rgba(0, 153, 255, 1) 0%,
|
||||||
font-size: 12px;
|
rgba(0, 153, 255, 1) 0%,
|
||||||
color: #ffffff;
|
rgba(0, 102, 255, 1) 39%,
|
||||||
line-height: 40px;
|
rgba(102, 51, 204, 1) 100%,
|
||||||
text-align: center;
|
rgba(102, 51, 204, 1) 100%
|
||||||
padding: 5px 0 0 10px;
|
);
|
||||||
// margin-top: 10px;
|
}
|
||||||
|
|
||||||
|
.mode_off {
|
||||||
|
.mode_name,
|
||||||
|
.mode_subName,
|
||||||
|
.test_button {
|
||||||
|
color: #fff !important;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
.test_button {
|
.test_button:hover {
|
||||||
display: flex;
|
// background: rgba(0, 0, 0, 0.2) !important;
|
||||||
text-align: center;
|
cursor: pointer;
|
||||||
width: 100%;
|
}
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: flex-end;
|
|
||||||
padding-right: 5px;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.mode_img {
|
|
||||||
width: 100%;
|
|
||||||
height: auto;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
// padding: 30px 0 50px;
|
|
||||||
margin-top: 100px;
|
|
||||||
// margin-bottom: 100px;
|
|
||||||
|
|
||||||
img:nth-child(1) {
|
|
||||||
width: 60%;
|
|
||||||
height: auto;
|
|
||||||
display: block;
|
|
||||||
}
|
|
||||||
|
|
||||||
img:nth-child(2) {
|
|
||||||
width: 70%;
|
|
||||||
height: auto;
|
|
||||||
display: block;
|
|
||||||
}
|
|
||||||
|
|
||||||
img:nth-child(3) {
|
|
||||||
width: 60%;
|
|
||||||
height: auto;
|
|
||||||
display: block;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.mode_test {
|
|
||||||
width: 100%;
|
|
||||||
height: 40px;
|
|
||||||
display: flex;
|
|
||||||
justify-content: center;
|
|
||||||
margin-bottom: 20px;
|
|
||||||
|
|
||||||
|
|
||||||
.test_button:hover {
|
|
||||||
background: rgba(0, 0, 0, 0.2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.test_button {
|
|
||||||
position: absolute;
|
|
||||||
bottom: 30px;
|
|
||||||
left: 50%;
|
|
||||||
transform: translateX(-50%);
|
|
||||||
border-radius: 5px;
|
|
||||||
font-family: "微软雅黑", sans-serif;
|
|
||||||
font-weight: 400;
|
|
||||||
font-style: normal;
|
|
||||||
color: #fff;
|
|
||||||
text-align: center;
|
|
||||||
line-height: 40px;
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
.mode:nth-child(3n + 3) {
|
|
||||||
background: linear-gradient(180deg,
|
|
||||||
rgba(0, 153, 255, 1) 0%,
|
|
||||||
rgba(0, 153, 255, 1) 0%,
|
|
||||||
rgba(0, 102, 255, 1) 39%,
|
|
||||||
rgba(102, 51, 204, 1) 100%,
|
|
||||||
rgba(102, 51, 204, 1) 100%);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
.mode_off {
|
|
||||||
|
|
||||||
.mode_name,
|
|
||||||
.mode_subName,
|
|
||||||
.test_button {
|
|
||||||
color: #fff !important;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
.test_button:hover {
|
|
||||||
// background: rgba(0, 0, 0, 0.2) !important;
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
:deep(.el-sub-menu__title) {
|
:deep(.el-sub-menu__title) {
|
||||||
border-bottom: 0 !important;
|
border-bottom: 0 !important;
|
||||||
outline: none !important;
|
outline: none !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
// .modeBG {
|
// .modeBG {
|
||||||
@@ -297,13 +273,12 @@ onMounted(() => {
|
|||||||
// ;
|
// ;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
|
||||||
// }
|
// }
|
||||||
:deep(.el-carousel__container) {
|
:deep(.el-carousel__container) {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
:deep(.el-carousel__item) {
|
:deep(.el-carousel__item) {
|
||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -96,12 +96,20 @@ const login = (formEl: FormInstance | undefined) => {
|
|||||||
username: forge.util.encode64(loginForm.username),
|
username: forge.util.encode64(loginForm.username),
|
||||||
password: encryptPassword(loginForm.password)
|
password: encryptPassword(loginForm.password)
|
||||||
})
|
})
|
||||||
|
ElNotification({
|
||||||
|
title: getTimeState(),
|
||||||
|
message: '登录成功',
|
||||||
|
type: 'success',
|
||||||
|
duration: 3000
|
||||||
|
})
|
||||||
userStore.setAccessToken(data.accessToken)
|
userStore.setAccessToken(data.accessToken)
|
||||||
userStore.setRefreshToken(data.refreshToken)
|
userStore.setRefreshToken(data.refreshToken)
|
||||||
userStore.setUserInfo(data.userInfo)
|
userStore.setUserInfo(data.userInfo)
|
||||||
if (loginForm.checked) {
|
if (loginForm.checked) {
|
||||||
userStore.setExp(Date.now() + 1000 * 60 * 60 * 24 * 30)
|
userStore.setExp(Date.now() + 1000 * 60 * 60 * 24 * 30)
|
||||||
}
|
}
|
||||||
|
// 设置激活信息
|
||||||
|
await authStore.setActivateInfo()
|
||||||
const response = await getDictList()
|
const response = await getDictList()
|
||||||
const dictData = response.data as unknown as Dict[]
|
const dictData = response.data as unknown as Dict[]
|
||||||
await dictStore.initDictData(dictData)
|
await dictStore.initDictData(dictData)
|
||||||
@@ -109,19 +117,12 @@ const login = (formEl: FormInstance | undefined) => {
|
|||||||
await initDynamicRouter()
|
await initDynamicRouter()
|
||||||
|
|
||||||
// 3.清空 tabs、keepAlive 数据
|
// 3.清空 tabs、keepAlive 数据
|
||||||
tabsStore.setTabs([])
|
await tabsStore.setTabs([])
|
||||||
keepAliveStore.setKeepAliveName([])
|
await keepAliveStore.setKeepAliveName([])
|
||||||
|
// 登录默认不显示菜单和导航栏
|
||||||
// 4.跳转到首页
|
await authStore.resetAuthStore()
|
||||||
router.push(HOME_URL)
|
// 跳转到首页
|
||||||
// 5.登录默认不显示菜单和导航栏
|
await router.push(HOME_URL)
|
||||||
authStore.resetAuthStore()
|
|
||||||
ElNotification({
|
|
||||||
title: getTimeState(),
|
|
||||||
message: '登录成功',
|
|
||||||
type: 'success',
|
|
||||||
duration: 3000
|
|
||||||
})
|
|
||||||
} finally {
|
} finally {
|
||||||
loading.value = false
|
loading.value = false
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -299,7 +299,7 @@ watch(
|
|||||||
if (props.formControl.scriptId != '') {
|
if (props.formControl.scriptId != '') {
|
||||||
nextTick(async () => {
|
nextTick(async () => {
|
||||||
await getTree()
|
await getTree()
|
||||||
console.log('props.formControl.scriptId')
|
|
||||||
treeRef.value.checkTree()
|
treeRef.value.checkTree()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -129,11 +129,9 @@ function findFirstLeafNode(node: any): any {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const checkTree = () => {
|
const checkTree = () => {
|
||||||
console.log('checkTree11')
|
|
||||||
console.log('checkTree22',props.treeData.length)
|
|
||||||
console.log('checkTree33',treeRef.value)
|
|
||||||
if (props.treeData.length > 0 && treeRef.value) {
|
if (props.treeData.length > 0 && treeRef.value) {
|
||||||
console.log('checkTree44')
|
|
||||||
const firstNode = props.treeData[0];
|
const firstNode = props.treeData[0];
|
||||||
const firstLeafNode = findFirstLeafNode(firstNode);
|
const firstLeafNode = findFirstLeafNode(firstNode);
|
||||||
const firstLeafNodeId = firstLeafNode.id;
|
const firstLeafNodeId = firstLeafNode.id;
|
||||||
@@ -143,7 +141,7 @@ const checkTree = () => {
|
|||||||
|
|
||||||
// 确保在组件挂载后也执行一次
|
// 确保在组件挂载后也执行一次
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
console.log('onMounted',props.treeData);
|
|
||||||
nextTick(() => {
|
nextTick(() => {
|
||||||
checkTree()
|
checkTree()
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -184,7 +184,7 @@ onMounted(async () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
watch(webMsgSend, function (newValue, oldValue) {
|
watch(webMsgSend, function (newValue, oldValue) {
|
||||||
console.log('webMsgSend:', newValue)
|
|
||||||
if (newValue.requestId.includes('formal_real&&') && newValue.operateCode === 'OPER_GATHER') {
|
if (newValue.requestId.includes('formal_real&&') && newValue.operateCode === 'OPER_GATHER') {
|
||||||
if (newValue.code === 10200) {
|
if (newValue.code === 10200) {
|
||||||
ElMessage.success('启动成功!')
|
ElMessage.success('启动成功!')
|
||||||
@@ -195,7 +195,7 @@ watch(webMsgSend, function (newValue, oldValue) {
|
|||||||
ElMessage.error('启动失败!')
|
ElMessage.error('启动失败!')
|
||||||
startDisabeld.value = false
|
startDisabeld.value = false
|
||||||
pauseDisabled.value = true
|
pauseDisabled.value = true
|
||||||
console.log('错误信息:',webMsgSend)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (newValue.requestId.includes('close_source') && newValue.operateCode === 'CLOSE_GATHER') {
|
if (newValue.requestId.includes('close_source') && newValue.operateCode === 'CLOSE_GATHER') {
|
||||||
@@ -211,7 +211,7 @@ watch(webMsgSend, function (newValue, oldValue) {
|
|||||||
ElMessage.error('停止失败!')
|
ElMessage.error('停止失败!')
|
||||||
startDisabeld.value = true
|
startDisabeld.value = true
|
||||||
pauseDisabled.value = false
|
pauseDisabled.value = false
|
||||||
console.log('错误信息:',webMsgSend)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
switch (newValue.requestId) {
|
switch (newValue.requestId) {
|
||||||
@@ -225,7 +225,7 @@ watch(webMsgSend, function (newValue, oldValue) {
|
|||||||
pauseDisabled.value = false
|
pauseDisabled.value = false
|
||||||
} else if(newValue.code !== 10201) {
|
} else if(newValue.code !== 10201) {
|
||||||
ElMessage.error('源连接失败!')
|
ElMessage.error('源连接失败!')
|
||||||
console.log('错误信息:',webMsgSend)
|
// console.log('错误信息:',webMsgSend)
|
||||||
connectDisabeld.value = false
|
connectDisabeld.value = false
|
||||||
startDisabeld.value = true
|
startDisabeld.value = true
|
||||||
pauseDisabled.value = true
|
pauseDisabled.value = true
|
||||||
|
|||||||
@@ -138,7 +138,7 @@ const columns = reactive<ColumnProps<Monitor.ResPqMon>[]>([
|
|||||||
const emit = defineEmits(['get-parameter'])
|
const emit = defineEmits(['get-parameter'])
|
||||||
|
|
||||||
const getParameter = (data: Monitor.ResPqMon) => {
|
const getParameter = (data: Monitor.ResPqMon) => {
|
||||||
console.log('data', data)
|
|
||||||
if (title_Type.value === 'edit') {
|
if (title_Type.value === 'edit') {
|
||||||
// 编辑:替换已有的数据
|
// 编辑:替换已有的数据
|
||||||
const index = tableData.value.findIndex(item => item.id === data.id)
|
const index = tableData.value.findIndex(item => item.id === data.id)
|
||||||
|
|||||||
@@ -279,7 +279,7 @@ const open = async (sign: string, data: StandardDevice.ResPqStandardDevice,devTy
|
|||||||
|
|
||||||
|
|
||||||
const handleDevTypeChange = (value: string) => {
|
const handleDevTypeChange = (value: string) => {
|
||||||
console.log('handleDevTypeChange', value)
|
|
||||||
// 在这里处理选中事件的逻辑
|
// 在这里处理选中事件的逻辑
|
||||||
const dev = devTypeOptions.value.find(t =>t.id === value)
|
const dev = devTypeOptions.value.find(t =>t.id === value)
|
||||||
if (dev) {
|
if (dev) {
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ const handleInputRetainTime = value => {
|
|||||||
props.childForm[0].dipData.retainTime = 300
|
props.childForm[0].dipData.retainTime = 300
|
||||||
emit('setRetainTime', 300 )
|
emit('setRetainTime', 300 )
|
||||||
}else{
|
}else{
|
||||||
console.log(props);
|
|
||||||
|
|
||||||
emit('setRetainTime', value )
|
emit('setRetainTime', value )
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ const defaultProps = {
|
|||||||
const activeName = ref('')
|
const activeName = ref('')
|
||||||
const childActiveName = ref('')
|
const childActiveName = ref('')
|
||||||
const handleNodeClick = (data, node) => {
|
const handleNodeClick = (data, node) => {
|
||||||
console.log('handleNodeClick', data, node)
|
|
||||||
let code = ['Base', 'VOL', 'Freq', 'Harm', 'Base_0_10', 'Base_20_85', 'Base_110_200']
|
let code = ['Base', 'VOL', 'Freq', 'Harm', 'Base_0_10', 'Base_20_85', 'Base_110_200']
|
||||||
const parents = getParentNodes(node, [])
|
const parents = getParentNodes(node, [])
|
||||||
parents.pop()
|
parents.pop()
|
||||||
|
|||||||
@@ -53,7 +53,7 @@
|
|||||||
const proTable = ref<ProTableInstance>()
|
const proTable = ref<ProTableInstance>()
|
||||||
|
|
||||||
const getTableList = (params: any) => {
|
const getTableList = (params: any) => {
|
||||||
console.log("getTableList",params)
|
|
||||||
let newParams = JSON.parse(JSON.stringify(params))
|
let newParams = JSON.parse(JSON.stringify(params))
|
||||||
const patternId = dictStore.getDictData('Pattern').find(item=>item.name=== modeStore.currentMode)?.id//获取数据字典中对应的id
|
const patternId = dictStore.getDictData('Pattern').find(item=>item.name=== modeStore.currentMode)?.id//获取数据字典中对应的id
|
||||||
newParams.pattern = patternId
|
newParams.pattern = patternId
|
||||||
|
|||||||
@@ -128,7 +128,7 @@ const router = useRouter()
|
|||||||
const value1 = ref('')
|
const value1 = ref('')
|
||||||
const value2 = ref('')
|
const value2 = ref('')
|
||||||
const tableHeight = ref(0)
|
const tableHeight = ref(0)
|
||||||
console.log(window.innerHeight, '+++++++++')
|
|
||||||
tableHeight.value = window.innerHeight - 630
|
tableHeight.value = window.innerHeight - 630
|
||||||
|
|
||||||
//下拉框数据
|
//下拉框数据
|
||||||
@@ -443,8 +443,7 @@ const handleRefresh = () => {
|
|||||||
}
|
}
|
||||||
// 表格拖拽排序
|
// 表格拖拽排序
|
||||||
const sortTable = ({ newIndex, oldIndex }: { newIndex?: number; oldIndex?: number }) => {
|
const sortTable = ({ newIndex, oldIndex }: { newIndex?: number; oldIndex?: number }) => {
|
||||||
console.log(newIndex, oldIndex)
|
|
||||||
console.log(proTable.value?.tableData)
|
|
||||||
ElMessage.success('修改列表排序成功')
|
ElMessage.success('修改列表排序成功')
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -493,7 +492,7 @@ const handleTest = () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
console.log(proTable.value?.tableData)
|
|
||||||
})
|
})
|
||||||
defineExpose({ changeActiveTabs })
|
defineExpose({ changeActiveTabs })
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ const currentIndex = ref(0);
|
|||||||
// currentIndex.value++;
|
// currentIndex.value++;
|
||||||
// if (currentIndex.value > 14)
|
// if (currentIndex.value > 14)
|
||||||
// currentIndex.value = 0;
|
// currentIndex.value = 0;
|
||||||
// // console.log(currentIndex.value);
|
// console.log(currentIndex.value);
|
||||||
|
|
||||||
// }, 2000);
|
// }, 2000);
|
||||||
|
|
||||||
@@ -94,7 +94,7 @@ const changeSelect=()=>{
|
|||||||
//console.log(treeRef.value.getCheckedKeys());
|
//console.log(treeRef.value.getCheckedKeys());
|
||||||
}
|
}
|
||||||
const handleNodeClick = (data) => {
|
const handleNodeClick = (data) => {
|
||||||
console.log(data);
|
|
||||||
};
|
};
|
||||||
const filterNode = (value: string, data) => {
|
const filterNode = (value: string, data) => {
|
||||||
if (!value) return true;
|
if (!value) return true;
|
||||||
@@ -105,7 +105,7 @@ const detail = (e: any) => {
|
|||||||
emit("jump", e);
|
emit("jump", e);
|
||||||
};
|
};
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
console.log();
|
|
||||||
});
|
});
|
||||||
defineExpose({ getTreeData,getCurrentIndex });
|
defineExpose({ getTreeData,getCurrentIndex });
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -289,7 +289,7 @@ const preTestData = [
|
|||||||
// 弹出数据查询页面
|
// 弹出数据查询页面
|
||||||
const handleClick = (item, index, vvs) => {
|
const handleClick = (item, index, vvs) => {
|
||||||
//const data = "检测脚本为:"+item.name+";被检设备为:"+item.children.value.devID+";被检通道序号为:"+ item.children.monitorIndex;
|
//const data = "检测脚本为:"+item.name+";被检设备为:"+item.children.value.devID+";被检通道序号为:"+ item.children.monitorIndex;
|
||||||
console.log(vvs, index, item.name, item.children)
|
|
||||||
PopupVisible.value = true
|
PopupVisible.value = true
|
||||||
showDataPopup.value.open()
|
showDataPopup.value.open()
|
||||||
}
|
}
|
||||||
@@ -379,7 +379,7 @@ const customColors = [
|
|||||||
]
|
]
|
||||||
//加载进度条
|
//加载进度条
|
||||||
const refreshProgress = () => {
|
const refreshProgress = () => {
|
||||||
console.log(currentIndex, totalNum, percentage.value)
|
|
||||||
if (percentage.value < 100) {
|
if (percentage.value < 100) {
|
||||||
percentage.value = Math.trunc((currentIndex / totalNum) * 100)
|
percentage.value = Math.trunc((currentIndex / totalNum) * 100)
|
||||||
} else {
|
} else {
|
||||||
@@ -397,7 +397,7 @@ const refreshProgress = () => {
|
|||||||
status: 0
|
status: 0
|
||||||
})
|
})
|
||||||
|
|
||||||
console.log('检测结束')
|
|
||||||
if (testModel.value === 'preTest') ElMessage.success('预检测过程全部结束')
|
if (testModel.value === 'preTest') ElMessage.success('预检测过程全部结束')
|
||||||
else if (testModel.value === 'Test')
|
else if (testModel.value === 'Test')
|
||||||
//ElMessage.success("正式检测全部结束,你可以停留在此页面查看检测结果,或返回首页进行复检、报告生成和归档等操作")
|
//ElMessage.success("正式检测全部结束,你可以停留在此页面查看检测结果,或返回首页进行复检、报告生成和归档等操作")
|
||||||
@@ -507,7 +507,7 @@ const handleFinishTest = () => {
|
|||||||
|
|
||||||
// 表格拖拽排序
|
// 表格拖拽排序
|
||||||
const sortTable = ({ newIndex, oldIndex }: { newIndex?: number; oldIndex?: number }) => {
|
const sortTable = ({ newIndex, oldIndex }: { newIndex?: number; oldIndex?: number }) => {
|
||||||
console.log(newIndex, oldIndex)
|
|
||||||
ElMessage.success('修改列表排序成功')
|
ElMessage.success('修改列表排序成功')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -465,7 +465,7 @@ const addTab = (type: string) => {
|
|||||||
subPlanFormContent.value = planFormContent.value?.children?.find(
|
subPlanFormContent.value = planFormContent.value?.children?.find(
|
||||||
(child: Plan.ReqPlan) => child.id === planId.value
|
(child: Plan.ReqPlan) => child.id === planId.value
|
||||||
)
|
)
|
||||||
console.log('0000---', subPlanFormContent.value)
|
|
||||||
planPopup.value?.open('edit', subPlanFormContent.value, modeStore.currentMode, 2)
|
planPopup.value?.open('edit', subPlanFormContent.value, modeStore.currentMode, 2)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -531,7 +531,7 @@ const removeTab = async (targetName: TabPaneName) => {
|
|||||||
}
|
}
|
||||||
// 弹窗打开方法
|
// 弹窗打开方法
|
||||||
const open = async (textTitle: string, data: Plan.ReqPlan, pattern: string) => {
|
const open = async (textTitle: string, data: Plan.ReqPlan, pattern: string) => {
|
||||||
console.log('open', data)
|
|
||||||
dialogVisible.value = true
|
dialogVisible.value = true
|
||||||
title.value = textTitle
|
title.value = textTitle
|
||||||
planTitle.value = data.name
|
planTitle.value = data.name
|
||||||
@@ -579,13 +579,13 @@ const handleTabClick = (tab: any) => {
|
|||||||
|
|
||||||
const handleTableDataUpdate = async (newData: any[]) => {
|
const handleTableDataUpdate = async (newData: any[]) => {
|
||||||
// 👇 处理新数据,例如更新 planFormContent
|
// 👇 处理新数据,例如更新 planFormContent
|
||||||
console.log('handleTableDataUpdate', newData)
|
|
||||||
const matchedItem = findItemById(newData, planId.value)
|
const matchedItem = findItemById(newData, planId.value)
|
||||||
if (matchedItem) {
|
if (matchedItem) {
|
||||||
planFormContent.value = matchedItem
|
planFormContent.value = matchedItem
|
||||||
console.log('递归匹配成功:', planFormContent.value)
|
//console.log('递归匹配成功:', planFormContent.value)
|
||||||
} else {
|
} else {
|
||||||
console.warn('未找到匹配的 planId:', planId.value)
|
// console.warn('未找到匹配的 planId:', planId.value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -616,7 +616,7 @@ const handleRemove = async (row: any) => {
|
|||||||
ElMessage.warning(`当前设备已被子计划绑定,无法删除!`)
|
ElMessage.warning(`当前设备已被子计划绑定,无法删除!`)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
console.log('shcn', planFormContent.value)
|
|
||||||
proTable.value?.getTableList() // 刷新当前表格
|
proTable.value?.getTableList() // 刷新当前表格
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
@@ -739,7 +739,7 @@ const initSSE = () => {
|
|||||||
eventSource.value = http.sse('/sse/createSse')
|
eventSource.value = http.sse('/sse/createSse')
|
||||||
|
|
||||||
eventSource.value.onmessage = event => {
|
eventSource.value.onmessage = event => {
|
||||||
console.log('收到消息内容是:', event.data)
|
|
||||||
const res = JSON.parse(event.data)
|
const res = JSON.parse(event.data)
|
||||||
progressData.value.percentage = res.data
|
progressData.value.percentage = res.data
|
||||||
progressData.value.message = res.message
|
progressData.value.message = res.message
|
||||||
@@ -763,7 +763,7 @@ const closeEventSource = () => {
|
|||||||
if (eventSource.value) {
|
if (eventSource.value) {
|
||||||
eventSource.value.close()
|
eventSource.value.close()
|
||||||
eventSource.value = null
|
eventSource.value = null
|
||||||
console.log('SSE连接已关闭')
|
//console.log('SSE连接已关闭')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -439,7 +439,7 @@ const convertToTree = (data: Device[], groupBy?: string | undefined) => {
|
|||||||
}
|
}
|
||||||
const filterNode: FilterNodeMethodFunction = (value: string, data: Tree) => {
|
const filterNode: FilterNodeMethodFunction = (value: string, data: Tree) => {
|
||||||
if (!value) return true
|
if (!value) return true
|
||||||
console.log('data', data)
|
|
||||||
if (data.id.toString().includes('_')) {
|
if (data.id.toString().includes('_')) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ const filterMethod = (query: string, item: { label?: string }) => {
|
|||||||
const open = async (data: Plan.ReqPlan) => {
|
const open = async (data: Plan.ReqPlan) => {
|
||||||
dialogVisible.value = true
|
dialogVisible.value = true
|
||||||
planData.value = data
|
planData.value = data
|
||||||
console.log('planData.value', planData.value)
|
|
||||||
const standardDevList_Result1 = await getUnboundStandardDevList(data)
|
const standardDevList_Result1 = await getUnboundStandardDevList(data)
|
||||||
unboundStandardDevList.value = standardDevList_Result1.data as StandardDevice.ResPqStandardDevice[]
|
unboundStandardDevList.value = standardDevList_Result1.data as StandardDevice.ResPqStandardDevice[]
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
align-center
|
align-center
|
||||||
v-bind="dialogBig"
|
v-bind="dialogBig"
|
||||||
@close="close"
|
@close="close"
|
||||||
|
|
||||||
>
|
>
|
||||||
<el-form ref="dialogFormRef" :model="formContent" :rules="rules">
|
<el-form ref="dialogFormRef" :model="formContent" :rules="rules">
|
||||||
<el-row :gutter="24">
|
<el-row :gutter="24">
|
||||||
@@ -365,6 +366,7 @@
|
|||||||
/>
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
|
|
||||||
</el-row>
|
</el-row>
|
||||||
</el-collapse-item>
|
</el-collapse-item>
|
||||||
</el-collapse>
|
</el-collapse>
|
||||||
@@ -678,7 +680,7 @@ const save = () => {
|
|||||||
formContent.memberIds = formContent.memberIds ? [formContent.memberIds?.toString()] : []
|
formContent.memberIds = formContent.memberIds ? [formContent.memberIds?.toString()] : []
|
||||||
await updatePlan(formContent)
|
await updatePlan(formContent)
|
||||||
emit('update:tab')
|
emit('update:tab')
|
||||||
console.log('更新子计划', formContent)
|
|
||||||
} else {
|
} else {
|
||||||
formContent.sourceIds = null
|
formContent.sourceIds = null
|
||||||
await updatePlan(formContent)
|
await updatePlan(formContent)
|
||||||
@@ -752,7 +754,7 @@ const open = async (sign: string, data: Plan.ReqPlan, currentMode: string, plan:
|
|||||||
user_Result: any
|
user_Result: any
|
||||||
|
|
||||||
if (mode.value === '比对式') {
|
if (mode.value === '比对式') {
|
||||||
;[
|
[
|
||||||
PqErrSys_Result,
|
PqErrSys_Result,
|
||||||
pqDevList_Result,
|
pqDevList_Result,
|
||||||
pqReportName_Result,
|
pqReportName_Result,
|
||||||
@@ -792,7 +794,7 @@ const open = async (sign: string, data: Plan.ReqPlan, currentMode: string, plan:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
;[pqSource_Result, PqScript_Result, PqErrSys_Result, pqDevList_Result, pqReportName_Result] =
|
[pqSource_Result, PqScript_Result, PqErrSys_Result, pqDevList_Result, pqReportName_Result] =
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
getTestSourceList(data),
|
getTestSourceList(data),
|
||||||
getPqScriptList(data),
|
getPqScriptList(data),
|
||||||
@@ -825,7 +827,10 @@ const open = async (sign: string, data: Plan.ReqPlan, currentMode: string, plan:
|
|||||||
formContent.errorSysId = pqErrSysList.value[0]?.id ?? ''
|
formContent.errorSysId = pqErrSysList.value[0]?.id ?? ''
|
||||||
formContent.sourceIds = pqSourceList.value[0]?.id ?? ''
|
formContent.sourceIds = pqSourceList.value[0]?.id ?? ''
|
||||||
const datasourceDicts = dictStore.getDictData('Datasource')
|
const datasourceDicts = dictStore.getDictData('Datasource')
|
||||||
formContent.datasourceIds = [datasourceDicts[0]?.code] ?? []
|
|
||||||
|
formContent.datasourceIds = datasourceDicts
|
||||||
|
.filter(item => ['real', 'wave_data'].includes(item.code))
|
||||||
|
.map(item => item.code)
|
||||||
} else {
|
} else {
|
||||||
//编辑时先给表单赋值(这会没接收被检设备),需要手动再给被检设备复制后整体表单赋值
|
//编辑时先给表单赋值(这会没接收被检设备),需要手动再给被检设备复制后整体表单赋值
|
||||||
|
|
||||||
@@ -902,7 +907,7 @@ const open = async (sign: string, data: Plan.ReqPlan, currentMode: string, plan:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
;[
|
[
|
||||||
pqSource_Result,
|
pqSource_Result,
|
||||||
PqScript_Result,
|
PqScript_Result,
|
||||||
PqErrSys_Result,
|
PqErrSys_Result,
|
||||||
@@ -1052,7 +1057,9 @@ const handleErrorSysChange = async (value: string) => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
formContent.testItems = secondLevelOptions.map(option => option.value)
|
formContent.testItems = secondLevelOptions
|
||||||
|
.filter(option => option.label !== '闪变')
|
||||||
|
.map(option => option.value)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
formContent.testItems = []
|
formContent.testItems = []
|
||||||
console.error('获取检测项失败:', error)
|
console.error('获取检测项失败:', error)
|
||||||
@@ -1083,7 +1090,9 @@ const loadTestItemsForErrorSys = async (errorSysId: string) => {
|
|||||||
label: (res.data as Record<string, string>)[key]
|
label: (res.data as Record<string, string>)[key]
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
formContent.testItems = secondLevelOptions.map(option => option.value)
|
formContent.testItems = secondLevelOptions
|
||||||
|
.filter(option => option.label !== '闪变')
|
||||||
|
.map(option => option.value)
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('获取检测项失败:', error)
|
console.error('获取检测项失败:', error)
|
||||||
@@ -1226,6 +1235,7 @@ const props = defineProps<{
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
|
||||||
// :deep(.dialog-small .el-dialog__body){
|
// :deep(.dialog-small .el-dialog__body){
|
||||||
// max-height: 330px !important;
|
// max-height: 330px !important;
|
||||||
// }
|
// }
|
||||||
@@ -1244,4 +1254,6 @@ const props = defineProps<{
|
|||||||
justify-content: center;
|
justify-content: center;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -43,6 +43,7 @@
|
|||||||
v-auth.plan="'analysis'"
|
v-auth.plan="'analysis'"
|
||||||
icon="DataLine"
|
icon="DataLine"
|
||||||
:disabled="!scope.isSelected"
|
:disabled="!scope.isSelected"
|
||||||
|
v-if=" modeStore.currentMode != '比对式'"
|
||||||
@click="statisticalAnalysisMore(scope.selectedListIds, scope.selectedList)"
|
@click="statisticalAnalysisMore(scope.selectedListIds, scope.selectedList)"
|
||||||
>
|
>
|
||||||
统计分析
|
统计分析
|
||||||
@@ -104,7 +105,7 @@
|
|||||||
v-auth.plan="'analysis'"
|
v-auth.plan="'analysis'"
|
||||||
link
|
link
|
||||||
icon="DataLine"
|
icon="DataLine"
|
||||||
v-if="scope.row.testState == '2'"
|
v-if="scope.row.testState == '2' && modeStore.currentMode != '比对式'"
|
||||||
@click="statisticalAnalysis(scope.row)"
|
@click="statisticalAnalysis(scope.row)"
|
||||||
>
|
>
|
||||||
统计分析
|
统计分析
|
||||||
@@ -206,13 +207,13 @@ onMounted(async () => {
|
|||||||
//假分页后用data刷新
|
//假分页后用data刷新
|
||||||
const refreshTable = async () => {
|
const refreshTable = async () => {
|
||||||
try {
|
try {
|
||||||
console.log('表格刷新')
|
|
||||||
patternId.value = dictStore.getDictData('Pattern').find(item => item.name === modeStore.currentMode)?.id
|
patternId.value = dictStore.getDictData('Pattern').find(item => item.name === modeStore.currentMode)?.id
|
||||||
const result = await getPlanList({ patternId: patternId.value })
|
const result = await getPlanList({ patternId: patternId.value })
|
||||||
tableData.value = buildTree(result.data as any[])
|
tableData.value = buildTree(result.data as any[])
|
||||||
pageTotal.value = tableData.value.length
|
pageTotal.value = tableData.value.length
|
||||||
updateCurrentPageData(tableData.value)
|
updateCurrentPageData(tableData.value)
|
||||||
console.log('表格刷新成功')
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
tableData.value = []
|
tableData.value = []
|
||||||
ElMessage.error('获取计划列表失败')
|
ElMessage.error('获取计划列表失败')
|
||||||
@@ -224,7 +225,7 @@ watch(
|
|||||||
() => tableData.value,
|
() => tableData.value,
|
||||||
newVal => {
|
newVal => {
|
||||||
if (childrenPlanView.value && newVal) {
|
if (childrenPlanView.value && newVal) {
|
||||||
console.log('监听 tableData 变化', newVal)
|
|
||||||
childrenPlanView.value.handleTableDataUpdate?.(newVal)
|
childrenPlanView.value.handleTableDataUpdate?.(newVal)
|
||||||
updateCurrentPageData(newVal)
|
updateCurrentPageData(newVal)
|
||||||
}
|
}
|
||||||
@@ -308,7 +309,7 @@ const updateCurrentPageData = (data = tableData.value) => {
|
|||||||
const start = (currentPage.value - 1) * pageSize.value
|
const start = (currentPage.value - 1) * pageSize.value
|
||||||
const end = start + pageSize.value
|
const end = start + pageSize.value
|
||||||
currentPageData.value = data.slice(start, end)
|
currentPageData.value = data.slice(start, end)
|
||||||
console.log('currentPageData', currentPageData.value)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const dataSourceType = computed(() => {
|
const dataSourceType = computed(() => {
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ const open = (list: any) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
console.log();
|
|
||||||
});
|
});
|
||||||
defineExpose({ open });
|
defineExpose({ open });
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -201,10 +201,10 @@ const submitForm = async (formEl: FormInstance | undefined) => {
|
|||||||
if (!formEl) return
|
if (!formEl) return
|
||||||
await formEl.validate((valid, fields) => {
|
await formEl.validate((valid, fields) => {
|
||||||
if (valid) {
|
if (valid) {
|
||||||
console.log('submit!')
|
//console.log('submit!')
|
||||||
close()
|
close()
|
||||||
} else {
|
} else {
|
||||||
console.log('error submit!', fields)
|
//console.log('error submit!', fields)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -220,7 +220,7 @@ const options = Array.from({ length: 10000 }).map((_, idx) => ({
|
|||||||
label: `${idx + 1}`,
|
label: `${idx + 1}`,
|
||||||
}))
|
}))
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
console.log();
|
|
||||||
});
|
});
|
||||||
const dialogVisible = ref<boolean>(false);
|
const dialogVisible = ref<boolean>(false);
|
||||||
const dialogTitle = ref<string>("");
|
const dialogTitle = ref<string>("");
|
||||||
@@ -231,9 +231,7 @@ const open = (title: string) => {
|
|||||||
const close=()=>{
|
const close=()=>{
|
||||||
dialogVisible.value = false;
|
dialogVisible.value = false;
|
||||||
}
|
}
|
||||||
onMounted(() => {
|
|
||||||
console.log();
|
|
||||||
});
|
|
||||||
defineExpose({ open });
|
defineExpose({ open });
|
||||||
</script>
|
</script>
|
||||||
<style lang="scss" scoped></style>
|
<style lang="scss" scoped></style>
|
||||||
|
|||||||
@@ -207,7 +207,7 @@ const getTableList = (params: any) => {
|
|||||||
//查看详情
|
//查看详情
|
||||||
const detailsRef: any = ref()
|
const detailsRef: any = ref()
|
||||||
const handleDetails = () => {
|
const handleDetails = () => {
|
||||||
console.log(detailsRef.value, '+++++++++++++++')
|
|
||||||
detailsRef.value.open('查看计划')
|
detailsRef.value.open('查看计划')
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -391,7 +391,7 @@ const changeStatus = async (row: User.ResUserList) => {
|
|||||||
proTable.value?.getTableList()
|
proTable.value?.getTableList()
|
||||||
}
|
}
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
console.log(proTable.value?.tableData)
|
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
|||||||
@@ -1,55 +1,281 @@
|
|||||||
|
|
||||||
<template>
|
<template>
|
||||||
<el-dialog v-model="dialogVisible" title="程序激活" v-bind="dialogSmall">
|
<el-dialog
|
||||||
<el-form :model="formContent">
|
v-model="dialogVisible"
|
||||||
<el-form-item label="程序版本号" prop="id" :label-width="100">
|
title="程序激活"
|
||||||
<el-input v-model='formContent.id' disabled/>
|
width="450px"
|
||||||
</el-form-item>
|
draggable
|
||||||
<el-form-item label="模拟式模块" prop="type" :label-width="100">
|
:close-on-click-modal="false"
|
||||||
<el-checkbox v-model="formContent.type" label="已激活"/>
|
:before-close="beforeClose"
|
||||||
</el-form-item>
|
:destroy-on-close="true"
|
||||||
<el-form-item label="数字式模块" prop="type" :label-width="100">
|
>
|
||||||
<el-checkbox v-model="formContent.type" label="未激活"/>
|
<el-form :label-width="100" label-position="left">
|
||||||
</el-form-item>
|
<el-form-item label="程序版本号">
|
||||||
<el-form-item label="比对式模块" prop="type" :label-width="100">
|
<el-text style="margin-left: 82%">{{ 'v' + versionNumber }}</el-text>
|
||||||
<el-checkbox v-model="formContent.type" label="未激活"/>
|
</el-form-item>
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="序列号" prop="code" :label-width="100">
|
|
||||||
<el-input v-model='formContent.code' placeholder="请输入序列号" :rows="2" type="textarea"/>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="注册码" prop="licenseKey" :label-width="100">
|
|
||||||
<el-input v-model='formContent.licenseKey' placeholder="请输入注册码" :rows="2" type="textarea"/>
|
|
||||||
</el-form-item>
|
|
||||||
</el-form>
|
</el-form>
|
||||||
<template #footer>
|
<el-descriptions
|
||||||
<span class="dialog-footer">
|
class="mode-descriptions"
|
||||||
<el-button @click="dialogVisible = false">取消</el-button>
|
v-if="!hadActivationCode"
|
||||||
<el-button type="primary" @click="dialogVisible = false">激活</el-button>
|
title="模块激活状态"
|
||||||
</span>
|
size="small"
|
||||||
</template>
|
></el-descriptions>
|
||||||
|
<el-form
|
||||||
|
ref="applicationFormRef"
|
||||||
|
v-if="!hadActivationCode"
|
||||||
|
:model="applicationForm"
|
||||||
|
label-position="left"
|
||||||
|
:label-width="100"
|
||||||
|
>
|
||||||
|
<el-form-item
|
||||||
|
class="mode-item"
|
||||||
|
v-if="activateInfo.simulate.apply !== 1 || activateInfo.simulate.permanently !== 1"
|
||||||
|
label="模拟式模块"
|
||||||
|
prop="simulate.apply"
|
||||||
|
>
|
||||||
|
<el-tag disable-transitions type="danger">未激活</el-tag>
|
||||||
|
<el-checkbox
|
||||||
|
:false-value="0"
|
||||||
|
:true-value="1"
|
||||||
|
class="apply-checkbox"
|
||||||
|
v-model="applicationForm.simulate.apply"
|
||||||
|
label="激活"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item
|
||||||
|
class="mode-item"
|
||||||
|
v-if="activateInfo.simulate.apply === 1 && activateInfo.simulate.permanently === 1"
|
||||||
|
label="模拟式模块"
|
||||||
|
>
|
||||||
|
<el-tag class="activated-tag" disable-transitions type="success">已激活</el-tag>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item
|
||||||
|
class="mode-item"
|
||||||
|
v-if="activateInfo.digital.apply !== 1 || activateInfo.digital.permanently !== 1"
|
||||||
|
label="数字式模块"
|
||||||
|
prop="digital.apply"
|
||||||
|
>
|
||||||
|
<el-tag disable-transitions type="danger">未激活</el-tag>
|
||||||
|
<el-checkbox
|
||||||
|
:false-value="0"
|
||||||
|
:true-value="1"
|
||||||
|
class="apply-checkbox"
|
||||||
|
v-model="applicationForm.digital.apply"
|
||||||
|
label="激活"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item
|
||||||
|
class="mode-item"
|
||||||
|
v-if="activateInfo.digital.apply === 1 && activateInfo.digital.permanently === 1"
|
||||||
|
label="数字式模块"
|
||||||
|
>
|
||||||
|
<el-tag class="activated-tag" disable-transitions type="success">已激活</el-tag>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item
|
||||||
|
class="mode-item"
|
||||||
|
v-if="activateInfo.contrast.apply !== 1 || activateInfo.contrast.permanently !== 1"
|
||||||
|
label="比对式模块"
|
||||||
|
prop="contrast.apply"
|
||||||
|
>
|
||||||
|
<el-tag disable-transitions type="danger">未激活</el-tag>
|
||||||
|
<el-checkbox
|
||||||
|
:false-value="0"
|
||||||
|
:true-value="1"
|
||||||
|
class="apply-checkbox"
|
||||||
|
v-model="applicationForm.contrast.apply"
|
||||||
|
label="激活"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item
|
||||||
|
class="mode-item"
|
||||||
|
v-if="activateInfo.contrast.apply === 1 && activateInfo.contrast.permanently === 1"
|
||||||
|
label="比对式模块"
|
||||||
|
>
|
||||||
|
<el-tag class="activated-tag" disable-transitions type="success">已激活</el-tag>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
<el-row v-if="applicationCode">
|
||||||
|
<el-descriptions class="mode-descriptions" title="设备申请码" size="small"></el-descriptions>
|
||||||
|
<el-tooltip placement="top-end" effect="light">
|
||||||
|
<el-input
|
||||||
|
v-model="applicationCode"
|
||||||
|
:rows="5"
|
||||||
|
type="textarea"
|
||||||
|
readonly
|
||||||
|
resize="none"
|
||||||
|
class="code-display"
|
||||||
|
/>
|
||||||
|
<template #content>
|
||||||
|
<el-button size="small" @click="copyCode" icon="DocumentCopy">复制</el-button>
|
||||||
|
</template>
|
||||||
|
</el-tooltip>
|
||||||
|
</el-row>
|
||||||
|
<el-row v-if="applicationCode || hadActivationCode">
|
||||||
|
<el-descriptions class="mode-descriptions" title="设备激活码" size="small"></el-descriptions>
|
||||||
|
<el-input
|
||||||
|
placeholder="请输入设备激活码"
|
||||||
|
v-model="activationCode"
|
||||||
|
:rows="5"
|
||||||
|
resize="none"
|
||||||
|
type="textarea"
|
||||||
|
class="code-input"
|
||||||
|
/>
|
||||||
|
</el-row>
|
||||||
|
<template #footer v-if="!activatedAll">
|
||||||
|
<div v-if="!applicationCode && !hadActivationCode">
|
||||||
|
<el-button @click="cancel">取消</el-button>
|
||||||
|
<el-button type="primary" @click="getApplicationCode">获取申请码</el-button>
|
||||||
|
<el-button type="primary" @click="hadActivationCode = true">已有激活码</el-button>
|
||||||
|
</div>
|
||||||
|
<div v-if="applicationCode || hadActivationCode">
|
||||||
|
<el-button @click="cancel">取消</el-button>
|
||||||
|
<el-button :disabled="!activationCode" type="primary" @click="submitActivation">激活</el-button>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { type VersionRegister } from "@/api/system/versionRegister/interface";
|
import { ref } from 'vue'
|
||||||
import { ref } from "vue";
|
import { version } from '../../../../package.json'
|
||||||
import { dialogSmall } from '@/utils/elementBind'
|
import type { Activate } from '@/api/activate/interface'
|
||||||
const formContent = ref<VersionRegister.ResSys_Reg_Res>({
|
import { generateApplicationCode, verifyActivationCode } from '@/api/activate'
|
||||||
id: '', //版本注册表Id
|
import { useAuthStore } from '@/stores/modules/auth'
|
||||||
type: '', //版本类型(模拟式、数字式、比对式)
|
|
||||||
code: '', //注册码
|
|
||||||
licenseKey: '', //密钥
|
|
||||||
expireDate: '', //到期时间
|
|
||||||
waveRecord: 0,
|
|
||||||
realTime: 20,
|
|
||||||
statistics: 5,
|
|
||||||
flicker: 1,
|
|
||||||
state: 1, //状态
|
|
||||||
})
|
|
||||||
const dialogVisible = ref(false);
|
|
||||||
const openDialog = () => {
|
|
||||||
dialogVisible.value = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
defineExpose({ openDialog });
|
const authStore = useAuthStore()
|
||||||
</script>
|
const activateInfo = authStore.activateInfo
|
||||||
|
const versionNumber = ref(version)
|
||||||
|
const applicationForm = reactive<Activate.ApplicationCodePlaintext>({
|
||||||
|
simulate: { apply: 0 },
|
||||||
|
digital: { apply: 0 },
|
||||||
|
contrast: { apply: 0 }
|
||||||
|
})
|
||||||
|
const activatedAll = computed(() => {
|
||||||
|
return (
|
||||||
|
activateInfo.simulate.apply === 1 &&
|
||||||
|
activateInfo.simulate.permanently === 1 &&
|
||||||
|
activateInfo.digital.apply === 1 &&
|
||||||
|
activateInfo.digital.permanently === 1 &&
|
||||||
|
activateInfo.contrast.apply === 1 &&
|
||||||
|
activateInfo.contrast.permanently === 1
|
||||||
|
)
|
||||||
|
})
|
||||||
|
const applicationFormRef = ref()
|
||||||
|
const hadActivationCode = ref(false)
|
||||||
|
const applicationCode = ref('')
|
||||||
|
const activationCode = ref('')
|
||||||
|
const dialogVisible = ref(false)
|
||||||
|
// 获取申请码
|
||||||
|
const getApplicationCode = async () => {
|
||||||
|
if (
|
||||||
|
applicationForm.simulate.apply == 0 &&
|
||||||
|
applicationForm.digital.apply == 0 &&
|
||||||
|
applicationForm.contrast.apply == 0
|
||||||
|
) {
|
||||||
|
ElMessage.warning('请选择需要激活的模块')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (activateInfo.simulate.apply === 1) {
|
||||||
|
applicationForm.simulate.apply = 1
|
||||||
|
}
|
||||||
|
if (activateInfo.digital.apply === 1) {
|
||||||
|
applicationForm.digital.apply = 1
|
||||||
|
}
|
||||||
|
if (activateInfo.contrast.apply === 1) {
|
||||||
|
applicationForm.contrast.apply = 1
|
||||||
|
}
|
||||||
|
|
||||||
|
const res = await generateApplicationCode(applicationForm)
|
||||||
|
if (res.code == 'A0000') {
|
||||||
|
applicationCode.value = res.data as string
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 复制申请码
|
||||||
|
const copyCode = async () => {
|
||||||
|
try {
|
||||||
|
await navigator.clipboard.writeText(applicationCode.value)
|
||||||
|
ElMessage.success('已复制到剪贴板')
|
||||||
|
} catch {
|
||||||
|
ElMessage.error('复制失败,请手动选择内容')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const openDialog = () => {
|
||||||
|
hadActivationCode.value = false
|
||||||
|
activationCode.value = ''
|
||||||
|
applicationCode.value = ''
|
||||||
|
applicationForm.simulate.apply = 0
|
||||||
|
applicationForm.digital.apply = 0
|
||||||
|
applicationForm.contrast.apply = 0
|
||||||
|
dialogVisible.value = true
|
||||||
|
}
|
||||||
|
const beforeClose = (done: Function) => {
|
||||||
|
applicationFormRef.value?.resetFields()
|
||||||
|
done()
|
||||||
|
}
|
||||||
|
const cancel = () => {
|
||||||
|
applicationFormRef.value?.resetFields()
|
||||||
|
dialogVisible.value = false
|
||||||
|
}
|
||||||
|
const submitActivation = async () => {
|
||||||
|
const res = await verifyActivationCode(activationCode.value)
|
||||||
|
if (res.code == 'A0000') {
|
||||||
|
ElMessage.success('激活成功')
|
||||||
|
await authStore.setActivateInfo()
|
||||||
|
window.location.reload()
|
||||||
|
} else {
|
||||||
|
ElMessage.error(res.message)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
defineExpose({ openDialog })
|
||||||
|
</script>
|
||||||
|
<style scoped>
|
||||||
|
.apply-checkbox {
|
||||||
|
margin-left: 62%;
|
||||||
|
}
|
||||||
|
.activated-tag {
|
||||||
|
margin-left: 80%;
|
||||||
|
}
|
||||||
|
.code-display,
|
||||||
|
.code-input {
|
||||||
|
font-family: consolas;
|
||||||
|
}
|
||||||
|
:deep(.el-tag) {
|
||||||
|
user-select: none;
|
||||||
|
-moz-user-select: none;
|
||||||
|
-webkit-user-select: none;
|
||||||
|
-ms-user-select: none;
|
||||||
|
}
|
||||||
|
:deep(.el-divider__text) {
|
||||||
|
user-select: none;
|
||||||
|
-moz-user-select: none;
|
||||||
|
-webkit-user-select: none;
|
||||||
|
-ms-user-select: none;
|
||||||
|
}
|
||||||
|
.mode-descriptions {
|
||||||
|
user-select: none;
|
||||||
|
-moz-user-select: none;
|
||||||
|
-webkit-user-select: none;
|
||||||
|
-ms-user-select: none;
|
||||||
|
margin-top: 15px;
|
||||||
|
}
|
||||||
|
:deep(.el-form-item) {
|
||||||
|
border: 1px solid #e5e7eb;
|
||||||
|
border-radius: 4px;
|
||||||
|
padding: 0 10px !important;
|
||||||
|
margin-bottom: 10px !important;
|
||||||
|
margin-right: 0 !important;
|
||||||
|
user-select: none;
|
||||||
|
-moz-user-select: none;
|
||||||
|
-webkit-user-select: none;
|
||||||
|
-ms-user-select: none;
|
||||||
|
}
|
||||||
|
:deep(.el-divider--horizontal) {
|
||||||
|
margin: 10px 0 !important;
|
||||||
|
margin-top: 20px !important;
|
||||||
|
}
|
||||||
|
.mode-item {
|
||||||
|
transition: background-color 0.2s ease;
|
||||||
|
}
|
||||||
|
.mode-item:hover {
|
||||||
|
background-color: #f9fafb;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
59
package.json
@@ -1,40 +1,24 @@
|
|||||||
{
|
{
|
||||||
"name": "ee",
|
"name": "ee",
|
||||||
"version": "3.12.0",
|
"version": "4.0.0",
|
||||||
"description": "A fast, desktop software development framework",
|
"description": "南京灿能C端工具",
|
||||||
"main": "main.js",
|
"main": "./public/electron/main.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "ee-bin dev",
|
"dev": "ee-bin dev",
|
||||||
|
"build": "npm run build-frontend && npm run build-electron && ee-bin encrypt",
|
||||||
|
"start": "ee-bin start",
|
||||||
"dev-frontend": "ee-bin dev --serve=frontend",
|
"dev-frontend": "ee-bin dev --serve=frontend",
|
||||||
"dev-electron": "ee-bin dev --serve=electron",
|
"dev-electron": "ee-bin dev --serve=electron",
|
||||||
"build-frontend": "ee-bin build --cmds=frontend && ee-bin move --flag=frontend_dist",
|
"build-frontend": "ee-bin build --cmds=frontend && ee-bin move --flag=frontend_dist",
|
||||||
"start": "ee-bin start",
|
"build-electron": "ee-bin build --cmds=electron",
|
||||||
"rd": "ee-bin move --flag=frontend_dist",
|
|
||||||
"encrypt": "ee-bin encrypt",
|
"encrypt": "ee-bin encrypt",
|
||||||
"clean": "ee-bin clean",
|
|
||||||
"icon": "ee-bin icon",
|
"icon": "ee-bin icon",
|
||||||
"reload": "nodemon --config ./electron/config/nodemon.json",
|
|
||||||
"rebuild": "electron-rebuild",
|
|
||||||
"re-sqlite": "electron-rebuild -f -w better-sqlite3",
|
"re-sqlite": "electron-rebuild -f -w better-sqlite3",
|
||||||
"build-w": "electron-builder --config=./electron/config/builder.json -w=nsis --x64",
|
"build-w": "ee-bin build --cmds=win64",
|
||||||
"build-w-32": "electron-builder --config=./electron/config/builder.json -w=nsis --ia32",
|
"build-we": "ee-bin build --cmds=win_e",
|
||||||
"build-w-64": "electron-builder --config=./electron/config/builder.json -w=nsis --x64",
|
"build-m": "ee-bin build --cmds=mac",
|
||||||
"build-w-arm64": "electron-builder --config=./electron/config/builder.json -w=nsis --arm64",
|
"build-m-arm64": "ee-bin build --cmds=mac_arm64",
|
||||||
"build-we": "electron-builder --config=./electron/config/builder.json -w=portable --x64",
|
"build-l": "ee-bin build --cmds=linux"
|
||||||
"build-wz": "electron-builder --config=./electron/config/builder.json -w=7z --x64",
|
|
||||||
"build-wz-32": "electron-builder --config=./electron/config/builder.json -w=7z --ia32",
|
|
||||||
"build-wz-64": "electron-builder --config=./electron/config/builder.json -w=7z --x64",
|
|
||||||
"build-wz-arm64": "electron-builder --config=./electron/config/builder.json -w=7z --arm64",
|
|
||||||
"build-m": "electron-builder --config=./electron/config/builder.json -m",
|
|
||||||
"build-m-arm64": "electron-builder --config=./electron/config/builder.json -m --arm64",
|
|
||||||
"build-l": "electron-builder --config=./electron/config/builder.json -l=deb --x64",
|
|
||||||
"build-l-32": "electron-builder --config=./electron/config/builder.json -l=deb --ia32",
|
|
||||||
"build-l-64": "electron-builder --config=./electron/config/builder.json -l=deb --x64",
|
|
||||||
"build-l-arm64": "electron-builder --config=./electron/config/builder.json -l=deb --arm64",
|
|
||||||
"build-l-armv7l": "electron-builder --config=./electron/config/builder.json -l=deb --armv7l",
|
|
||||||
"build-lr-64": "electron-builder --config=./electron/config/builder.json -l=rpm --x64",
|
|
||||||
"build-lp-64": "electron-builder --config=./electron/config/builder.json -l=pacman --x64",
|
|
||||||
"test": "set DEBUG=* && electron . --env=local"
|
|
||||||
},
|
},
|
||||||
"repository": "https://github.com/dromara/electron-egg.git",
|
"repository": "https://github.com/dromara/electron-egg.git",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
@@ -42,25 +26,26 @@
|
|||||||
"electron-egg",
|
"electron-egg",
|
||||||
"ElectronEgg"
|
"ElectronEgg"
|
||||||
],
|
],
|
||||||
"author": "hongawen, Inc <83944980@qq.com>",
|
"author": "hongawen",
|
||||||
"license": "Apache",
|
"license": "Apache",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@electron/rebuild": "^3.2.13",
|
"@electron/rebuild": "^3.7.1",
|
||||||
"@vitejs/plugin-vue-jsx": "^4.0.1",
|
"@types/node": "^20.16.0",
|
||||||
"debug": "^4.3.3",
|
"debug": "^4.4.0",
|
||||||
"ee-bin": "1.6.0",
|
"ee-bin": "^4.1.4",
|
||||||
"electron": "^21.4.4",
|
"electron": "^31.7.6",
|
||||||
"electron-builder": "^23.6.0",
|
"electron-builder": "^25.1.8"
|
||||||
"eslint": "^5.13.0",
|
|
||||||
"eslint-plugin-prettier": "^3.0.1",
|
|
||||||
"nodemon": "^2.0.16"
|
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|
||||||
|
"autofit.js": "^3.2.8",
|
||||||
"dayjs": "^1.10.7",
|
"dayjs": "^1.10.7",
|
||||||
"ee-core": "2.10.0",
|
"ee-core": "2.10.0",
|
||||||
"electron-updater": "^5.3.0",
|
"electron-updater": "^5.3.0",
|
||||||
|
"event-source-polyfill": "^1.0.31",
|
||||||
"lodash": "^4.17.21",
|
"lodash": "^4.17.21",
|
||||||
"mqtt": "^5.10.1",
|
"mqtt": "^5.10.1",
|
||||||
"sass": "^1.80.4"
|
"sass": "^1.80.4"
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||