Skip to content

Commit 17ebd76

Browse files
authored
Merge pull request #15 from zjutjh/feat/infraUpdate
refactor: 迁移主题色定义位置并加深danger主题色;更改遮罩式加载态的delay逻辑;删去首页无用项
2 parents 04b002c + d4ec90b commit 17ebd76

File tree

5 files changed

+16
-40
lines changed

5 files changed

+16
-40
lines changed

apps/admin/src/app.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@
55
</template>
66

77
<script setup lang="ts">
8-
import { THEME_VAR_RECORD } from "@/configs/theme-vars";
8+
import { THEME_VAR_RECORD } from "@/constants";
99
</script>

apps/admin/src/components/loading-container/index.vue

Lines changed: 6 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,16 @@
2525
<script setup lang="ts">
2626
import "./index.scss";
2727
28+
import { refDebounced } from "@vueuse/core";
2829
import type { LoadingProps } from "vant";
29-
import { ref, watch } from "vue";
30+
import { computed, toRef } from "vue";
3031
3132
export interface LoadingContainerProps extends Partial<LoadingProps> {
3233
/** 加载图标下方的文本 */
3334
text?: string;
3435
/** 是否正在加载 */
3536
loading: boolean;
36-
/** 加载已经持续多少毫秒时,视觉上显示遮罩,设为0时立即显示。
37+
/** 加载状态从false变为true持续多少毫秒后,视觉上才显示遮罩。为0则立即显示
3738
* @default 0
3839
*/
3940
delay?: number;
@@ -52,33 +53,8 @@ const props = withDefaults(defineProps<LoadingContainerProps>(), {
5253
});
5354
5455
/** 遮罩是否视觉上可见 */
55-
const isOverlayVisible = ref(false);
56-
/** 使遮罩可见的计时器 */
57-
let loadingDelayTimer: number | undefined;
58-
watch(
59-
() => props.loading,
60-
(newValue) => {
61-
// 重置使遮罩可见的计时器
62-
if (loadingDelayTimer !== undefined) {
63-
clearTimeout(loadingDelayTimer);
64-
loadingDelayTimer = undefined;
65-
}
66-
// 已退出加载状态,立刻将遮罩重置为不可见
67-
if (newValue === false) {
68-
isOverlayVisible.value = false;
69-
return;
70-
}
71-
// 已进入加载状态
72-
if (props.delay === 0) {
73-
// 无延时,立刻使遮罩可见
74-
isOverlayVisible.value = true;
75-
return;
76-
}
77-
// 延时后使遮罩可见
78-
loadingDelayTimer = setTimeout(() => {
79-
isOverlayVisible.value = true;
80-
}, props.delay);
81-
},
82-
{ immediate: true }
56+
const isOverlayVisible = refDebounced(
57+
toRef(() => props.loading),
58+
computed(() => (props.loading ? props.delay : 0))
8359
);
8460
</script>

apps/admin/src/configs/theme-vars.ts

Lines changed: 0 additions & 7 deletions
This file was deleted.

apps/admin/src/constants/ui.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,12 @@ export const BASE_ROOT_FONT_SIZE = 100;
66
export const MAX_REM_UNIT_PRECISION = 5;
77
/** 最大视口宽度 */
88
export const MAX_VIEW_WIDTH = 750;
9+
10+
/** 组件库主题色 */
11+
export const THEME_VAR_RECORD = {
12+
primaryColor: "#F58888",
13+
successColor: "#49DF17",
14+
warningColor: "#ADDF17",
15+
dangerColor: "#E53935",
16+
infoColor: "#3A87FA"
17+
} as const;
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<template>
22
<van-cell-group title="管理员信息">
33
<van-cell title="管理员">{{ adminName }}</van-cell>
4-
<van-cell title="路线">{{ walkRoute }}</van-cell>
54
<van-cell title="点位">{{ walkPoint }}</van-cell>
65
</van-cell-group>
76
</template>
@@ -10,7 +9,6 @@
109
import { ref } from "vue";
1110
1211
// TODO: 从接口中获取adminInfo
13-
const walkRoute = ref("屏峰全程");
1412
const walkPoint = ref("XXX");
1513
const adminName = ref("XXX");
1614
</script>

0 commit comments

Comments
 (0)