diff --git a/packages/devtools/src/common/utils.ts b/packages/devtools/src/common/utils.ts index f2da036..786e029 100644 --- a/packages/devtools/src/common/utils.ts +++ b/packages/devtools/src/common/utils.ts @@ -3,6 +3,7 @@ import { AppModel } from "../models/app.model"; import { LocaleModel } from "../models/locale.model"; import { ModalModel } from "../models/modal.model"; import { AppResult } from "./result"; +import { ExecOptions } from '../../../types/Niva_zh' let baseFileSystemUrl: string | null = null; let sep: string | null = null; @@ -190,7 +191,7 @@ export const checkVersion = (modal: ModalModel, locale: LocaleModel) => { }) } -export async function runCmd(cmd: string, args: string[], options?: unknown) { +export async function runCmd(cmd: string, args: string[], options?: ExecOptions) { const { process } = Niva.api; const res = await process.exec( cmd, diff --git a/packages/devtools/src/models/app.model.ts b/packages/devtools/src/models/app.model.ts index 40cd002..e77f1ac 100644 --- a/packages/devtools/src/models/app.model.ts +++ b/packages/devtools/src/models/app.model.ts @@ -43,7 +43,7 @@ export class AppModel extends StateModel<{ async openWithPicker(): Promise { const { modal } = this.state; - const path = await modal.showNative(() => + const path = await modal.showNative(() => Niva.api.dialog.pickDir() ); @@ -154,7 +154,7 @@ export class AppModel extends StateModel<{ async create(): Promise { const { modal } = this.state; - const path = await modal.showNative(() => + const path = await modal.showNative(() => Niva.api.dialog.saveFile() ); diff --git a/packages/devtools/src/models/project.model.ts b/packages/devtools/src/models/project.model.ts index 91edbb7..bc0778c 100644 --- a/packages/devtools/src/models/project.model.ts +++ b/packages/devtools/src/models/project.model.ts @@ -160,7 +160,7 @@ export class ProjectModel extends StateModel { const _p = { project: this, progress, - file: null + file: null as string | null } try { if (osType.toLowerCase().replace(/\s/g, "") === "macos") { @@ -184,7 +184,10 @@ export class ProjectModel extends StateModel { modal .confirm(locale.t("BUILD_SUCCESS"), locale.t("BUILD_SUCCESS_MESSAGE")) - .then((ok) => ok && process.open(dirname(appPath))); + .then((ok) => { + if (!ok) return + return process.open(dirname(appPath)) + }); }); } diff --git a/packages/types/Niva_zh.d.ts b/packages/types/Niva_zh.d.ts index bec85dc..0dee351 100644 --- a/packages/types/Niva_zh.d.ts +++ b/packages/types/Niva_zh.d.ts @@ -705,7 +705,7 @@ interface NivaOs { locale(): Promise; } -interface ExecOptions { +export interface ExecOptions { env?: Record; current_dir?: string; detached?: boolean;