diff --git a/package.json b/package.json index d1afaa1d..c23fe26d 100644 --- a/package.json +++ b/package.json @@ -52,4 +52,4 @@ "vue-tsc": "^2.1.6" }, "prettier": "@sxzz/prettier-config" -} \ No newline at end of file +} diff --git a/src/composables/store.ts b/src/composables/store.ts index 0a679f56..87c74fab 100644 --- a/src/composables/store.ts +++ b/src/composables/store.ts @@ -28,6 +28,9 @@ export type Versions = Record export interface UserOptions { styleSource?: string showHidden?: boolean + vueVersion?: string + tsVersion?: string + epVersion?: string } export type SerializeState = Record & { _o?: UserOptions @@ -50,9 +53,9 @@ export const useStore = (initial: Initial) => { const prUrl = `https://preview-${pr}-element-plus.surge.sh/bundle/dist` const versions = reactive({ - vue: 'latest', - elementPlus: pr ? 'preview' : 'latest', - typescript: 'latest', + vue: saved?._o?.vueVersion ?? 'latest', + elementPlus: pr ? 'preview' : (saved?._o?.epVersion ?? 'latest'), + typescript: saved?._o?.tsVersion ?? 'latest', }) const userOptions: UserOptions = pr ? { @@ -60,7 +63,11 @@ export const useStore = (initial: Initial) => { styleSource: `${prUrl}/index.css`, } : {} - + Object.assign(userOptions, { + vueVersion: saved?._o?.vueVersion, + tsVersion: saved?._o?.tsVersion, + epVersion: saved?._o?.epVersion, + }) const hideFile = !IS_DEV && !userOptions.showHidden const [nightly, toggleNightly] = useToggle(false) @@ -210,13 +217,16 @@ export const useStore = (initial: Initial) => { async function setVersion(key: VersionKey, version: string) { switch (key) { case 'vue': + userOptions.vueVersion = version await setVueVersion(version) break case 'elementPlus': versions.elementPlus = version + userOptions.epVersion = version break case 'typescript': store.typescriptVersion = version + userOptions.tsVersion = version break } }