C端改造
This commit is contained in:
@@ -88,15 +88,15 @@ class ConfigGenerator {
|
||||
console.log('[ConfigGenerator] Data path:', this.dataPath);
|
||||
console.log('[ConfigGenerator] MySQL port:', options.mysqlPort || 3306);
|
||||
console.log('[ConfigGenerator] MySQL password:', options.mysqlPassword || 'njcnpqs');
|
||||
console.log('[ConfigGenerator] Java port:', options.javaPort || 18092);
|
||||
console.log('[ConfigGenerator] WebSocket port:', options.websocketPort || 7777);
|
||||
|
||||
console.log('[ConfigGenerator] Java port:', options.javaPort || 18093);
|
||||
console.log('[ConfigGenerator] WebSocket port:', options.websocketPort || 7778);
|
||||
|
||||
resolve({
|
||||
configPath: this.configPath,
|
||||
dataPath: this.dataPath,
|
||||
mysqlPort: options.mysqlPort || 3306,
|
||||
javaPort: options.javaPort || 18092,
|
||||
websocketPort: options.websocketPort || 7777
|
||||
javaPort: options.javaPort || 18093,
|
||||
websocketPort: options.websocketPort || 7778
|
||||
});
|
||||
} catch (error) {
|
||||
console.error('[ConfigGenerator] Failed to generate config:', error);
|
||||
@@ -123,6 +123,75 @@ class ConfigGenerator {
|
||||
console.log('[ConfigGenerator] Created directory:', dir);
|
||||
}
|
||||
});
|
||||
|
||||
// 复制内置的报告模板文件
|
||||
this.copyBuiltInTemplates();
|
||||
}
|
||||
|
||||
/**
|
||||
* 复制内置的报告模板文件到用户数据目录
|
||||
*/
|
||||
copyBuiltInTemplates() {
|
||||
try {
|
||||
const isDev = !process.resourcesPath;
|
||||
const baseDir = isDev
|
||||
? path.join(__dirname, '..')
|
||||
: path.dirname(process.resourcesPath);
|
||||
|
||||
// 内置模板源路径
|
||||
const templateSource = isDev
|
||||
? path.join(baseDir, 'build', 'extraResources', 'templates')
|
||||
: path.join(process.resourcesPath, 'extraResources', 'templates');
|
||||
|
||||
// 目标路径:用户数据目录/template/
|
||||
const templateDest = path.join(this.dataPath, 'template');
|
||||
|
||||
// 检查源模板是否存在
|
||||
if (!fs.existsSync(templateSource)) {
|
||||
console.log('[ConfigGenerator] Built-in templates not found, skipping copy');
|
||||
return;
|
||||
}
|
||||
|
||||
// 递归复制模板文件(只复制不存在的文件,不覆盖已有文件)
|
||||
this.copyTemplatesRecursive(templateSource, templateDest);
|
||||
|
||||
console.log('[ConfigGenerator] Built-in templates copied successfully');
|
||||
} catch (error) {
|
||||
console.error('[ConfigGenerator] Failed to copy templates:', error);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 递归复制模板文件(不覆盖已存在的文件)
|
||||
* @param {string} src 源目录
|
||||
* @param {string} dest 目标目录
|
||||
*/
|
||||
copyTemplatesRecursive(src, dest) {
|
||||
// 确保目标目录存在
|
||||
if (!fs.existsSync(dest)) {
|
||||
fs.mkdirSync(dest, { recursive: true });
|
||||
}
|
||||
|
||||
// 读取源目录内容
|
||||
const entries = fs.readdirSync(src, { withFileTypes: true });
|
||||
|
||||
entries.forEach(entry => {
|
||||
const srcPath = path.join(src, entry.name);
|
||||
const destPath = path.join(dest, entry.name);
|
||||
|
||||
if (entry.isDirectory()) {
|
||||
// 递归复制子目录
|
||||
this.copyTemplatesRecursive(srcPath, destPath);
|
||||
} else {
|
||||
// 只复制不存在的文件(不覆盖用户修改过的文件)
|
||||
if (!fs.existsSync(destPath)) {
|
||||
fs.copyFileSync(srcPath, destPath);
|
||||
console.log('[ConfigGenerator] Copied template:', destPath);
|
||||
} else {
|
||||
console.log('[ConfigGenerator] Template already exists, skipping:', destPath);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user