更新:登录功能
This commit is contained in:
39
uni_modules/wot-design-uni/components/wd-loadmore/index.scss
Normal file
39
uni_modules/wot-design-uni/components/wd-loadmore/index.scss
Normal file
@@ -0,0 +1,39 @@
|
||||
@import '../common/abstracts/variable';
|
||||
@import '../common/abstracts/mixin';
|
||||
.wot-theme-dark {
|
||||
@include b(loadmore) {
|
||||
color: $-dark-color;
|
||||
}
|
||||
}
|
||||
|
||||
@include b(loadmore) {
|
||||
width: 100%;
|
||||
height: $-loadmore-height;
|
||||
line-height: $-loadmore-height;
|
||||
text-align: center;
|
||||
color: $-loadmore-color;
|
||||
|
||||
@include edeep(loading) {
|
||||
display: inline-block;
|
||||
margin-right: 8px;
|
||||
vertical-align: middle;
|
||||
width: $-loadmore-loading-size;
|
||||
height: $-loadmore-loading-size;
|
||||
}
|
||||
@include e(text) {
|
||||
display: inline-block;
|
||||
font-size: $-loadmore-fs;
|
||||
vertical-align: middle;
|
||||
|
||||
@include when(light) {
|
||||
margin: 0 6px;
|
||||
color: $-loadmore-error-color;
|
||||
}
|
||||
}
|
||||
@include edeep(refresh) {
|
||||
display: inline-block;
|
||||
color: $-loadmore-error-color;
|
||||
vertical-align: middle;
|
||||
font-size: $-loadmore-refresh-fs;
|
||||
}
|
||||
}
|
||||
30
uni_modules/wot-design-uni/components/wd-loadmore/types.ts
Normal file
30
uni_modules/wot-design-uni/components/wd-loadmore/types.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import type { PropType } from 'vue'
|
||||
import { baseProps } from '../common/props'
|
||||
import type { LoadingProps } from '../wd-loading/types'
|
||||
|
||||
export type LoadMoreState = 'loading' | 'error' | 'finished'
|
||||
|
||||
export const loadmoreProps = {
|
||||
...baseProps,
|
||||
/**
|
||||
* 加载状态,可选值:'loading' | 'error' | 'finished'
|
||||
*/
|
||||
state: String as PropType<LoadMoreState>,
|
||||
/**
|
||||
* 加载提示文案
|
||||
*/
|
||||
loadingText: String,
|
||||
/**
|
||||
* 全部加载完的提示文案
|
||||
*/
|
||||
finishedText: String,
|
||||
/**
|
||||
* 加载失败的提示文案
|
||||
*/
|
||||
errorText: String,
|
||||
/**
|
||||
* 加载中loading组件的属性
|
||||
* 参考loading组件
|
||||
*/
|
||||
loadingProps: Object as PropType<Partial<LoadingProps>>
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
<!--
|
||||
* @Author: weisheng
|
||||
* @Date: 2024-11-09 12:35:25
|
||||
* @LastEditTime: 2024-11-09 15:01:32
|
||||
* @LastEditors: weisheng
|
||||
* @Description:
|
||||
* @FilePath: /wot-design-uni/src/uni_modules/wot-design-uni/components/wd-loadmore/wd-loadmore.vue
|
||||
* 记得注释
|
||||
-->
|
||||
<template>
|
||||
<view :class="['wd-loadmore', customClass]" :style="customStyle" @click="reload">
|
||||
<wd-divider v-if="state === 'finished'">{{ finishedText || translate('finished') }}</wd-divider>
|
||||
<block v-if="state === 'error'">
|
||||
<text class="wd-loadmore__text">{{ errorText || translate('error') }}</text>
|
||||
<text class="wd-loadmore__text is-light">{{ translate('retry') }}</text>
|
||||
<wd-icon name="refresh" custom-class="wd-loadmore__refresh" />
|
||||
</block>
|
||||
<block v-if="state === 'loading'">
|
||||
<wd-loading v-bind="customLoadingProps" />
|
||||
<text class="wd-loadmore__text">{{ loadingText || translate('loading') }}</text>
|
||||
</block>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
export default {
|
||||
name: 'wd-loadmore',
|
||||
options: {
|
||||
virtualHost: true,
|
||||
addGlobalClass: true,
|
||||
styleIsolation: 'shared'
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import wdDivider from '../wd-divider/wd-divider.vue'
|
||||
import wdLoading from '../wd-loading/wd-loading.vue'
|
||||
import wdIcon from '../wd-icon/wd-icon.vue'
|
||||
import { computed, ref } from 'vue'
|
||||
import { useTranslate } from '../composables/useTranslate'
|
||||
import { loadmoreProps, type LoadMoreState } from './types'
|
||||
import type { LoadingProps } from '../wd-loading/types'
|
||||
import { isDef, isUndefined, omitBy } from '../common/util'
|
||||
|
||||
const customLoadingProps = computed(() => {
|
||||
const loadingProps: Partial<LoadingProps> = isDef(props.loadingProps) ? omitBy(props.loadingProps, isUndefined) : {}
|
||||
loadingProps.customClass = `wd-loadmore__loading ${loadingProps.customClass || ''}`
|
||||
return loadingProps
|
||||
})
|
||||
|
||||
const props = defineProps(loadmoreProps)
|
||||
const emit = defineEmits(['reload'])
|
||||
|
||||
const { translate } = useTranslate('loadmore')
|
||||
|
||||
const currentState = ref<LoadMoreState | null>(null)
|
||||
|
||||
function reload() {
|
||||
if (props.state !== 'error') return
|
||||
currentState.value = 'loading'
|
||||
emit('reload')
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
@import './index.scss';
|
||||
</style>
|
||||
Reference in New Issue
Block a user