index.vue 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <template>
  2. <view class="" :style="{minHeight:infoHeight+'px'}" :class="$tm.vx.state().tmVuetify.black ? 'grey-darken-6' : 'grey text '">
  3. <tm-menubars title="体验主题切换" color="primary" :showback="true"></tm-menubars>
  4. <view class="ma-32 ">
  5. <view class=" round-8 mb-24 fulled py-n16"
  6. :class="$tm.vx.state().tmVuetify.black ? 'grey-darken-5 bk' : 'white'">
  7. <view class="flex-center flex-col pa-32">
  8. <view class="text-size-lg text-weight-b">更换主题</view>
  9. <view class="text-size-n py-12">当前:{{$tm.vx.state().tmVuetify.color}},更多主题请查阅官方文档</view>
  10. <view class="flex">
  11. <tm-pickers @confirm="change" :default-value="defaultTheme"
  12. :list='themeSList' title="请选择主题" btn-color="primary">
  13. <tm-tags color="primary" size="g" model="text">选择内置主题</tm-tags>
  14. </tm-pickers>
  15. <view class="flex-shrink"><tm-tags @click="clearTheme" color="primary" size="g" model="text">恢复默认布局</tm-tags></view>
  16. </view>
  17. </view>
  18. </view>
  19. <view class=" round-8 mb-24 fulled py-n16"
  20. :class="$tm.vx.state().tmVuetify.black ? 'grey-darken-5 bk' : 'white'">
  21. <view class="flex-center flex-col pa-32">
  22. <view class="text-size-lg text-weight-b">暗黑主题的切换</view>
  23. <view class="text-size-n py-12">当前:{{$tm.vx.state().tmVuetify.black?'暗黑模式':'亮色模式'}}</view>
  24. <view class="flex">
  25. <tm-tags @click="$tm.theme.setBlack(true)" color="primary" size="g" model="text">切换暗黑</tm-tags>
  26. <view class="flex-shrink"><tm-tags @click="$tm.theme.setBlack(false)" color="primary" size="g" model="text">切换亮色</tm-tags></view>
  27. </view>
  28. </view>
  29. </view>
  30. </view>
  31. </view>
  32. </template>
  33. <script>
  34. export default {
  35. data() {
  36. return {
  37. defaultTheme:[],
  38. themeSList:["primary","red","green","blue","pink","orange","yellow","indigo"],
  39. infoHeight:0
  40. };
  41. },
  42. created() {
  43. this.defaultTheme = [this.$tm.vx.state().tmVuetify.color||'primary']
  44. this.infoHeight = uni.getSystemInfoSync().windowHeight
  45. },
  46. methods: {
  47. change(e) {
  48. this.defaultTheme = [e[0].data]
  49. this.$tm.theme.setTheme(e[0].data)
  50. },
  51. clearTheme(){
  52. this.$tm.theme.clear();
  53. this.defaultTheme = ['primary']
  54. }
  55. },
  56. }
  57. </script>
  58. <style lang="scss">
  59. </style>