Skip to content

Commit d0376f3

Browse files
authored
feat: support vue pr (#323)
1 parent 1bad099 commit d0376f3

File tree

2 files changed

+41
-13
lines changed

2 files changed

+41
-13
lines changed

src/components/Header.vue

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,22 @@ function refreshView() {
8686
languageToolsVersion
8787
}}</el-tag
8888
>
89-
<el-tag v-if="store.pr" size="small">
90-
<el-link
91-
type="primary"
92-
:href="`https://github.com/element-plus/element-plus/pull/${store.pr}`"
93-
>PR {{ store.pr }}</el-link
94-
>
95-
</el-tag>
89+
<div flex="~ col gap-1">
90+
<el-tag v-if="store.pr" size="small">
91+
<el-link
92+
type="primary"
93+
:href="`https://github.com/element-plus/element-plus/pull/${store.pr}`"
94+
>PR {{ store.pr }}</el-link
95+
>
96+
</el-tag>
97+
<el-tag v-if="store.vuePr" size="small">
98+
<el-link
99+
type="primary"
100+
:href="`https://github.com/vuejs/core/pull/${store.vuePr}`"
101+
>Vue PR {{ store.vuePr }}</el-link
102+
>
103+
</el-tag>
104+
</div>
96105
</div>
97106
</div>
98107

src/composables/store.ts

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ export interface UserOptions {
3131
vueVersion?: string
3232
tsVersion?: string
3333
epVersion?: string
34+
vuePr?: string
3435
}
3536
export type SerializeState = Record<string, string> & {
3637
_o?: UserOptions
@@ -51,18 +52,27 @@ export const useStore = (initial: Initial) => {
5152
new URLSearchParams(location.search).get('pr') ||
5253
saved?._o?.styleSource?.split('-', 2)[1]
5354
const prUrl = `https://preview-${pr}-element-plus.surge.sh/bundle/dist`
55+
const vuePr =
56+
new URLSearchParams(location.search).get('vue') || saved?._o?.vuePr
57+
const vuePrUrl = `https://esm.sh/pr`
5458

5559
const versions = reactive<Versions>({
5660
vue: saved?._o?.vueVersion ?? 'latest',
5761
elementPlus: pr ? 'preview' : (saved?._o?.epVersion ?? 'latest'),
5862
typescript: saved?._o?.tsVersion ?? 'latest',
5963
})
60-
const userOptions: UserOptions = pr
61-
? {
62-
showHidden: true,
63-
styleSource: `${prUrl}/index.css`,
64-
}
65-
: {}
64+
const userOptions: UserOptions = {}
65+
if (pr) {
66+
Object.assign(userOptions, {
67+
showHidden: true,
68+
styleSource: `${prUrl}/index.css`,
69+
})
70+
}
71+
if (vuePr) {
72+
Object.assign(userOptions, {
73+
vuePr,
74+
})
75+
}
6676
Object.assign(userOptions, {
6777
vueVersion: saved?._o?.vueVersion,
6878
tsVersion: saved?._o?.tsVersion,
@@ -80,6 +90,14 @@ export const useStore = (initial: Initial) => {
8090
'element-plus/': 'unsupported',
8191
},
8292
})
93+
94+
if (vuePr)
95+
importMap = mergeImportMap(importMap, {
96+
imports: {
97+
vue: `${vuePrUrl}/vue@${vuePr}`,
98+
'@vue/shared': `${vuePrUrl}/@vue/shared@${vuePr}`,
99+
},
100+
})
83101
return importMap
84102
})
85103

@@ -238,6 +256,7 @@ export const useStore = (initial: Initial) => {
238256
toggleNightly,
239257
serialize,
240258
init,
259+
vuePr,
241260
}
242261
Object.assign(store, utils)
243262

0 commit comments

Comments
 (0)