chore(sfc-playground): correctly show selected version on start up

This commit is contained in:
Evan You 2023-12-27 10:08:26 +08:00
parent 9183069888
commit 9e529f8acb
1 changed files with 6 additions and 0 deletions

View File

@ -27,6 +27,12 @@ const { store } = props
const currentCommit = __COMMIT__
const vueVersion = ref(`@${currentCommit}`)
const vueURL = store.getImportMap().imports.vue
if (vueURL && !vueURL.startsWith(location.origin)) {
const versionMatch = vueURL.match(/runtime-dom@([^/]+)/)
if (versionMatch) vueVersion.value = versionMatch[1]
}
async function setVueVersion(v: string) {
vueVersion.value = `loading...`
await store.setVueVersion(v)