diff --git a/bin/README_EN.md b/bin/README_EN.md index 2ae5eef..85e9c0d 100644 --- a/bin/README_EN.md +++ b/bin/README_EN.md @@ -34,7 +34,7 @@ The application name, if not specified when entering, will prompt you to enter, #### [icon] -应用 icon,支持本地/远程文件,默认为 Pake 自带图标。 +The application icon, support local and remote files. The default is brand icon of Pake. - MacOS must be `.icns` - Windows must be `.ico` diff --git a/bin/builders/BuilderFactory.ts b/bin/builders/BuilderFactory.ts index aa3e97c..759ef70 100644 --- a/bin/builders/BuilderFactory.ts +++ b/bin/builders/BuilderFactory.ts @@ -6,7 +6,6 @@ import LinuxBuilder from './LinuxBuilder.js'; export default class BuilderFactory { static create(): IBuilder { - console.log("now platform is ", process.platform); if (IS_MAC) { return new MacBuilder(); } diff --git a/bin/options/icon.ts b/bin/options/icon.ts index 8b803b9..8aff0d6 100644 --- a/bin/options/icon.ts +++ b/bin/options/icon.ts @@ -4,8 +4,9 @@ import { PakeAppOptions } from '../types.js'; import { dir } from 'tmp-promise'; import path from 'path'; import fs from 'fs/promises'; -import { fileURLToPath } from 'url'; import logger from './logger.js'; +import { npmDirectory } from '@/utils/dir.js'; +import { IS_LINUX, IS_WIN } from '@/utils/platform.js'; export async function handleIcon(options: PakeAppOptions, url: string) { if (options.icon) { @@ -16,14 +17,20 @@ export async function handleIcon(options: PakeAppOptions, url: string) { } } if (!options.icon) { - return inferIcon(options.name, url); + return getDefaultIcon(); } } -export async function inferIcon(name: string, url: string) { +export async function getDefaultIcon() { logger.info('You have not provided an app icon, use the default icon.(use --icon option to assign an icon)') - const npmDirectory = path.join(path.dirname(fileURLToPath(import.meta.url)), '..'); - return path.join(npmDirectory, 'pake-default.icns'); + let iconPath = 'src-tauri/icons/icon.icns'; + if (IS_WIN) { + iconPath = 'src-tauri/png/icon_256.ico'; + } else if (IS_LINUX) { + iconPath = 'src-tauri/png/icon_512.png'; + } + + return path.join(npmDirectory, iconPath); } // export async function getIconFromPageUrl(url: string) { diff --git a/dist/cli.js b/dist/cli.js index dfafabf..2a4389a 100644 --- a/dist/cli.js +++ b/dist/cli.js @@ -1678,6 +1678,10 @@ const logger = { } }; +const IS_MAC = process.platform === 'darwin'; +const IS_WIN = process.platform === 'win32'; +const IS_LINUX = process.platform === 'linux'; + function handleIcon(options, url) { return __awaiter(this, void 0, void 0, function* () { if (options.icon) { @@ -1689,15 +1693,21 @@ function handleIcon(options, url) { } } if (!options.icon) { - return inferIcon(options.name); + return getDefaultIcon(); } }); } -function inferIcon(name, url) { +function getDefaultIcon() { return __awaiter(this, void 0, void 0, function* () { logger.info('You have not provided an app icon, use the default icon.(use --icon option to assign an icon)'); - const npmDirectory = path.join(path.dirname(fileURLToPath(import.meta.url)), '..'); - return path.join(npmDirectory, 'pake-default.icns'); + let iconPath = 'src-tauri/icons/icon.icns'; + if (IS_WIN) { + iconPath = 'src-tauri/png/icon_256.ico'; + } + else if (IS_LINUX) { + iconPath = 'src-tauri/png/icon_512.png'; + } + return path.join(npmDirectory, iconPath); }); } // export async function getIconFromPageUrl(url: string) { @@ -1773,10 +1783,6 @@ function handleOptions(options, url) { }); } -const IS_MAC = process.platform === 'darwin'; -const IS_WIN = process.platform === 'win32'; -const IS_LINUX = process.platform === 'linux'; - function shellExec(command) { return new Promise((resolve, reject) => { shelljs.exec(command, { async: true, silent: false }, (code) => { @@ -2137,7 +2143,6 @@ Type=Application class BuilderFactory { static create() { - console.log("now platform is ", process.platform); if (IS_MAC) { return new MacBuilder(); } @@ -2168,8 +2173,7 @@ var author = { var files = [ "dist", "src-tauri", - "cli.js", - "pake-default.icns" + "cli.js" ]; var scripts = { start: "npm run dev", diff --git a/package.json b/package.json index 75ff93c..6cc41ca 100644 --- a/package.json +++ b/package.json @@ -16,8 +16,7 @@ "files": [ "dist", "src-tauri", - "cli.js", - "pake-default.icns" + "cli.js" ], "scripts": { "start": "npm run dev",