C端打包修复不能在中文路径下启动的问题
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const { resolveRuntimeStrategy } = require('./path-utils');
|
||||
|
||||
/**
|
||||
* 配置文件生成器
|
||||
@@ -8,11 +9,12 @@ const path = require('path');
|
||||
class ConfigGenerator {
|
||||
constructor() {
|
||||
// 开发环境:项目根目录
|
||||
// 打包后:应用根目录(win-unpacked)
|
||||
// 打包后:应用根目录(最终交付目录)
|
||||
const isDev = !process.resourcesPath;
|
||||
const baseDir = isDev
|
||||
? path.join(__dirname, '..')
|
||||
: path.dirname(process.resourcesPath);
|
||||
const pathStrategy = resolveRuntimeStrategy(baseDir);
|
||||
|
||||
// 开发环境:build/extraResources/java
|
||||
// 打包后:resources/extraResources/java
|
||||
@@ -21,9 +23,12 @@ class ConfigGenerator {
|
||||
: path.join(process.resourcesPath, 'extraResources', 'java');
|
||||
this.templatePath = path.join(this.javaPath, 'application.yml.template');
|
||||
this.configPath = path.join(this.javaPath, 'application.yml');
|
||||
this.pathStrategy = pathStrategy;
|
||||
|
||||
// 数据目录(使用应用所在盘符的根目录下的data文件夹)
|
||||
this.dataPath = this.getDataPath(baseDir);
|
||||
// 数据目录:
|
||||
// - 安全路径:使用应用目录内的 NPQS9100_Data
|
||||
// - 非 ASCII 路径:切到英文安全运行根目录下,避免在盘符根目录创建多个文件夹
|
||||
this.dataPath = this.getDataPath(baseDir, pathStrategy);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -31,8 +36,11 @@ class ConfigGenerator {
|
||||
* @param {string} baseDir 应用基础目录
|
||||
* @returns {string} 数据目录路径
|
||||
*/
|
||||
getDataPath(baseDir) {
|
||||
// 数据目录设置在应用目录内的 NPQS9100_Data 文件夹
|
||||
getDataPath(baseDir, pathStrategy = resolveRuntimeStrategy(baseDir)) {
|
||||
if (pathStrategy.usesSafePaths) {
|
||||
return path.join(pathStrategy.safeRuntimeRoot, 'data');
|
||||
}
|
||||
|
||||
return path.join(baseDir, 'NPQS9100_Data');
|
||||
}
|
||||
|
||||
@@ -85,6 +93,7 @@ class ConfigGenerator {
|
||||
this.createDirectories();
|
||||
|
||||
console.log('[ConfigGenerator] Configuration file generated successfully');
|
||||
console.log('[ConfigGenerator] Path mode:', this.pathStrategy.usesSafePaths ? 'safe-data-root' : 'app-local-data');
|
||||
console.log('[ConfigGenerator] Data path:', this.dataPath);
|
||||
console.log('[ConfigGenerator] MySQL port:', options.mysqlPort || 3306);
|
||||
console.log('[ConfigGenerator] MySQL password:', options.mysqlPassword || 'njcnpqs');
|
||||
|
||||
Reference in New Issue
Block a user