feat(图标): 添加 Iconify 图标库支持并创建测试页面
添加 @iconify/vue 依赖并全局注册组件 创建图标测试页面用于验证不同图标库的使用体验 添加相关测试用例确保组件正常导入
Showing
7 changed files
with
166 additions
and
7 deletions
| ... | @@ -26,6 +26,7 @@ | ... | @@ -26,6 +26,7 @@ |
| 26 | "@fortawesome/free-solid-svg-icons": "^6.5.1", | 26 | "@fortawesome/free-solid-svg-icons": "^6.5.1", |
| 27 | "@fortawesome/vue-fontawesome": "^3.0.5", | 27 | "@fortawesome/vue-fontawesome": "^3.0.5", |
| 28 | "@heroicons/vue": "^2.2.0", | 28 | "@heroicons/vue": "^2.2.0", |
| 29 | + "@iconify/vue": "^5.0.0", | ||
| 29 | "@sunsetglow/vue-pdf-viewer": "^0.3.67", | 30 | "@sunsetglow/vue-pdf-viewer": "^0.3.67", |
| 30 | "@vant/touch-emulator": "^1.4.0", | 31 | "@vant/touch-emulator": "^1.4.0", |
| 31 | "@vant/use": "^1.6.0", | 32 | "@vant/use": "^1.6.0", | ... | ... |
| ... | @@ -20,6 +20,9 @@ importers: | ... | @@ -20,6 +20,9 @@ importers: |
| 20 | '@heroicons/vue': | 20 | '@heroicons/vue': |
| 21 | specifier: ^2.2.0 | 21 | specifier: ^2.2.0 |
| 22 | version: 2.2.0(vue@3.5.25) | 22 | version: 2.2.0(vue@3.5.25) |
| 23 | + '@iconify/vue': | ||
| 24 | + specifier: ^5.0.0 | ||
| 25 | + version: 5.0.0(vue@3.5.25) | ||
| 23 | '@sunsetglow/vue-pdf-viewer': | 26 | '@sunsetglow/vue-pdf-viewer': |
| 24 | specifier: ^0.3.67 | 27 | specifier: ^0.3.67 |
| 25 | version: 0.3.72(vite@6.4.1(@types/node@20.19.25)(jiti@1.21.7)(less@4.4.2)) | 28 | version: 0.3.72(vite@6.4.1(@types/node@20.19.25)(jiti@1.21.7)(less@4.4.2)) |
| ... | @@ -460,6 +463,14 @@ packages: | ... | @@ -460,6 +463,14 @@ packages: |
| 460 | peerDependencies: | 463 | peerDependencies: |
| 461 | vue: '>= 3' | 464 | vue: '>= 3' |
| 462 | 465 | ||
| 466 | + '@iconify/types@2.0.0': | ||
| 467 | + resolution: {integrity: sha512-+wluvCrRhXrhyOmRDJ3q8mux9JkKy5SJ/v8ol2tu4FVjyYvtEzkc/3pK15ET6RKg4b4w4BmTk1+gsCUhf21Ykg==} | ||
| 468 | + | ||
| 469 | + '@iconify/vue@5.0.0': | ||
| 470 | + resolution: {integrity: sha512-C+KuEWIF5nSBrobFJhT//JS87OZ++QDORB6f2q2Wm6fl2mueSTpFBeBsveK0KW9hWiZ4mNiPjsh6Zs4jjdROSg==} | ||
| 471 | + peerDependencies: | ||
| 472 | + vue: '>=3' | ||
| 473 | + | ||
| 463 | '@jridgewell/gen-mapping@0.3.13': | 474 | '@jridgewell/gen-mapping@0.3.13': |
| 464 | resolution: {integrity: sha512-2kkt/7niJ6MgEPxF0bYdQ6etZaA+fQvDcLKckhy1yIQOzaoKjBBjSj63/aLVjYE3qhRt5dvM+uUyfCg6UKCBbA==} | 475 | resolution: {integrity: sha512-2kkt/7niJ6MgEPxF0bYdQ6etZaA+fQvDcLKckhy1yIQOzaoKjBBjSj63/aLVjYE3qhRt5dvM+uUyfCg6UKCBbA==} |
| 465 | 476 | ||
| ... | @@ -2414,6 +2425,13 @@ snapshots: | ... | @@ -2414,6 +2425,13 @@ snapshots: |
| 2414 | dependencies: | 2425 | dependencies: |
| 2415 | vue: 3.5.25 | 2426 | vue: 3.5.25 |
| 2416 | 2427 | ||
| 2428 | + '@iconify/types@2.0.0': {} | ||
| 2429 | + | ||
| 2430 | + '@iconify/vue@5.0.0(vue@3.5.25)': | ||
| 2431 | + dependencies: | ||
| 2432 | + '@iconify/types': 2.0.0 | ||
| 2433 | + vue: 3.5.25 | ||
| 2434 | + | ||
| 2417 | '@jridgewell/gen-mapping@0.3.13': | 2435 | '@jridgewell/gen-mapping@0.3.13': |
| 2418 | dependencies: | 2436 | dependencies: |
| 2419 | '@jridgewell/sourcemap-codec': 1.5.5 | 2437 | '@jridgewell/sourcemap-codec': 1.5.5 | ... | ... |
| 1 | /* | 1 | /* |
| 2 | * @Date: 2025-03-20 20:36:36 | 2 | * @Date: 2025-03-20 20:36:36 |
| 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 4 | - * @LastEditTime: 2025-12-10 11:50:37 | 4 | + * @LastEditTime: 2025-12-27 22:06:35 |
| 5 | * @FilePath: /mlaj/src/main.js | 5 | * @FilePath: /mlaj/src/main.js |
| 6 | * @Description: 文件描述 | 6 | * @Description: 文件描述 |
| 7 | */ | 7 | */ |
| ... | @@ -17,6 +17,7 @@ import '@vant/touch-emulator'; | ... | @@ -17,6 +17,7 @@ import '@vant/touch-emulator'; |
| 17 | import { library } from '@fortawesome/fontawesome-svg-core' | 17 | import { library } from '@fortawesome/fontawesome-svg-core' |
| 18 | /* import font awesome icon component */ | 18 | /* import font awesome icon component */ |
| 19 | import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome' | 19 | import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome' |
| 20 | +import { Icon as IconifyIcon } from '@iconify/vue' | ||
| 20 | /* import specific icons */ | 21 | /* import specific icons */ |
| 21 | import { faCirclePause, faCirclePlay, faPlay, faPause, faBackwardStep, faForwardStep, faVolumeUp, faRedo, faRepeat, faList, faChevronDown, faVolumeOff, faXmark, faFileAlt, faTimes, faEye, faFilePdf, faExternalLinkAlt, faSpinner, faExclamationCircle, faDownload, faVenus, faMars, faMagnifyingGlassPlus, faMagnifyingGlassMinus } from '@fortawesome/free-solid-svg-icons' | 22 | import { faCirclePause, faCirclePlay, faPlay, faPause, faBackwardStep, faForwardStep, faVolumeUp, faRedo, faRepeat, faList, faChevronDown, faVolumeOff, faXmark, faFileAlt, faTimes, faEye, faFilePdf, faExternalLinkAlt, faSpinner, faExclamationCircle, faDownload, faVenus, faMars, faMagnifyingGlassPlus, faMagnifyingGlassMinus } from '@fortawesome/free-solid-svg-icons' |
| 22 | 23 | ||
| ... | @@ -31,13 +32,13 @@ if (!Array.prototype.at) { | ... | @@ -31,13 +32,13 @@ if (!Array.prototype.at) { |
| 31 | return this[n]; | 32 | return this[n]; |
| 32 | }; | 33 | }; |
| 33 | } | 34 | } |
| 34 | - | ||
| 35 | const app = createApp(App) | 35 | const app = createApp(App) |
| 36 | +app.component('Icon', IconifyIcon) | ||
| 37 | +app.component('font-awesome-icon', FontAwesomeIcon) | ||
| 36 | // 屏蔽警告信息 | 38 | // 屏蔽警告信息 |
| 37 | app.config.warnHandler = () => null; | 39 | app.config.warnHandler = () => null; |
| 38 | 40 | ||
| 39 | app.config.globalProperties.$http = axios; // 关键语句 | 41 | app.config.globalProperties.$http = axios; // 关键语句 |
| 40 | -app.component('font-awesome-icon', FontAwesomeIcon) | ||
| 41 | /** | 42 | /** |
| 42 | * @function restoreHashAfterOAuth | 43 | * @function restoreHashAfterOAuth |
| 43 | * @description 前端复原 OAuth 回跳的 hash 路由位置:当 URL 中存在 ret_hash 参数且当前无 hash 时,将其拼回地址栏。 | 44 | * @description 前端复原 OAuth 回跳的 hash 路由位置:当 URL 中存在 ret_hash 参数且当前无 hash 时,将其拼回地址栏。 |
| ... | @@ -55,6 +56,7 @@ function restoreHashAfterOAuth() { | ... | @@ -55,6 +56,7 @@ function restoreHashAfterOAuth() { |
| 55 | window.history.replaceState(null, '', new_url); | 56 | window.history.replaceState(null, '', new_url); |
| 56 | } | 57 | } |
| 57 | } | 58 | } |
| 59 | +void restoreHashAfterOAuth | ||
| 58 | 60 | ||
| 59 | // 在安装路由前进行一次 hash 复原,确保初始路由正确 | 61 | // 在安装路由前进行一次 hash 复原,确保初始路由正确 |
| 60 | // restoreHashAfterOAuth() | 62 | // restoreHashAfterOAuth() | ... | ... |
| 1 | /* | 1 | /* |
| 2 | * @Date: 2025-03-20 20:36:36 | 2 | * @Date: 2025-03-20 20:36:36 |
| 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 4 | - * @LastEditTime: 2025-12-24 10:58:25 | 4 | + * @LastEditTime: 2025-12-27 22:18:08 |
| 5 | * @FilePath: /mlaj/src/router/routes.js | 5 | * @FilePath: /mlaj/src/router/routes.js |
| 6 | * @Description: 路由地址映射配置 | 6 | * @Description: 路由地址映射配置 |
| 7 | */ | 7 | */ |
| ... | @@ -248,6 +248,12 @@ export const routes = [ | ... | @@ -248,6 +248,12 @@ export const routes = [ |
| 248 | meta: { title: 'test' }, | 248 | meta: { title: 'test' }, |
| 249 | }, | 249 | }, |
| 250 | { | 250 | { |
| 251 | + path: '/test/icon', | ||
| 252 | + name: 'IconTest', | ||
| 253 | + component: () => import('../views/IconTestPage.vue'), | ||
| 254 | + meta: { title: 'Icon测试' }, | ||
| 255 | + }, | ||
| 256 | + { | ||
| 251 | path: '/animation', | 257 | path: '/animation', |
| 252 | name: 'animation', | 258 | name: 'animation', |
| 253 | component: () => import('../views/animation.vue'), | 259 | component: () => import('../views/animation.vue'), | ... | ... |
src/utils/__tests__/iconify_import.test.js
0 → 100644
src/views/IconTestPage.vue
0 → 100644
| 1 | +<template> | ||
| 2 | + <div class="min-h-screen bg-gradient-to-br from-slate-50 via-white to-slate-50 p-4"> | ||
| 3 | + <div class="mx-auto max-w-3xl"> | ||
| 4 | + <div class="flex items-center justify-between"> | ||
| 5 | + <div> | ||
| 6 | + <div class="text-xl font-bold text-slate-900">图标库测试</div> | ||
| 7 | + <div class="mt-1 text-sm text-slate-600">在本页验证 Iconify 的使用体验与渲染效果</div> | ||
| 8 | + </div> | ||
| 9 | + <div class="flex items-center gap-3"> | ||
| 10 | + <van-icon name="apps-o" size="22" class="text-slate-700" /> | ||
| 11 | + <font-awesome-icon icon="eye" class="text-slate-700" /> | ||
| 12 | + </div> | ||
| 13 | + </div> | ||
| 14 | + | ||
| 15 | + <div class="mt-4 rounded-xl border border-slate-200 bg-white p-4 shadow-sm"> | ||
| 16 | + <div class="flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between"> | ||
| 17 | + <div class="flex-1"> | ||
| 18 | + <div class="text-sm font-medium text-slate-800">Iconify 图标名</div> | ||
| 19 | + <div class="mt-2 flex items-center gap-2"> | ||
| 20 | + <input | ||
| 21 | + v-model="icon_name" | ||
| 22 | + type="text" | ||
| 23 | + class="w-full rounded-lg border border-slate-200 px-3 py-2 text-sm outline-none focus:border-slate-400" | ||
| 24 | + placeholder="例如:mdi:home / lucide:camera / solar:heart-bold" | ||
| 25 | + /> | ||
| 26 | + <button | ||
| 27 | + type="button" | ||
| 28 | + class="shrink-0 rounded-lg border border-slate-200 px-3 py-2 text-sm text-slate-700 hover:bg-slate-50" | ||
| 29 | + @click="resetIcon" | ||
| 30 | + > | ||
| 31 | + 重置 | ||
| 32 | + </button> | ||
| 33 | + </div> | ||
| 34 | + </div> | ||
| 35 | + | ||
| 36 | + <div class="flex gap-4"> | ||
| 37 | + <div class="w-28"> | ||
| 38 | + <div class="text-sm font-medium text-slate-800">大小</div> | ||
| 39 | + <input v-model.number="icon_size" type="range" min="16" max="64" class="mt-3 w-full" /> | ||
| 40 | + <div class="mt-1 text-xs text-slate-500">{{ icon_size }}px</div> | ||
| 41 | + </div> | ||
| 42 | + <div class="w-28"> | ||
| 43 | + <div class="text-sm font-medium text-slate-800">颜色</div> | ||
| 44 | + <input v-model="icon_color" type="color" class="mt-2 h-9 w-full rounded-md border border-slate-200 bg-white" /> | ||
| 45 | + </div> | ||
| 46 | + </div> | ||
| 47 | + </div> | ||
| 48 | + | ||
| 49 | + <div class="mt-4 grid grid-cols-1 gap-4 sm:grid-cols-2"> | ||
| 50 | + <div class="rounded-xl border border-slate-200 bg-slate-50 p-4"> | ||
| 51 | + <div class="text-sm font-medium text-slate-800">Iconify(推荐)</div> | ||
| 52 | + <div class="mt-3 flex items-center gap-3"> | ||
| 53 | + <Icon :icon="icon_name" :style="{ fontSize: icon_size + 'px', color: icon_color }" /> | ||
| 54 | + <div class="text-xs text-slate-600"> | ||
| 55 | + <div class="font-mono">{{ icon_name }}</div> | ||
| 56 | + <div class="mt-1">按需加载 SVG,无需手动挑选图标包</div> | ||
| 57 | + </div> | ||
| 58 | + </div> | ||
| 59 | + </div> | ||
| 60 | + | ||
| 61 | + <div class="rounded-xl border border-slate-200 bg-slate-50 p-4"> | ||
| 62 | + <div class="text-sm font-medium text-slate-800">Vant / FontAwesome(对比)</div> | ||
| 63 | + <div class="mt-3 flex items-center gap-4"> | ||
| 64 | + <div class="flex items-center gap-2"> | ||
| 65 | + <van-icon name="star-o" :size="icon_size" :color="icon_color" /> | ||
| 66 | + <div class="text-xs text-slate-600">van-icon</div> | ||
| 67 | + </div> | ||
| 68 | + <div class="flex items-center gap-2"> | ||
| 69 | + <font-awesome-icon icon="star" :style="{ fontSize: icon_size + 'px', color: icon_color }" /> | ||
| 70 | + <div class="text-xs text-slate-600">fa</div> | ||
| 71 | + </div> | ||
| 72 | + </div> | ||
| 73 | + </div> | ||
| 74 | + </div> | ||
| 75 | + | ||
| 76 | + <div class="mt-4 rounded-xl border border-slate-200 bg-white p-4"> | ||
| 77 | + <div class="text-sm font-medium text-slate-800">常用图标示例</div> | ||
| 78 | + <div class="mt-3 grid grid-cols-3 gap-3 sm:grid-cols-6"> | ||
| 79 | + <button | ||
| 80 | + v-for="item in quick_icons" | ||
| 81 | + :key="item" | ||
| 82 | + type="button" | ||
| 83 | + class="flex flex-col items-center gap-2 rounded-lg border border-slate-200 bg-slate-50 px-2 py-3 hover:bg-slate-100" | ||
| 84 | + @click="icon_name = item" | ||
| 85 | + > | ||
| 86 | + <Icon :icon="item" class="text-slate-800" style="font-size: 26px;" /> | ||
| 87 | + <div class="w-full truncate text-[11px] text-slate-600">{{ item }}</div> | ||
| 88 | + </button> | ||
| 89 | + </div> | ||
| 90 | + </div> | ||
| 91 | + </div> | ||
| 92 | + </div> | ||
| 93 | + </div> | ||
| 94 | +</template> | ||
| 95 | + | ||
| 96 | +<script setup> | ||
| 97 | +import { ref } from 'vue' | ||
| 98 | + | ||
| 99 | +const icon_name = ref('mdi:home') | ||
| 100 | +const icon_size = ref(32) | ||
| 101 | +const icon_color = ref('#0f172a') | ||
| 102 | + | ||
| 103 | +const quick_icons = [ | ||
| 104 | + 'mdi:home', | ||
| 105 | + 'mdi:account', | ||
| 106 | + 'mdi:bell-outline', | ||
| 107 | + 'mdi:qrcode-scan', | ||
| 108 | + 'lucide:camera', | ||
| 109 | + 'lucide:search', | ||
| 110 | + 'solar:heart-bold', | ||
| 111 | + 'solar:cart-3-bold', | ||
| 112 | + 'tabler:settings', | ||
| 113 | + 'tabler:share', | ||
| 114 | + 'ri:wechat-fill', | ||
| 115 | + 'ph:download-simple-bold' | ||
| 116 | +] | ||
| 117 | + | ||
| 118 | +const resetIcon = () => { | ||
| 119 | + icon_name.value = 'mdi:home' | ||
| 120 | + icon_size.value = 32 | ||
| 121 | + icon_color.value = '#0f172a' | ||
| 122 | +} | ||
| 123 | +</script> | ||
| 124 | + | ||
| 125 | +<style scoped></style> |
| 1 | <!-- | 1 | <!-- |
| 2 | * @Date: 2025-12-18 00:22:07 | 2 | * @Date: 2025-12-18 00:22:07 |
| 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 4 | - * @LastEditTime: 2025-12-22 14:01:23 | 4 | + * @LastEditTime: 2025-12-27 22:17:50 |
| 5 | * @FilePath: /mlaj/src/views/test.vue | 5 | * @FilePath: /mlaj/src/views/test.vue |
| 6 | * @Description: 文件描述 | 6 | * @Description: 文件描述 |
| 7 | --> | 7 | --> |
| ... | @@ -9,7 +9,6 @@ | ... | @@ -9,7 +9,6 @@ |
| 9 | <button @click="setVolume">设置音量</button> | 9 | <button @click="setVolume">设置音量</button> |
| 10 | <audio ref="audioRef" src="https://img.tukuppt.com/newpreview_music/09/03/95/5c8af46b01eb138909.mp3"></audio> | 10 | <audio ref="audioRef" src="https://img.tukuppt.com/newpreview_music/09/03/95/5c8af46b01eb138909.mp3"></audio> |
| 11 | 11 | ||
| 12 | - <!-- 使用封装的星空背景组件 --> | ||
| 13 | <StarryBackground bgImage="https://cdn.ipadbiz.cn/mlaj/images/test-bgg03.jpg" /> | 12 | <StarryBackground bgImage="https://cdn.ipadbiz.cn/mlaj/images/test-bgg03.jpg" /> |
| 14 | </template> | 13 | </template> |
| 15 | 14 | ||
| ... | @@ -21,7 +20,6 @@ const audioRef = ref(null); | ... | @@ -21,7 +20,6 @@ const audioRef = ref(null); |
| 21 | 20 | ||
| 22 | const setVolume = async () => { | 21 | const setVolume = async () => { |
| 23 | try { | 22 | try { |
| 24 | - // 激活音频上下文 | ||
| 25 | await audioRef.value.play(); | 23 | await audioRef.value.play(); |
| 26 | if (typeof WeixinJSBridge !== 'undefined') { | 24 | if (typeof WeixinJSBridge !== 'undefined') { |
| 27 | WeixinJSBridge.invoke('setAudioVolume', { volume: 0.5 }, (res) => { | 25 | WeixinJSBridge.invoke('setAudioVolume', { volume: 0.5 }, (res) => { | ... | ... |
-
Please register or login to post a comment