hooks.ts 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. // 抽离可公用的工具函数等用于系统管理页面逻辑
  2. import { computed } from "vue";
  3. import { useDark } from "@pureadmin/utils";
  4. export function usePublicHooks() {
  5. const { isDark } = useDark();
  6. const switchStyle = computed(() => {
  7. return {
  8. "--el-switch-on-color": "#6abe39",
  9. "--el-switch-off-color": "#e84749"
  10. };
  11. });
  12. const tagStyle = computed(() => {
  13. return (status: number) => {
  14. return status === 1
  15. ? {
  16. "--el-tag-text-color": isDark.value ? "#6abe39" : "#389e0d",
  17. "--el-tag-bg-color": isDark.value ? "#172412" : "#f6ffed",
  18. "--el-tag-border-color": isDark.value ? "#274a17" : "#b7eb8f"
  19. }
  20. : {
  21. "--el-tag-text-color": isDark.value ? "#e84749" : "#cf1322",
  22. "--el-tag-bg-color": isDark.value ? "#2b1316" : "#fff1f0",
  23. "--el-tag-border-color": isDark.value ? "#58191c" : "#ffa39e"
  24. };
  25. };
  26. });
  27. return {
  28. /** 当前网页是否为`dark`模式 */
  29. isDark,
  30. /** 表现更鲜明的`el-switch`组件 */
  31. switchStyle,
  32. /** 表现更鲜明的`el-tag`组件 */
  33. tagStyle
  34. };
  35. }