feat: 完善一波代码 & 支持win(待测试验证)
This commit is contained in:
40
bin/builders/common.ts
vendored
40
bin/builders/common.ts
vendored
@@ -1,4 +1,8 @@
|
||||
import { PakeAppOptions } from '@/types.js';
|
||||
import prompts from 'prompts';
|
||||
import path from 'path';
|
||||
import fs from 'fs/promises';
|
||||
import { npmDirectory } from '@/utils/dir.js';
|
||||
|
||||
export async function promptText(message: string, initial?: string) {
|
||||
const response = await prompts({
|
||||
@@ -9,3 +13,39 @@ export async function promptText(message: string, initial?: string) {
|
||||
});
|
||||
return response.content;
|
||||
}
|
||||
|
||||
export async function mergeTauriConfig(
|
||||
url: string,
|
||||
options: PakeAppOptions,
|
||||
tauriConf: any
|
||||
) {
|
||||
const {
|
||||
width,
|
||||
height,
|
||||
fullscreen,
|
||||
transparent,
|
||||
resizable,
|
||||
identifier,
|
||||
name,
|
||||
} = options;
|
||||
|
||||
const tauriConfWindowOptions = {
|
||||
width,
|
||||
height,
|
||||
fullscreen,
|
||||
transparent,
|
||||
resizable,
|
||||
};
|
||||
|
||||
Object.assign(tauriConf.tauri.windows[0], { url, ...tauriConfWindowOptions });
|
||||
tauriConf.package.productName = name;
|
||||
tauriConf.tauri.bundle.identifier = identifier;
|
||||
tauriConf.tauri.bundle.icon = [options.icon];
|
||||
|
||||
|
||||
const configJsonPath = path.join(npmDirectory, 'src-tauri/tauri.conf.json');
|
||||
await fs.writeFile(
|
||||
configJsonPath,
|
||||
Buffer.from(JSON.stringify(tauriConf), 'utf-8')
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user