@varlet/cli 2.10.0-alpha.1682067841655 → 2.10.0-alpha.1682270341744
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/client/index.d.ts +1 -0
- package/lib/client/index.js +4 -1
- package/package.json +7 -7
- package/site/mobile/main.ts +4 -4
- package/site/pc/Layout.vue +18 -1
- package/site/pc/components/AppMobile.vue +4 -1
- package/site/pc/main.ts +15 -5
package/lib/client/index.d.ts
CHANGED
package/lib/client/index.js
CHANGED
|
@@ -21,10 +21,13 @@ export function StyleProvider(styleVars = {}) {
|
|
|
21
21
|
});
|
|
22
22
|
}
|
|
23
23
|
export function getPCLocationInfo() {
|
|
24
|
-
|
|
24
|
+
var _a;
|
|
25
|
+
const [, language, path] = window.location.hash.split('/');
|
|
26
|
+
const [menuName, hash = ''] = (_a = path === null || path === void 0 ? void 0 : path.split('#')) !== null && _a !== void 0 ? _a : [];
|
|
25
27
|
return {
|
|
26
28
|
language,
|
|
27
29
|
menuName,
|
|
30
|
+
hash,
|
|
28
31
|
};
|
|
29
32
|
}
|
|
30
33
|
function getHashSearch() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@varlet/cli",
|
|
3
|
-
"version": "2.10.0-alpha.
|
|
3
|
+
"version": "2.10.0-alpha.1682270341744",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "cli of varlet",
|
|
6
6
|
"bin": {
|
|
@@ -70,8 +70,8 @@
|
|
|
70
70
|
"vite": "4.0.4",
|
|
71
71
|
"vue": "3.2.25",
|
|
72
72
|
"webfont": "^9.0.0",
|
|
73
|
-
"@varlet/shared": "2.10.0-alpha.
|
|
74
|
-
"@varlet/vite-plugins": "2.10.0-alpha.
|
|
73
|
+
"@varlet/shared": "2.10.0-alpha.1682270341744",
|
|
74
|
+
"@varlet/vite-plugins": "2.10.0-alpha.1682270341744"
|
|
75
75
|
},
|
|
76
76
|
"devDependencies": {
|
|
77
77
|
"@types/babel__core": "^7.1.12",
|
|
@@ -85,8 +85,8 @@
|
|
|
85
85
|
"@types/node": "^18.7.20",
|
|
86
86
|
"@types/semver": "^7.3.9",
|
|
87
87
|
"@types/sharp": "0.31.1",
|
|
88
|
-
"@varlet/touch-emulator": "2.10.0-alpha.
|
|
89
|
-
"@varlet/icons": "2.10.0-alpha.
|
|
88
|
+
"@varlet/touch-emulator": "2.10.0-alpha.1682270341744",
|
|
89
|
+
"@varlet/icons": "2.10.0-alpha.1682270341744"
|
|
90
90
|
},
|
|
91
91
|
"peerDependencies": {
|
|
92
92
|
"@vue/runtime-core": "3.2.47",
|
|
@@ -96,8 +96,8 @@
|
|
|
96
96
|
"lodash-es": "^4.17.21",
|
|
97
97
|
"vue": "3.2.47",
|
|
98
98
|
"vue-router": "4.1.6",
|
|
99
|
-
"@varlet/
|
|
100
|
-
"@varlet/
|
|
99
|
+
"@varlet/touch-emulator": "2.10.0-alpha.1682270341744",
|
|
100
|
+
"@varlet/icons": "2.10.0-alpha.1682270341744"
|
|
101
101
|
},
|
|
102
102
|
"scripts": {
|
|
103
103
|
"dev": "tsc --watch",
|
package/site/mobile/main.ts
CHANGED
|
@@ -37,9 +37,9 @@ const router = createRouter({
|
|
|
37
37
|
})
|
|
38
38
|
|
|
39
39
|
router.beforeEach((to: any) => {
|
|
40
|
-
const
|
|
41
|
-
const
|
|
42
|
-
const replace =
|
|
40
|
+
const { path, hash, query } = to
|
|
41
|
+
const language = query.language ?? defaultLanguage
|
|
42
|
+
const replace = query.replace
|
|
43
43
|
|
|
44
44
|
if (!isPhone() && !inIframe()) {
|
|
45
45
|
window.location.href = `./#/${language}${path}`
|
|
@@ -48,7 +48,7 @@ router.beforeEach((to: any) => {
|
|
|
48
48
|
if (!isPhone() && inIframe()) {
|
|
49
49
|
try {
|
|
50
50
|
// @ts-ignore
|
|
51
|
-
window.parent.onMobileRouteChange(path, language, replace)
|
|
51
|
+
window.parent.onMobileRouteChange(path, language, replace, hash)
|
|
52
52
|
} catch (e) {
|
|
53
53
|
console.log(e)
|
|
54
54
|
}
|
package/site/pc/Layout.vue
CHANGED
|
@@ -18,6 +18,7 @@ const mobileRedirect = get(config, 'mobile.redirect')
|
|
|
18
18
|
const language: Ref<string> = ref('')
|
|
19
19
|
const componentName: Ref<null | string> = ref(null)
|
|
20
20
|
const menuName: Ref<string> = ref('')
|
|
21
|
+
const hash: Ref<string> = ref('')
|
|
21
22
|
const doc: Ref<HTMLElement | null> = ref(null)
|
|
22
23
|
const route = useRoute()
|
|
23
24
|
|
|
@@ -48,6 +49,7 @@ const handleSidebarChange = (menu: Menu) => {
|
|
|
48
49
|
doc.value!.scrollTop = 0
|
|
49
50
|
componentName.value = getComponentNameByMenuName(menu.doc)
|
|
50
51
|
menuName.value = menu.doc
|
|
52
|
+
hash.value = ''
|
|
51
53
|
}
|
|
52
54
|
|
|
53
55
|
const confirmClose = () => {
|
|
@@ -79,13 +81,14 @@ onMounted(() => {
|
|
|
79
81
|
watch(
|
|
80
82
|
() => route.path,
|
|
81
83
|
() => {
|
|
82
|
-
const { language: lang, menuName: _menuName } = getPCLocationInfo()
|
|
84
|
+
const { language: lang, menuName: _menuName, hash: _hash } = getPCLocationInfo()
|
|
83
85
|
if (!lang || !_menuName) {
|
|
84
86
|
return
|
|
85
87
|
}
|
|
86
88
|
|
|
87
89
|
componentName.value = getComponentNameByMenuName(_menuName)
|
|
88
90
|
menuName.value = _menuName
|
|
91
|
+
hash.value = _hash
|
|
89
92
|
language.value = lang
|
|
90
93
|
useMobile.value = menu.value.find(item => item.doc === _menuName)?.useMobile ?? get(config, 'useMobile')
|
|
91
94
|
document.title = get(config, 'pc.title')[lang] as string
|
|
@@ -118,6 +121,7 @@ watch(
|
|
|
118
121
|
:component-name="componentName"
|
|
119
122
|
:language="language"
|
|
120
123
|
:replace="menuName"
|
|
124
|
+
:hash="hash"
|
|
121
125
|
v-show="useMobile"
|
|
122
126
|
/>
|
|
123
127
|
</div>
|
|
@@ -282,6 +286,19 @@ iframe {
|
|
|
282
286
|
}
|
|
283
287
|
|
|
284
288
|
&-doc {
|
|
289
|
+
h3 {
|
|
290
|
+
display: flex;
|
|
291
|
+
align-items: center;
|
|
292
|
+
|
|
293
|
+
.router-link-active {
|
|
294
|
+
font-size: 20px;
|
|
295
|
+
margin-right: 8px;
|
|
296
|
+
user-select: none;
|
|
297
|
+
text-decoration: none;
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
|
|
285
302
|
a {
|
|
286
303
|
color: var(--site-config-color-link);
|
|
287
304
|
-webkit-font-smoothing: antialiased;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div class="varlet-site-mobile varlet-site-mobile--375">
|
|
3
3
|
<div class="varlet-site-mobile-content">
|
|
4
|
-
<iframe id="mobile" :src="`./mobile.html#/${componentName}?language=${language}&platform=pc&replace=${replace}`"></iframe>
|
|
4
|
+
<iframe id="mobile" :src="`./mobile.html#/${componentName}?language=${language}&platform=pc&replace=${replace}${hash ? `#${hash}` : ''}`"></iframe>
|
|
5
5
|
</div>
|
|
6
6
|
</div>
|
|
7
7
|
</template>
|
|
@@ -18,6 +18,9 @@ export default {
|
|
|
18
18
|
},
|
|
19
19
|
replace: {
|
|
20
20
|
type: String
|
|
21
|
+
},
|
|
22
|
+
hash: {
|
|
23
|
+
type: String
|
|
21
24
|
}
|
|
22
25
|
}
|
|
23
26
|
}
|
package/site/pc/main.ts
CHANGED
|
@@ -36,14 +36,24 @@ redirect &&
|
|
|
36
36
|
|
|
37
37
|
const router = createRouter({
|
|
38
38
|
history: createWebHashHistory(),
|
|
39
|
-
scrollBehavior: () => ({ top: 0 }),
|
|
40
39
|
routes,
|
|
40
|
+
scrollBehavior(to: any) {
|
|
41
|
+
if (to.hash) {
|
|
42
|
+
return {
|
|
43
|
+
el: to.hash,
|
|
44
|
+
behavior: 'smooth',
|
|
45
|
+
top: 100
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return { top: 0 };
|
|
50
|
+
},
|
|
41
51
|
})
|
|
42
52
|
|
|
43
53
|
let isEnd = true
|
|
44
54
|
|
|
45
55
|
router.beforeEach((to: any, from: any) => {
|
|
46
|
-
if (to.
|
|
56
|
+
if (to.fullPath === from.fullPath) {
|
|
47
57
|
return false
|
|
48
58
|
}
|
|
49
59
|
|
|
@@ -65,13 +75,13 @@ router.afterEach(() => {
|
|
|
65
75
|
})
|
|
66
76
|
|
|
67
77
|
Object.defineProperty(window, 'onMobileRouteChange', {
|
|
68
|
-
value: (path: string, language: string, replace: string) => {
|
|
78
|
+
value: (path: string, language: string, replace: string, hash: string) => {
|
|
69
79
|
if (path === mobileRedirect) {
|
|
70
|
-
router.replace(`/${language}/${replace}`)
|
|
80
|
+
router.replace(`/${language}/${replace}${hash}`)
|
|
71
81
|
return
|
|
72
82
|
}
|
|
73
83
|
|
|
74
|
-
router.replace(`/${language}${path}`)
|
|
84
|
+
router.replace(`/${language}${path}${hash}`)
|
|
75
85
|
}
|
|
76
86
|
})
|
|
77
87
|
|