App.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. <template>
  2. <ConfigProvider :theme="appTheme" :locale="getAntdLocale">
  3. <AppProvider>
  4. <RouterView />
  5. </AppProvider>
  6. </ConfigProvider>
  7. </template>
  8. <script lang="ts" setup>
  9. import { watch, ref } from 'vue';
  10. import { theme } from 'ant-design-vue';
  11. import { ConfigProvider } from 'ant-design-vue';
  12. import { AppProvider } from '/@/components/Application';
  13. import { useTitle } from '/@/hooks/web/useTitle';
  14. import { useLocale } from '/@/locales/useLocale';
  15. import { useAppStore } from '/@/store/modules/app';
  16. import { useRootSetting } from '/@/hooks/setting/useRootSetting';
  17. import { ThemeEnum } from '/@/enums/appEnum';
  18. import { changeTheme } from '/@/logics/theme/index';
  19. const appStore = useAppStore();
  20. // 解决日期时间国际化问题
  21. import 'dayjs/locale/zh-cn';
  22. // support Multi-language
  23. const { getAntdLocale } = useLocale();
  24. useTitle();
  25. /**
  26. * 2024-04-07
  27. * liaozhiyang
  28. * 暗黑模式下默认文字白色,白天模式默认文字 #333
  29. * */
  30. const modeAction = (data) => {
  31. if (data.token) {
  32. if (getDarkMode.value === ThemeEnum.DARK) {
  33. Object.assign(data.token, { colorTextBase: 'fff' });
  34. } else {
  35. Object.assign(data.token, { colorTextBase: '#333' });
  36. }
  37. }
  38. };
  39. // update-begin--author:liaozhiyang---date:20231218---for:【QQYUN-6366】升级到antd4.x
  40. const appTheme: any = ref({});
  41. const { getDarkMode } = useRootSetting();
  42. watch(
  43. () => getDarkMode.value,
  44. (newValue) => {
  45. delete appTheme.value.algorithm;
  46. if (newValue === ThemeEnum.DARK) {
  47. appTheme.value.algorithm = theme.darkAlgorithm;
  48. }
  49. // update-begin--author:liaozhiyang---date:20240322---for:【QQYUN-8570】生产环境暗黑模式下主题色不生效
  50. if (import.meta.env.PROD) {
  51. changeTheme(appStore.getProjectConfig.themeColor);
  52. }
  53. // update-end--author:liaozhiyang---date:20240322---for:【QQYUN-8570】生产环境暗黑模式下主题色不生效
  54. modeAction(appTheme.value);
  55. appTheme.value = {
  56. ...appTheme.value,
  57. };
  58. },
  59. { immediate: true }
  60. );
  61. watch(
  62. appStore.getProjectConfig,
  63. (newValue) => {
  64. const primary = newValue.themeColor;
  65. const result = {
  66. ...appTheme.value,
  67. ...{
  68. token: {
  69. colorPrimary: primary,
  70. wireframe: true,
  71. fontSize: 14,
  72. colorTextBase: '#333',
  73. colorSuccess: '#55D187',
  74. colorInfo: primary,
  75. borderRadius: 4,
  76. sizeStep: 4,
  77. sizeUnit: 4,
  78. colorWarning: '#EFBD47',
  79. colorError: '#ED6F6F',
  80. fontFamily:
  81. '-apple-system,BlinkMacSystemFont,Segoe UI,PingFang SC,Hiragino Sans GB,Microsoft YaHei,Helvetica Neue,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol',
  82. },
  83. },
  84. };
  85. appTheme.value = result;
  86. modeAction(result);
  87. },
  88. { immediate: true }
  89. );
  90. setTimeout(() => {
  91. appStore.getProjectConfig?.themeColor && changeTheme(appStore.getProjectConfig.themeColor);
  92. }, 300);
  93. // update-end--author:liaozhiyang---date:20231218---for:【QQYUN-6366】升级到antd4.x
  94. </script>
  95. <style lang="less">
  96. // update-begin--author:liaozhiyang---date:20230803---for:【QQYUN-5839】windi会影响到html2canvas绘制的图片样式
  97. img {
  98. display: inline-block;
  99. }
  100. // update-end--author:liaozhiyang---date:20230803---for:【QQYUN-5839】windi会影响到html2canvas绘制的图片样式
  101. </style>