Skip to content

Commit dba6a4b

Browse files
huangmingfuDsaquel
andauthored
fix: copy the link to carry vue/ep and ts versions (#300)
* fix: user selected version * Update src/composables/store.ts fix: cannot be persistent between reload Co-authored-by: Noblet Ouways <[email protected]> * style: code format * fix: recovery changes wait fix * fix: user selected version --------- Co-authored-by: Noblet Ouways <[email protected]>
1 parent f395f8d commit dba6a4b

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,4 @@
5252
"vue-tsc": "^2.1.6"
5353
},
5454
"prettier": "@sxzz/prettier-config"
55-
}
55+
}

src/composables/store.ts

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ export type Versions = Record<VersionKey, string>
2828
export interface UserOptions {
2929
styleSource?: string
3030
showHidden?: boolean
31+
vueVersion?: string
32+
tsVersion?: string
33+
epVersion?: string
3134
}
3235
export type SerializeState = Record<string, string> & {
3336
_o?: UserOptions
@@ -50,17 +53,21 @@ export const useStore = (initial: Initial) => {
5053
const prUrl = `https://preview-${pr}-element-plus.surge.sh/bundle/dist`
5154

5255
const versions = reactive<Versions>({
53-
vue: 'latest',
54-
elementPlus: pr ? 'preview' : 'latest',
55-
typescript: 'latest',
56+
vue: saved?._o?.vueVersion ?? 'latest',
57+
elementPlus: pr ? 'preview' : (saved?._o?.epVersion ?? 'latest'),
58+
typescript: saved?._o?.tsVersion ?? 'latest',
5659
})
5760
const userOptions: UserOptions = pr
5861
? {
5962
showHidden: true,
6063
styleSource: `${prUrl}/index.css`,
6164
}
6265
: {}
63-
66+
Object.assign(userOptions, {
67+
vueVersion: saved?._o?.vueVersion,
68+
tsVersion: saved?._o?.tsVersion,
69+
epVersion: saved?._o?.epVersion,
70+
})
6471
const hideFile = !IS_DEV && !userOptions.showHidden
6572

6673
const [nightly, toggleNightly] = useToggle(false)
@@ -210,13 +217,16 @@ export const useStore = (initial: Initial) => {
210217
async function setVersion(key: VersionKey, version: string) {
211218
switch (key) {
212219
case 'vue':
220+
userOptions.vueVersion = version
213221
await setVueVersion(version)
214222
break
215223
case 'elementPlus':
216224
versions.elementPlus = version
225+
userOptions.epVersion = version
217226
break
218227
case 'typescript':
219228
store.typescriptVersion = version
229+
userOptions.tsVersion = version
220230
break
221231
}
222232
}

0 commit comments

Comments
 (0)