🐛 Support Chinese naming and fix the use of local icons
This commit is contained in:
8
bin/options/icon.ts
vendored
8
bin/options/icon.ts
vendored
@@ -43,9 +43,11 @@ const API_KEYS = {
|
||||
/**
|
||||
* Generates platform-specific icon paths and handles copying for Windows
|
||||
*/
|
||||
import { generateSafeFilename } from '@/utils/name';
|
||||
|
||||
function generateIconPath(appName: string, isDefault = false): string {
|
||||
const safeName = appName.toLowerCase().replace(/[^a-z0-9-_]/g, '_');
|
||||
const baseName = isDefault ? 'icon' : safeName;
|
||||
const safeName = isDefault ? 'icon' : generateSafeFilename(appName).toLowerCase();
|
||||
const baseName = safeName;
|
||||
|
||||
if (IS_WIN) {
|
||||
return path.join(npmDirectory, 'src-tauri', 'png', `${baseName}_256.ico`);
|
||||
@@ -122,7 +124,7 @@ async function convertIconFormat(
|
||||
await fsExtra.ensureDir(platformOutputDir);
|
||||
|
||||
const processedInputPath = await preprocessIcon(inputPath);
|
||||
const iconName = appName.toLowerCase();
|
||||
const iconName = generateSafeFilename(appName).toLowerCase();
|
||||
|
||||
// Generate platform-specific format
|
||||
if (IS_WIN) {
|
||||
|
||||
9
bin/options/index.ts
vendored
9
bin/options/index.ts
vendored
@@ -4,6 +4,7 @@ import logger from '@/options/logger';
|
||||
import { handleIcon } from './icon';
|
||||
import { getDomain } from '@/utils/url';
|
||||
import { getIdentifier, promptText, capitalizeFirstLetter } from '@/utils/info';
|
||||
import { generateLinuxPackageName } from '@/utils/name';
|
||||
import { PakeAppOptions, PakeCliOptions, PlatformMap } from '@/types';
|
||||
|
||||
function resolveAppName(name: string, platform: NodeJS.Platform): string {
|
||||
@@ -13,8 +14,8 @@ function resolveAppName(name: string, platform: NodeJS.Platform): string {
|
||||
|
||||
function isValidName(name: string, platform: NodeJS.Platform): boolean {
|
||||
const platformRegexMapping: PlatformMap = {
|
||||
linux: /^[a-z0-9][a-z0-9-]*$/,
|
||||
default: /^[a-zA-Z0-9][a-zA-Z0-9- ]*$/,
|
||||
linux: /^[a-z0-9\u4e00-\u9fff][a-z0-9\u4e00-\u9fff-]*$/,
|
||||
default: /^[a-zA-Z0-9\u4e00-\u9fff][a-zA-Z0-9\u4e00-\u9fff- ]*$/,
|
||||
};
|
||||
const reg = platformRegexMapping[platform] || platformRegexMapping.default;
|
||||
return !!name && reg.test(name);
|
||||
@@ -36,10 +37,8 @@ export default async function handleOptions(
|
||||
name = namePrompt || defaultName;
|
||||
}
|
||||
|
||||
// Handle platform-specific name formatting
|
||||
if (name && platform === 'linux') {
|
||||
// Convert to lowercase and replace spaces with dashes for Linux
|
||||
name = name.toLowerCase().replace(/\s+/g, '-');
|
||||
name = generateLinuxPackageName(name);
|
||||
}
|
||||
|
||||
if (!isValidName(name, platform)) {
|
||||
|
||||
Reference in New Issue
Block a user