@varlet/cli 2.13.2 → 2.13.3
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 +6 -1
- package/package.json +7 -7
- package/site/pc/main.ts +0 -21
- package/site/pc/pages/index/index.less +28 -0
- package/site/pc/pages/index/index.vue +4 -4
- package/site/utils.ts +4 -3
- package/site/components/loading-bar/LoadingBar.tsx +0 -30
- package/site/components/loading-bar/index.ts +0 -91
- package/site/components/loading-bar/loadingBar.less +0 -18
- package/site/components/loading-bar/props.ts +0 -23
package/lib/client/index.d.ts
CHANGED
|
@@ -14,5 +14,6 @@ export declare function withSiteConfigNamespace(styleVars: Record<string, any>):
|
|
|
14
14
|
export declare function watchPlatform(cb: (platform: string) => void): void;
|
|
15
15
|
export declare function useRouteListener(cb: () => void): void;
|
|
16
16
|
export declare function watchDarkMode(dark: StyleVars, cb?: (theme: Theme) => void): void;
|
|
17
|
+
export declare function setColorScheme(theme: Theme): void;
|
|
17
18
|
export declare function watchTheme(cb: (theme: Theme, from: 'pc' | 'mobile' | 'default' | 'playground') => void, shouldUnmount?: boolean): void;
|
|
18
19
|
export { AppType };
|
package/lib/client/index.js
CHANGED
|
@@ -87,10 +87,15 @@ export function useRouteListener(cb) {
|
|
|
87
87
|
export function watchDarkMode(dark, cb) {
|
|
88
88
|
watchTheme((theme) => {
|
|
89
89
|
const siteStyleVars = withSiteConfigNamespace(get(config, theme, {}));
|
|
90
|
-
|
|
90
|
+
const darkStyleVars = Object.assign(Object.assign({}, siteStyleVars), dark);
|
|
91
|
+
StyleProvider(theme === 'darkTheme' ? darkStyleVars : siteStyleVars);
|
|
92
|
+
setColorScheme(theme);
|
|
91
93
|
cb === null || cb === void 0 ? void 0 : cb(theme);
|
|
92
94
|
});
|
|
93
95
|
}
|
|
96
|
+
export function setColorScheme(theme) {
|
|
97
|
+
document.documentElement.style.setProperty('color-scheme', theme === 'darkTheme' ? 'dark' : 'light');
|
|
98
|
+
}
|
|
94
99
|
export function watchTheme(cb, shouldUnmount = true) {
|
|
95
100
|
const handleThemeChange = (event) => {
|
|
96
101
|
const { data } = event;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@varlet/cli",
|
|
3
|
-
"version": "2.13.
|
|
3
|
+
"version": "2.13.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "cli of varlet",
|
|
6
6
|
"bin": {
|
|
@@ -70,8 +70,8 @@
|
|
|
70
70
|
"vite": "4.3.5",
|
|
71
71
|
"vue": "3.3.4",
|
|
72
72
|
"webfont": "^9.0.0",
|
|
73
|
-
"@varlet/shared": "2.13.
|
|
74
|
-
"@varlet/vite-plugins": "2.13.
|
|
73
|
+
"@varlet/shared": "2.13.3",
|
|
74
|
+
"@varlet/vite-plugins": "2.13.3"
|
|
75
75
|
},
|
|
76
76
|
"devDependencies": {
|
|
77
77
|
"@types/babel__core": "^7.20.1",
|
|
@@ -86,8 +86,8 @@
|
|
|
86
86
|
"@types/semver": "^7.3.9",
|
|
87
87
|
"@types/sharp": "0.31.1",
|
|
88
88
|
"rimraf": "^5.0.1",
|
|
89
|
-
"@varlet/
|
|
90
|
-
"@varlet/
|
|
89
|
+
"@varlet/touch-emulator": "2.13.3",
|
|
90
|
+
"@varlet/icons": "2.13.3"
|
|
91
91
|
},
|
|
92
92
|
"peerDependencies": {
|
|
93
93
|
"@vue/runtime-core": "3.3.4",
|
|
@@ -97,8 +97,8 @@
|
|
|
97
97
|
"lodash-es": "^4.17.21",
|
|
98
98
|
"vue": "3.3.4",
|
|
99
99
|
"vue-router": "4.2.0",
|
|
100
|
-
"@varlet/
|
|
101
|
-
"@varlet/
|
|
100
|
+
"@varlet/touch-emulator": "2.13.3",
|
|
101
|
+
"@varlet/icons": "2.13.3"
|
|
102
102
|
},
|
|
103
103
|
"scripts": {
|
|
104
104
|
"dev": "tsc --watch",
|
package/site/pc/main.ts
CHANGED
|
@@ -10,13 +10,11 @@ import Button from '../components/button'
|
|
|
10
10
|
import Popup from '../components/popup'
|
|
11
11
|
import CodeExample from '../components/code-example'
|
|
12
12
|
import Snackbar from '../components/snackbar'
|
|
13
|
-
import LoadingBar from '../components/loading-bar'
|
|
14
13
|
|
|
15
14
|
import '../components/styles/common.less'
|
|
16
15
|
import '../components/styles/elevation.less'
|
|
17
16
|
|
|
18
17
|
import { createApp } from 'vue'
|
|
19
|
-
import { getBrowserTheme, Theme, watchTheme } from '@varlet/cli/client'
|
|
20
18
|
import { createRouter, createWebHashHistory } from 'vue-router'
|
|
21
19
|
import { get } from 'lodash-es'
|
|
22
20
|
|
|
@@ -26,8 +24,6 @@ const mobileRedirect = get(config, 'mobile.redirect')
|
|
|
26
24
|
|
|
27
25
|
Snackbar.allowMultiple(true)
|
|
28
26
|
|
|
29
|
-
setLoadingBar()
|
|
30
|
-
|
|
31
27
|
redirect &&
|
|
32
28
|
routes.push({
|
|
33
29
|
path: '/:pathMatch(.*)*',
|
|
@@ -50,16 +46,11 @@ const router = createRouter({
|
|
|
50
46
|
},
|
|
51
47
|
})
|
|
52
48
|
|
|
53
|
-
let isEnd = true
|
|
54
|
-
|
|
55
49
|
router.beforeEach((to: any, from: any) => {
|
|
56
50
|
if (to.fullPath === from.fullPath) {
|
|
57
51
|
return false
|
|
58
52
|
}
|
|
59
53
|
|
|
60
|
-
isEnd = false
|
|
61
|
-
setTimeout(() => !isEnd && LoadingBar.start(), 200)
|
|
62
|
-
|
|
63
54
|
// @ts-ignore
|
|
64
55
|
if (window._hmt) {
|
|
65
56
|
if (to.path) {
|
|
@@ -69,10 +60,6 @@ router.beforeEach((to: any, from: any) => {
|
|
|
69
60
|
}
|
|
70
61
|
})
|
|
71
62
|
|
|
72
|
-
router.afterEach(() => {
|
|
73
|
-
isEnd = true
|
|
74
|
-
LoadingBar.finish()
|
|
75
|
-
})
|
|
76
63
|
|
|
77
64
|
Object.defineProperty(window, 'onMobileRouteChange', {
|
|
78
65
|
value: (path: string, language: string, replace: string, hash: string) => {
|
|
@@ -95,14 +82,6 @@ Object.defineProperty(window, 'scrollToMenu', {
|
|
|
95
82
|
}
|
|
96
83
|
})
|
|
97
84
|
|
|
98
|
-
function setLoadingBar() {
|
|
99
|
-
const getColor = (theme?: Theme) => get(config, `${theme ?? getBrowserTheme()}.color-loading-bar`)
|
|
100
|
-
|
|
101
|
-
watchTheme((theme) => {
|
|
102
|
-
LoadingBar({ color: getColor(theme) })
|
|
103
|
-
}, false)
|
|
104
|
-
}
|
|
105
|
-
|
|
106
85
|
createApp(App)
|
|
107
86
|
.use(router)
|
|
108
87
|
// @ts-ignore
|
|
@@ -158,6 +158,34 @@
|
|
|
158
158
|
width: 100%;
|
|
159
159
|
}
|
|
160
160
|
|
|
161
|
+
&__sponsors {
|
|
162
|
+
display: flex;
|
|
163
|
+
flex-direction: column;
|
|
164
|
+
align-items: center;
|
|
165
|
+
margin-top: 80px;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
&__sponsors-title {
|
|
169
|
+
padding-top: 30px;
|
|
170
|
+
line-height: 32px;
|
|
171
|
+
font-size: 22px;
|
|
172
|
+
border-top: thin solid var(--site-config-color-index-page-divider-color);
|
|
173
|
+
color: var(--site-config-color-index-page-second-text-color);
|
|
174
|
+
letter-spacing: 1px;
|
|
175
|
+
transition: all .2s;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
&__sponsors-link {
|
|
179
|
+
display: block;
|
|
180
|
+
margin-top: 50px;
|
|
181
|
+
width: 1100px;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
&__sponsors-image {
|
|
185
|
+
display: block;
|
|
186
|
+
width: 100%;
|
|
187
|
+
}
|
|
188
|
+
|
|
161
189
|
&__footer {
|
|
162
190
|
position: absolute;
|
|
163
191
|
bottom: 0;
|
|
@@ -115,11 +115,11 @@ watch(() => route.path, setLocale, { immediate: true })
|
|
|
115
115
|
</a>
|
|
116
116
|
</div>
|
|
117
117
|
|
|
118
|
-
<div class="varlet-doc-
|
|
119
|
-
<div class="varlet-doc-
|
|
118
|
+
<div class="varlet-doc-index__sponsors" v-if="indexPage.sponsors">
|
|
119
|
+
<div class="varlet-doc-index__sponsors-title">{{ indexPage.sponsors.label[language] }}</div>
|
|
120
120
|
|
|
121
|
-
<a class="varlet-doc-
|
|
122
|
-
<img class="varlet-doc-
|
|
121
|
+
<a class="varlet-doc-index__sponsors-link" :href="indexPage.sponsors.link">
|
|
122
|
+
<img class="varlet-doc-index__sponsors-image" :src="indexPage.sponsors.image">
|
|
123
123
|
</a>
|
|
124
124
|
</div>
|
|
125
125
|
|
package/site/utils.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { get } from 'lodash-es'
|
|
2
|
-
import { StyleProvider, type Theme, withSiteConfigNamespace } from '@varlet/cli/client'
|
|
2
|
+
import { StyleProvider, type Theme, withSiteConfigNamespace, setColorScheme } from '@varlet/cli/client'
|
|
3
3
|
|
|
4
4
|
export interface Menu {
|
|
5
5
|
doc: string
|
|
@@ -30,10 +30,11 @@ export function inIframe() {
|
|
|
30
30
|
return window.self !== window.top
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
export function setTheme(config: Record<string, any>,
|
|
34
|
-
const styleVars = withSiteConfigNamespace(get(config,
|
|
33
|
+
export function setTheme(config: Record<string, any>, theme: Theme) {
|
|
34
|
+
const styleVars = withSiteConfigNamespace(get(config, theme, {}))
|
|
35
35
|
|
|
36
36
|
StyleProvider(styleVars)
|
|
37
|
+
setColorScheme(theme)
|
|
37
38
|
}
|
|
38
39
|
|
|
39
40
|
export function utoa(data: string): string {
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { defineComponent } from 'vue'
|
|
2
|
-
import context from '../context'
|
|
3
|
-
import { createNamespace } from '../utils/components'
|
|
4
|
-
import { toSizeUnit } from '../utils/elements'
|
|
5
|
-
import { props } from './props'
|
|
6
|
-
import '../styles/common.less'
|
|
7
|
-
import './loadingBar.less'
|
|
8
|
-
|
|
9
|
-
const { classes, n } = createNamespace('loading-bar')
|
|
10
|
-
|
|
11
|
-
export default defineComponent({
|
|
12
|
-
name: 'VarLoadingBar',
|
|
13
|
-
props,
|
|
14
|
-
setup(props) {
|
|
15
|
-
return () => {
|
|
16
|
-
return (
|
|
17
|
-
<div
|
|
18
|
-
class={classes(n(), [props.error, n('--error')])}
|
|
19
|
-
style={{
|
|
20
|
-
zIndex: context.zIndex + 10,
|
|
21
|
-
width: `${props.value}%`,
|
|
22
|
-
opacity: props.opacity,
|
|
23
|
-
height: toSizeUnit(props.height),
|
|
24
|
-
backgroundColor: props.error ? props.errorColor : props.color,
|
|
25
|
-
}}
|
|
26
|
-
></div>
|
|
27
|
-
)
|
|
28
|
-
}
|
|
29
|
-
},
|
|
30
|
-
})
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
import LoadingBarComponent from './LoadingBar'
|
|
2
|
-
import { reactive } from 'vue'
|
|
3
|
-
import { mountInstance } from '../utils/components'
|
|
4
|
-
|
|
5
|
-
interface LoadingBarOptions {
|
|
6
|
-
color?: string
|
|
7
|
-
errorColor?: string
|
|
8
|
-
height?: string | number
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
interface InternalProps {
|
|
12
|
-
value: number
|
|
13
|
-
opacity: number
|
|
14
|
-
error: boolean
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
interface LoadingBar {
|
|
18
|
-
(options: LoadingBarOptions): void
|
|
19
|
-
|
|
20
|
-
start(): void
|
|
21
|
-
|
|
22
|
-
finish(): void
|
|
23
|
-
|
|
24
|
-
error(): void
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
let timer: number
|
|
28
|
-
let isMount: boolean
|
|
29
|
-
const props: LoadingBarOptions & InternalProps = reactive({
|
|
30
|
-
value: 0,
|
|
31
|
-
opacity: 0,
|
|
32
|
-
error: false,
|
|
33
|
-
})
|
|
34
|
-
|
|
35
|
-
const LoadingBar: LoadingBar = (options: LoadingBarOptions) => {
|
|
36
|
-
Object.assign(props, options)
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
const changeValue = () => {
|
|
40
|
-
timer = window.setTimeout(() => {
|
|
41
|
-
if (props.value >= 95) return
|
|
42
|
-
let num = Math.random()
|
|
43
|
-
|
|
44
|
-
if (props.value < 70) num = Math.round(5 * Math.random())
|
|
45
|
-
|
|
46
|
-
props.value += num
|
|
47
|
-
changeValue()
|
|
48
|
-
}, 200)
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
LoadingBar.start = () => {
|
|
52
|
-
if (!isMount) {
|
|
53
|
-
isMount = true
|
|
54
|
-
mountInstance(LoadingBarComponent, props)
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
if (!props.error || props.value === 100) {
|
|
58
|
-
props.value = 0
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
setTimeout(() => {
|
|
62
|
-
props.opacity = 1
|
|
63
|
-
}, 200)
|
|
64
|
-
changeValue()
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
LoadingBar.finish = () => {
|
|
68
|
-
props.value = 100
|
|
69
|
-
|
|
70
|
-
setTimeout(() => {
|
|
71
|
-
props.opacity = 0
|
|
72
|
-
|
|
73
|
-
setTimeout(() => {
|
|
74
|
-
props.error = false
|
|
75
|
-
}, 250)
|
|
76
|
-
}, 300)
|
|
77
|
-
|
|
78
|
-
window.clearTimeout(timer)
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
LoadingBar.error = () => {
|
|
82
|
-
props.error = true
|
|
83
|
-
|
|
84
|
-
LoadingBar.start()
|
|
85
|
-
|
|
86
|
-
setTimeout(LoadingBar.finish, 300)
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
export const _LoadingBarComponent = LoadingBarComponent
|
|
90
|
-
|
|
91
|
-
export default LoadingBar
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
:root {
|
|
2
|
-
--loading-bar-color: var(--color-primary);
|
|
3
|
-
--loading-bar-error-color: var(--color-danger);
|
|
4
|
-
--loading-bar-height: 3px;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
.var-site-loading-bar {
|
|
8
|
-
position: fixed;
|
|
9
|
-
left: 0;
|
|
10
|
-
top: 0;
|
|
11
|
-
transition: all 0.25s;
|
|
12
|
-
height: var(--loading-bar-height);
|
|
13
|
-
background-color: var(--loading-bar-color);
|
|
14
|
-
|
|
15
|
-
&--error {
|
|
16
|
-
background-color: var(--loading-bar-error-color);
|
|
17
|
-
}
|
|
18
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
export const props = {
|
|
2
|
-
value: {
|
|
3
|
-
type: Number,
|
|
4
|
-
default: 0,
|
|
5
|
-
},
|
|
6
|
-
opacity: {
|
|
7
|
-
type: Number,
|
|
8
|
-
default: 0,
|
|
9
|
-
},
|
|
10
|
-
error: {
|
|
11
|
-
type: Boolean,
|
|
12
|
-
default: false,
|
|
13
|
-
},
|
|
14
|
-
color: {
|
|
15
|
-
type: String,
|
|
16
|
-
},
|
|
17
|
-
errorColor: {
|
|
18
|
-
type: String,
|
|
19
|
-
},
|
|
20
|
-
height: {
|
|
21
|
-
type: [Number, String],
|
|
22
|
-
},
|
|
23
|
-
}
|