完成配套pake-cli命令
This commit is contained in:
128
bin/builders/common.ts
vendored
128
bin/builders/common.ts
vendored
@@ -15,6 +15,7 @@ export async function promptText(message: string, initial?: string) {
|
|||||||
return response.content;
|
return response.content;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export async function mergeTauriConfig(
|
export async function mergeTauriConfig(
|
||||||
url: string,
|
url: string,
|
||||||
options: PakeAppOptions,
|
options: PakeAppOptions,
|
||||||
@@ -26,6 +27,11 @@ export async function mergeTauriConfig(
|
|||||||
fullscreen,
|
fullscreen,
|
||||||
transparent,
|
transparent,
|
||||||
resizable,
|
resizable,
|
||||||
|
userAgent,
|
||||||
|
showMenu,
|
||||||
|
showSystemTray,
|
||||||
|
systemTrayIcon,
|
||||||
|
// iter_copy_file,
|
||||||
identifier,
|
identifier,
|
||||||
name,
|
name,
|
||||||
} = options;
|
} = options;
|
||||||
@@ -56,10 +62,84 @@ export async function mergeTauriConfig(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// logger.warn(JSON.stringify(tauriConf.pake.windows, null, 4));
|
||||||
|
Object.assign(tauriConf.pake.windows[0], { url, ...tauriConfWindowOptions });
|
||||||
|
// 判断一下url类型,是文件还是网站
|
||||||
|
// 如果是文件,则需要将该文件以及所在文件夹下的所有文件拷贝到src目录下(待做)
|
||||||
|
|
||||||
|
// const src_exists = await fs.stat("src")
|
||||||
|
// .then(() => true)
|
||||||
|
// .catch(() => false);
|
||||||
|
// if (!src_exists) {
|
||||||
|
// fs.mkdir("src")
|
||||||
|
// } else {
|
||||||
|
// fs.rm
|
||||||
|
// }
|
||||||
|
const url_exists = await fs.stat(url)
|
||||||
|
.then(() => true)
|
||||||
|
.catch(() => false);
|
||||||
|
if (url_exists) {
|
||||||
|
tauriConf.pake.windows[0].url_type = "local";
|
||||||
|
const file_name = path.basename(url);
|
||||||
|
// const dir_name = path.dirname(url);
|
||||||
|
const url_path = path.join("dist/", file_name);
|
||||||
|
await fs.copyFile(url, url_path);
|
||||||
|
tauriConf.pake.windows[0].url = file_name;
|
||||||
|
tauriConf.pake.windows[0].url_type = "local";
|
||||||
|
} else {
|
||||||
|
tauriConf.pake.windows[0].url_type = "web";
|
||||||
|
}
|
||||||
|
|
||||||
|
// 处理user-agent
|
||||||
|
logger.warn(userAgent);
|
||||||
|
if (userAgent.length > 0) {
|
||||||
|
if (process.platform === "win32") {
|
||||||
|
tauriConf.pake.user_agent.windows = userAgent;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (process.platform === "linux") {
|
||||||
|
tauriConf.pake.user_agent.linux = userAgent;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (process.platform === "darwin") {
|
||||||
|
tauriConf.pake.user_agent.macos = userAgent;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 处理菜单栏
|
||||||
|
if (showMenu) {
|
||||||
|
if (process.platform === "win32") {
|
||||||
|
tauriConf.pake.menu.windows = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (process.platform === "linux") {
|
||||||
|
tauriConf.pake.menu.linux = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (process.platform === "darwin") {
|
||||||
|
tauriConf.pake.user_agent.macos = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 处理托盘
|
||||||
|
if (showSystemTray) {
|
||||||
|
if (process.platform === "win32") {
|
||||||
|
tauriConf.pake.system_tray.windows = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (process.platform === "linux") {
|
||||||
|
tauriConf.pake.system_tray.linux = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (process.platform === "darwin") {
|
||||||
|
tauriConf.pake.system_tray.macos = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Object.assign(tauriConf.tauri.windows[0], { url, ...tauriConfWindowOptions });
|
|
||||||
tauriConf.package.productName = name;
|
tauriConf.package.productName = name;
|
||||||
tauriConf.tauri.bundle.identifier = identifier;
|
tauriConf.tauri.bundle.identifier = identifier;
|
||||||
|
|
||||||
|
// 处理应用图标
|
||||||
const exists = await fs.stat(options.icon)
|
const exists = await fs.stat(options.icon)
|
||||||
.then(() => true)
|
.then(() => true)
|
||||||
.catch(() => false);
|
.catch(() => false);
|
||||||
@@ -97,7 +177,40 @@ export async function mergeTauriConfig(
|
|||||||
logger.warn("the custom icon path may not exists. we will use default icon to replace it");
|
logger.warn("the custom icon path may not exists. we will use default icon to replace it");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 处理托盘自定义图标
|
||||||
|
let useDefaultIcon = true; // 是否使用默认托盘图标
|
||||||
|
if (systemTrayIcon.length > 0) {
|
||||||
|
const icon_exists = await fs.stat(systemTrayIcon)
|
||||||
|
.then(() => true)
|
||||||
|
.catch(() => false);
|
||||||
|
if (icon_exists) {
|
||||||
|
// 需要判断图标格式,默认只支持ico和png两种
|
||||||
|
let iconExt = path.extname(systemTrayIcon).toLowerCase();
|
||||||
|
if (iconExt == ".png" || iconExt == ".icon") {
|
||||||
|
useDefaultIcon = false;
|
||||||
|
const trayIcoPath = path.join(npmDirectory, `src-tauri/png/${name.toLowerCase()}${iconExt}`);
|
||||||
|
tauriConf.tauri.systemTray.iconPath = `png/${name.toLowerCase()}${iconExt}`;
|
||||||
|
await fs.copyFile(systemTrayIcon, trayIcoPath);
|
||||||
|
} else {
|
||||||
|
logger.warn(`file type for system tray icon mut be .ico or .png , but you give ${iconExt}`);
|
||||||
|
logger.warn(`system tray icon file will not change with default.`);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
logger.warn(`${systemTrayIcon} not exists!`)
|
||||||
|
logger.warn(`system tray icon file will not change with default.`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 处理托盘默认图标
|
||||||
|
if (useDefaultIcon) {
|
||||||
|
if (process.platform === "linux" || process.platform === "win32") {
|
||||||
|
tauriConf.tauri.systemTray.iconPath = tauriConf.tauri.bundle.icon[0];
|
||||||
|
} else {
|
||||||
|
tauriConf.tauri.systemTray.iconPath = "png/icon_512.png";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 保存配置文件
|
||||||
let configPath = "";
|
let configPath = "";
|
||||||
switch (process.platform) {
|
switch (process.platform) {
|
||||||
case "win32": {
|
case "win32": {
|
||||||
@@ -117,13 +230,22 @@ export async function mergeTauriConfig(
|
|||||||
let bundleConf = {tauri: {bundle: tauriConf.tauri.bundle}};
|
let bundleConf = {tauri: {bundle: tauriConf.tauri.bundle}};
|
||||||
await fs.writeFile(
|
await fs.writeFile(
|
||||||
configPath,
|
configPath,
|
||||||
Buffer.from(JSON.stringify(bundleConf), 'utf-8')
|
Buffer.from(JSON.stringify(bundleConf, null, 4), 'utf-8')
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const pakeConfigPath = path.join(npmDirectory, 'src-tauri/pake.json')
|
||||||
|
await fs.writeFile(
|
||||||
|
pakeConfigPath,
|
||||||
|
Buffer.from(JSON.stringify(tauriConf.pake, null, 4), 'utf-8')
|
||||||
|
);
|
||||||
|
|
||||||
|
let tauriConf2 = JSON.parse(JSON.stringify(tauriConf));
|
||||||
|
delete tauriConf2.pake;
|
||||||
|
delete tauriConf2.tauri.bundle;
|
||||||
|
|
||||||
const configJsonPath = path.join(npmDirectory, 'src-tauri/tauri.conf.json')
|
const configJsonPath = path.join(npmDirectory, 'src-tauri/tauri.conf.json')
|
||||||
await fs.writeFile(
|
await fs.writeFile(
|
||||||
configJsonPath,
|
configJsonPath,
|
||||||
Buffer.from(JSON.stringify(tauriConf), 'utf-8')
|
Buffer.from(JSON.stringify(tauriConf2, null, 4), 'utf-8')
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
4
bin/builders/tauriConf.js
vendored
4
bin/builders/tauriConf.js
vendored
@@ -1,11 +1,13 @@
|
|||||||
import CommonConf from '../../src-tauri/tauri.conf.json';
|
import CommonConf from '../../src-tauri/tauri.conf.json';
|
||||||
|
import pakeConf from '../../src-tauri/pake.json';
|
||||||
import WinConf from '../../src-tauri/tauri.windows.conf.json';
|
import WinConf from '../../src-tauri/tauri.windows.conf.json';
|
||||||
import MacConf from '../../src-tauri/tauri.macos.conf.json';
|
import MacConf from '../../src-tauri/tauri.macos.conf.json';
|
||||||
import LinuxConf from '../../src-tauri/tauri.linux.conf.json';
|
import LinuxConf from '../../src-tauri/tauri.linux.conf.json';
|
||||||
|
|
||||||
let tauriConf = {
|
let tauriConf = {
|
||||||
package: CommonConf.package,
|
package: CommonConf.package,
|
||||||
tauri: CommonConf.tauri
|
tauri: CommonConf.tauri,
|
||||||
|
pake: pakeConf
|
||||||
}
|
}
|
||||||
switch (process.platform) {
|
switch (process.platform) {
|
||||||
case "win32": {
|
case "win32": {
|
||||||
|
|||||||
9
bin/cli.ts
vendored
9
bin/cli.ts
vendored
@@ -23,6 +23,13 @@ program
|
|||||||
.option('--no-resizable', 'whether the window can be resizable', DEFAULT_PAKE_OPTIONS.resizable)
|
.option('--no-resizable', 'whether the window can be resizable', DEFAULT_PAKE_OPTIONS.resizable)
|
||||||
.option('--fullscreen', 'makes the packaged app start in full screen', DEFAULT_PAKE_OPTIONS.fullscreen)
|
.option('--fullscreen', 'makes the packaged app start in full screen', DEFAULT_PAKE_OPTIONS.fullscreen)
|
||||||
.option('--transparent', 'transparent title bar', DEFAULT_PAKE_OPTIONS.transparent)
|
.option('--transparent', 'transparent title bar', DEFAULT_PAKE_OPTIONS.transparent)
|
||||||
|
.option('--user-agent <string>', 'custom user agent', DEFAULT_PAKE_OPTIONS.userAgent)
|
||||||
|
.option('--show-menu', 'show menu in app', DEFAULT_PAKE_OPTIONS.showMenu)
|
||||||
|
.option('--show-system-tray', 'show system tray in app', DEFAULT_PAKE_OPTIONS.showSystemTray)
|
||||||
|
.option('--system-tray-icon <string>', 'custom system tray icon', DEFAULT_PAKE_OPTIONS.systemTrayIcon)
|
||||||
|
// .option('--iter-copy-file',
|
||||||
|
// 'copy all static file to pake app when url is a static file',
|
||||||
|
// DEFAULT_PAKE_OPTIONS.iter_copy_file)
|
||||||
.option('--debug', 'debug', DEFAULT_PAKE_OPTIONS.transparent)
|
.option('--debug', 'debug', DEFAULT_PAKE_OPTIONS.transparent)
|
||||||
.action(async (url: string, options: PakeCliOptions) => {
|
.action(async (url: string, options: PakeCliOptions) => {
|
||||||
checkUpdateTips();
|
checkUpdateTips();
|
||||||
@@ -41,7 +48,7 @@ program
|
|||||||
await builder.prepare();
|
await builder.prepare();
|
||||||
|
|
||||||
const appOptions = await handleInputOptions(options, url);
|
const appOptions = await handleInputOptions(options, url);
|
||||||
|
// logger.warn(JSON.stringify(appOptions, null, 4));
|
||||||
builder.build(url, appOptions);
|
builder.build(url, appOptions);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
5
bin/defaults.ts
vendored
5
bin/defaults.ts
vendored
@@ -7,6 +7,11 @@ export const DEFAULT_PAKE_OPTIONS: PakeCliOptions = {
|
|||||||
fullscreen: false,
|
fullscreen: false,
|
||||||
resizable: true,
|
resizable: true,
|
||||||
transparent: false,
|
transparent: false,
|
||||||
|
userAgent: '',
|
||||||
|
showMenu: false,
|
||||||
|
showSystemTray: false,
|
||||||
|
// iter_copy_file: false,
|
||||||
|
systemTrayIcon: '',
|
||||||
debug: false,
|
debug: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
15
bin/types.ts
vendored
15
bin/types.ts
vendored
@@ -20,6 +20,21 @@ export interface PakeCliOptions {
|
|||||||
/** 是否开启沉浸式头部,默认为 false 不开启 ƒ*/
|
/** 是否开启沉浸式头部,默认为 false 不开启 ƒ*/
|
||||||
transparent: boolean;
|
transparent: boolean;
|
||||||
|
|
||||||
|
/** 自定义UA,默认为不开启 ƒ*/
|
||||||
|
userAgent: string;
|
||||||
|
|
||||||
|
/** 开启菜单栏,MacOS默认开启,Windows,Linux默认不开启 ƒ*/
|
||||||
|
showMenu: boolean;
|
||||||
|
|
||||||
|
/** 开启系统托盘,MacOS默认不开启,Windows,Linux默认开启 ƒ*/
|
||||||
|
showSystemTray: boolean;
|
||||||
|
|
||||||
|
/** 托盘图标, Windows、Linux默认和应用图标共用一样的,MacOS需要提别提供, 格式为png或者ico */
|
||||||
|
systemTrayIcon: string;
|
||||||
|
|
||||||
|
// /** 递归拷贝,当url为本地文件路径时候,将文件所在文件夹下面的所有子文件都拷贝到pake静态文件夹,默认不开启 */
|
||||||
|
// iter_copy_file: false;
|
||||||
|
|
||||||
/** 调试模式,会输出更多日志 */
|
/** 调试模式,会输出更多日志 */
|
||||||
debug: boolean;
|
debug: boolean;
|
||||||
}
|
}
|
||||||
|
|||||||
198
dist/cli.js
vendored
198
dist/cli.js
vendored
@@ -47,6 +47,11 @@ const DEFAULT_PAKE_OPTIONS = {
|
|||||||
fullscreen: false,
|
fullscreen: false,
|
||||||
resizable: true,
|
resizable: true,
|
||||||
transparent: false,
|
transparent: false,
|
||||||
|
userAgent: '',
|
||||||
|
showMenu: false,
|
||||||
|
showSystemTray: false,
|
||||||
|
// iter_copy_file: false,
|
||||||
|
systemTrayIcon: '',
|
||||||
debug: false,
|
debug: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1624,7 +1629,9 @@ function promptText(message, initial) {
|
|||||||
}
|
}
|
||||||
function mergeTauriConfig(url, options, tauriConf) {
|
function mergeTauriConfig(url, options, tauriConf) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
const { width, height, fullscreen, transparent, resizable, identifier, name, } = options;
|
const { width, height, fullscreen, transparent, resizable, userAgent, showMenu, showSystemTray, systemTrayIcon,
|
||||||
|
// iter_copy_file,
|
||||||
|
identifier, name, } = options;
|
||||||
const tauriConfWindowOptions = {
|
const tauriConfWindowOptions = {
|
||||||
width,
|
width,
|
||||||
height,
|
height,
|
||||||
@@ -1650,9 +1657,73 @@ function mergeTauriConfig(url, options, tauriConf) {
|
|||||||
process.exit();
|
process.exit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Object.assign(tauriConf.tauri.windows[0], Object.assign({ url }, tauriConfWindowOptions));
|
// logger.warn(JSON.stringify(tauriConf.pake.windows, null, 4));
|
||||||
|
Object.assign(tauriConf.pake.windows[0], Object.assign({ url }, tauriConfWindowOptions));
|
||||||
|
// 判断一下url类型,是文件还是网站
|
||||||
|
// 如果是文件,则需要将该文件以及所在文件夹下的所有文件拷贝到src目录下(待做)
|
||||||
|
// const src_exists = await fs.stat("src")
|
||||||
|
// .then(() => true)
|
||||||
|
// .catch(() => false);
|
||||||
|
// if (!src_exists) {
|
||||||
|
// fs.mkdir("src")
|
||||||
|
// } else {
|
||||||
|
// fs.rm
|
||||||
|
// }
|
||||||
|
const url_exists = yield fs.stat(url)
|
||||||
|
.then(() => true)
|
||||||
|
.catch(() => false);
|
||||||
|
if (url_exists) {
|
||||||
|
tauriConf.pake.windows[0].url_type = "local";
|
||||||
|
const file_name = path.basename(url);
|
||||||
|
// const dir_name = path.dirname(url);
|
||||||
|
const url_path = path.join("dist/", file_name);
|
||||||
|
yield fs.copyFile(url, url_path);
|
||||||
|
tauriConf.pake.windows[0].url = file_name;
|
||||||
|
tauriConf.pake.windows[0].url_type = "local";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
tauriConf.pake.windows[0].url_type = "web";
|
||||||
|
}
|
||||||
|
// 处理user-agent
|
||||||
|
logger.warn(userAgent);
|
||||||
|
if (userAgent.length > 0) {
|
||||||
|
if (process.platform === "win32") {
|
||||||
|
tauriConf.pake.user_agent.windows = userAgent;
|
||||||
|
}
|
||||||
|
if (process.platform === "linux") {
|
||||||
|
tauriConf.pake.user_agent.linux = userAgent;
|
||||||
|
}
|
||||||
|
if (process.platform === "darwin") {
|
||||||
|
tauriConf.pake.user_agent.macos = userAgent;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 处理菜单栏
|
||||||
|
if (showMenu) {
|
||||||
|
if (process.platform === "win32") {
|
||||||
|
tauriConf.pake.menu.windows = true;
|
||||||
|
}
|
||||||
|
if (process.platform === "linux") {
|
||||||
|
tauriConf.pake.menu.linux = true;
|
||||||
|
}
|
||||||
|
if (process.platform === "darwin") {
|
||||||
|
tauriConf.pake.user_agent.macos = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 处理托盘
|
||||||
|
if (showSystemTray) {
|
||||||
|
if (process.platform === "win32") {
|
||||||
|
tauriConf.pake.system_tray.windows = true;
|
||||||
|
}
|
||||||
|
if (process.platform === "linux") {
|
||||||
|
tauriConf.pake.system_tray.linux = true;
|
||||||
|
}
|
||||||
|
if (process.platform === "darwin") {
|
||||||
|
tauriConf.pake.system_tray.macos = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
tauriConf.package.productName = name;
|
tauriConf.package.productName = name;
|
||||||
tauriConf.tauri.bundle.identifier = identifier;
|
tauriConf.tauri.bundle.identifier = identifier;
|
||||||
|
// 处理应用图标
|
||||||
const exists = yield fs.stat(options.icon)
|
const exists = yield fs.stat(options.icon)
|
||||||
.then(() => true)
|
.then(() => true)
|
||||||
.catch(() => false);
|
.catch(() => false);
|
||||||
@@ -1691,6 +1762,41 @@ function mergeTauriConfig(url, options, tauriConf) {
|
|||||||
else {
|
else {
|
||||||
logger.warn("the custom icon path may not exists. we will use default icon to replace it");
|
logger.warn("the custom icon path may not exists. we will use default icon to replace it");
|
||||||
}
|
}
|
||||||
|
// 处理托盘自定义图标
|
||||||
|
let useDefaultIcon = true; // 是否使用默认托盘图标
|
||||||
|
if (systemTrayIcon.length > 0) {
|
||||||
|
const icon_exists = yield fs.stat(systemTrayIcon)
|
||||||
|
.then(() => true)
|
||||||
|
.catch(() => false);
|
||||||
|
if (icon_exists) {
|
||||||
|
// 需要判断图标格式,默认只支持ico和png两种
|
||||||
|
let iconExt = path.extname(systemTrayIcon).toLowerCase();
|
||||||
|
if (iconExt == ".png" || iconExt == ".icon") {
|
||||||
|
useDefaultIcon = false;
|
||||||
|
const trayIcoPath = path.join(npmDirectory, `src-tauri/png/${name.toLowerCase()}${iconExt}`);
|
||||||
|
tauriConf.tauri.systemTray.iconPath = `png/${name.toLowerCase()}${iconExt}`;
|
||||||
|
yield fs.copyFile(systemTrayIcon, trayIcoPath);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
logger.warn(`file type for system tray icon mut be .ico or .png , but you give ${iconExt}`);
|
||||||
|
logger.warn(`system tray icon file will not change with default.`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
logger.warn(`${systemTrayIcon} not exists!`);
|
||||||
|
logger.warn(`system tray icon file will not change with default.`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 处理托盘默认图标
|
||||||
|
if (useDefaultIcon) {
|
||||||
|
if (process.platform === "linux" || process.platform === "win32") {
|
||||||
|
tauriConf.tauri.systemTray.iconPath = tauriConf.tauri.bundle.icon[0];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
tauriConf.tauri.systemTray.iconPath = "png/icon_512.png";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 保存配置文件
|
||||||
let configPath = "";
|
let configPath = "";
|
||||||
switch (process.platform) {
|
switch (process.platform) {
|
||||||
case "win32": {
|
case "win32": {
|
||||||
@@ -1707,9 +1813,14 @@ function mergeTauriConfig(url, options, tauriConf) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
let bundleConf = { tauri: { bundle: tauriConf.tauri.bundle } };
|
let bundleConf = { tauri: { bundle: tauriConf.tauri.bundle } };
|
||||||
yield fs.writeFile(configPath, Buffer.from(JSON.stringify(bundleConf), 'utf-8'));
|
yield fs.writeFile(configPath, Buffer.from(JSON.stringify(bundleConf, null, 4), 'utf-8'));
|
||||||
|
const pakeConfigPath = path.join(npmDirectory, 'src-tauri/pake.json');
|
||||||
|
yield fs.writeFile(pakeConfigPath, Buffer.from(JSON.stringify(tauriConf.pake, null, 4), 'utf-8'));
|
||||||
|
let tauriConf2 = JSON.parse(JSON.stringify(tauriConf));
|
||||||
|
delete tauriConf2.pake;
|
||||||
|
delete tauriConf2.tauri.bundle;
|
||||||
const configJsonPath = path.join(npmDirectory, 'src-tauri/tauri.conf.json');
|
const configJsonPath = path.join(npmDirectory, 'src-tauri/tauri.conf.json');
|
||||||
yield fs.writeFile(configJsonPath, Buffer.from(JSON.stringify(tauriConf), 'utf-8'));
|
yield fs.writeFile(configJsonPath, Buffer.from(JSON.stringify(tauriConf2, null, 4), 'utf-8'));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1859,36 +1970,56 @@ function checkRustInstalled() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var tauri$3 = {
|
var tauri$3 = {
|
||||||
windows: [
|
|
||||||
{
|
|
||||||
url: "https://weread.qq.com/",
|
|
||||||
transparent: true,
|
|
||||||
fullscreen: false,
|
|
||||||
width: 1200,
|
|
||||||
height: 780,
|
|
||||||
resizable: true
|
|
||||||
}
|
|
||||||
],
|
|
||||||
security: {
|
security: {
|
||||||
csp: null
|
csp: null
|
||||||
},
|
},
|
||||||
updater: {
|
updater: {
|
||||||
active: false
|
active: false
|
||||||
|
},
|
||||||
|
systemTray: {
|
||||||
|
iconPath: "/home/tlntin/data/code/rust_study/Pake/src-tauri/png/code_512.png",
|
||||||
|
iconAsTemplate: true
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
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 windows = [
|
||||||
|
{
|
||||||
|
url: "https://www.baidu.com",
|
||||||
|
transparent: false,
|
||||||
|
fullscreen: false,
|
||||||
|
width: 1200,
|
||||||
|
height: 780,
|
||||||
|
resizable: true,
|
||||||
|
url_type: "web"
|
||||||
|
}
|
||||||
|
];
|
||||||
|
var user_agent = {
|
||||||
|
macos: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.1 Safari/605.1.15",
|
||||||
|
linux: "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36",
|
||||||
|
windows: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36"
|
||||||
|
};
|
||||||
|
var menu = {
|
||||||
|
macos: true,
|
||||||
|
linux: true,
|
||||||
|
windows: false
|
||||||
|
};
|
||||||
|
var system_tray = {
|
||||||
|
macos: false,
|
||||||
|
linux: true,
|
||||||
|
windows: true
|
||||||
|
};
|
||||||
|
var pakeConf = {
|
||||||
|
windows: windows,
|
||||||
|
user_agent: user_agent,
|
||||||
|
menu: menu,
|
||||||
|
system_tray: system_tray
|
||||||
};
|
};
|
||||||
|
|
||||||
var tauri$2 = {
|
var tauri$2 = {
|
||||||
@@ -1963,10 +2094,9 @@ var MacConf = {
|
|||||||
var tauri = {
|
var tauri = {
|
||||||
bundle: {
|
bundle: {
|
||||||
icon: [
|
icon: [
|
||||||
"png/weread_256.ico",
|
"/home/tlntin/data/code/rust_study/Pake/src-tauri/png/code_512.png"
|
||||||
"png/weread_512.png"
|
|
||||||
],
|
],
|
||||||
identifier: "com.tw93.weread",
|
identifier: "pake-f9751d",
|
||||||
active: true,
|
active: true,
|
||||||
category: "DeveloperTool",
|
category: "DeveloperTool",
|
||||||
copyright: "",
|
copyright: "",
|
||||||
@@ -1982,10 +2112,7 @@ var tauri = {
|
|||||||
"librsvg2-dev",
|
"librsvg2-dev",
|
||||||
"gnome-video-effects",
|
"gnome-video-effects",
|
||||||
"gnome-video-effects-extra"
|
"gnome-video-effects-extra"
|
||||||
],
|
]
|
||||||
files: {
|
|
||||||
"/usr/share/applications/com-tw93-weread.desktop": "assets/com-tw93-weread.desktop"
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
externalBin: [
|
externalBin: [
|
||||||
],
|
],
|
||||||
@@ -2005,7 +2132,8 @@ var LinuxConf = {
|
|||||||
|
|
||||||
let tauriConf = {
|
let tauriConf = {
|
||||||
package: CommonConf.package,
|
package: CommonConf.package,
|
||||||
tauri: CommonConf.tauri
|
tauri: CommonConf.tauri,
|
||||||
|
pake: pakeConf
|
||||||
};
|
};
|
||||||
switch (process.platform) {
|
switch (process.platform) {
|
||||||
case "win32": {
|
case "win32": {
|
||||||
@@ -2301,6 +2429,13 @@ program
|
|||||||
.option('--no-resizable', 'whether the window can be resizable', DEFAULT_PAKE_OPTIONS.resizable)
|
.option('--no-resizable', 'whether the window can be resizable', DEFAULT_PAKE_OPTIONS.resizable)
|
||||||
.option('--fullscreen', 'makes the packaged app start in full screen', DEFAULT_PAKE_OPTIONS.fullscreen)
|
.option('--fullscreen', 'makes the packaged app start in full screen', DEFAULT_PAKE_OPTIONS.fullscreen)
|
||||||
.option('--transparent', 'transparent title bar', DEFAULT_PAKE_OPTIONS.transparent)
|
.option('--transparent', 'transparent title bar', DEFAULT_PAKE_OPTIONS.transparent)
|
||||||
|
.option('--user-agent <string>', 'custom user agent', DEFAULT_PAKE_OPTIONS.userAgent)
|
||||||
|
.option('--show-menu', 'show menu in app', DEFAULT_PAKE_OPTIONS.showMenu)
|
||||||
|
.option('--show-system-tray', 'show system tray in app', DEFAULT_PAKE_OPTIONS.showSystemTray)
|
||||||
|
.option('--system-tray-icon <string>', 'custom system tray icon', DEFAULT_PAKE_OPTIONS.systemTrayIcon)
|
||||||
|
// .option('--iter-copy-file',
|
||||||
|
// 'copy all static file to pake app when url is a static file',
|
||||||
|
// DEFAULT_PAKE_OPTIONS.iter_copy_file)
|
||||||
.option('--debug', 'debug', DEFAULT_PAKE_OPTIONS.transparent)
|
.option('--debug', 'debug', DEFAULT_PAKE_OPTIONS.transparent)
|
||||||
.action((url, options) => __awaiter(void 0, void 0, void 0, function* () {
|
.action((url, options) => __awaiter(void 0, void 0, void 0, function* () {
|
||||||
checkUpdateTips();
|
checkUpdateTips();
|
||||||
@@ -2315,6 +2450,7 @@ program
|
|||||||
const builder = BuilderFactory.create();
|
const builder = BuilderFactory.create();
|
||||||
yield builder.prepare();
|
yield builder.prepare();
|
||||||
const appOptions = yield handleOptions(options, url);
|
const appOptions = yield handleOptions(options, url);
|
||||||
|
// logger.warn(JSON.stringify(appOptions, null, 4));
|
||||||
builder.build(url, appOptions);
|
builder.build(url, appOptions);
|
||||||
}));
|
}));
|
||||||
program.parse();
|
program.parse();
|
||||||
|
|||||||
Reference in New Issue
Block a user