support multiple-instances

This commit is contained in:
Tw93
2025-10-06 12:25:38 +08:00
parent 7ee7924eec
commit 3d4c018641
10 changed files with 61 additions and 18 deletions

26
dist/cli.js vendored
View File

@@ -343,26 +343,21 @@ function generateLinuxPackageName(name) {
.replace(/-+/g, '-');
}
function generateIdentifierSafeName(name) {
// Support Chinese characters (CJK Unified Ideographs: U+4E00-U+9FFF)
// and other common Unicode letter categories
const cleaned = name
.replace(/[^a-zA-Z0-9\u4e00-\u9fff]/g, '')
.toLowerCase();
// If result is empty after cleaning, generate a fallback based on original name
const cleaned = name.replace(/[^a-zA-Z0-9\u4e00-\u9fff]/g, '').toLowerCase();
if (cleaned === '') {
// Convert to ASCII-safe representation using character codes
const fallback = Array.from(name)
.map(char => {
.map((char) => {
const code = char.charCodeAt(0);
// Keep ASCII alphanumeric, convert others to their hex codes
if ((code >= 48 && code <= 57) || (code >= 65 && code <= 90) || (code >= 97 && code <= 122)) {
if ((code >= 48 && code <= 57) ||
(code >= 65 && code <= 90) ||
(code >= 97 && code <= 122)) {
return char.toLowerCase();
}
return code.toString(16);
})
.join('')
.slice(0, 50); // Limit length to avoid extremely long names
return fallback || 'pake-app'; // Ultimate fallback
.slice(0, 50);
return fallback || 'pake-app';
}
return cleaned;
}
@@ -387,7 +382,7 @@ async function mergeConfig(url, options, tauriConf) {
await fsExtra.copy(sourcePath, destPath);
}
}));
const { width, height, fullscreen, hideTitleBar, alwaysOnTop, appVersion, darkMode, disabledWebShortcuts, activationShortcut, userAgent, showSystemTray, systemTrayIcon, useLocalFile, identifier, name, resizable = true, inject, proxyUrl, installerLanguage, hideOnClose, incognito, title, wasm, enableDragDrop, } = options;
const { width, height, fullscreen, hideTitleBar, alwaysOnTop, appVersion, darkMode, disabledWebShortcuts, activationShortcut, userAgent, showSystemTray, systemTrayIcon, useLocalFile, identifier, name, resizable = true, inject, proxyUrl, installerLanguage, hideOnClose, incognito, title, wasm, enableDragDrop, multiInstance, } = options;
const { platform } = process;
const platformHideOnClose = hideOnClose ?? platform === 'darwin';
const tauriConfWindowOptions = {
@@ -602,6 +597,7 @@ StartupNotify=true
await fsExtra.writeFile(injectFilePath, '');
}
tauriConf.pake.proxy_url = proxyUrl || '';
tauriConf.pake.multi_instance = multiInstance;
// Configure WASM support with required HTTP headers
if (wasm) {
tauriConf.app.security = {
@@ -1181,6 +1177,7 @@ const DEFAULT_PAKE_OPTIONS = {
wasm: false,
enableDragDrop: false,
keepBinary: false,
multiInstance: false,
};
async function checkUpdateTips() {
@@ -1704,6 +1701,9 @@ program
.addOption(new Option('--keep-binary', 'Keep raw binary file alongside installer')
.default(DEFAULT_PAKE_OPTIONS.keepBinary)
.hideHelp())
.addOption(new Option('--multi-instance', 'Allow multiple app instances')
.default(DEFAULT_PAKE_OPTIONS.multiInstance)
.hideHelp())
.addOption(new Option('--installer-language <string>', 'Installer language')
.default(DEFAULT_PAKE_OPTIONS.installerLanguage)
.hideHelp())