From c3f8b628f0af7f5e05e6e31f10215eba37270069 Mon Sep 17 00:00:00 2001 From: Tlntin Date: Thu, 26 Jan 2023 12:18:50 +0800 Subject: [PATCH] add multi-architecture support for MacOS --- bin/README.md | 14 +++++----- bin/README_EN.md | 12 +++++---- bin/builders/MacBuilder.ts | 4 +-- bin/cli.ts | 2 +- bin/defaults.ts | 2 +- bin/types.ts | 2 +- dist/cli.js | 53 ++++++++++++++++++++++++++------------ 7 files changed, 55 insertions(+), 34 deletions(-) diff --git a/bin/README.md b/bin/README.md index 9a16cba..7aa7928 100644 --- a/bin/README.md +++ b/bin/README.md @@ -99,7 +99,7 @@ url 为你需要打包的网页链接 🔗,必须提供。 #### [transparent] -是否开启沉浸式头部,默认为 `false` 不开启。 +是否开启沉浸式头部,默认为 `false` 不开启。使用下面的命令来开启该功能。 ```shell --transparent @@ -109,7 +109,7 @@ url 为你需要打包的网页链接 🔗,必须提供。 #### [resize] -是否可以拖动大小,默认为 `true` 可拖动。 +是否可以拖动大小,默认为 `true` 可拖动。使用下面的命令来关闭该功能。 ```shell --no-resizable @@ -117,12 +117,12 @@ url 为你需要打包的网页链接 🔗,必须提供。 #### [fullscreen] -打开应用后是否开启全屏,默认为 `false`。 +打开应用后是否开启全屏,默认为 `false`,使用下面的命令开启该功能。 ```shell ---fullscreen +--fullscreen # 或者 --f +-f ``` #### [multi-arch] @@ -140,7 +140,7 @@ rustup target add x86_64-apple-darwin ``` ##### 使用方法 ```shell ---multi-arch +--multi-arch # 或者 --m +-m ``` \ No newline at end of file diff --git a/bin/README_EN.md b/bin/README_EN.md index 74a385b..7f6b359 100644 --- a/bin/README_EN.md +++ b/bin/README_EN.md @@ -98,7 +98,7 @@ The width of the packaged application window. The default is `1200px`. #### [transparent] -Whether to enable the immersive header. The default is `false`. +Whether to enable the immersive header. The default is `false`. Use the command below to enable this feature. ```shell --transparent @@ -109,6 +109,7 @@ Whether to enable the immersive header. The default is `false`. #### [resize] Indicates if the window can be resized. The default value is `true`. +Use the command below to disable this feature. ```shell --no-resizable @@ -117,11 +118,12 @@ Indicates if the window can be resized. The default value is `true`. #### [fullscreen] Indicates if the window should be full screen on application launch. The default is `false`. +Use the command below to enable this feature. ```shell ---fullscreen +--fullscreen # or --f +-f ``` #### [multi-arch] @@ -139,7 +141,7 @@ rustup target add x86_64-apple-darwin ``` ##### Instructions ```shell ---multi-arch +--multi-arch # or --m +-m ``` diff --git a/bin/builders/MacBuilder.ts b/bin/builders/MacBuilder.ts index e1e123e..71dc5d0 100644 --- a/bin/builders/MacBuilder.ts +++ b/bin/builders/MacBuilder.ts @@ -40,7 +40,7 @@ export default class MacBuilder implements IBuilder { await mergeTauriConfig(url, options, tauriConf); let dmgName: string; - if (options.multi_arch) { + if (options.multiArch) { await shellExec(`cd ${npmDirectory} && npm install && npm run build:mac`); dmgName = `${name}_${tauriConf.package.version}_universal.dmg`; } else { @@ -53,7 +53,7 @@ export default class MacBuilder implements IBuilder { } dmgName = `${name}_${tauriConf.package.version}_${arch}.dmg`; } - const appPath = this.getBuildAppPath(npmDirectory, dmgName, options.multi_arch); + const appPath = this.getBuildAppPath(npmDirectory, dmgName, options.multiArch); const distPath = path.resolve(`${name}.dmg`); await fs.copyFile(appPath, distPath); await fs.unlink(appPath); diff --git a/bin/cli.ts b/bin/cli.ts index b68ef5d..cdb586a 100644 --- a/bin/cli.ts +++ b/bin/cli.ts @@ -22,7 +22,7 @@ program .option('-f, --fullscreen', 'makes the packaged app start in full screen', DEFAULT_PAKE_OPTIONS.fullscreen) .option('-t, --transparent', 'transparent title bar', DEFAULT_PAKE_OPTIONS.transparent) .option('-d, --debug', 'debug', DEFAULT_PAKE_OPTIONS.debug) - .option('-m, --multi-arch', "Supports both Intel and m1 chips, only for Mac.", DEFAULT_PAKE_OPTIONS.multi_arch) + .option('-m, --multi-arch', "Supports both Intel and m1 chips, only for Mac.", DEFAULT_PAKE_OPTIONS.multiArch) .action(async (url: string, options: PakeCliOptions) => { await checkUpdateTips(); diff --git a/bin/defaults.ts b/bin/defaults.ts index db801ca..b82cd08 100644 --- a/bin/defaults.ts +++ b/bin/defaults.ts @@ -8,7 +8,7 @@ export const DEFAULT_PAKE_OPTIONS: PakeCliOptions = { resizable: true, transparent: false, debug: false, - multi_arch: false, + multiArch: false, }; export const DEFAULT_APP_NAME = 'Pake'; diff --git a/bin/types.ts b/bin/types.ts index 7431d88..b503e52 100644 --- a/bin/types.ts +++ b/bin/types.ts @@ -24,7 +24,7 @@ export interface PakeCliOptions { debug: boolean; /** mutli arch, Supports both Intel and m1 chips, only for Mac */ - multi_arch: boolean; + multiArch: boolean; } export interface PakeAppOptions extends PakeCliOptions { diff --git a/dist/cli.js b/dist/cli.js index e69f157..64f6eca 100644 --- a/dist/cli.js +++ b/dist/cli.js @@ -48,7 +48,7 @@ const DEFAULT_PAKE_OPTIONS = { resizable: true, transparent: false, debug: false, - multi_arch: false, + multiArch: false, }; const tlds = [ @@ -1830,8 +1830,8 @@ function checkRustInstalled() { var tauri$3 = { windows: [ { - url: "https://weread.qq.com/", - transparent: true, + url: "https://www.baidu.com", + transparent: false, fullscreen: false, width: 1200, height: 780, @@ -1843,21 +1843,40 @@ var tauri$3 = { }, updater: { active: false + }, + bundle: { + icon: [ + "/Users/hfy/Documents/electron_s/Pake/src-tauri/icons/icon.icns" + ], + identifier: "pake-f9751d", + active: true, + category: "DeveloperTool", + copyright: "", + externalBin: [ + ], + longDescription: "", + macOS: { + entitlements: null, + exceptionDomain: "", + frameworks: [ + ], + providerShortName: null, + signingIdentity: null + }, + resources: [ + ], + shortDescription: "", + targets: [ + "dmg" + ] } }; -var build = { - devPath: "../dist", - distDir: "../dist", - beforeBuildCommand: "", - beforeDevCommand: "" -}; var CommonConf = { "package": { - productName: "WeRead", + productName: "baidu", version: "1.0.0" }, - tauri: tauri$3, - build: build + tauri: tauri$3 }; var tauri$2 = { @@ -1900,9 +1919,9 @@ var WinConf = { var tauri$1 = { bundle: { icon: [ - "icons/weread.icns" + "/Users/hfy/Documents/electron_s/Pake/src-tauri/icons/icon.icns" ], - identifier: "com.tw93.weread", + identifier: "pake-f9751d", active: true, category: "DeveloperTool", copyright: "", @@ -2018,7 +2037,7 @@ class MacBuilder { const { name } = options; yield mergeTauriConfig(url, options, tauriConf); let dmgName; - if (options.multi_arch) { + if (options.multiArch) { yield shellExec(`cd ${npmDirectory} && npm install && npm run build:mac`); dmgName = `${name}_${tauriConf.package.version}_universal.dmg`; } @@ -2033,7 +2052,7 @@ class MacBuilder { } dmgName = `${name}_${tauriConf.package.version}_${arch}.dmg`; } - const appPath = this.getBuildAppPath(npmDirectory, dmgName, options.multi_arch); + const appPath = this.getBuildAppPath(npmDirectory, dmgName, options.multiArch); const distPath = path.resolve(`${name}.dmg`); yield fs.copyFile(appPath, distPath); yield fs.unlink(appPath); @@ -2285,7 +2304,7 @@ program .option('-f, --fullscreen', 'makes the packaged app start in full screen', DEFAULT_PAKE_OPTIONS.fullscreen) .option('-t, --transparent', 'transparent title bar', DEFAULT_PAKE_OPTIONS.transparent) .option('-d, --debug', 'debug', DEFAULT_PAKE_OPTIONS.debug) - .option('-m, --multi-arch', "Supports both Intel and m1 chips, only for Mac.", DEFAULT_PAKE_OPTIONS.multi_arch) + .option('-m, --multi-arch', "Supports both Intel and m1 chips, only for Mac.", DEFAULT_PAKE_OPTIONS.multiArch) .action((url, options) => __awaiter(void 0, void 0, void 0, function* () { yield checkUpdateTips(); if (!url) {