icon.uvue 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <template>
  2. <cl-page>
  3. <view class="p-3">
  4. <demo-item :label="t('设置颜色')">
  5. <view class="flex flex-row">
  6. <cl-icon name="heart-fill" color="primary" class="mr-2"></cl-icon>
  7. <cl-icon name="heart-fill" color="success" class="mr-2"></cl-icon>
  8. <cl-icon name="heart-fill" color="error" class="mr-2"></cl-icon>
  9. <cl-icon name="heart-fill" color="warn" class="mr-2"></cl-icon>
  10. <cl-icon name="heart-fill" color="info" class="mr-2"></cl-icon>
  11. <cl-icon name="heart-fill" color="#428bca" class="mr-2"></cl-icon>
  12. <cl-icon name="heart-fill" color="purple"></cl-icon>
  13. </view>
  14. </demo-item>
  15. <demo-item :label="t('设置大小')">
  16. <view class="flex flex-row">
  17. <cl-icon name="heart-fill" class="mr-2" :size="26"></cl-icon>
  18. <cl-icon name="heart-fill" class="mr-2" :size="22"></cl-icon>
  19. <cl-icon name="heart-fill" class="mr-2" :size="18"></cl-icon>
  20. <cl-icon name="heart-fill" class="mr-2" :size="14"></cl-icon>
  21. </view>
  22. </demo-item>
  23. <demo-item>
  24. <cl-text>{{ t("集成 iconfont 与 remixicon 图标库,展示部分示例") }}</cl-text>
  25. </demo-item>
  26. <demo-item :label="t('iconfont')">
  27. <cl-row :gutter="10">
  28. <cl-col :span="4" v-for="item in iconfont" :key="item">
  29. <view
  30. class="flex flex-col items-center justify-center h-[50px] rounded-lg"
  31. hover-class="opacity-60"
  32. :hover-stay-time="250"
  33. @tap="copy(item)"
  34. >
  35. <cl-icon :name="item" :size="16"></cl-icon>
  36. </view>
  37. </cl-col>
  38. </cl-row>
  39. </demo-item>
  40. <demo-item :label="t('remixicon')">
  41. <cl-row :gutter="10">
  42. <cl-col :span="4" v-for="item in remixicon" :key="item">
  43. <view
  44. class="flex flex-col items-center justify-center h-[50px]"
  45. hover-class="opacity-60"
  46. :hover-stay-time="250"
  47. @tap="copy(item)"
  48. >
  49. <cl-icon :name="item" :size="16"></cl-icon>
  50. </view>
  51. </cl-col>
  52. </cl-row>
  53. </demo-item>
  54. </view>
  55. </cl-page>
  56. </template>
  57. <script lang="ts" setup>
  58. import { ref } from "vue";
  59. import DemoItem from "../components/item.uvue";
  60. import { forInObject, keys, icons, t } from "@/.cool";
  61. import { useUi } from "@/uni_modules/cool-ui";
  62. const ui = useUi();
  63. const remixicon = ref<string[]>([]);
  64. const iconfont = ref<string[]>([]);
  65. forInObject(icons, (value, key) => {
  66. if (key == "iconfont") {
  67. iconfont.value = keys(value).slice(0, 100);
  68. } else {
  69. remixicon.value = keys(value).slice(0, 100);
  70. }
  71. });
  72. function copy(data: string) {
  73. uni.setClipboardData({
  74. data,
  75. showToast: false,
  76. success() {
  77. ui.showToast({
  78. message: t("复制成功")
  79. });
  80. }
  81. });
  82. }
  83. </script>