JcDemo.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <script setup>
  2. import { computed, nextTick, ref } from "vue";
  3. const props = defineProps({
  4. title: '',
  5. classes: {
  6. default: []
  7. },
  8. scss: '',
  9. hasShowClass: {
  10. default: true
  11. }
  12. })
  13. const showClasses = ref(false)
  14. function toggleShowClasses() {
  15. showClasses.value = !showClasses.value
  16. }
  17. function copy({ name }) {
  18. uni.setClipboardData({
  19. data: name
  20. })
  21. }
  22. </script>
  23. <template>
  24. <view>
  25. <view class="p-2 sticky top-0 z-10 flex items-center bg-slate-100">
  26. <view class="flex-1 font-medium font-bold font-sans text-2xl">{{title}}</view>
  27. <view class="text-blue-500" @tap="toggleShowClasses" v-if="hasShowClass">查看</view>
  28. </view>
  29. <view class="p-2 bg-white" v-if="classes.length || $slots.default">
  30. <view class="border-b-2 border-slate-100 mb-3-5 " v-if="classes.length && showClasses">
  31. <view class="pb-2 flex items-center border-b-2 border-slate-100 text-slate-700 text-xs">
  32. <view class="flex-1 font-medium mr-2">Class</view>
  33. <view class="font-medium">Properties</view>
  34. </view>
  35. <view class="max-h-96 overflow-auto">
  36. <view v-for="d, i in classes" :key="i" @tap="copy(d)">
  37. <view class="p-2 border-slate-100 flex items-center font-mono text-xs whitespace-nowrap overflow-auto" :class="{'border-t': i > 0}">
  38. <view class="flex-1 text-sky-500 mr-6 flex items-center">
  39. <text class="mr-2 w-4 h-4" :style="{backgroundColor: d.bgcolor}" v-if="d.bgcolor != undefined" @tap.stop="copy({name: d.bgcolor})"></text>
  40. <text class="mr-2 font-medium text-base" :style="{color: d.textcolor}" v-if="d.textcolor != undefined" @tap.stop="copy({name: d.textcolor})">Aa</text>
  41. {{d.name}}
  42. </view>
  43. <view class="text-indigo-500">
  44. <view class="flex items-center" v-for="v, k in d.value" :key="k">
  45. <text>{{v.value ? v.value : v}}</text>
  46. <template v-if="v.value != undefined">
  47. <text class="text-indigo-300 ml-2" v-if="v.rpx != undefined">/* {{v.rpx}}rpx */</text>
  48. <text class="text-indigo-300 ml-2" v-if="v.percent != undefined">/* {{v.percent}} */</text>
  49. <text class="text-indigo-300 ml-2" v-if="v.desc != undefined">/* {{v.desc}} */</text>
  50. </template>
  51. <template v-else>
  52. <text class="text-indigo-300 ml-2" v-if="d.rpx != undefined">/* {{d.rpx}}rpx */</text>
  53. <text class="text-indigo-300 ml-2" v-if="d.percent != undefined">/* {{d.percent}} */</text>
  54. <text class="text-indigo-300 ml-2" v-if="d.desc != undefined">/* {{d.desc}} */</text>
  55. </template>
  56. </view>
  57. </view>
  58. </view>
  59. </view>
  60. </view>
  61. </view>
  62. <view :class="{'relative rounded-xl overflow-auto p-2 border border-slate-200 bg-slate-50 box-border': $slots.default}">
  63. <slot></slot>
  64. </view>
  65. </view>
  66. </view>
  67. </template>