fix: 补充 tauriConfig 类型定义
This commit is contained in:
21
bin/builders/common.ts
vendored
21
bin/builders/common.ts
vendored
@@ -3,10 +3,29 @@ import prompts, { override } from 'prompts';
|
|||||||
import path from 'path';
|
import path from 'path';
|
||||||
import fs from 'fs/promises';
|
import fs from 'fs/promises';
|
||||||
import fs2 from 'fs-extra';
|
import fs2 from 'fs-extra';
|
||||||
|
import {TauriConfig} from 'tauri/src/types';
|
||||||
|
|
||||||
import { npmDirectory } from '@/utils/dir.js';
|
import { npmDirectory } from '@/utils/dir.js';
|
||||||
import logger from '@/options/logger.js';
|
import logger from '@/options/logger.js';
|
||||||
import URL from 'node:url';
|
import URL from 'node:url';
|
||||||
|
|
||||||
|
type DangerousRemoteDomainIpAccess = {
|
||||||
|
domain: string;
|
||||||
|
windows: string[];
|
||||||
|
enableTauriAPI: boolean;
|
||||||
|
schema?: string;
|
||||||
|
plugins?: string[];
|
||||||
|
}
|
||||||
|
|
||||||
|
// https://tauri.app/v1/api/config/#remotedomainaccessscope
|
||||||
|
type NextTauriConfig = TauriConfig & {
|
||||||
|
tauri: {
|
||||||
|
security: {
|
||||||
|
dangerousRemoteDomainIpcAccess?: DangerousRemoteDomainIpAccess[]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
export async function promptText(message: string, initial?: string) {
|
export async function promptText(message: string, initial?: string) {
|
||||||
const response = await prompts({
|
const response = await prompts({
|
||||||
@@ -18,7 +37,7 @@ export async function promptText(message: string, initial?: string) {
|
|||||||
return response.content;
|
return response.content;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setSecurityConfigWithUrl(tauriConfig: any, url: string) {
|
function setSecurityConfigWithUrl(tauriConfig: NextTauriConfig, url: string) {
|
||||||
const {hostname} = URL.parse(url);
|
const {hostname} = URL.parse(url);
|
||||||
tauriConfig.tauri.security.dangerousRemoteDomainIpcAccess[0].domain = hostname;
|
tauriConfig.tauri.security.dangerousRemoteDomainIpcAccess[0].domain = hostname;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -78,6 +78,7 @@
|
|||||||
"concurrently": "^7.5.0",
|
"concurrently": "^7.5.0",
|
||||||
"cross-env": "^7.0.3",
|
"cross-env": "^7.0.3",
|
||||||
"rollup": "^3.3.0",
|
"rollup": "^3.3.0",
|
||||||
|
"tauri": "^0.15.0",
|
||||||
"tslib": "^2.4.1",
|
"tslib": "^2.4.1",
|
||||||
"typescript": "^4.9.3"
|
"typescript": "^4.9.3"
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user