add multi-architecture support for MacOS

This commit is contained in:
Tlntin
2023-01-26 12:18:50 +08:00
parent c6555370dc
commit c3f8b628f0
7 changed files with 55 additions and 34 deletions

14
bin/README.md vendored
View File

@@ -99,7 +99,7 @@ url 为你需要打包的网页链接 🔗,必须提供。
#### [transparent] #### [transparent]
是否开启沉浸式头部,默认为 `false` 不开启。 是否开启沉浸式头部,默认为 `false` 不开启。使用下面的命令来开启该功能。
```shell ```shell
--transparent --transparent
@@ -109,7 +109,7 @@ url 为你需要打包的网页链接 🔗,必须提供。
#### [resize] #### [resize]
是否可以拖动大小,默认为 `true` 可拖动。 是否可以拖动大小,默认为 `true` 可拖动。使用下面的命令来关闭该功能。
```shell ```shell
--no-resizable --no-resizable
@@ -117,12 +117,12 @@ url 为你需要打包的网页链接 🔗,必须提供。
#### [fullscreen] #### [fullscreen]
打开应用后是否开启全屏,默认为 `false`。 打开应用后是否开启全屏,默认为 `false`,使用下面的命令开启该功能
```shell ```shell
--fullscreen <value> --fullscreen
# 或者 # 或者
-f <value> -f
``` ```
#### [multi-arch] #### [multi-arch]
@@ -140,7 +140,7 @@ rustup target add x86_64-apple-darwin
``` ```
##### 使用方法 ##### 使用方法
```shell ```shell
--multi-arch <value> --multi-arch
# 或者 # 或者
-m <value> -m
``` ```

12
bin/README_EN.md vendored
View File

@@ -98,7 +98,7 @@ The width of the packaged application window. The default is `1200px`.
#### [transparent] #### [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 ```shell
--transparent --transparent
@@ -109,6 +109,7 @@ Whether to enable the immersive header. The default is `false`.
#### [resize] #### [resize]
Indicates if the window can be resized. The default value is `true`. Indicates if the window can be resized. The default value is `true`.
Use the command below to disable this feature.
```shell ```shell
--no-resizable --no-resizable
@@ -117,11 +118,12 @@ Indicates if the window can be resized. The default value is `true`.
#### [fullscreen] #### [fullscreen]
Indicates if the window should be full screen on application launch. The default is `false`. Indicates if the window should be full screen on application launch. The default is `false`.
Use the command below to enable this feature.
```shell ```shell
--fullscreen <value> --fullscreen
# or # or
-f <value> -f
``` ```
#### [multi-arch] #### [multi-arch]
@@ -139,7 +141,7 @@ rustup target add x86_64-apple-darwin
``` ```
##### Instructions ##### Instructions
```shell ```shell
--multi-arch <value> --multi-arch
# or # or
-m <value> -m
``` ```

View File

@@ -40,7 +40,7 @@ export default class MacBuilder implements IBuilder {
await mergeTauriConfig(url, options, tauriConf); await mergeTauriConfig(url, options, tauriConf);
let dmgName: string; let dmgName: string;
if (options.multi_arch) { if (options.multiArch) {
await shellExec(`cd ${npmDirectory} && npm install && npm run build:mac`); await shellExec(`cd ${npmDirectory} && npm install && npm run build:mac`);
dmgName = `${name}_${tauriConf.package.version}_universal.dmg`; dmgName = `${name}_${tauriConf.package.version}_universal.dmg`;
} else { } else {
@@ -53,7 +53,7 @@ export default class MacBuilder implements IBuilder {
} }
dmgName = `${name}_${tauriConf.package.version}_${arch}.dmg`; 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`); const distPath = path.resolve(`${name}.dmg`);
await fs.copyFile(appPath, distPath); await fs.copyFile(appPath, distPath);
await fs.unlink(appPath); await fs.unlink(appPath);

2
bin/cli.ts vendored
View File

@@ -22,7 +22,7 @@ program
.option('-f, --fullscreen', 'makes the packaged app start in full screen', DEFAULT_PAKE_OPTIONS.fullscreen) .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('-t, --transparent', 'transparent title bar', DEFAULT_PAKE_OPTIONS.transparent)
.option('-d, --debug', 'debug', DEFAULT_PAKE_OPTIONS.debug) .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) => { .action(async (url: string, options: PakeCliOptions) => {
await checkUpdateTips(); await checkUpdateTips();

2
bin/defaults.ts vendored
View File

@@ -8,7 +8,7 @@ export const DEFAULT_PAKE_OPTIONS: PakeCliOptions = {
resizable: true, resizable: true,
transparent: false, transparent: false,
debug: false, debug: false,
multi_arch: false, multiArch: false,
}; };
export const DEFAULT_APP_NAME = 'Pake'; export const DEFAULT_APP_NAME = 'Pake';

2
bin/types.ts vendored
View File

@@ -24,7 +24,7 @@ export interface PakeCliOptions {
debug: boolean; debug: boolean;
/** mutli arch, Supports both Intel and m1 chips, only for Mac */ /** mutli arch, Supports both Intel and m1 chips, only for Mac */
multi_arch: boolean; multiArch: boolean;
} }
export interface PakeAppOptions extends PakeCliOptions { export interface PakeAppOptions extends PakeCliOptions {

53
dist/cli.js vendored
View File

@@ -48,7 +48,7 @@ const DEFAULT_PAKE_OPTIONS = {
resizable: true, resizable: true,
transparent: false, transparent: false,
debug: false, debug: false,
multi_arch: false, multiArch: false,
}; };
const tlds = [ const tlds = [
@@ -1830,8 +1830,8 @@ function checkRustInstalled() {
var tauri$3 = { var tauri$3 = {
windows: [ windows: [
{ {
url: "https://weread.qq.com/", url: "https://www.baidu.com",
transparent: true, transparent: false,
fullscreen: false, fullscreen: false,
width: 1200, width: 1200,
height: 780, height: 780,
@@ -1843,21 +1843,40 @@ var tauri$3 = {
}, },
updater: { updater: {
active: false 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 = { var CommonConf = {
"package": { "package": {
productName: "WeRead", productName: "baidu",
version: "1.0.0" version: "1.0.0"
}, },
tauri: tauri$3, tauri: tauri$3
build: build
}; };
var tauri$2 = { var tauri$2 = {
@@ -1900,9 +1919,9 @@ var WinConf = {
var tauri$1 = { var tauri$1 = {
bundle: { bundle: {
icon: [ icon: [
"icons/weread.icns" "/Users/hfy/Documents/electron_s/Pake/src-tauri/icons/icon.icns"
], ],
identifier: "com.tw93.weread", identifier: "pake-f9751d",
active: true, active: true,
category: "DeveloperTool", category: "DeveloperTool",
copyright: "", copyright: "",
@@ -2018,7 +2037,7 @@ class MacBuilder {
const { name } = options; const { name } = options;
yield mergeTauriConfig(url, options, tauriConf); yield mergeTauriConfig(url, options, tauriConf);
let dmgName; let dmgName;
if (options.multi_arch) { if (options.multiArch) {
yield shellExec(`cd ${npmDirectory} && npm install && npm run build:mac`); yield shellExec(`cd ${npmDirectory} && npm install && npm run build:mac`);
dmgName = `${name}_${tauriConf.package.version}_universal.dmg`; dmgName = `${name}_${tauriConf.package.version}_universal.dmg`;
} }
@@ -2033,7 +2052,7 @@ class MacBuilder {
} }
dmgName = `${name}_${tauriConf.package.version}_${arch}.dmg`; 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`); const distPath = path.resolve(`${name}.dmg`);
yield fs.copyFile(appPath, distPath); yield fs.copyFile(appPath, distPath);
yield fs.unlink(appPath); 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('-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('-t, --transparent', 'transparent title bar', DEFAULT_PAKE_OPTIONS.transparent)
.option('-d, --debug', 'debug', DEFAULT_PAKE_OPTIONS.debug) .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* () { .action((url, options) => __awaiter(void 0, void 0, void 0, function* () {
yield checkUpdateTips(); yield checkUpdateTips();
if (!url) { if (!url) {