Index.vue 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <template>
  2. <div id="app-demo-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. export default {
  36. data() {
  37. return {
  38. currentThemeMode: '',
  39. themeList: [
  40. 'system',
  41. 'light',
  42. 'dark'
  43. ]
  44. };
  45. },
  46. mounted () {
  47. this.init();
  48. },
  49. methods: {
  50. init () {
  51. const self = this;
  52. this.$ipc.on('example.setTheme', (event, result) => {
  53. console.log('result:', result)
  54. self.currentThemeMode = result;
  55. })
  56. this.$ipc.on('example.getTheme', (event, result) => {
  57. console.log('result:', result)
  58. self.currentThemeMode = result;
  59. })
  60. },
  61. setTheme (e) {
  62. this.currentThemeMode = e.target.value;
  63. console.log('setTheme currentThemeMode:', this.currentThemeMode)
  64. this.$ipc.send('example.setTheme', this.currentThemeMode);
  65. },
  66. getTheme () {
  67. this.$ipc.send('example.getTheme', '');
  68. },
  69. }
  70. };
  71. </script>
  72. <style lang="less" scoped>
  73. #app-demo-screen {
  74. padding: 0px 10px;
  75. text-align: left;
  76. width: 100%;
  77. .one-block-1 {
  78. font-size: 16px;
  79. padding-top: 10px;
  80. }
  81. .one-block-2 {
  82. padding-top: 10px;
  83. }
  84. }
  85. </style>