App.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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. import '/src/assets/less/common.less';
  20. const appStore = useAppStore();
  21. // 解决日期时间国际化问题
  22. import 'dayjs/locale/zh-cn';
  23. // support Multi-language
  24. const { getAntdLocale } = useLocale();
  25. useTitle();
  26. /**
  27. * 2024-04-07
  28. * liaozhiyang
  29. * 暗黑模式下默认文字白色,白天模式默认文字 #333
  30. * */
  31. const modeAction = (data) => {
  32. if (data.token) {
  33. if (getDarkMode.value === ThemeEnum.DARK) {
  34. Object.assign(data.token, { colorTextBase: 'fff' });
  35. } else {
  36. Object.assign(data.token, { colorTextBase: '#333' });
  37. }
  38. }
  39. };
  40. // update-begin--author:liaozhiyang---date:20231218---for:【QQYUN-6366】升级到antd4.x
  41. const appTheme: any = ref({});
  42. const { getDarkMode } = useRootSetting();
  43. watch(
  44. () => getDarkMode.value,
  45. (newValue) => {
  46. delete appTheme.value.algorithm;
  47. if (newValue === ThemeEnum.DARK) {
  48. appTheme.value.algorithm = theme.darkAlgorithm;
  49. }
  50. // update-begin--author:liaozhiyang---date:20240322---for:【QQYUN-8570】生产环境暗黑模式下主题色不生效
  51. if (import.meta.env.PROD) {
  52. changeTheme(appStore.getProjectConfig.themeColor);
  53. }
  54. // update-end--author:liaozhiyang---date:20240322---for:【QQYUN-8570】生产环境暗黑模式下主题色不生效
  55. modeAction(appTheme.value);
  56. appTheme.value = {
  57. ...appTheme.value,
  58. };
  59. },
  60. { immediate: true }
  61. );
  62. watch(
  63. appStore.getProjectConfig,
  64. (newValue) => {
  65. const primary = newValue.themeColor;
  66. const result = {
  67. ...appTheme.value,
  68. ...{
  69. token: {
  70. colorPrimary: primary,
  71. wireframe: true,
  72. fontSize: 14,
  73. colorTextBase: '#333',
  74. colorSuccess: '#55D187',
  75. colorInfo: primary,
  76. borderRadius: 4,
  77. sizeStep: 4,
  78. sizeUnit: 4,
  79. colorWarning: '#EFBD47',
  80. colorError: '#ED6F6F',
  81. fontFamily:
  82. '-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',
  83. },
  84. },
  85. };
  86. appTheme.value = result;
  87. modeAction(result);
  88. },
  89. { immediate: true }
  90. );
  91. setTimeout(() => {
  92. appStore.getProjectConfig?.themeColor && changeTheme(appStore.getProjectConfig.themeColor);
  93. }, 300);
  94. // update-end--author:liaozhiyang---date:20231218---for:【QQYUN-6366】升级到antd4.x
  95. </script>
  96. <style lang="less">
  97. // update-begin--author:liaozhiyang---date:20230803---for:【QQYUN-5839】windi会影响到html2canvas绘制的图片样式
  98. img {
  99. display: inline-block;
  100. }
  101. // update-end--author:liaozhiyang---date:20230803---for:【QQYUN-5839】windi会影响到html2canvas绘制的图片样式
  102. </style>