- backend/:Egg 3 纯 JSON 接口服务(MySQL 8 + Redis),全部走 header 令牌鉴权; 已彻底去掉服务端渲染(删除 page 控制器 / app/view / nunjucks / session / CSRF), 开发时把页面请求反代到前端 dev server,生产托管 frontend/dist(SPA 回退)。 单测 91 个通过(不需要本机数据库)。 - frontend/:Vite + Vue3 + TypeScript 的 SPA(登录 / 注册 / 找回密码 / 扫码登录与确认 / 首页统计 / 设备管理 / 扫码记录 / 个人中心 / 测试页),vue-tsc 类型检查与构建通过。 - extension/:MV3 浏览器扩展(零构建),注入第三方 WMS 页面识别运单号并打开溯源页。 - 忽略规则统一放根 .gitignore:node_modules、dist、logs / logs-*、run、typings、 .env*、config.local.js(含本机数据库与 Redis 密码,绝不入库)。
34 lines
1.0 KiB
JavaScript
34 lines
1.0 KiB
JavaScript
'use strict';
|
||
|
||
/**
|
||
* 脚本共用的数据库连接信息解析:
|
||
* 环境变量 > config/config.local.js(已 gitignore)> 内置默认值
|
||
*/
|
||
|
||
const fs = require('fs');
|
||
const path = require('path');
|
||
|
||
const { env } = process;
|
||
|
||
module.exports = function resolveDbConfig() {
|
||
const config = {
|
||
host: env.MYSQL_HOST || '127.0.0.1',
|
||
port: Number(env.MYSQL_PORT || 3307),
|
||
user: env.MYSQL_USER || 'packservice',
|
||
password: env.MYSQL_PASSWORD || '',
|
||
database: env.MYSQL_DATABASE || 'packservice',
|
||
multipleStatements: true,
|
||
};
|
||
|
||
const localPath = path.join(__dirname, '..', 'config', 'config.local.js');
|
||
if (fs.existsSync(localPath)) {
|
||
const { sequelize = {} } = require(localPath);
|
||
if (sequelize.host) config.host = sequelize.host;
|
||
if (sequelize.port) config.port = sequelize.port;
|
||
if (sequelize.username) config.user = sequelize.username;
|
||
if (sequelize.password !== undefined) config.password = sequelize.password;
|
||
if (sequelize.database) config.database = sequelize.database;
|
||
}
|
||
return config;
|
||
};
|