auth-web/src/views/hooks.ts

39 lines
1.0 KiB
TypeScript
Raw Normal View History

2024-09-26 09:38:02 +08:00
// 抽离可公用的工具函数等用于系统管理页面逻辑
import { computed } from 'vue';
import { useDark } from '@pureadmin/utils';
2024-09-26 09:38:02 +08:00
export function usePublicHooks() {
const { isDark } = useDark();
2024-09-26 09:38:02 +08:00
const switchStyle = computed(() => {
return {
'--el-switch-on-color': '#6abe39',
'--el-switch-off-color': '#e84749',
};
});
2024-09-26 09:38:02 +08:00
const tagStyle = computed(() => {
return (status: number) => {
return status === 1
? {
'--el-tag-text-color': isDark.value ? '#6abe39' : '#389e0d',
'--el-tag-bg-color': isDark.value ? '#172412' : '#f6ffed',
'--el-tag-border-color': isDark.value ? '#274a17' : '#b7eb8f',
}
: {
'--el-tag-text-color': isDark.value ? '#e84749' : '#cf1322',
'--el-tag-bg-color': isDark.value ? '#2b1316' : '#fff1f0',
'--el-tag-border-color': isDark.value ? '#58191c' : '#ffa39e',
};
};
});
return {
/** 当前网页是否为`dark`模式 */
isDark,
/** 表现更鲜明的`el-switch`组件 */
switchStyle,
/** 表现更鲜明的`el-tag`组件 */
tagStyle,
};
2024-09-26 09:38:02 +08:00
}