App.vue 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <template>
  2. <el-config-provider :locale="locale" :size="config.size" :zIndex="config.zIndex" :button="config.button">
  3. <router-view></router-view>
  4. </el-config-provider>
  5. </template>
  6. <script>
  7. import colorTool from '@/utils/color'
  8. export default {
  9. name: 'App',
  10. data() {
  11. return {
  12. config: {
  13. size: "default",
  14. zIndex: 2000,
  15. button: {
  16. autoInsertSpace: false
  17. }
  18. }
  19. }
  20. },
  21. computed: {
  22. locale(){
  23. return this.$i18n.messages[this.$i18n.locale].el
  24. },
  25. },
  26. created() {
  27. //设置主题颜色
  28. const app_color = this.$CONFIG.COLOR || this.$TOOL.data.get('APP_COLOR')
  29. if(app_color){
  30. document.documentElement.style.setProperty('--el-color-primary', app_color);
  31. for (let i = 1; i <= 9; i++) {
  32. document.documentElement.style.setProperty(`--el-color-primary-light-${i}`, colorTool.lighten(app_color,i/10));
  33. }
  34. for (let i = 1; i <= 9; i++) {
  35. document.documentElement.style.setProperty(`--el-color-primary-dark-${i}`, colorTool.darken(app_color,i/10));
  36. }
  37. }
  38. }
  39. }
  40. </script>
  41. <style lang="scss">
  42. @import '@/style/style.scss';
  43. </style>