From 1f3f6cf9a8435c7f65d092d5c72f7f62aa0ce0d4 Mon Sep 17 00:00:00 2001 From: josc146 Date: Tue, 30 May 2023 22:58:52 +0800 Subject: [PATCH] chore --- frontend/src/startup.ts | 4 ++-- frontend/src/stores/commonStore.ts | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/frontend/src/startup.ts b/frontend/src/startup.ts index b0ea34c..a602afb 100644 --- a/frontend/src/startup.ts +++ b/frontend/src/startup.ts @@ -1,4 +1,4 @@ -import commonStore from './stores/commonStore'; +import commonStore, { Platform } from './stores/commonStore'; import { GetPlatform, ReadJson } from '../wailsjs/go/backend_golang/App'; import { Cache, checkUpdate, downloadProgramFiles, LocalConfig, refreshModels } from './utils'; import { getStatus } from './apis'; @@ -15,7 +15,7 @@ export async function startup() { initCache().then(initRemoteText); - await GetPlatform().then(p => commonStore.setPlatform(p)); + await GetPlatform().then(p => commonStore.setPlatform(p as Platform)); await initConfig(); if (commonStore.settings.autoUpdatesCheck) // depends on config settings diff --git a/frontend/src/stores/commonStore.ts b/frontend/src/stores/commonStore.ts index 441f197..abed62a 100644 --- a/frontend/src/stores/commonStore.ts +++ b/frontend/src/stores/commonStore.ts @@ -25,6 +25,8 @@ export type Status = { device_name: string; } +export type Platform = 'windows' | 'darwin' | 'linux'; + class CommonStore { // global status: Status = { @@ -33,7 +35,7 @@ class CommonStore { device_name: 'CPU' }; depComplete: boolean = false; - platform: string = 'windows'; + platform: Platform = 'windows'; // home introduction: IntroductionContent = manifest.introduction; // chat @@ -170,7 +172,7 @@ class CommonStore { this.completionGenerating = value; } - setPlatform(value: string) { + setPlatform(value: Platform) { this.platform = value; } }