From 48cb1c14b52a8ed28c809def69ac73eaabb82d45 Mon Sep 17 00:00:00 2001 From: Tlntin <371043382@qq.com> Date: Tue, 6 Dec 2022 18:22:46 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=9B=BE=E6=A0=87=E5=A4=B1?= =?UTF-8?q?=E6=95=88=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/builders/common.ts | 22 ++++++++++++++++++++++ dist/cli.js | 35 +++++++++++++++++++++++++++-------- 2 files changed, 49 insertions(+), 8 deletions(-) diff --git a/bin/builders/common.ts b/bin/builders/common.ts index 14dc8e5..91ad334 100644 --- a/bin/builders/common.ts +++ b/bin/builders/common.ts @@ -41,6 +41,28 @@ export async function mergeTauriConfig( tauriConf.package.productName = name; tauriConf.tauri.bundle.identifier = identifier; tauriConf.tauri.bundle.icon = [options.icon]; + if (process.platform === "win32") { + const ico_path = path.join(npmDirectory, 'src-tauri/png/weread_32.ico'); + await fs.copyFile(options.icon, ico_path); + + } + let configPath = ""; + switch (process.platform) { + case "win32": { + configPath = path.join(npmDirectory, 'src-tauri/tauri.windows.conf.json'); + break; + } + case "darwin": { + configPath = path.join(npmDirectory, 'src-tauri/tauri.macos.conf.json'); + break; + } + } + + let bundleConf = {tauri: {bundle: tauriConf.tauri.bundle}}; + await fs.writeFile( + configPath, + Buffer.from(JSON.stringify(bundleConf), 'utf-8') + ); const configJsonPath = path.join(npmDirectory, 'src-tauri/tauri.conf.json') diff --git a/dist/cli.js b/dist/cli.js index 49abe02..018abeb 100644 --- a/dist/cli.js +++ b/dist/cli.js @@ -1618,6 +1618,25 @@ function mergeTauriConfig(url, options, tauriConf) { tauriConf.package.productName = name; tauriConf.tauri.bundle.identifier = identifier; tauriConf.tauri.bundle.icon = [options.icon]; + if (process.platform === "win32") { + const ico_path = path.join(npmDirectory, 'src-tauri/png/weread_32.ico'); + // tauriConf.tauri.bundle.resources = [options.icon]; + yield fs.copyFile(options.icon, ico_path); + } + let configPath = ""; + switch (process.platform) { + case "win32": { + configPath = path.join(npmDirectory, 'src-tauri/tauri.windows.conf.json'); + break; + } + case "darwin": { + configPath = path.join(npmDirectory, 'src-tauri/tauri.macos.conf.json'); + break; + } + } + let bundleConf = { tauri: { bundle: tauriConf.tauri.bundle } }; + yield fs.writeFile(configPath, Buffer.from(JSON.stringify(bundleConf), 'utf-8')); + // delete tauriConf.tauri.bundle; const configJsonPath = path.join(npmDirectory, 'src-tauri/tauri.conf.json'); yield fs.writeFile(configJsonPath, Buffer.from(JSON.stringify(tauriConf), 'utf-8')); }); @@ -1791,9 +1810,15 @@ var tauri$2 = { resizable: true } ], + security: { + csp: null + }, + updater: { + active: false + }, bundle: { icon: [ - "C:\\Users\\18826\\Documents\\electron_build\\Pake\\pake-default.icns" + "C:\\Users\\18826\\Documents\\electron_build\\Pake\\src-tauri\\png\\code_256.ico" ], identifier: "pake-f9751d", active: true, @@ -1803,7 +1828,7 @@ var tauri$2 = { ], longDescription: "", resources: [ - "png/weread_32.ico" + "C:\\Users\\18826\\Documents\\electron_build\\Pake\\src-tauri\\png\\code_256.ico" ], shortDescription: "", targets: [ @@ -1819,12 +1844,6 @@ var tauri$2 = { ] } } - }, - security: { - csp: null - }, - updater: { - active: false } }; var CommonConf = {