icon.uvue 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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="50"></cl-icon>
  18. <cl-icon name="heart-fill" class="mr-2" :size="40"></cl-icon>
  19. <cl-icon name="heart-fill" class="mr-2" :size="30"></cl-icon>
  20. <cl-icon name="heart-fill" class="mr-2" :size="20"></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-[100rpx] rounded-lg"
  31. hover-class="opacity-60"
  32. :hover-stay-time="100"
  33. @tap="copy(item)"
  34. >
  35. <cl-icon :name="item"></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-[100rpx]"
  45. hover-class="opacity-60"
  46. :hover-stay-time="100"
  47. @tap="copy(item)"
  48. >
  49. <cl-icon :name="item"></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 { icons } from "@/icons";
  61. import { forInObject, keys } from "@/cool";
  62. import { useUi } from "@/uni_modules/cool-ui";
  63. import { t } from "@/locale";
  64. const ui = useUi();
  65. const remixicon = ref<string[]>([]);
  66. const iconfont = ref<string[]>([]);
  67. forInObject(icons, (value, key) => {
  68. if (key == "iconfont") {
  69. iconfont.value = keys(value).slice(0, 100);
  70. } else {
  71. remixicon.value = keys(value).slice(0, 100);
  72. }
  73. });
  74. function copy(data: string) {
  75. uni.setClipboardData({
  76. data,
  77. showToast: false,
  78. success() {
  79. ui.showToast({
  80. message: t("复制成功")
  81. });
  82. }
  83. });
  84. }
  85. </script>