2
bin/README_EN.md
vendored
2
bin/README_EN.md
vendored
@@ -34,7 +34,7 @@ The application name, if not specified when entering, will prompt you to enter,
|
|||||||
|
|
||||||
#### [icon]
|
#### [icon]
|
||||||
|
|
||||||
应用 icon,支持本地/远程文件,默认为 Pake 自带图标。
|
The application icon, support local and remote files. The default is brand icon of Pake.
|
||||||
|
|
||||||
- MacOS must be `.icns`
|
- MacOS must be `.icns`
|
||||||
- Windows must be `.ico`
|
- Windows must be `.ico`
|
||||||
|
|||||||
1
bin/builders/BuilderFactory.ts
vendored
1
bin/builders/BuilderFactory.ts
vendored
@@ -6,7 +6,6 @@ import LinuxBuilder from './LinuxBuilder.js';
|
|||||||
|
|
||||||
export default class BuilderFactory {
|
export default class BuilderFactory {
|
||||||
static create(): IBuilder {
|
static create(): IBuilder {
|
||||||
console.log("now platform is ", process.platform);
|
|
||||||
if (IS_MAC) {
|
if (IS_MAC) {
|
||||||
return new MacBuilder();
|
return new MacBuilder();
|
||||||
}
|
}
|
||||||
|
|||||||
17
bin/options/icon.ts
vendored
17
bin/options/icon.ts
vendored
@@ -4,8 +4,9 @@ import { PakeAppOptions } from '../types.js';
|
|||||||
import { dir } from 'tmp-promise';
|
import { dir } from 'tmp-promise';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import fs from 'fs/promises';
|
import fs from 'fs/promises';
|
||||||
import { fileURLToPath } from 'url';
|
|
||||||
import logger from './logger.js';
|
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) {
|
export async function handleIcon(options: PakeAppOptions, url: string) {
|
||||||
if (options.icon) {
|
if (options.icon) {
|
||||||
@@ -16,14 +17,20 @@ export async function handleIcon(options: PakeAppOptions, url: string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!options.icon) {
|
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)')
|
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)), '..');
|
let iconPath = 'src-tauri/icons/icon.icns';
|
||||||
return path.join(npmDirectory, 'pake-default.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) {
|
// export async function getIconFromPageUrl(url: string) {
|
||||||
|
|||||||
26
dist/cli.js
vendored
26
dist/cli.js
vendored
@@ -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) {
|
function handleIcon(options, url) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
if (options.icon) {
|
if (options.icon) {
|
||||||
@@ -1689,15 +1693,21 @@ function handleIcon(options, url) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!options.icon) {
|
if (!options.icon) {
|
||||||
return inferIcon(options.name);
|
return getDefaultIcon();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
function inferIcon(name, url) {
|
function getDefaultIcon() {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
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)');
|
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)), '..');
|
let iconPath = 'src-tauri/icons/icon.icns';
|
||||||
return path.join(npmDirectory, 'pake-default.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) {
|
// 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) {
|
function shellExec(command) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
shelljs.exec(command, { async: true, silent: false }, (code) => {
|
shelljs.exec(command, { async: true, silent: false }, (code) => {
|
||||||
@@ -2137,7 +2143,6 @@ Type=Application
|
|||||||
|
|
||||||
class BuilderFactory {
|
class BuilderFactory {
|
||||||
static create() {
|
static create() {
|
||||||
console.log("now platform is ", process.platform);
|
|
||||||
if (IS_MAC) {
|
if (IS_MAC) {
|
||||||
return new MacBuilder();
|
return new MacBuilder();
|
||||||
}
|
}
|
||||||
@@ -2168,8 +2173,7 @@ var author = {
|
|||||||
var files = [
|
var files = [
|
||||||
"dist",
|
"dist",
|
||||||
"src-tauri",
|
"src-tauri",
|
||||||
"cli.js",
|
"cli.js"
|
||||||
"pake-default.icns"
|
|
||||||
];
|
];
|
||||||
var scripts = {
|
var scripts = {
|
||||||
start: "npm run dev",
|
start: "npm run dev",
|
||||||
|
|||||||
@@ -16,8 +16,7 @@
|
|||||||
"files": [
|
"files": [
|
||||||
"dist",
|
"dist",
|
||||||
"src-tauri",
|
"src-tauri",
|
||||||
"cli.js",
|
"cli.js"
|
||||||
"pake-default.icns"
|
|
||||||
],
|
],
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "npm run dev",
|
"start": "npm run dev",
|
||||||
|
|||||||
Reference in New Issue
Block a user