Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,4 @@
"vue-tsc": "^2.1.6"
},
"prettier": "@sxzz/prettier-config"
}
}
18 changes: 14 additions & 4 deletions src/composables/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ export type Versions = Record<VersionKey, string>
export interface UserOptions {
styleSource?: string
showHidden?: boolean
vueVersion?: string
tsVersion?: string
epVersion?: string
}
export type SerializeState = Record<string, string> & {
_o?: UserOptions
Expand All @@ -50,17 +53,21 @@ export const useStore = (initial: Initial) => {
const prUrl = `https://preview-${pr}-element-plus.surge.sh/bundle/dist`

const versions = reactive<Versions>({
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
? {
showHidden: true,
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)
Expand Down Expand Up @@ -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
}
}
Expand Down