修正启动模式
This commit is contained in:
@@ -38,8 +38,8 @@ if (!fs.existsSync(distDir)) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 使用node启动服务器
|
// 使用start:node server.js启动服务器
|
||||||
const server = spawn('node', [serverPath], {
|
const server = spawn('node', ['server/index.js'], {
|
||||||
cwd: rootDir,
|
cwd: rootDir,
|
||||||
env: {
|
env: {
|
||||||
...process.env,
|
...process.env,
|
||||||
@@ -49,6 +49,8 @@ const server = spawn('node', [serverPath], {
|
|||||||
stdio: ['ignore', 'pipe', 'pipe']
|
stdio: ['ignore', 'pipe', 'pipe']
|
||||||
});
|
});
|
||||||
|
|
||||||
|
console.log('使用启动命令: start:node server.js');
|
||||||
|
|
||||||
// 将输出写入日志
|
// 将输出写入日志
|
||||||
server.stdout.pipe(logStream);
|
server.stdout.pipe(logStream);
|
||||||
server.stderr.pipe(logStream);
|
server.stderr.pipe(logStream);
|
||||||
|
|||||||
46
reset_password.js
Normal file
46
reset_password.js
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
// 重置所有密码为123456的脚本
|
||||||
|
const sqlite3 = require('sqlite3').verbose();
|
||||||
|
const path = require('path');
|
||||||
|
const fs = require('fs');
|
||||||
|
|
||||||
|
// 获取项目根目录
|
||||||
|
const rootDir = __dirname;
|
||||||
|
const dbPath = path.join(rootDir, 'server', 'lottery.db');
|
||||||
|
|
||||||
|
console.log('开始重置所有密码为123456...');
|
||||||
|
console.log(`数据库路径: ${dbPath}`);
|
||||||
|
|
||||||
|
// 检查数据库文件是否存在
|
||||||
|
if (!fs.existsSync(dbPath)) {
|
||||||
|
console.error(`错误: 数据库文件不存在: ${dbPath}`);
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 连接数据库
|
||||||
|
const db = new sqlite3.Database(dbPath, (err) => {
|
||||||
|
if (err) {
|
||||||
|
console.error(`连接数据库失败: ${err.message}`);
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
console.log('成功连接到数据库');
|
||||||
|
|
||||||
|
// 更新系统配置表中的密码
|
||||||
|
db.run(
|
||||||
|
`UPDATE system_config SET admin_password = '123456', login_password = '123456'`,
|
||||||
|
function(err) {
|
||||||
|
if (err) {
|
||||||
|
console.error(`更新密码失败: ${err.message}`);
|
||||||
|
db.close();
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(`密码更新成功! 已修改 ${this.changes} 条记录`);
|
||||||
|
console.log('所有密码已重置为: 123456');
|
||||||
|
|
||||||
|
// 关闭数据库连接
|
||||||
|
db.close(() => {
|
||||||
|
console.log('数据库连接已关闭');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user