更新优化

This commit is contained in:
24kycj
2025-12-12 00:10:13 +08:00
parent 026d564c92
commit 50ff0d347a
34 changed files with 8669 additions and 7884 deletions
+58 -6
View File
@@ -152,26 +152,78 @@ function createWindow() {
const fileName = 'User Manual.pdf';
if (app.isPackaged) {
helpPath = path.join(process.resourcesPath, 'help', fileName);
// Linux打包后的路径:resources/help/ 或 resources/app.asar/help/
// Windows/Mac打包后的路径:resources/help/
if (process.platform === 'linux') {
// Linux上,尝试多个可能的路径
const possiblePaths = [
path.join(process.resourcesPath, 'help', fileName),
path.join(process.resourcesPath, 'app.asar', 'help', fileName),
path.join(__dirname, 'help', fileName),
path.join(process.resourcesPath, '..', 'help', fileName)
];
for (const testPath of possiblePaths) {
if (fs.existsSync(testPath)) {
helpPath = testPath;
break;
}
}
} else {
helpPath = path.join(process.resourcesPath, 'help', fileName);
}
} else {
helpPath = path.join(process.cwd(), 'help', fileName);
}
console.log("Help file path: ", helpPath);
if (fs.existsSync(helpPath)) {
if (helpPath && fs.existsSync(helpPath)) {
try {
const errorMessage = await shell.openPath(helpPath);
if (errorMessage) {
console.error('Error opening help file:', errorMessage);
// Linux上使用shell.openExternal更可靠
if (process.platform === 'linux') {
await shell.openExternal(`file://${helpPath}`);
} else {
console.log('Help file opened successfully');
const errorMessage = await shell.openPath(helpPath);
if (errorMessage) {
console.error('Error opening help file:', errorMessage);
// 如果openPath失败,尝试openExternal
await shell.openExternal(`file://${helpPath}`);
}
}
console.log('Help file opened successfully');
} catch (err) {
console.error('Exception when opening file:', err);
// 尝试使用openExternal作为后备方案
try {
await shell.openExternal(`file://${helpPath}`);
} catch (err2) {
console.error('Failed to open with openExternal:', err2);
}
}
} else {
console.error('Help file not found at:', helpPath);
// 尝试查找help文件的其他可能位置
const searchPaths = [
path.join(__dirname, 'help', fileName),
path.join(process.cwd(), 'help', fileName),
path.join(app.getAppPath(), 'help', fileName)
];
for (const searchPath of searchPaths) {
if (fs.existsSync(searchPath)) {
console.log('Found help file at alternative path:', searchPath);
try {
if (process.platform === 'linux') {
await shell.openExternal(`file://${searchPath}`);
} else {
await shell.openPath(searchPath);
}
return;
} catch (err) {
console.error('Failed to open help file:', err);
}
}
}
}
});