@varlet/cli 2.4.0-alpha.1670569085974 → 2.4.0-alpha.1670766368590
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/node/config/varlet.default.config.js +2 -4
- package/package.json +9 -9
- package/site/components/loading-bar/LoadingBar.tsx +30 -0
- package/site/components/loading-bar/index.ts +92 -0
- package/site/components/loading-bar/loadingBar.less +18 -0
- package/site/components/loading-bar/props.ts +23 -0
- package/site/components/utils/elements.ts +8 -6
- package/site/pc/main.ts +14 -4
- package/site/components/progress/Progress.vue +0 -111
- package/site/components/progress/index.ts +0 -10
- package/site/components/progress/progress.less +0 -101
- package/site/components/progress/props.ts +0 -52
- package/site/useProgress.ts +0 -73
|
@@ -194,8 +194,7 @@ export default defineConfig({
|
|
|
194
194
|
'color-primary': '#2196f3',
|
|
195
195
|
'color-link': '#00c48f',
|
|
196
196
|
'color-type': '#00c48f',
|
|
197
|
-
'color-
|
|
198
|
-
'color-progress-track': 'transparent',
|
|
197
|
+
'color-loading-bar': '#1d92e9',
|
|
199
198
|
'color-side-bar': '#3a7afe',
|
|
200
199
|
'color-side-bar-active-background': '#3a7afe1a',
|
|
201
200
|
'color-app-bar': '#3a7afe',
|
|
@@ -236,8 +235,7 @@ export default defineConfig({
|
|
|
236
235
|
'color-primary': '#96cbfe',
|
|
237
236
|
'color-link': '#A8FFC4',
|
|
238
237
|
'color-type': '#A8FFC4',
|
|
239
|
-
'color-
|
|
240
|
-
'color-progress-track': 'transparent',
|
|
238
|
+
'color-loading-bar': '#5580f8',
|
|
241
239
|
'color-side-bar': '#4a7afe',
|
|
242
240
|
'color-side-bar-active-background': '#4a7afe1a',
|
|
243
241
|
'color-app-bar': '#272727',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@varlet/cli",
|
|
3
|
-
"version": "2.4.0-alpha.
|
|
3
|
+
"version": "2.4.0-alpha.1670766368590",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "cli of varlet",
|
|
6
6
|
"bin": {
|
|
@@ -40,8 +40,6 @@
|
|
|
40
40
|
"@babel/preset-env": "^7.14.8",
|
|
41
41
|
"@babel/preset-typescript": "^7.14.5",
|
|
42
42
|
"@types/inquirer": "^9.0.2",
|
|
43
|
-
"@varlet/markdown-vite-plugin": "2.4.0-alpha.1670569085974",
|
|
44
|
-
"@varlet/shared": "2.4.0-alpha.1670569085974",
|
|
45
43
|
"@vitejs/plugin-vue": "3.0.1",
|
|
46
44
|
"@vitejs/plugin-vue-jsx": "2.0.0",
|
|
47
45
|
"@vue/babel-plugin-jsx": "1.1.1",
|
|
@@ -69,7 +67,9 @@
|
|
|
69
67
|
"vite": "3.0.4",
|
|
70
68
|
"vite-plugin-html": "^2.1.0",
|
|
71
69
|
"vue": "3.2.25",
|
|
72
|
-
"vue-jest": "^5.0.0-alpha.8"
|
|
70
|
+
"vue-jest": "^5.0.0-alpha.8",
|
|
71
|
+
"@varlet/markdown-vite-plugin": "2.4.0-alpha.1670766368590",
|
|
72
|
+
"@varlet/shared": "2.4.0-alpha.1670766368590"
|
|
73
73
|
},
|
|
74
74
|
"devDependencies": {
|
|
75
75
|
"@types/babel__core": "^7.1.12",
|
|
@@ -80,19 +80,19 @@
|
|
|
80
80
|
"@types/lodash-es": "^4.17.5",
|
|
81
81
|
"@types/node": "^18.7.20",
|
|
82
82
|
"@types/semver": "^7.3.9",
|
|
83
|
-
"@varlet/icons": "2.4.0-alpha.
|
|
84
|
-
"@varlet/touch-emulator": "2.4.0-alpha.
|
|
83
|
+
"@varlet/icons": "2.4.0-alpha.1670766368590",
|
|
84
|
+
"@varlet/touch-emulator": "2.4.0-alpha.1670766368590"
|
|
85
85
|
},
|
|
86
86
|
"peerDependencies": {
|
|
87
|
-
"@varlet/icons": "2.4.0-alpha.1670569085974",
|
|
88
|
-
"@varlet/touch-emulator": "2.4.0-alpha.1670569085974",
|
|
89
87
|
"@vue/runtime-core": "3.2.16",
|
|
90
88
|
"@vue/test-utils": "^2.0.2",
|
|
91
89
|
"clipboard": "^2.0.6",
|
|
92
90
|
"live-server": "^1.2.1",
|
|
93
91
|
"lodash-es": "^4.17.21",
|
|
94
92
|
"vue": "3.2.25",
|
|
95
|
-
"vue-router": "4.0.12"
|
|
93
|
+
"vue-router": "4.0.12",
|
|
94
|
+
"@varlet/icons": "2.4.0-alpha.1670766368590",
|
|
95
|
+
"@varlet/touch-emulator": "2.4.0-alpha.1670766368590"
|
|
96
96
|
},
|
|
97
97
|
"scripts": {
|
|
98
98
|
"dev": "tsc --watch",
|
|
@@ -0,0 +1,30 @@
|
|
|
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
|
+
})
|
|
@@ -0,0 +1,92 @@
|
|
|
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
|
+
console.log(isMount)
|
|
53
|
+
if (!isMount) {
|
|
54
|
+
isMount = true
|
|
55
|
+
mountInstance(LoadingBarComponent, props)
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if (!props.error || props.value === 100) {
|
|
59
|
+
props.value = 0
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
setTimeout(() => {
|
|
63
|
+
props.opacity = 1
|
|
64
|
+
}, 200)
|
|
65
|
+
changeValue()
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
LoadingBar.finish = () => {
|
|
69
|
+
props.value = 100
|
|
70
|
+
|
|
71
|
+
setTimeout(() => {
|
|
72
|
+
props.opacity = 0
|
|
73
|
+
|
|
74
|
+
setTimeout(() => {
|
|
75
|
+
props.error = false
|
|
76
|
+
}, 250)
|
|
77
|
+
}, 300)
|
|
78
|
+
|
|
79
|
+
window.clearTimeout(timer)
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
LoadingBar.error = () => {
|
|
83
|
+
props.error = true
|
|
84
|
+
|
|
85
|
+
LoadingBar.start()
|
|
86
|
+
|
|
87
|
+
setTimeout(LoadingBar.finish, 300)
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export const _LoadingBarComponent = LoadingBarComponent
|
|
91
|
+
|
|
92
|
+
export default LoadingBar
|
|
@@ -0,0 +1,18 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
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
|
+
}
|
|
@@ -7,19 +7,21 @@ export function getLeft(element: HTMLElement): number {
|
|
|
7
7
|
return left + (document.body.scrollLeft || document.documentElement.scrollLeft)
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
// example 1rem
|
|
11
|
+
export const isRem = (value: unknown): value is string => isString(value) && value.endsWith('rem')
|
|
11
12
|
|
|
12
13
|
// example 1 || 1px
|
|
13
|
-
export const isPx = (value: unknown)
|
|
14
|
+
export const isPx = (value: unknown): value is string | number =>
|
|
15
|
+
(isString(value) && value.endsWith('px')) || isNumber(value)
|
|
14
16
|
|
|
15
17
|
// example 1%
|
|
16
|
-
export const isPercent = (value: unknown) => isString(value) && value.endsWith('%')
|
|
18
|
+
export const isPercent = (value: unknown): value is string => isString(value) && value.endsWith('%')
|
|
17
19
|
|
|
18
20
|
// example 1vw
|
|
19
|
-
export const isVw = (value: unknown) => isString(value) && value.endsWith('vw')
|
|
21
|
+
export const isVw = (value: unknown): value is string => isString(value) && value.endsWith('vw')
|
|
20
22
|
|
|
21
23
|
// example 1vh
|
|
22
|
-
export const isVh = (value: unknown) => isString(value) && value.endsWith('vh')
|
|
24
|
+
export const isVh = (value: unknown): value is string => isString(value) && value.endsWith('vh')
|
|
23
25
|
|
|
24
26
|
// example return 1
|
|
25
27
|
export const toPxNum = (value: unknown): number => {
|
|
@@ -57,7 +59,7 @@ export const toPxNum = (value: unknown): number => {
|
|
|
57
59
|
// example return 1px 1% 1vw 1vh 1rem null
|
|
58
60
|
export const toSizeUnit = (value: unknown) => {
|
|
59
61
|
if (value == null) {
|
|
60
|
-
return
|
|
62
|
+
return undefined
|
|
61
63
|
}
|
|
62
64
|
|
|
63
65
|
if (isPercent(value) || isVw(value) || isVh(value) || isRem(value)) {
|
package/site/pc/main.ts
CHANGED
|
@@ -10,14 +10,15 @@ 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'
|
|
13
14
|
|
|
14
15
|
import '../components/styles/common.less'
|
|
15
16
|
import '../components/styles/elevation.less'
|
|
16
17
|
|
|
17
18
|
import { createApp } from 'vue'
|
|
19
|
+
import { getBrowserTheme, Theme, watchTheme } from '@varlet/cli/client'
|
|
18
20
|
import { createRouter, createWebHashHistory } from 'vue-router'
|
|
19
21
|
import { get } from 'lodash-es'
|
|
20
|
-
import { useProgress } from '../useProgress'
|
|
21
22
|
|
|
22
23
|
const defaultLanguage = get(config, 'defaultLanguage')
|
|
23
24
|
const redirect = get(config, 'pc.redirect')
|
|
@@ -25,6 +26,8 @@ const mobileRedirect = get(config, 'mobile.redirect')
|
|
|
25
26
|
|
|
26
27
|
Snackbar.allowMultiple(true)
|
|
27
28
|
|
|
29
|
+
setLoadingBar()
|
|
30
|
+
|
|
28
31
|
redirect &&
|
|
29
32
|
routes.push({
|
|
30
33
|
path: '/:pathMatch(.*)*',
|
|
@@ -38,7 +41,6 @@ const router = createRouter({
|
|
|
38
41
|
})
|
|
39
42
|
|
|
40
43
|
let isEnd = true
|
|
41
|
-
const { start, end } = useProgress()
|
|
42
44
|
|
|
43
45
|
router.beforeEach((to: any, from: any) => {
|
|
44
46
|
if (to.path === from.path) {
|
|
@@ -46,7 +48,7 @@ router.beforeEach((to: any, from: any) => {
|
|
|
46
48
|
}
|
|
47
49
|
|
|
48
50
|
isEnd = false
|
|
49
|
-
setTimeout(() => !isEnd && start(), 200)
|
|
51
|
+
setTimeout(() => !isEnd && LoadingBar.start(), 200)
|
|
50
52
|
|
|
51
53
|
// @ts-ignore
|
|
52
54
|
if (window._hmt) {
|
|
@@ -59,7 +61,7 @@ router.beforeEach((to: any, from: any) => {
|
|
|
59
61
|
|
|
60
62
|
router.afterEach(() => {
|
|
61
63
|
isEnd = true
|
|
62
|
-
|
|
64
|
+
LoadingBar.finish()
|
|
63
65
|
})
|
|
64
66
|
|
|
65
67
|
Object.defineProperty(window, 'onMobileRouteChange', {
|
|
@@ -83,6 +85,14 @@ Object.defineProperty(window, 'scrollToMenu', {
|
|
|
83
85
|
}
|
|
84
86
|
})
|
|
85
87
|
|
|
88
|
+
function setLoadingBar() {
|
|
89
|
+
const getColor = (theme?: Theme) => get(config, `${theme ?? getBrowserTheme()}.color-loading-bar`)
|
|
90
|
+
|
|
91
|
+
watchTheme((theme) => {
|
|
92
|
+
LoadingBar({ color: getColor(theme) })
|
|
93
|
+
}, false)
|
|
94
|
+
}
|
|
95
|
+
|
|
86
96
|
createApp(App)
|
|
87
97
|
.use(router)
|
|
88
98
|
// @ts-ignore
|
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div :class="n()">
|
|
3
|
-
<div :class="n('linear')" v-if="mode === 'linear'">
|
|
4
|
-
<div :class="n('linear-block')" :style="{ height: toSizeUnit(lineWidth) }">
|
|
5
|
-
<div :class="n('linear-background')" v-if="track" :style="{ background: trackColor }"></div>
|
|
6
|
-
<div
|
|
7
|
-
:class="classes(n('linear-certain'), [ripple, n('linear-ripple')])"
|
|
8
|
-
:style="{ background: color, width: linearProps.width }"
|
|
9
|
-
></div>
|
|
10
|
-
</div>
|
|
11
|
-
<div :class="classes(n('linear-label'), [labelClass, labelClass])" v-if="label">
|
|
12
|
-
<slot>
|
|
13
|
-
{{ linearProps.roundValue }}
|
|
14
|
-
</slot>
|
|
15
|
-
</div>
|
|
16
|
-
</div>
|
|
17
|
-
|
|
18
|
-
<div :class="n('circle')" v-if="mode === 'circle'" :style="{ width: toSizeUnit(size), height: toSizeUnit(size) }">
|
|
19
|
-
<svg :class="n('circle-svg')" :style="{ transform: `rotate(${rotate - 90}deg)` }" :viewBox="circleProps.viewBox">
|
|
20
|
-
<circle
|
|
21
|
-
v-if="track"
|
|
22
|
-
:class="n('circle-background')"
|
|
23
|
-
:cx="multiplySizeUnit(size, 0.5)"
|
|
24
|
-
:cy="multiplySizeUnit(size, 0.5)"
|
|
25
|
-
:r="circleProps.radius"
|
|
26
|
-
fill="transparent"
|
|
27
|
-
:stroke-width="toSizeUnit(lineWidth)"
|
|
28
|
-
:style="{
|
|
29
|
-
strokeDasharray: circleProps.perimeter,
|
|
30
|
-
stroke: trackColor,
|
|
31
|
-
}"
|
|
32
|
-
></circle>
|
|
33
|
-
<circle
|
|
34
|
-
:class="n('circle-certain')"
|
|
35
|
-
:cx="multiplySizeUnit(size, 0.5)"
|
|
36
|
-
:cy="multiplySizeUnit(size, 0.5)"
|
|
37
|
-
:r="circleProps.radius"
|
|
38
|
-
fill="transparent"
|
|
39
|
-
:stroke-width="toSizeUnit(lineWidth)"
|
|
40
|
-
:style="{
|
|
41
|
-
strokeDasharray: circleProps.strokeDasharray,
|
|
42
|
-
stroke: color,
|
|
43
|
-
}"
|
|
44
|
-
></circle>
|
|
45
|
-
</svg>
|
|
46
|
-
|
|
47
|
-
<div :class="classes(n('circle-label'), [labelClass, labelClass])" v-if="label">
|
|
48
|
-
<slot>
|
|
49
|
-
{{ circleProps.roundValue }}
|
|
50
|
-
</slot>
|
|
51
|
-
</div>
|
|
52
|
-
</div>
|
|
53
|
-
</div>
|
|
54
|
-
</template>
|
|
55
|
-
|
|
56
|
-
<script lang="ts">
|
|
57
|
-
import { defineComponent, computed } from 'vue'
|
|
58
|
-
import { props } from './props'
|
|
59
|
-
import { toNumber } from '@varlet/shared'
|
|
60
|
-
import { toSizeUnit, multiplySizeUnit, toPxNum } from '../utils/elements'
|
|
61
|
-
import { createNamespace } from '../utils/components'
|
|
62
|
-
|
|
63
|
-
const { n, classes } = createNamespace('progress')
|
|
64
|
-
|
|
65
|
-
export default defineComponent({
|
|
66
|
-
name: 'VarProgress',
|
|
67
|
-
props,
|
|
68
|
-
setup(props) {
|
|
69
|
-
const linearProps = computed(() => {
|
|
70
|
-
const value = toNumber(props.value)
|
|
71
|
-
const width = value > 100 ? 100 : value
|
|
72
|
-
const roundValue = value > 100 ? 100 : Math.round(value)
|
|
73
|
-
|
|
74
|
-
return {
|
|
75
|
-
width: `${width}%`,
|
|
76
|
-
roundValue: `${roundValue}%`,
|
|
77
|
-
}
|
|
78
|
-
})
|
|
79
|
-
|
|
80
|
-
const circleProps = computed(() => {
|
|
81
|
-
const { size, lineWidth, value } = props
|
|
82
|
-
const viewBox = `0 0 ${toPxNum(size)} ${toPxNum(size)}`
|
|
83
|
-
const roundValue = toNumber(value) > 100 ? 100 : Math.round(toNumber(value))
|
|
84
|
-
const radius = (toPxNum(size) - toPxNum(lineWidth)) / 2
|
|
85
|
-
const perimeter = 2 * Math.PI * radius
|
|
86
|
-
const strokeDasharray = `${(roundValue / 100) * perimeter}, ${perimeter}`
|
|
87
|
-
|
|
88
|
-
return {
|
|
89
|
-
viewBox,
|
|
90
|
-
radius,
|
|
91
|
-
strokeDasharray,
|
|
92
|
-
perimeter,
|
|
93
|
-
roundValue: `${roundValue}%`,
|
|
94
|
-
}
|
|
95
|
-
})
|
|
96
|
-
return {
|
|
97
|
-
n,
|
|
98
|
-
classes,
|
|
99
|
-
toSizeUnit,
|
|
100
|
-
multiplySizeUnit,
|
|
101
|
-
linearProps,
|
|
102
|
-
circleProps,
|
|
103
|
-
}
|
|
104
|
-
},
|
|
105
|
-
})
|
|
106
|
-
</script>
|
|
107
|
-
|
|
108
|
-
<style lang="less">
|
|
109
|
-
@import '../styles/common';
|
|
110
|
-
@import './progress';
|
|
111
|
-
</style>
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
@site-progress-font-size: var(--site-font-size-sm);
|
|
2
|
-
@site-progress-ripple-color: #fff;
|
|
3
|
-
@site-progress-track-color: #d8d8d8;
|
|
4
|
-
@site-progress-background: var(--color-primary);
|
|
5
|
-
|
|
6
|
-
:root {
|
|
7
|
-
--site-progress-font-size: @site-progress-font-size;
|
|
8
|
-
--site-progress-ripple-color: @site-progress-ripple-color;
|
|
9
|
-
--site-progress-track-color: @site-progress-track-color;
|
|
10
|
-
--site-progress-background: @site-progress-background;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
.var-site-progress {
|
|
14
|
-
position: relative;
|
|
15
|
-
font-size: var(--site-progress-font-size);
|
|
16
|
-
|
|
17
|
-
&__linear {
|
|
18
|
-
display: flex;
|
|
19
|
-
align-items: center;
|
|
20
|
-
|
|
21
|
-
&-block {
|
|
22
|
-
flex: 1;
|
|
23
|
-
position: relative;
|
|
24
|
-
overflow: hidden;
|
|
25
|
-
height: 4px;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
&-background,
|
|
29
|
-
&-certain {
|
|
30
|
-
width: 100%;
|
|
31
|
-
height: 100%;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
&-ripple {
|
|
35
|
-
&::after {
|
|
36
|
-
position: absolute;
|
|
37
|
-
width: 0;
|
|
38
|
-
background-color: var(--site-progress-ripple-color);
|
|
39
|
-
height: 100%;
|
|
40
|
-
opacity: 0;
|
|
41
|
-
animation: ripple 1.8s cubic-bezier(0.4, 0, 0.2, 1) infinite;
|
|
42
|
-
content: '';
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
&-background {
|
|
47
|
-
background-color: var(--site-progress-track-color);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
&-certain {
|
|
51
|
-
position: absolute;
|
|
52
|
-
background-color: var(--site-progress-background);
|
|
53
|
-
top: 0;
|
|
54
|
-
left: 0;
|
|
55
|
-
transition: all 0.2s, background-color 0.8s;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
&-label {
|
|
59
|
-
margin-left: 8px;
|
|
60
|
-
flex: 0;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
@keyframes ripple {
|
|
64
|
-
0% {
|
|
65
|
-
width: 0;
|
|
66
|
-
opacity: 0.1;
|
|
67
|
-
}
|
|
68
|
-
20% {
|
|
69
|
-
width: 0;
|
|
70
|
-
opacity: 0.5;
|
|
71
|
-
}
|
|
72
|
-
80% {
|
|
73
|
-
width: 100%;
|
|
74
|
-
opacity: 0;
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
&__circle {
|
|
80
|
-
position: relative;
|
|
81
|
-
width: 40px;
|
|
82
|
-
height: 40px;
|
|
83
|
-
|
|
84
|
-
&-background {
|
|
85
|
-
stroke: var(--site-progress-track-color);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
&-certain {
|
|
89
|
-
transition: all 0.2s;
|
|
90
|
-
stroke: var(--site-progress-background);
|
|
91
|
-
position: absolute;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
&-label {
|
|
95
|
-
position: absolute;
|
|
96
|
-
left: 50%;
|
|
97
|
-
top: 50%;
|
|
98
|
-
transform: translate(-50%, -50%);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { type PropType } from 'vue'
|
|
2
|
-
|
|
3
|
-
function modeValidator(mode: string): boolean {
|
|
4
|
-
return ['linear', 'circle'].includes(mode)
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
type ProgressMode = 'linear' | 'circle'
|
|
8
|
-
|
|
9
|
-
export const props = {
|
|
10
|
-
mode: {
|
|
11
|
-
type: String as PropType<ProgressMode>,
|
|
12
|
-
default: 'linear',
|
|
13
|
-
validator: modeValidator,
|
|
14
|
-
},
|
|
15
|
-
lineWidth: {
|
|
16
|
-
type: [Number, String],
|
|
17
|
-
default: 4,
|
|
18
|
-
},
|
|
19
|
-
color: {
|
|
20
|
-
type: String,
|
|
21
|
-
},
|
|
22
|
-
trackColor: {
|
|
23
|
-
type: String,
|
|
24
|
-
},
|
|
25
|
-
ripple: {
|
|
26
|
-
type: Boolean,
|
|
27
|
-
default: false,
|
|
28
|
-
},
|
|
29
|
-
value: {
|
|
30
|
-
type: [Number, String],
|
|
31
|
-
default: 0,
|
|
32
|
-
},
|
|
33
|
-
label: {
|
|
34
|
-
type: Boolean,
|
|
35
|
-
default: false,
|
|
36
|
-
},
|
|
37
|
-
labelClass: {
|
|
38
|
-
type: String,
|
|
39
|
-
},
|
|
40
|
-
size: {
|
|
41
|
-
type: [Number, String],
|
|
42
|
-
default: 40,
|
|
43
|
-
},
|
|
44
|
-
rotate: {
|
|
45
|
-
type: Number,
|
|
46
|
-
default: 0,
|
|
47
|
-
},
|
|
48
|
-
track: {
|
|
49
|
-
type: Boolean,
|
|
50
|
-
default: true,
|
|
51
|
-
}
|
|
52
|
-
}
|
package/site/useProgress.ts
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import Progress from './components/progress'
|
|
2
|
-
import config from '@config'
|
|
3
|
-
import { reactive } from 'vue'
|
|
4
|
-
import { getBrowserTheme, Theme, watchTheme } from '@varlet/cli/client'
|
|
5
|
-
import { mountInstance } from './components/utils/components'
|
|
6
|
-
import { get } from 'lodash-es'
|
|
7
|
-
|
|
8
|
-
function getColor(theme?: Theme) {
|
|
9
|
-
return get(config, `${theme ?? getBrowserTheme()}.color-progress`)
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
function getTrackColor(theme?: Theme) {
|
|
13
|
-
return get(config, `${theme ?? getBrowserTheme()}.color-progress-track`)
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export function useProgress() {
|
|
17
|
-
let timer: number
|
|
18
|
-
let currentTheme: Theme
|
|
19
|
-
|
|
20
|
-
const trackColor = getTrackColor()
|
|
21
|
-
const color = getColor()
|
|
22
|
-
|
|
23
|
-
const props = reactive({
|
|
24
|
-
style: {
|
|
25
|
-
position: 'fixed',
|
|
26
|
-
width: '100%',
|
|
27
|
-
left: 0,
|
|
28
|
-
top: 0,
|
|
29
|
-
zIndex: 10086,
|
|
30
|
-
},
|
|
31
|
-
trackColor,
|
|
32
|
-
color,
|
|
33
|
-
lineWidth: 3,
|
|
34
|
-
value: 0,
|
|
35
|
-
})
|
|
36
|
-
|
|
37
|
-
watchTheme((theme) => {
|
|
38
|
-
currentTheme = theme
|
|
39
|
-
props.trackColor = getTrackColor(theme)
|
|
40
|
-
props.color = props.value === 100 ? getTrackColor(theme) : getColor(theme)
|
|
41
|
-
}, false)
|
|
42
|
-
|
|
43
|
-
const changeValue = () => {
|
|
44
|
-
timer = window.setTimeout(() => {
|
|
45
|
-
if (props.value >= 95) return
|
|
46
|
-
let num = Math.random()
|
|
47
|
-
|
|
48
|
-
if (props.value < 70) num = Math.round(5 * Math.random())
|
|
49
|
-
|
|
50
|
-
props.value += num
|
|
51
|
-
changeValue()
|
|
52
|
-
}, 200)
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
const start = () => {
|
|
56
|
-
props.value = 0
|
|
57
|
-
setTimeout(() => (props.color = getColor(currentTheme)), 200)
|
|
58
|
-
changeValue()
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
const end = () => {
|
|
62
|
-
props.value = 100
|
|
63
|
-
setTimeout(() => (props.color = getTrackColor(currentTheme)), 300)
|
|
64
|
-
window.clearTimeout(timer)
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
mountInstance(Progress, props)
|
|
68
|
-
|
|
69
|
-
return {
|
|
70
|
-
start,
|
|
71
|
-
end,
|
|
72
|
-
}
|
|
73
|
-
}
|