更新:登录功能

This commit is contained in:
2025-11-04 12:37:04 +08:00
commit a21fb92916
897 changed files with 51500 additions and 0 deletions

View File

@@ -0,0 +1,15 @@
@import '../common/abstracts/variable';
@import '../common/abstracts/mixin';
.wot-theme-dark {
@include b(count-down) {
color: $-dark-color;
}
}
@include b(count-down) {
color: $-count-down-text-color;
font-size: $-count-down-font-size;
line-height: $-count-down-line-height;
}

View File

@@ -0,0 +1,41 @@
import type { ComponentPublicInstance, ExtractPropTypes } from 'vue'
import { baseProps, makeBooleanProp, makeRequiredProp, makeStringProp } from '../common/props'
export const countDownProps = {
...baseProps,
/**
* 倒计时时长,单位毫秒
*/
time: makeRequiredProp(Number),
/**
* 是否开启毫秒
*/
millisecond: makeBooleanProp(false),
/**
* 格式化时间
*/
format: makeStringProp('HH:mm:ss'),
/**
* 是否自动开始
*/
autoStart: makeBooleanProp(true)
}
export type CountDownProps = ExtractPropTypes<typeof countDownProps>
export type CountDownExpose = {
/**
* 开始倒计时
*/
start: () => void
/**
* 暂停倒计时
*/
pause: () => void
/**
* 重设倒计时,若 auto-start 为 true重设后会自动开始倒计时
*/
reset: () => void
}
export type CountDownInstance = ComponentPublicInstance<CountDownProps, CountDownExpose>

View File

@@ -0,0 +1,52 @@
import { padZero } from '../common/util'
export type TimeData = {
days: number
hours: number
minutes: number
seconds: number
milliseconds: number
}
export function parseFormat(format: string, timeData: TimeData): string {
const { days } = timeData
let { hours, minutes, seconds, milliseconds } = timeData
if (format.includes('DD')) {
format = format.replace('DD', padZero(days))
} else {
hours += days * 24
}
if (format.includes('HH')) {
format = format.replace('HH', padZero(hours))
} else {
minutes += hours * 60
}
if (format.includes('mm')) {
format = format.replace('mm', padZero(minutes))
} else {
seconds += minutes * 60
}
if (format.includes('ss')) {
format = format.replace('ss', padZero(seconds))
} else {
milliseconds += seconds * 1000
}
if (format.includes('S')) {
const ms = padZero(milliseconds, 3)
if (format.includes('SSS')) {
format = format.replace('SSS', ms)
} else if (format.includes('SS')) {
format = format.replace('SS', ms.slice(0, 2))
} else {
format = format.replace('S', ms.charAt(0))
}
}
return format
}

View File

@@ -0,0 +1,60 @@
<template>
<view :class="`wd-count-down ${customClass}`" :style="customStyle">
<slot :current="current" v-if="$slots.default" />
<block v-else>{{ timeText }}</block>
</view>
</template>
<script lang="ts">
export default {
name: 'wd-count-down',
options: {
virtualHost: true,
addGlobalClass: true,
styleIsolation: 'shared'
}
}
</script>
<script setup lang="ts">
import { watch, computed, onMounted } from 'vue'
import { parseFormat } from './utils'
import { useCountDown } from '../composables/useCountDown'
import { countDownProps, type CountDownExpose } from './types'
const props = defineProps(countDownProps)
const emit = defineEmits(['change', 'finish'])
const { start, pause, reset, current } = useCountDown({
time: props.time,
millisecond: props.millisecond,
onChange: (current) => emit('change', current),
onFinish: () => emit('finish')
})
const timeText = computed(() => parseFormat(props.format, current.value))
const resetTime = () => {
reset(props.time)
if (props.autoStart) {
start()
}
}
watch(() => props.time, resetTime, { immediate: false })
onMounted(() => {
resetTime()
})
defineExpose<CountDownExpose>({
start,
pause,
reset: resetTime
})
</script>
<style lang="scss" scoped>
@import './index.scss';
</style>