Index.vue 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <template>
  2. <div id="app-base-screen">
  3. <div class="one-block-1">
  4. <span>
  5. 1. 系统主题模式
  6. </span>
  7. </div>
  8. <div class="one-block-2">
  9. <a-space>
  10. <a-button @click="getTheme()">获取模式</a-button>
  11. </a-space>
  12. <span>
  13. 结果:{{ currentThemeMode }}
  14. </span>
  15. </div>
  16. <div class="one-block-1">
  17. 2. 设置主题模式(请自行实现前端UI效果)
  18. </div>
  19. <div class="one-block-2">
  20. <a-radio-group v-model="currentThemeMode" @change="setTheme">
  21. <a-radio :value="themeList[0]">
  22. {{ themeList[0] }}
  23. </a-radio>
  24. <a-radio :value="themeList[1]">
  25. {{ themeList[1] }}
  26. </a-radio>
  27. <a-radio :value="themeList[2]">
  28. {{ themeList[2] }}
  29. </a-radio>
  30. </a-radio-group>
  31. </div>
  32. </div>
  33. </template>
  34. <script>
  35. import { ipcApiRoute } from '@/api/main'
  36. export default {
  37. data() {
  38. return {
  39. currentThemeMode: '',
  40. themeList: [
  41. 'system',
  42. 'light',
  43. 'dark'
  44. ]
  45. };
  46. },
  47. mounted () {
  48. },
  49. methods: {
  50. setTheme (e) {
  51. const self = this;
  52. this.currentThemeMode = e.target.value;
  53. console.log('setTheme currentThemeMode:', this.currentThemeMode)
  54. this.$ipcCall(ipcApiRoute.setTheme, this.currentThemeMode).then(result => {
  55. console.log('result:', result)
  56. self.currentThemeMode = result;
  57. })
  58. },
  59. getTheme () {
  60. const self = this;
  61. this.$ipcCall(ipcApiRoute.getTheme).then(result => {
  62. console.log('result:', result)
  63. self.currentThemeMode = result;
  64. })
  65. },
  66. }
  67. };
  68. </script>
  69. <style lang="less" scoped>
  70. #app-base-screen {
  71. padding: 0px 10px;
  72. text-align: left;
  73. width: 100%;
  74. .one-block-1 {
  75. font-size: 16px;
  76. padding-top: 10px;
  77. }
  78. .one-block-2 {
  79. padding-top: 10px;
  80. }
  81. }
  82. </style>