在mac上写的win7适配

This commit is contained in:
chenqiang 2025-08-16 21:18:01 +08:00
parent 2ce39b142d
commit 23b917b5da
5 changed files with 59 additions and 9445 deletions

18
.npmrc Normal file
View File

@ -0,0 +1,18 @@
# 设置npm镜像源为淘宝镜像
registry=https://registry.npmmirror.com/
# 设置electron下载镜像
ELECTRON_MIRROR=https://npmmirror.com/mirrors/electron/
# 设置electron-builder下载镜像
ELECTRON_BUILDER_BINARIES_MIRROR=https://npmmirror.com/mirrors/electron-builder-binaries/
# 设置node-pre-gyp镜像用于sqlite3、bcrypt等原生模块
NODE_PRE_GYP_GITHUB_TOKEN=token
node_pre_gyp=https://npmmirror.com/mirrors/node-pre-gyp/
# 设置python路径如果需要
python=python3
# 设置代理(可选,如果有网络代理)
# https-proxy=
# proxy=

View File

@ -6,7 +6,7 @@ import {
getConfigById, getConfigById,
deleteConfig, deleteConfig,
} from "../db/config.js"; } from "../db/config.js";
import argon2 from "argon2"; import bcrypt from 'bcrypt';
// 原有接口保持不变 // 原有接口保持不变
/** /**
@ -135,14 +135,19 @@ export async function increaseQuestionBankVersion() {
* @param {string} password - 用户输入的密码 * @param {string} password - 用户输入的密码
* @returns {Promise<{success: boolean, message: string}>} * @returns {Promise<{success: boolean, message: string}>}
*/ */
export async function verifyAdminPassword(password) { /**
* 验证管理员密码
* @param {string} password - 待验证的密码
* @returns {Promise<{success: boolean, message: string}>}
*/
async function verifyAdminPassword(password) {
try { try {
const config = await getConfig("admin_password"); const config = await getConfig("admin_password");
if (!config || !config.value) { if (!config || !config.value) {
return { success: false, message: "管理员密码未设置" }; return { success: false, message: "管理员密码未设置" };
} }
const isMatch = await argon2.verify(config.value, password); const isMatch = await bcrypt.compare(password, config.value);
if (isMatch) { if (isMatch) {
return { success: true, message: "登录成功" }; return { success: true, message: "登录成功" };
} else { } else {

9400
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -5,7 +5,7 @@
"type": "module", "type": "module",
"main": "electron/main.js", "main": "electron/main.js",
"engines": { "engines": {
"node": "^20.19.0 || >=22.12.0" "node": "12.16.2"
}, },
"scripts": { "scripts": {
"start": "vite --mode electron", "start": "vite --mode electron",
@ -20,33 +20,31 @@
"electron:build:portable32": "vite build && set WIN_CODE_SIGN_MIRROR=https://npmmirror.com/mirrors/electron-builder-binaries/ && electron-builder --win --ia32" "electron:build:portable32": "vite build && set WIN_CODE_SIGN_MIRROR=https://npmmirror.com/mirrors/electron-builder-binaries/ && electron-builder --win --ia32"
}, },
"dependencies": { "dependencies": {
"@element-plus/icons-vue": "^2.3.1", "@element-plus/icons-vue": "1.1.4",
"@fortawesome/fontawesome-svg-core": "^7.0.0", "@fortawesome/fontawesome-svg-core": "6.4.0",
"@fortawesome/free-brands-svg-icons": "^7.0.0", "@fortawesome/free-brands-svg-icons": "6.4.0",
"@fortawesome/free-regular-svg-icons": "^7.0.0", "@fortawesome/free-regular-svg-icons": "6.4.0",
"@fortawesome/free-solid-svg-icons": "^7.0.0", "@fortawesome/free-solid-svg-icons": "6.4.0",
"@fortawesome/vue-fontawesome": "^3.1.1", "@fortawesome/vue-fontawesome": "3.0.0-5",
"@popperjs/core": "^2.11.8", "@popperjs/core": "2.11.6",
"argon2": "^0.43.1", "bcrypt": "5.0.1",
"bootstrap": "^5.3.7", "bootstrap": "5.2.3",
"element-plus": "^2.10.5", "element-plus": "2.2.36",
"fs": "^0.0.1-security", "fs": "0.0.1-security",
"pdfkit": "^0.17.1", "pdfkit": "0.16.0",
"popper.js": "^1.16.1", "popper.js": "1.16.1",
"sqlite": "^5.1.1", "sqlite3": "5.0.2",
"sqlite3": "^5.1.7", "vue": "3.2.37",
"vue": "^3.5.18", "vue-router": "4.0.16",
"vue-router": "^4.5.1", "xlsx": "0.18.5"
"xlsx": "^0.18.5"
}, },
"devDependencies": { "devDependencies": {
"@electron/rebuild": "^4.0.1", "@electron/rebuild": "3.2.10",
"@vitejs/plugin-vue": "^6.0.1", "@vitejs/plugin-vue": "2.3.3",
"electron": "^37.2.5", "electron": "^12.2.3",
"electron-builder": "^26.0.12", "electron-builder": "20.38.2",
"vite": "^7.0.6", "vite": "2.9.16",
"vite-plugin-electron": "^0.29.0", "vite-plugin-electron": "0.9.0"
"vite-plugin-vue-devtools": "^8.0.0"
}, },
"build": { "build": {
"appId": "com.example.electron-exam", "appId": "com.example.electron-exam",

View File

@ -1,35 +1,28 @@
import { defineConfig } from 'vite' import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue' import vue from '@vitejs/plugin-vue';
import vueDevTools from 'vite-plugin-vue-devtools' import electron from 'vite-plugin-electron';
import electron from 'vite-plugin-electron'
import { fileURLToPath } from 'url';
// 不使用任何global对象操作仅使用基本配置
export default defineConfig({ export default defineConfig({
base: './', base: './',
plugins: [ plugins: [
vue(), vue(),
vueDevTools(),
electron({ electron({
entry: 'electron/main.js', entry: 'electron/main.js',
onstart(options) {
// 确保只启动一个 Electron 实例
options.startup(['.', '--no-sandbox']);
}
}), }),
], ],
resolve: { resolve: {
alias: { alias: {
'@': fileURLToPath(new URL('./src', import.meta.url)) '@': '/Users/chenqiang/workspace/work/exam/electron/win7/src'
}, },
}, },
build: { build: {
// 确保打包后的文件使用相对路径
rollupOptions: { rollupOptions: {
output: { output: {
assetFileNames: 'assets/[name]-[hash].[ext]', assetFileNames: 'assets/[name].[hash].[ext]',
chunkFileNames: 'chunks/[name]-[hash].js', chunkFileNames: 'assets/[name].[hash].js',
entryFileNames: 'entry-[name]-[hash].js', entryFileNames: 'assets/[name].[hash].js'
} }
} }
} }
}) });