refactor: pake-cli support tauri 2.x beta
This commit is contained in:
2
bin/builders/LinuxBuilder.ts
vendored
2
bin/builders/LinuxBuilder.ts
vendored
@@ -10,7 +10,7 @@ export default class LinuxBuilder extends BaseBuilder {
|
|||||||
getFileName(): string {
|
getFileName(): string {
|
||||||
const { name } = this.options;
|
const { name } = this.options;
|
||||||
const arch = process.arch === 'x64' ? 'amd64' : process.arch;
|
const arch = process.arch === 'x64' ? 'amd64' : process.arch;
|
||||||
return `${name}_${tauriConfig.package.version}_${arch}`;
|
return `${name}_${tauriConfig.version}_${arch}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Customize it, considering that there are all targets.
|
// Customize it, considering that there are all targets.
|
||||||
|
|||||||
2
bin/builders/MacBuilder.ts
vendored
2
bin/builders/MacBuilder.ts
vendored
@@ -16,7 +16,7 @@ export default class MacBuilder extends BaseBuilder {
|
|||||||
} else {
|
} else {
|
||||||
arch = process.arch === 'arm64' ? 'aarch64' : process.arch;
|
arch = process.arch === 'arm64' ? 'aarch64' : process.arch;
|
||||||
}
|
}
|
||||||
return `${name}_${tauriConfig.package.version}_${arch}`;
|
return `${name}_${tauriConfig.version}_${arch}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected getBuildCommand(): string {
|
protected getBuildCommand(): string {
|
||||||
|
|||||||
4
bin/builders/WinBuilder.ts
vendored
4
bin/builders/WinBuilder.ts
vendored
@@ -11,7 +11,7 @@ export default class WinBuilder extends BaseBuilder {
|
|||||||
getFileName(): string {
|
getFileName(): string {
|
||||||
const { name } = this.options;
|
const { name } = this.options;
|
||||||
const { arch } = process;
|
const { arch } = process;
|
||||||
const language = tauriConfig.tauri.bundle.windows.wix.language[0];
|
const language = tauriConfig.bundle.windows.wix.language[0];
|
||||||
return `${name}_${tauriConfig.package.version}_${arch}_${language}`;
|
return `${name}_${tauriConfig.version}_${arch}_${language}`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
7
bin/defaults.ts
vendored
7
bin/defaults.ts
vendored
@@ -11,7 +11,7 @@ export const DEFAULT_PAKE_OPTIONS: PakeCliOptions = {
|
|||||||
disabledWebShortcuts: false,
|
disabledWebShortcuts: false,
|
||||||
activationShortcut: '',
|
activationShortcut: '',
|
||||||
userAgent: '',
|
userAgent: '',
|
||||||
showSystemTray: false,
|
showSystemTray: true,
|
||||||
multiArch: false,
|
multiArch: false,
|
||||||
targets: 'deb',
|
targets: 'deb',
|
||||||
useLocalFile: false,
|
useLocalFile: false,
|
||||||
@@ -24,8 +24,7 @@ export const DEFAULT_PAKE_OPTIONS: PakeCliOptions = {
|
|||||||
// Just for cli development
|
// Just for cli development
|
||||||
export const DEFAULT_DEV_PAKE_OPTIONS: PakeCliOptions & { url: string } = {
|
export const DEFAULT_DEV_PAKE_OPTIONS: PakeCliOptions & { url: string } = {
|
||||||
...DEFAULT_PAKE_OPTIONS,
|
...DEFAULT_PAKE_OPTIONS,
|
||||||
url: 'https://weread.qq.com',
|
url: 'https://www.xiaoyuzhoufm.com/',
|
||||||
name: 'WeRead',
|
name: 'XiaoYuZhou',
|
||||||
safeDomain: ['weread.qq.com'],
|
|
||||||
hideTitleBar: true,
|
hideTitleBar: true,
|
||||||
};
|
};
|
||||||
|
|||||||
52
bin/helpers/merge.ts
vendored
52
bin/helpers/merge.ts
vendored
@@ -24,7 +24,6 @@ export async function mergeConfig(url: string, options: PakeAppOptions, tauriCon
|
|||||||
name,
|
name,
|
||||||
resizable = true,
|
resizable = true,
|
||||||
inject,
|
inject,
|
||||||
safeDomain,
|
|
||||||
} = options;
|
} = options;
|
||||||
|
|
||||||
const { platform } = process;
|
const { platform } = process;
|
||||||
@@ -42,8 +41,8 @@ export async function mergeConfig(url: string, options: PakeAppOptions, tauriCon
|
|||||||
};
|
};
|
||||||
Object.assign(tauriConf.pake.windows[0], { url, ...tauriConfWindowOptions });
|
Object.assign(tauriConf.pake.windows[0], { url, ...tauriConfWindowOptions });
|
||||||
|
|
||||||
tauriConf.package.productName = name;
|
tauriConf.productName = name;
|
||||||
tauriConf.tauri.bundle.identifier = identifier;
|
tauriConf.identifier = identifier;
|
||||||
|
|
||||||
//Judge the type of URL, whether it is a file or a website.
|
//Judge the type of URL, whether it is a file or a website.
|
||||||
const pathExists = await fsExtra.pathExists(url);
|
const pathExists = await fsExtra.pathExists(url);
|
||||||
@@ -76,25 +75,6 @@ export async function mergeConfig(url: string, options: PakeAppOptions, tauriCon
|
|||||||
tauriConf.pake.windows[0].url_type = 'local';
|
tauriConf.pake.windows[0].url_type = 'local';
|
||||||
} else {
|
} else {
|
||||||
tauriConf.pake.windows[0].url_type = 'web';
|
tauriConf.pake.windows[0].url_type = 'web';
|
||||||
// Set the secure domain for calling window.__TAURI__ to the application domain that has been set.
|
|
||||||
tauriConf.tauri.security.dangerousRemoteDomainIpcAccess = [
|
|
||||||
{
|
|
||||||
domain: new URL(url).hostname,
|
|
||||||
windows: ['pake'],
|
|
||||||
enableTauriAPI: true,
|
|
||||||
},
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (safeDomain.length > 0) {
|
|
||||||
tauriConf.tauri.security.dangerousRemoteDomainIpcAccess = [
|
|
||||||
...tauriConf.tauri.security.dangerousRemoteDomainIpcAccess,
|
|
||||||
...safeDomain.map(domain => ({
|
|
||||||
domain,
|
|
||||||
windows: ['pake'],
|
|
||||||
enableTauriAPI: true,
|
|
||||||
})),
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const platformMap: PlatformMap = {
|
const platformMap: PlatformMap = {
|
||||||
@@ -112,10 +92,10 @@ export async function mergeConfig(url: string, options: PakeAppOptions, tauriCon
|
|||||||
|
|
||||||
// Processing targets are currently only open to Linux.
|
// Processing targets are currently only open to Linux.
|
||||||
if (platform === 'linux') {
|
if (platform === 'linux') {
|
||||||
delete tauriConf.tauri.bundle.deb.files;
|
delete tauriConf.bundle.linux.deb.files;
|
||||||
const validTargets = ['all', 'deb', 'appimage'];
|
const validTargets = ['all', 'deb', 'appimage'];
|
||||||
if (validTargets.includes(options.targets)) {
|
if (validTargets.includes(options.targets)) {
|
||||||
tauriConf.tauri.bundle.targets = options.targets === 'all' ? ['deb', 'appimage'] : [options.targets];
|
tauriConf.bundle.targets = options.targets === 'all' ? ['deb', 'appimage'] : [options.targets];
|
||||||
} else {
|
} else {
|
||||||
logger.warn(`✼ The target must be one of ${validTargets.join(', ')}, the default 'deb' will be used.`);
|
logger.warn(`✼ The target must be one of ${validTargets.join(', ')}, the default 'deb' will be used.`);
|
||||||
}
|
}
|
||||||
@@ -151,25 +131,25 @@ export async function mergeConfig(url: string, options: PakeAppOptions, tauriCon
|
|||||||
if (customIconExt !== iconInfo.fileExt) {
|
if (customIconExt !== iconInfo.fileExt) {
|
||||||
updateIconPath = false;
|
updateIconPath = false;
|
||||||
logger.warn(`✼ ${iconInfo.message}, but you give ${customIconExt}`);
|
logger.warn(`✼ ${iconInfo.message}, but you give ${customIconExt}`);
|
||||||
tauriConf.tauri.bundle.icon = [iconInfo.defaultIcon];
|
tauriConf.bundle.icon = [iconInfo.defaultIcon];
|
||||||
} else {
|
} else {
|
||||||
const iconPath = path.join(npmDirectory, 'src-tauri/', iconInfo.path);
|
const iconPath = path.join(npmDirectory, 'src-tauri/', iconInfo.path);
|
||||||
tauriConf.tauri.bundle.resources = [iconInfo.path];
|
tauriConf.bundle.resources = [iconInfo.path];
|
||||||
await fsExtra.copy(options.icon, iconPath);
|
await fsExtra.copy(options.icon, iconPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (updateIconPath) {
|
if (updateIconPath) {
|
||||||
tauriConf.tauri.bundle.icon = [options.icon];
|
tauriConf.bundle.icon = [options.icon];
|
||||||
} else {
|
} else {
|
||||||
logger.warn(`✼ Icon will remain as default.`);
|
logger.warn(`✼ Icon will remain as default.`);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
logger.warn('✼ Custom icon path may be invalid, default icon will be used instead.');
|
logger.warn('✼ Custom icon path may be invalid, default icon will be used instead.');
|
||||||
tauriConf.tauri.bundle.icon = [iconInfo.defaultIcon];
|
tauriConf.bundle.icon = [iconInfo.defaultIcon];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set tray icon path.
|
// Set tray icon path.
|
||||||
let trayIconPath = platform === 'darwin' ? 'png/icon_512.png' : tauriConf.tauri.bundle.icon[0];
|
let trayIconPath = platform === 'darwin' ? 'png/icon_512.png' : tauriConf.bundle.icon[0];
|
||||||
if (systemTrayIcon.length > 0) {
|
if (systemTrayIcon.length > 0) {
|
||||||
try {
|
try {
|
||||||
await fsExtra.pathExists(systemTrayIcon);
|
await fsExtra.pathExists(systemTrayIcon);
|
||||||
@@ -189,7 +169,11 @@ export async function mergeConfig(url: string, options: PakeAppOptions, tauriCon
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tauriConf.tauri.systemTray.iconPath = trayIconPath;
|
tauriConf.app.trayIcon.iconPath = trayIconPath;
|
||||||
|
tauriConf.pake.system_tray_path = trayIconPath;
|
||||||
|
|
||||||
|
delete tauriConf.app.trayIcon;
|
||||||
|
|
||||||
const injectFilePath = path.join(npmDirectory, `src-tauri/src/inject/custom.js`);
|
const injectFilePath = path.join(npmDirectory, `src-tauri/src/inject/custom.js`);
|
||||||
// inject js or css files
|
// inject js or css files
|
||||||
if (inject?.length > 0) {
|
if (inject?.length > 0) {
|
||||||
@@ -213,17 +197,19 @@ export async function mergeConfig(url: string, options: PakeAppOptions, tauriCon
|
|||||||
};
|
};
|
||||||
const configPath = path.join(tauriConfigDirectory, platformConfigPaths[platform]);
|
const configPath = path.join(tauriConfigDirectory, platformConfigPaths[platform]);
|
||||||
|
|
||||||
const bundleConf = { tauri: { bundle: tauriConf.tauri.bundle } };
|
const bundleConf = { bundle: tauriConf.bundle };
|
||||||
|
console.log('pakeConfig', tauriConf.pake);
|
||||||
await fsExtra.outputJSON(configPath, bundleConf, { spaces: 4 });
|
await fsExtra.outputJSON(configPath, bundleConf, { spaces: 4 });
|
||||||
const pakeConfigPath = path.join(tauriConfigDirectory, 'pake.json');
|
const pakeConfigPath = path.join(tauriConfigDirectory, 'pake.json');
|
||||||
await fsExtra.outputJSON(pakeConfigPath, tauriConf.pake, { spaces: 4 });
|
await fsExtra.outputJSON(pakeConfigPath, tauriConf.pake, { spaces: 4 });
|
||||||
|
|
||||||
let tauriConf2 = JSON.parse(JSON.stringify(tauriConf));
|
let tauriConf2 = JSON.parse(JSON.stringify(tauriConf));
|
||||||
delete tauriConf2.pake;
|
delete tauriConf2.pake;
|
||||||
delete tauriConf2.tauri.bundle;
|
// delete tauriConf2.bundle;
|
||||||
if (process.env.NODE_ENV === 'development') {
|
if (process.env.NODE_ENV === 'development') {
|
||||||
tauriConf2.tauri.bundle = bundleConf.tauri.bundle;
|
tauriConf2.bundle = bundleConf.bundle;
|
||||||
}
|
}
|
||||||
|
console.log('tauriConf', tauriConf2)
|
||||||
const configJsonPath = path.join(tauriConfigDirectory, 'tauri.conf.json');
|
const configJsonPath = path.join(tauriConfigDirectory, 'tauri.conf.json');
|
||||||
await fsExtra.outputJSON(configJsonPath, tauriConf2, { spaces: 4 });
|
await fsExtra.outputJSON(configJsonPath, tauriConf2, { spaces: 4 });
|
||||||
}
|
}
|
||||||
|
|||||||
12
bin/helpers/tauriConfig.ts
vendored
12
bin/helpers/tauriConfig.ts
vendored
@@ -15,11 +15,15 @@ const { platform } = process;
|
|||||||
const platformConfig = platformConfigs[platform];
|
const platformConfig = platformConfigs[platform];
|
||||||
|
|
||||||
let tauriConfig = {
|
let tauriConfig = {
|
||||||
tauri: {
|
...CommonConf,
|
||||||
...CommonConf.tauri,
|
bundle: platformConfig.bundle,
|
||||||
bundle: platformConfig.tauri.bundle,
|
app: {
|
||||||
|
...CommonConf.app,
|
||||||
|
trayIcon: {
|
||||||
|
...CommonConf.app.trayIcon,
|
||||||
|
...(platformConfig?.app?.trayIcon ?? {}),
|
||||||
|
},
|
||||||
},
|
},
|
||||||
package: CommonConf.package,
|
|
||||||
build: CommonConf.build,
|
build: CommonConf.build,
|
||||||
pake: pakeConf,
|
pake: pakeConf,
|
||||||
};
|
};
|
||||||
|
|||||||
283
dist/cli.js
vendored
283
dist/cli.js
vendored
@@ -20,7 +20,7 @@ import psl from 'psl';
|
|||||||
import isUrl from 'is-url';
|
import isUrl from 'is-url';
|
||||||
|
|
||||||
var name = "pake-cli";
|
var name = "pake-cli";
|
||||||
var version = "2.5.2";
|
var version$1 = "2.5.2";
|
||||||
var description = "🤱🏻 Turn any webpage into a desktop app with Rust. 🤱🏻 利用 Rust 轻松构建轻量级多端桌面应用。";
|
var description = "🤱🏻 Turn any webpage into a desktop app with Rust. 🤱🏻 利用 Rust 轻松构建轻量级多端桌面应用。";
|
||||||
var engines = {
|
var engines = {
|
||||||
node: ">=16.0.0"
|
node: ">=16.0.0"
|
||||||
@@ -68,7 +68,7 @@ var exports = "./dist/pake.js";
|
|||||||
var license = "MIT";
|
var license = "MIT";
|
||||||
var dependencies = {
|
var dependencies = {
|
||||||
"@tauri-apps/api": "^1.5.4",
|
"@tauri-apps/api": "^1.5.4",
|
||||||
"@tauri-apps/cli": "^1.5.13",
|
"@tauri-apps/cli": "^2.0.0-beta.22",
|
||||||
axios: "^1.6.8",
|
axios: "^1.6.8",
|
||||||
chalk: "^5.3.0",
|
chalk: "^5.3.0",
|
||||||
commander: "^11.1.0",
|
commander: "^11.1.0",
|
||||||
@@ -107,7 +107,7 @@ var devDependencies = {
|
|||||||
};
|
};
|
||||||
var packageJson = {
|
var packageJson = {
|
||||||
name: name,
|
name: name,
|
||||||
version: version,
|
version: version$1,
|
||||||
description: description,
|
description: description,
|
||||||
engines: engines,
|
engines: engines,
|
||||||
bin: bin,
|
bin: bin,
|
||||||
@@ -156,130 +156,109 @@ var pakeConf = {
|
|||||||
inject: inject
|
inject: inject
|
||||||
};
|
};
|
||||||
|
|
||||||
var tauri$3 = {
|
var build = {
|
||||||
|
beforeBuildCommand: "",
|
||||||
|
frontendDist: "../dist",
|
||||||
|
beforeDevCommand: ""
|
||||||
|
};
|
||||||
|
var plugins = {
|
||||||
|
};
|
||||||
|
var productName = "WeRead";
|
||||||
|
var version = "1.0.0";
|
||||||
|
var app = {
|
||||||
security: {
|
security: {
|
||||||
csp: null,
|
csp: null
|
||||||
dangerousRemoteDomainIpcAccess: [
|
|
||||||
{
|
|
||||||
domain: "weread.qq.com",
|
|
||||||
windows: [
|
|
||||||
"pake"
|
|
||||||
],
|
|
||||||
enableTauriAPI: true
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
updater: {
|
trayIcon: {
|
||||||
active: false
|
|
||||||
},
|
|
||||||
systemTray: {
|
|
||||||
iconPath: "png/icon_512.png",
|
iconPath: "png/icon_512.png",
|
||||||
iconAsTemplate: false
|
iconAsTemplate: false
|
||||||
},
|
},
|
||||||
allowlist: {
|
withGlobalTauri: true
|
||||||
all: true,
|
|
||||||
fs: {
|
|
||||||
all: true,
|
|
||||||
scope: [
|
|
||||||
"$DOWNLOAD/*"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
var build = {
|
|
||||||
withGlobalTauri: true,
|
|
||||||
devPath: "../dist",
|
|
||||||
distDir: "../dist",
|
|
||||||
beforeBuildCommand: "",
|
|
||||||
beforeDevCommand: ""
|
|
||||||
};
|
};
|
||||||
var CommonConf = {
|
var CommonConf = {
|
||||||
"package": {
|
build: build,
|
||||||
productName: "WeRead",
|
plugins: plugins,
|
||||||
version: "1.0.0"
|
productName: productName,
|
||||||
},
|
version: version,
|
||||||
tauri: tauri$3,
|
app: app
|
||||||
build: build
|
|
||||||
};
|
};
|
||||||
|
|
||||||
var tauri$2 = {
|
var identifier$2 = "com.pake.weread";
|
||||||
bundle: {
|
var bundle$2 = {
|
||||||
icon: [
|
icon: [
|
||||||
"png/weread_256.ico",
|
"png/weread_256.ico",
|
||||||
"png/weread_32.ico"
|
"png/weread_32.ico"
|
||||||
],
|
],
|
||||||
identifier: "com.pake.weread",
|
active: true,
|
||||||
active: true,
|
category: "DeveloperTool",
|
||||||
category: "DeveloperTool",
|
copyright: "",
|
||||||
copyright: "",
|
externalBin: [
|
||||||
externalBin: [
|
],
|
||||||
],
|
longDescription: "",
|
||||||
longDescription: "",
|
resources: [
|
||||||
resources: [
|
"png/weread_32.ico"
|
||||||
"png/weread_32.ico"
|
],
|
||||||
],
|
shortDescription: "",
|
||||||
shortDescription: "",
|
targets: [
|
||||||
targets: [
|
"msi"
|
||||||
"msi"
|
],
|
||||||
],
|
windows: {
|
||||||
windows: {
|
certificateThumbprint: null,
|
||||||
certificateThumbprint: null,
|
digestAlgorithm: "sha256",
|
||||||
digestAlgorithm: "sha256",
|
timestampUrl: "",
|
||||||
timestampUrl: "",
|
wix: {
|
||||||
wix: {
|
language: [
|
||||||
language: [
|
"en-US"
|
||||||
"en-US"
|
],
|
||||||
],
|
template: "assets/main.wxs"
|
||||||
template: "assets/main.wxs"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
var WinConf = {
|
var WinConf = {
|
||||||
tauri: tauri$2
|
identifier: identifier$2,
|
||||||
|
bundle: bundle$2
|
||||||
};
|
};
|
||||||
|
|
||||||
var tauri$1 = {
|
var identifier$1 = "com.pake.weread";
|
||||||
bundle: {
|
var bundle$1 = {
|
||||||
icon: [
|
icon: [
|
||||||
"icons/weread.icns"
|
"icons/weread.icns"
|
||||||
|
],
|
||||||
|
active: true,
|
||||||
|
category: "DeveloperTool",
|
||||||
|
copyright: "",
|
||||||
|
externalBin: [
|
||||||
|
],
|
||||||
|
longDescription: "",
|
||||||
|
macOS: {
|
||||||
|
entitlements: null,
|
||||||
|
exceptionDomain: null,
|
||||||
|
frameworks: [
|
||||||
],
|
],
|
||||||
identifier: "com.pake.weread",
|
providerShortName: null,
|
||||||
active: true,
|
signingIdentity: null
|
||||||
category: "DeveloperTool",
|
},
|
||||||
copyright: "",
|
resources: [
|
||||||
externalBin: [
|
],
|
||||||
],
|
shortDescription: "",
|
||||||
longDescription: "",
|
targets: [
|
||||||
macOS: {
|
"dmg"
|
||||||
entitlements: null,
|
]
|
||||||
exceptionDomain: "",
|
|
||||||
frameworks: [
|
|
||||||
],
|
|
||||||
providerShortName: null,
|
|
||||||
signingIdentity: null
|
|
||||||
},
|
|
||||||
resources: [
|
|
||||||
],
|
|
||||||
shortDescription: "",
|
|
||||||
targets: [
|
|
||||||
"dmg"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
var MacConf = {
|
var MacConf = {
|
||||||
tauri: tauri$1
|
identifier: identifier$1,
|
||||||
|
bundle: bundle$1
|
||||||
};
|
};
|
||||||
|
|
||||||
var tauri = {
|
var identifier = "com.pake.weread";
|
||||||
bundle: {
|
var bundle = {
|
||||||
icon: [
|
icon: [
|
||||||
"png/weread_512.png"
|
"png/weread_512.png"
|
||||||
],
|
],
|
||||||
identifier: "com.pake.weread",
|
active: true,
|
||||||
active: true,
|
category: "DeveloperTool",
|
||||||
category: "DeveloperTool",
|
copyright: "",
|
||||||
copyright: "",
|
linux: {
|
||||||
deb: {
|
deb: {
|
||||||
depends: [
|
depends: [
|
||||||
"curl",
|
"curl",
|
||||||
@@ -288,21 +267,22 @@ var tauri = {
|
|||||||
files: {
|
files: {
|
||||||
"/usr/share/applications/com-pake-weread.desktop": "assets/com-pake-weread.desktop"
|
"/usr/share/applications/com-pake-weread.desktop": "assets/com-pake-weread.desktop"
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
externalBin: [
|
},
|
||||||
],
|
externalBin: [
|
||||||
longDescription: "",
|
],
|
||||||
resources: [
|
longDescription: "",
|
||||||
],
|
resources: [
|
||||||
shortDescription: "",
|
],
|
||||||
targets: [
|
shortDescription: "",
|
||||||
"deb",
|
targets: [
|
||||||
"appimage"
|
"deb",
|
||||||
]
|
"appimage"
|
||||||
}
|
]
|
||||||
};
|
};
|
||||||
var LinuxConf = {
|
var LinuxConf = {
|
||||||
tauri: tauri
|
identifier: identifier,
|
||||||
|
bundle: bundle
|
||||||
};
|
};
|
||||||
|
|
||||||
const platformConfigs = {
|
const platformConfigs = {
|
||||||
@@ -314,11 +294,15 @@ const { platform: platform$2 } = process;
|
|||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
const platformConfig = platformConfigs[platform$2];
|
const platformConfig = platformConfigs[platform$2];
|
||||||
let tauriConfig = {
|
let tauriConfig = {
|
||||||
tauri: {
|
...CommonConf,
|
||||||
...CommonConf.tauri,
|
bundle: platformConfig.bundle,
|
||||||
bundle: platformConfig.tauri.bundle,
|
app: {
|
||||||
|
...CommonConf.app,
|
||||||
|
trayIcon: {
|
||||||
|
...CommonConf.app.trayIcon,
|
||||||
|
...platformConfig.app.trayIcon,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
package: CommonConf.package,
|
|
||||||
build: CommonConf.build,
|
build: CommonConf.build,
|
||||||
pake: pakeConf,
|
pake: pakeConf,
|
||||||
};
|
};
|
||||||
@@ -476,7 +460,7 @@ async function combineFiles(files, output) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function mergeConfig(url, options, tauriConf) {
|
async function mergeConfig(url, options, tauriConf) {
|
||||||
const { width, height, fullscreen, hideTitleBar, alwaysOnTop, disabledWebShortcuts, activationShortcut, userAgent, showSystemTray, systemTrayIcon, useLocalFile, identifier, name, resizable = true, inject, safeDomain, } = options;
|
const { width, height, fullscreen, hideTitleBar, alwaysOnTop, disabledWebShortcuts, activationShortcut, userAgent, showSystemTray, systemTrayIcon, useLocalFile, identifier, name, resizable = true, inject, } = options;
|
||||||
const { platform } = process;
|
const { platform } = process;
|
||||||
// Set Windows parameters.
|
// Set Windows parameters.
|
||||||
const tauriConfWindowOptions = {
|
const tauriConfWindowOptions = {
|
||||||
@@ -490,8 +474,8 @@ async function mergeConfig(url, options, tauriConf) {
|
|||||||
disabled_web_shortcuts: disabledWebShortcuts,
|
disabled_web_shortcuts: disabledWebShortcuts,
|
||||||
};
|
};
|
||||||
Object.assign(tauriConf.pake.windows[0], { url, ...tauriConfWindowOptions });
|
Object.assign(tauriConf.pake.windows[0], { url, ...tauriConfWindowOptions });
|
||||||
tauriConf.package.productName = name;
|
tauriConf.productName = name;
|
||||||
tauriConf.tauri.bundle.identifier = identifier;
|
tauriConf.identifier = identifier;
|
||||||
//Judge the type of URL, whether it is a file or a website.
|
//Judge the type of URL, whether it is a file or a website.
|
||||||
const pathExists = await fsExtra.pathExists(url);
|
const pathExists = await fsExtra.pathExists(url);
|
||||||
if (pathExists) {
|
if (pathExists) {
|
||||||
@@ -518,24 +502,6 @@ async function mergeConfig(url, options, tauriConf) {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
tauriConf.pake.windows[0].url_type = 'web';
|
tauriConf.pake.windows[0].url_type = 'web';
|
||||||
// Set the secure domain for calling window.__TAURI__ to the application domain that has been set.
|
|
||||||
tauriConf.tauri.security.dangerousRemoteDomainIpcAccess = [
|
|
||||||
{
|
|
||||||
domain: new URL(url).hostname,
|
|
||||||
windows: ['pake'],
|
|
||||||
enableTauriAPI: true,
|
|
||||||
},
|
|
||||||
];
|
|
||||||
}
|
|
||||||
if (safeDomain.length > 0) {
|
|
||||||
tauriConf.tauri.security.dangerousRemoteDomainIpcAccess = [
|
|
||||||
...tauriConf.tauri.security.dangerousRemoteDomainIpcAccess,
|
|
||||||
...safeDomain.map(domain => ({
|
|
||||||
domain,
|
|
||||||
windows: ['pake'],
|
|
||||||
enableTauriAPI: true,
|
|
||||||
})),
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
const platformMap = {
|
const platformMap = {
|
||||||
win32: 'windows',
|
win32: 'windows',
|
||||||
@@ -549,10 +515,10 @@ async function mergeConfig(url, options, tauriConf) {
|
|||||||
tauriConf.pake.system_tray[currentPlatform] = showSystemTray;
|
tauriConf.pake.system_tray[currentPlatform] = showSystemTray;
|
||||||
// Processing targets are currently only open to Linux.
|
// Processing targets are currently only open to Linux.
|
||||||
if (platform === 'linux') {
|
if (platform === 'linux') {
|
||||||
delete tauriConf.tauri.bundle.deb.files;
|
delete tauriConf.bundle.linux.deb.files;
|
||||||
const validTargets = ['all', 'deb', 'appimage'];
|
const validTargets = ['all', 'deb', 'appimage'];
|
||||||
if (validTargets.includes(options.targets)) {
|
if (validTargets.includes(options.targets)) {
|
||||||
tauriConf.tauri.bundle.targets = options.targets === 'all' ? ['deb', 'appimage'] : [options.targets];
|
tauriConf.bundle.targets = options.targets === 'all' ? ['deb', 'appimage'] : [options.targets];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
logger.warn(`✼ The target must be one of ${validTargets.join(', ')}, the default 'deb' will be used.`);
|
logger.warn(`✼ The target must be one of ${validTargets.join(', ')}, the default 'deb' will be used.`);
|
||||||
@@ -587,15 +553,15 @@ async function mergeConfig(url, options, tauriConf) {
|
|||||||
if (customIconExt !== iconInfo.fileExt) {
|
if (customIconExt !== iconInfo.fileExt) {
|
||||||
updateIconPath = false;
|
updateIconPath = false;
|
||||||
logger.warn(`✼ ${iconInfo.message}, but you give ${customIconExt}`);
|
logger.warn(`✼ ${iconInfo.message}, but you give ${customIconExt}`);
|
||||||
tauriConf.tauri.bundle.icon = [iconInfo.defaultIcon];
|
tauriConf.bundle.icon = [iconInfo.defaultIcon];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
const iconPath = path.join(npmDirectory, 'src-tauri/', iconInfo.path);
|
const iconPath = path.join(npmDirectory, 'src-tauri/', iconInfo.path);
|
||||||
tauriConf.tauri.bundle.resources = [iconInfo.path];
|
tauriConf.bundle.resources = [iconInfo.path];
|
||||||
await fsExtra.copy(options.icon, iconPath);
|
await fsExtra.copy(options.icon, iconPath);
|
||||||
}
|
}
|
||||||
if (updateIconPath) {
|
if (updateIconPath) {
|
||||||
tauriConf.tauri.bundle.icon = [options.icon];
|
tauriConf.bundle.icon = [options.icon];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
logger.warn(`✼ Icon will remain as default.`);
|
logger.warn(`✼ Icon will remain as default.`);
|
||||||
@@ -603,10 +569,10 @@ async function mergeConfig(url, options, tauriConf) {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
logger.warn('✼ Custom icon path may be invalid, default icon will be used instead.');
|
logger.warn('✼ Custom icon path may be invalid, default icon will be used instead.');
|
||||||
tauriConf.tauri.bundle.icon = [iconInfo.defaultIcon];
|
tauriConf.bundle.icon = [iconInfo.defaultIcon];
|
||||||
}
|
}
|
||||||
// Set tray icon path.
|
// Set tray icon path.
|
||||||
let trayIconPath = platform === 'darwin' ? 'png/icon_512.png' : tauriConf.tauri.bundle.icon[0];
|
let trayIconPath = platform === 'darwin' ? 'png/icon_512.png' : tauriConf.bundle.icon[0];
|
||||||
if (systemTrayIcon.length > 0) {
|
if (systemTrayIcon.length > 0) {
|
||||||
try {
|
try {
|
||||||
await fsExtra.pathExists(systemTrayIcon);
|
await fsExtra.pathExists(systemTrayIcon);
|
||||||
@@ -627,7 +593,7 @@ async function mergeConfig(url, options, tauriConf) {
|
|||||||
logger.warn(`✼ Default system tray icon will remain unchanged.`);
|
logger.warn(`✼ Default system tray icon will remain unchanged.`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tauriConf.tauri.systemTray.iconPath = trayIconPath;
|
tauriConf.app.trayIcon.iconPath = trayIconPath;
|
||||||
const injectFilePath = path.join(npmDirectory, `src-tauri/src/inject/custom.js`);
|
const injectFilePath = path.join(npmDirectory, `src-tauri/src/inject/custom.js`);
|
||||||
// inject js or css files
|
// inject js or css files
|
||||||
if (inject?.length > 0) {
|
if (inject?.length > 0) {
|
||||||
@@ -650,13 +616,12 @@ async function mergeConfig(url, options, tauriConf) {
|
|||||||
linux: 'tauri.linux.conf.json',
|
linux: 'tauri.linux.conf.json',
|
||||||
};
|
};
|
||||||
const configPath = path.join(tauriConfigDirectory, platformConfigPaths[platform]);
|
const configPath = path.join(tauriConfigDirectory, platformConfigPaths[platform]);
|
||||||
const bundleConf = { tauri: { bundle: tauriConf.tauri.bundle } };
|
const bundleConf = { bundle: tauriConf.bundle };
|
||||||
await fsExtra.outputJSON(configPath, bundleConf, { spaces: 4 });
|
await fsExtra.outputJSON(configPath, bundleConf, { spaces: 4 });
|
||||||
const pakeConfigPath = path.join(tauriConfigDirectory, 'pake.json');
|
const pakeConfigPath = path.join(tauriConfigDirectory, 'pake.json');
|
||||||
await fsExtra.outputJSON(pakeConfigPath, tauriConf.pake, { spaces: 4 });
|
await fsExtra.outputJSON(pakeConfigPath, tauriConf.pake, { spaces: 4 });
|
||||||
let tauriConf2 = JSON.parse(JSON.stringify(tauriConf));
|
let tauriConf2 = JSON.parse(JSON.stringify(tauriConf));
|
||||||
delete tauriConf2.pake;
|
delete tauriConf2.pake;
|
||||||
delete tauriConf2.tauri.bundle;
|
|
||||||
const configJsonPath = path.join(tauriConfigDirectory, 'tauri.conf.json');
|
const configJsonPath = path.join(tauriConfigDirectory, 'tauri.conf.json');
|
||||||
await fsExtra.outputJSON(configJsonPath, tauriConf2, { spaces: 4 });
|
await fsExtra.outputJSON(configJsonPath, tauriConf2, { spaces: 4 });
|
||||||
}
|
}
|
||||||
@@ -759,7 +724,7 @@ class MacBuilder extends BaseBuilder {
|
|||||||
else {
|
else {
|
||||||
arch = process.arch === 'arm64' ? 'aarch64' : process.arch;
|
arch = process.arch === 'arm64' ? 'aarch64' : process.arch;
|
||||||
}
|
}
|
||||||
return `${name}_${tauriConfig.package.version}_${arch}`;
|
return `${name}_${tauriConfig.version}_${arch}`;
|
||||||
}
|
}
|
||||||
getBuildCommand() {
|
getBuildCommand() {
|
||||||
return this.options.multiArch ? 'npm run build:mac' : super.getBuildCommand();
|
return this.options.multiArch ? 'npm run build:mac' : super.getBuildCommand();
|
||||||
@@ -779,8 +744,8 @@ class WinBuilder extends BaseBuilder {
|
|||||||
getFileName() {
|
getFileName() {
|
||||||
const { name } = this.options;
|
const { name } = this.options;
|
||||||
const { arch } = process;
|
const { arch } = process;
|
||||||
const language = tauriConfig.tauri.bundle.windows.wix.language[0];
|
const language = tauriConfig.bundle.windows.wix.language[0];
|
||||||
return `${name}_${tauriConfig.package.version}_${arch}_${language}`;
|
return `${name}_${tauriConfig.version}_${arch}_${language}`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -791,7 +756,7 @@ class LinuxBuilder extends BaseBuilder {
|
|||||||
getFileName() {
|
getFileName() {
|
||||||
const { name } = this.options;
|
const { name } = this.options;
|
||||||
const arch = process.arch === 'x64' ? 'amd64' : process.arch;
|
const arch = process.arch === 'x64' ? 'amd64' : process.arch;
|
||||||
return `${name}_${tauriConfig.package.version}_${arch}`;
|
return `${name}_${tauriConfig.version}_${arch}`;
|
||||||
}
|
}
|
||||||
// Customize it, considering that there are all targets.
|
// Customize it, considering that there are all targets.
|
||||||
async build(url) {
|
async build(url) {
|
||||||
|
|||||||
13
src-tauri/Cargo.lock
generated
13
src-tauri/Cargo.lock
generated
@@ -3552,9 +3552,9 @@ checksum = "e1fc403891a21bcfb7c37834ba66a547a8f402146eba7265b5a6d88059c9ff2f"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tauri"
|
name = "tauri"
|
||||||
version = "2.0.0-beta.24"
|
version = "2.0.0-beta.25"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "3eab508aad4ae86e23865e294b20a7bb89bd7afea523897b7478329b841d4295"
|
checksum = "4339c67eb7700fe4a80ad6507e3b9af0b4159959f3d74aae48feed298baf4cbf"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"bytes",
|
"bytes",
|
||||||
@@ -3568,6 +3568,7 @@ dependencies = [
|
|||||||
"gtk",
|
"gtk",
|
||||||
"heck 0.5.0",
|
"heck 0.5.0",
|
||||||
"http",
|
"http",
|
||||||
|
"image 0.24.9",
|
||||||
"jni",
|
"jni",
|
||||||
"libc",
|
"libc",
|
||||||
"log",
|
"log",
|
||||||
@@ -3781,9 +3782,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tauri-runtime"
|
name = "tauri-runtime"
|
||||||
version = "2.0.0-beta.20"
|
version = "2.0.0-beta.21"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "fe978df03966febbebc608931dc2cf26ef94df70855a18b05f07134cf474de09"
|
checksum = "189510033be50f6fde35cfa50b50c7ab4e0ced0c867ae0f643b4907b8385bbe5"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"dpi",
|
"dpi",
|
||||||
"gtk",
|
"gtk",
|
||||||
@@ -3800,9 +3801,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tauri-runtime-wry"
|
name = "tauri-runtime-wry"
|
||||||
version = "2.0.0-beta.20"
|
version = "2.0.0-beta.21"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "11e4d568f61095f507b3fc4254dfbfff3b20de2a1d66167ffca3f6d90b14db8f"
|
checksum = "6938bd63b6658e7b08f0fe2151390148ee5a8ccdba100d4dff961d2c8734d9a9"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cocoa",
|
"cocoa",
|
||||||
"gtk",
|
"gtk",
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ tauri-build = { version = "2.0.0-beta", features = [] }
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
serde_json = "1.0.116"
|
serde_json = "1.0.116"
|
||||||
serde = { version = "1.0.200", features = ["derive"] }
|
serde = { version = "1.0.200", features = ["derive"] }
|
||||||
tauri = { version = "2.0.0-beta", features = ["tray-icon"] }
|
tauri = { version = "2.0.0-beta.25", features = ["tray-icon", "image-ico", "image-png"] }
|
||||||
tauri-plugin-window-state = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" }
|
tauri-plugin-window-state = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" }
|
||||||
tauri-plugin-oauth = { git = "https://github.com/FabianLars/tauri-plugin-oauth", branch = "v2" }
|
tauri-plugin-oauth = { git = "https://github.com/FabianLars/tauri-plugin-oauth", branch = "v2" }
|
||||||
tauri-plugin-clipboard-manager = "2.1.0-beta.6"
|
tauri-plugin-clipboard-manager = "2.1.0-beta.6"
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -1921,6 +1921,13 @@
|
|||||||
"window:allow-set-size"
|
"window:allow-set-size"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"description": "window:allow-set-size-constraints -> Enables the set_size_constraints command without any pre-configured scope.",
|
||||||
|
"type": "string",
|
||||||
|
"enum": [
|
||||||
|
"window:allow-set-size-constraints"
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"description": "window:allow-set-skip-taskbar -> Enables the set_skip_taskbar command without any pre-configured scope.",
|
"description": "window:allow-set-skip-taskbar -> Enables the set_skip_taskbar command without any pre-configured scope.",
|
||||||
"type": "string",
|
"type": "string",
|
||||||
@@ -2369,6 +2376,13 @@
|
|||||||
"window:deny-set-size"
|
"window:deny-set-size"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"description": "window:deny-set-size-constraints -> Denies the set_size_constraints command without any pre-configured scope.",
|
||||||
|
"type": "string",
|
||||||
|
"enum": [
|
||||||
|
"window:deny-set-size-constraints"
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"description": "window:deny-set-skip-taskbar -> Denies the set_skip_taskbar command without any pre-configured scope.",
|
"description": "window:deny-set-skip-taskbar -> Denies the set_skip_taskbar command without any pre-configured scope.",
|
||||||
"type": "string",
|
"type": "string",
|
||||||
|
|||||||
@@ -1921,6 +1921,13 @@
|
|||||||
"window:allow-set-size"
|
"window:allow-set-size"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"description": "window:allow-set-size-constraints -> Enables the set_size_constraints command without any pre-configured scope.",
|
||||||
|
"type": "string",
|
||||||
|
"enum": [
|
||||||
|
"window:allow-set-size-constraints"
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"description": "window:allow-set-skip-taskbar -> Enables the set_skip_taskbar command without any pre-configured scope.",
|
"description": "window:allow-set-skip-taskbar -> Enables the set_skip_taskbar command without any pre-configured scope.",
|
||||||
"type": "string",
|
"type": "string",
|
||||||
@@ -2369,6 +2376,13 @@
|
|||||||
"window:deny-set-size"
|
"window:deny-set-size"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"description": "window:deny-set-size-constraints -> Denies the set_size_constraints command without any pre-configured scope.",
|
||||||
|
"type": "string",
|
||||||
|
"enum": [
|
||||||
|
"window:deny-set-size-constraints"
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"description": "window:deny-set-skip-taskbar -> Denies the set_skip_taskbar command without any pre-configured scope.",
|
"description": "window:deny-set-skip-taskbar -> Denies the set_skip_taskbar command without any pre-configured scope.",
|
||||||
"type": "string",
|
"type": "string",
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
BIN
src-tauri/icons/xiaoyuzhou.icns
Normal file
BIN
src-tauri/icons/xiaoyuzhou.icns
Normal file
Binary file not shown.
@@ -51,6 +51,7 @@ pub struct PakeConfig {
|
|||||||
pub windows: Vec<WindowConfig>,
|
pub windows: Vec<WindowConfig>,
|
||||||
pub user_agent: UserAgent,
|
pub user_agent: UserAgent,
|
||||||
pub system_tray: FunctionON,
|
pub system_tray: FunctionON,
|
||||||
|
pub system_tray_path: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl PakeConfig {
|
impl PakeConfig {
|
||||||
|
|||||||
@@ -1,16 +1,44 @@
|
|||||||
use tauri::{
|
use tauri::{
|
||||||
menu::{MenuBuilder, MenuItemBuilder}, tray::TrayIconBuilder, AppHandle, Manager
|
image::Image, include_image, menu::{ContextMenu, MenuBuilder, MenuItemBuilder}, tray::{MouseButton, MouseButtonState, TrayIcon, TrayIconBuilder, TrayIconEvent}, AppHandle, Config, Manager
|
||||||
};
|
};
|
||||||
use tauri_plugin_window_state::{AppHandleExt, StateFlags};
|
use tauri_plugin_window_state::{AppHandleExt, StateFlags};
|
||||||
|
|
||||||
pub fn set_system_tray(app: &AppHandle) -> tauri::Result<()> {
|
use super::config::PakeConfig;
|
||||||
|
|
||||||
|
pub fn set_system_tray(app: &AppHandle, pake_config: &PakeConfig) -> tauri::Result<()> {
|
||||||
let hide_app = MenuItemBuilder::with_id("hide_app", "Hide").build(app)?;
|
let hide_app = MenuItemBuilder::with_id("hide_app", "Hide").build(app)?;
|
||||||
let show_app = MenuItemBuilder::with_id("show_app", "Show").build(app)?;
|
let show_app = MenuItemBuilder::with_id("show_app", "Show").build(app)?;
|
||||||
let quit = MenuItemBuilder::with_id("quit", "Quit").build(app)?;
|
let quit = MenuItemBuilder::with_id("quit", "Quit").build(app)?;
|
||||||
let menu = MenuBuilder::new(app).items(&[&hide_app, &show_app, &quit]).build()?;
|
let menu = MenuBuilder::new(app).items(&[&hide_app, &show_app, &quit]).build()?;
|
||||||
|
app.app_handle().remove_tray_by_id("pake-tray");
|
||||||
TrayIconBuilder::new()
|
let tray = TrayIconBuilder::new()
|
||||||
|
.icon(Image::from_path(pake_config.system_tray_path.as_str())?)
|
||||||
.menu(&menu)
|
.menu(&menu)
|
||||||
|
.on_tray_icon_event(move |tray, event| {
|
||||||
|
if let TrayIconEvent::Click {
|
||||||
|
button: MouseButton::Left,
|
||||||
|
button_state: MouseButtonState::Up,
|
||||||
|
..
|
||||||
|
} = event {
|
||||||
|
println!("click");
|
||||||
|
|
||||||
|
let app = tray.app_handle();
|
||||||
|
|
||||||
|
|
||||||
|
#[cfg(not(target_os = "macos"))]
|
||||||
|
{
|
||||||
|
if let Some(webview_window) = app.get_webview_window("pake") {
|
||||||
|
let _ = webview_window.show();
|
||||||
|
let _ = webview_window.set_focus();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#[cfg(target_os = "macos")]
|
||||||
|
{
|
||||||
|
tauri::AppHandle::show(&app.app_handle()).unwrap();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
})
|
||||||
.on_menu_event(move |app, event| match event.id().as_ref() {
|
.on_menu_event(move |app, event| match event.id().as_ref() {
|
||||||
"hide_app" => {
|
"hide_app" => {
|
||||||
app.get_webview_window("pake").unwrap().minimize().unwrap();
|
app.get_webview_window("pake").unwrap().minimize().unwrap();
|
||||||
@@ -26,5 +54,6 @@ pub fn set_system_tray(app: &AppHandle) -> tauri::Result<()> {
|
|||||||
})
|
})
|
||||||
.build(app)?;
|
.build(app)?;
|
||||||
|
|
||||||
|
tray.set_icon_as_template(false)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ use tauri::{App, WebviewUrl, WebviewWindow, WebviewWindowBuilder};
|
|||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_os = "macos")]
|
||||||
use tauri::TitleBarStyle;
|
use tauri::TitleBarStyle;
|
||||||
|
|
||||||
pub fn get_window(app: &mut App, config: PakeConfig, _data_dir: PathBuf) -> WebviewWindow {
|
pub fn get_window(app: &mut App, config: &PakeConfig, _data_dir: PathBuf) -> WebviewWindow {
|
||||||
let window_config = config
|
let window_config = config
|
||||||
.windows
|
.windows
|
||||||
.first()
|
.first()
|
||||||
|
|||||||
6
src-tauri/src/inject/custom.js
vendored
6
src-tauri/src/inject/custom.js
vendored
@@ -1,6 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file serves as a collection point for external JS and CSS dependencies.
|
|
||||||
* It amalgamates these external resources for easier injection into the application.
|
|
||||||
* Additionally, you can directly include any script files in this file
|
|
||||||
* that you wish to attach to the application.
|
|
||||||
*/
|
|
||||||
|
|||||||
@@ -8,14 +8,14 @@ use app::{invoke, menu::set_system_tray, window};
|
|||||||
use invoke::{download_file, download_file_by_binary};
|
use invoke::{download_file, download_file_by_binary};
|
||||||
use tauri::Manager;
|
use tauri::Manager;
|
||||||
use tauri_plugin_window_state::Builder as windowStatePlugin;
|
use tauri_plugin_window_state::Builder as windowStatePlugin;
|
||||||
use tauri_plugin_global_shortcut::Shortcut;
|
use tauri_plugin_global_shortcut::{GlobalShortcutExt, Shortcut};
|
||||||
use util::{get_data_dir, get_pake_config};
|
use util::{get_data_dir, get_pake_config};
|
||||||
use window::get_window;
|
use window::get_window;
|
||||||
|
|
||||||
pub fn run_app() {
|
pub fn run_app() {
|
||||||
let (pake_config, tauri_config) = get_pake_config();
|
let (pake_config, tauri_config) = get_pake_config();
|
||||||
|
|
||||||
let mut tauri_app = tauri::Builder::default();
|
let tauri_app = tauri::Builder::default();
|
||||||
|
|
||||||
let show_system_tray = pake_config.show_system_tray();
|
let show_system_tray = pake_config.show_system_tray();
|
||||||
|
|
||||||
@@ -31,24 +31,26 @@ pub fn run_app() {
|
|||||||
download_file_by_binary
|
download_file_by_binary
|
||||||
])
|
])
|
||||||
.setup(move |app| {
|
.setup(move |app| {
|
||||||
let data_dir = get_data_dir(&app.app_handle(), tauri_config);
|
let data_dir = get_data_dir(&app.app_handle(), tauri_config.clone());
|
||||||
|
|
||||||
let _window = get_window(app, pake_config, data_dir);
|
let _window = get_window(app, &pake_config, data_dir);
|
||||||
// Prevent initial shaking
|
// Prevent initial shaking
|
||||||
_window.show().unwrap();
|
_window.show().unwrap();
|
||||||
|
|
||||||
if show_system_tray {
|
if show_system_tray {
|
||||||
let _ = set_system_tray(&app.app_handle());
|
let _ = set_system_tray(&app.app_handle(), &pake_config);
|
||||||
|
} else {
|
||||||
|
app.app_handle().remove_tray_by_id("pake-tray");
|
||||||
}
|
}
|
||||||
|
|
||||||
if !activation_shortcut.is_empty() {
|
if !activation_shortcut.is_empty() {
|
||||||
let app_handle = app.app_handle().clone();
|
let app_handle = app.app_handle().clone();
|
||||||
|
let shortcut_hotkey = Shortcut::from_str(&activation_shortcut.as_str()).unwrap();
|
||||||
|
|
||||||
app_handle
|
app_handle
|
||||||
.plugin(
|
.plugin(
|
||||||
tauri_plugin_global_shortcut::Builder::new()
|
tauri_plugin_global_shortcut::Builder::new()
|
||||||
.with_shortcut(activation_shortcut.as_str())
|
.with_handler(move |app, event, _shortcut| {
|
||||||
?.with_handler(move |app, event, _shortcut| {
|
|
||||||
let shortcut_hotkey = Shortcut::from_str(&activation_shortcut.as_str()).unwrap();
|
|
||||||
|
|
||||||
if shortcut_hotkey.eq(event) {
|
if shortcut_hotkey.eq(event) {
|
||||||
let window = app.get_webview_window("pake").unwrap();
|
let window = app.get_webview_window("pake").unwrap();
|
||||||
@@ -63,6 +65,8 @@ pub fn run_app() {
|
|||||||
}
|
}
|
||||||
).build())
|
).build())
|
||||||
.expect("Error registering global evoke shortcuts!");
|
.expect("Error registering global evoke shortcuts!");
|
||||||
|
|
||||||
|
app.global_shortcut().register(shortcut_hotkey)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|||||||
@@ -13,7 +13,8 @@
|
|||||||
},
|
},
|
||||||
"trayIcon": {
|
"trayIcon": {
|
||||||
"iconPath": "png/icon_512.png",
|
"iconPath": "png/icon_512.png",
|
||||||
"iconAsTemplate": false
|
"iconAsTemplate": false,
|
||||||
|
"id": "pake-tray"
|
||||||
},
|
},
|
||||||
"withGlobalTauri": true
|
"withGlobalTauri": true
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,14 +1,16 @@
|
|||||||
{
|
{
|
||||||
"tauri": {
|
"identifier": "com.pake.weread",
|
||||||
|
|
||||||
"bundle": {
|
"bundle": {
|
||||||
"icon": ["png/weread_512.png"],
|
"icon": ["png/weread_512.png"],
|
||||||
"identifier": "com.pake.weread",
|
|
||||||
"active": true,
|
"active": true,
|
||||||
"category": "DeveloperTool",
|
"category": "DeveloperTool",
|
||||||
"copyright": "",
|
"copyright": "",
|
||||||
"deb": {
|
"linux": {
|
||||||
"depends": ["curl", "wget"],
|
"deb": {
|
||||||
"files": { "/usr/share/applications/com-pake-weread.desktop": "assets/com-pake-weread.desktop" }
|
"depends": ["curl", "wget"],
|
||||||
|
"files": { "/usr/share/applications/com-pake-weread.desktop": "assets/com-pake-weread.desktop" }
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"externalBin": [],
|
"externalBin": [],
|
||||||
"longDescription": "",
|
"longDescription": "",
|
||||||
@@ -16,5 +18,4 @@
|
|||||||
"shortDescription": "",
|
"shortDescription": "",
|
||||||
"targets": ["deb", "appimage"]
|
"targets": ["deb", "appimage"]
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,24 +1,22 @@
|
|||||||
{
|
{
|
||||||
"tauri": {
|
"identifier": "com.pake.weread",
|
||||||
"bundle": {
|
"bundle": {
|
||||||
"icon": ["png/weread_256.ico", "png/weread_32.ico"],
|
"icon": ["png/weread_256.ico", "png/weread_32.ico"],
|
||||||
"identifier": "com.pake.weread",
|
"active": true,
|
||||||
"active": true,
|
"category": "DeveloperTool",
|
||||||
"category": "DeveloperTool",
|
"copyright": "",
|
||||||
"copyright": "",
|
"externalBin": [],
|
||||||
"externalBin": [],
|
"longDescription": "",
|
||||||
"longDescription": "",
|
"resources": ["png/weread_32.ico"],
|
||||||
"resources": ["png/weread_32.ico"],
|
"shortDescription": "",
|
||||||
"shortDescription": "",
|
"targets": ["msi"],
|
||||||
"targets": ["msi"],
|
"windows": {
|
||||||
"windows": {
|
"certificateThumbprint": null,
|
||||||
"certificateThumbprint": null,
|
"digestAlgorithm": "sha256",
|
||||||
"digestAlgorithm": "sha256",
|
"timestampUrl": "",
|
||||||
"timestampUrl": "",
|
"wix": {
|
||||||
"wix": {
|
"language": ["en-US"],
|
||||||
"language": ["en-US"],
|
"template": "assets/main.wxs"
|
||||||
"template": "assets/main.wxs"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user