feat(components): 修改 SectionItem 组件支持 SVG 图标显示
主要变更: - 将图标从 IconFont 组件改为 image 标签 - 支持本地 SVG 资源和远程 URL - 添加默认的"文案"图标 - 优化 icon prop,支持可选传值 - 更新 onboarding 页面使用新组件 技术细节: - 使用 import 导入本地 SVG 资源 - 通过 computed 属性判断本地/远程图标 - 保持原有背景色和圆角样式不变 Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Showing
3 changed files
with
58 additions
and
15 deletions
src/assets/images/icon/文案.svg
0 → 100644
| 1 | +<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1769844240265" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="5808" xmlns:xlink="http://www.w3.org/1999/xlink" width="256" height="256"><path d="M261.6 718.7h192.7c13.4 0 24.8 9.8 27.1 23.2 2.7 16 15.7 23.6 28.4 23 12.2 0.6 24.7-6.5 28.1-21.5 3.4-14.9 14.6-24.7 26.5-24.7h192.7c45.6 0 82.6-37.7 82.6-84.1V251.9c0-46.4-37-84.1-82.6-84.1H564.4c-21 0-39.8 8.7-54.2 22.5-15.2-14.4-35.1-22.5-55.9-22.5H261.6c-45.6 0-82.6 37.7-82.6 84.1v382.7c0 46.5 37 84.1 82.6 84.1z m275.3-500.3l220.2 5.5c15.2 0 27.5 12.6 27.5 28v382.7c0 15.5-12.3 28-27.5 28l-220.2-5.5c-9.3 0-18.3 1.7-26.7 4.8V243.8c3.1-14.9 14.3-25.4 26.7-25.4z m-302.8 33.5c0-15.5 12.3-28 27.5-28l221.1 0.3c12.9 0 23.7 9 26.7 21.1v422.2c-8.6-3-17.6-4.5-26.7-4.5l-221.1-0.3c-15.2 0-27.5-12.6-27.5-28V251.9z" p-id="5809" fill="#1296db"></path><path d="M893 308c-15.2 0-27.5 12.6-27.5 28v392.4c0 15.5-12.3 28-27.5 28H645.3c-29.5 0-56.8 16-71.5 42H443.3c-14.8-26-42-42-71.5-42H179c-15.2 0-27.5-12.6-27.5-28V336c0-15.5-12.3-28-27.5-28s-27.5 12.6-27.5 28v392.4c0 46.4 37 84.1 82.6 84.1h192.7c12.6 0 23.6 8.7 26.7 21 3.1 12.4 14.1 21.1 26.7 21.1h166.9c12.6 0 23.5-8.7 26.7-21.1 3.1-12.4 14.1-21 26.6-21H838c45.6 0 82.6-37.7 82.6-84.1V336c0-15.5-12.4-28-27.6-28z" p-id="5810" fill="#1296db"></path><path d="M302.9 442.5h97.3c15.2 0 27.5 7.1 27.5-8.4s-12.3-28-27.5-28h-97.3c-15.2 0-27.5 12.6-27.5 28 0 15.5 12.3 8.4 27.5 8.4zM302.9 339.5h97.3c15.2 0 27.5-2 27.5-17.5s-12.3-14-27.5-14h-97.3c-15.2 0-27.5-1.5-27.5 14s12.3 17.5 27.5 17.5z" p-id="5811" fill="#1296db"></path></svg> | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | +<!-- | ||
| 2 | + * @Date: 2026-01-30 20:12:45 | ||
| 3 | + * @LastEditors: hookehuyr hookehuyr@gmail.com | ||
| 4 | + * @LastEditTime: 2026-01-31 15:21:37 | ||
| 5 | + * @FilePath: /manulife-weapp/src/components/SectionItem.vue | ||
| 6 | + * @Description: 展示项目组件,包含图标、标题、副标题和右侧箭头 | ||
| 7 | +--> | ||
| 1 | <template> | 8 | <template> |
| 2 | <view class="flex items-center justify-between px-[40rpx] mt-[56rpx] cursor-pointer" @tap="handleClick"> | 9 | <view class="flex items-center justify-between px-[40rpx] mt-[56rpx] cursor-pointer" @tap="handleClick"> |
| 3 | <view class="flex items-center"> | 10 | <view class="flex items-center"> |
| 4 | <view class="w-[96rpx] h-[96rpx] mr-[32rpx] flex items-center justify-center bg-gray-50 rounded-full"> | 11 | <view class="w-[96rpx] h-[96rpx] mr-[32rpx] flex items-center justify-center bg-gray-50 rounded-full"> |
| 5 | - <IconFont :name="icon" class="text-blue-600" size="32" /> | 12 | + <image |
| 13 | + :src="iconUrl" | ||
| 14 | + class="w-[48rpx] h-[48rpx]" | ||
| 15 | + mode="aspectFit" | ||
| 16 | + /> | ||
| 6 | </view> | 17 | </view> |
| 7 | <view class="flex flex-col"> | 18 | <view class="flex flex-col"> |
| 8 | <text class="text-[#1f2937] text-[28rpx] font-normal leading-[40rpx]">{{ title }}</text> | 19 | <text class="text-[#1f2937] text-[28rpx] font-normal leading-[40rpx]">{{ title }}</text> |
| 9 | <text class="text-[#6b7280] text-[24rpx] mt-[8rpx] leading-[32rpx]">{{ subtitle }}</text> | 20 | <text class="text-[#6b7280] text-[24rpx] mt-[8rpx] leading-[32rpx]">{{ subtitle }}</text> |
| 10 | </view> | 21 | </view> |
| 11 | </view> | 22 | </view> |
| 12 | - <IconFont name="rectRight" class="text-gray-400" size="16" /> | 23 | + <IconFont name="rect-right" class="text-gray-400" size="16" /> |
| 13 | </view> | 24 | </view> |
| 14 | </template> | 25 | </template> |
| 15 | 26 | ||
| 16 | <script setup> | 27 | <script setup> |
| 28 | +import { computed } from 'vue' | ||
| 17 | import IconFont from '@/components/IconFont.vue' | 29 | import IconFont from '@/components/IconFont.vue' |
| 30 | +import defaultIcon from '@/assets/images/icon/文案.svg' | ||
| 18 | 31 | ||
| 19 | /** | 32 | /** |
| 20 | * Section Item Component | 33 | * Section Item Component |
| 21 | * @description 单个展示项目组件,包含图标、标题、副标题和右侧箭头 | 34 | * @description 单个展示项目组件,包含图标、标题、副标题和右侧箭头 |
| 35 | + * @example | ||
| 36 | + * <SectionItem | ||
| 37 | + * title="产品资料" | ||
| 38 | + * subtitle="查看全部产品资料" | ||
| 39 | + * /> | ||
| 40 | + * <!-- 默认使用文案图标 --> | ||
| 41 | + * | ||
| 42 | + * <SectionItem | ||
| 43 | + * :icon="remoteIconUrl" | ||
| 44 | + * title="远程图标" | ||
| 45 | + * subtitle="从接口获取的图标" | ||
| 46 | + * /> | ||
| 22 | */ | 47 | */ |
| 23 | -defineProps({ | 48 | +const props = defineProps({ |
| 24 | /** | 49 | /** |
| 25 | - * 图标名称(对应 IconFont 组件的 name) | 50 | + * 图标 |
| 26 | - * @example 'Edit', 'Check', 'Order' | 51 | + * - 不传或传空字符串:使用默认的"文案"图标 |
| 52 | + * - 传远程 URL(http/https 开头):使用远程图片 | ||
| 53 | + * @example undefined, '', 'https://example.com/icon.png' | ||
| 27 | */ | 54 | */ |
| 28 | icon: { | 55 | icon: { |
| 29 | type: String, | 56 | type: String, |
| 30 | - required: true | 57 | + default: '' |
| 31 | }, | 58 | }, |
| 32 | /** | 59 | /** |
| 33 | * 标题 | 60 | * 标题 |
| ... | @@ -52,6 +79,21 @@ defineProps({ | ... | @@ -52,6 +79,21 @@ defineProps({ |
| 52 | } | 79 | } |
| 53 | }) | 80 | }) |
| 54 | 81 | ||
| 82 | +/** | ||
| 83 | + * 计算图标 URL | ||
| 84 | + * @description 判断是远程 URL 还是使用默认图标 | ||
| 85 | + * @returns {string} 图标的完整路径 | ||
| 86 | + */ | ||
| 87 | +const iconUrl = computed(() => { | ||
| 88 | + // 如果是远程 URL(http/https 开头),直接返回 | ||
| 89 | + if (props.icon && (props.icon.startsWith('http://') || props.icon.startsWith('https://'))) { | ||
| 90 | + return props.icon | ||
| 91 | + } | ||
| 92 | + | ||
| 93 | + // 否则使用默认的本地 SVG 图标 | ||
| 94 | + return defaultIcon | ||
| 95 | +}) | ||
| 96 | + | ||
| 55 | const emit = defineEmits(['click']) | 97 | const emit = defineEmits(['click']) |
| 56 | 98 | ||
| 57 | /** | 99 | /** | ... | ... |
| ... | @@ -34,17 +34,17 @@ const sections = shallowRef([ | ... | @@ -34,17 +34,17 @@ const sections = shallowRef([ |
| 34 | title: '入职前', | 34 | title: '入职前', |
| 35 | items: [ | 35 | items: [ |
| 36 | { | 36 | { |
| 37 | - icon: 'edit', | 37 | + icon: '', |
| 38 | title: '考试报名', | 38 | title: '考试报名', |
| 39 | subtitle: '报名参加代理人资格考试' | 39 | subtitle: '报名参加代理人资格考试' |
| 40 | }, | 40 | }, |
| 41 | { | 41 | { |
| 42 | - icon: 'find', | 42 | + icon: '', |
| 43 | title: '面试结果查询', | 43 | title: '面试结果查询', |
| 44 | subtitle: '查看面试状态和结果' | 44 | subtitle: '查看面试状态和结果' |
| 45 | }, | 45 | }, |
| 46 | { | 46 | { |
| 47 | - icon: 'order', | 47 | + icon: '', |
| 48 | title: '入职材料提交', | 48 | title: '入职材料提交', |
| 49 | subtitle: '上传入职所需证件和资料' | 49 | subtitle: '上传入职所需证件和资料' |
| 50 | } | 50 | } |
| ... | @@ -54,17 +54,17 @@ const sections = shallowRef([ | ... | @@ -54,17 +54,17 @@ const sections = shallowRef([ |
| 54 | title: '入职中', | 54 | title: '入职中', |
| 55 | items: [ | 55 | items: [ |
| 56 | { | 56 | { |
| 57 | - icon: 'clock', | 57 | + icon: '', |
| 58 | title: '各个进度时间线表格', | 58 | title: '各个进度时间线表格', |
| 59 | subtitle: '查看入职流程关键节点' | 59 | subtitle: '查看入职流程关键节点' |
| 60 | }, | 60 | }, |
| 61 | { | 61 | { |
| 62 | - icon: 'checklist', | 62 | + icon: '', |
| 63 | title: '待办事项清单', | 63 | title: '待办事项清单', |
| 64 | subtitle: '你需要完成的任务列表' | 64 | subtitle: '你需要完成的任务列表' |
| 65 | }, | 65 | }, |
| 66 | { | 66 | { |
| 67 | - icon: 'check', | 67 | + icon: '', |
| 68 | title: '签署合同', | 68 | title: '签署合同', |
| 69 | subtitle: '电子合同在线签署' | 69 | subtitle: '电子合同在线签署' |
| 70 | } | 70 | } |
| ... | @@ -74,17 +74,17 @@ const sections = shallowRef([ | ... | @@ -74,17 +74,17 @@ const sections = shallowRef([ |
| 74 | title: '入职后', | 74 | title: '入职后', |
| 75 | items: [ | 75 | items: [ |
| 76 | { | 76 | { |
| 77 | - icon: 'star', | 77 | + icon: '', |
| 78 | title: '新人培训', | 78 | title: '新人培训', |
| 79 | subtitle: '参加新人岗前培训课程' | 79 | subtitle: '参加新人岗前培训课程' |
| 80 | }, | 80 | }, |
| 81 | { | 81 | { |
| 82 | - icon: 'top', | 82 | + icon: '', |
| 83 | title: '业绩目标设定', | 83 | title: '业绩目标设定', |
| 84 | subtitle: '制定首月业绩目标' | 84 | subtitle: '制定首月业绩目标' |
| 85 | }, | 85 | }, |
| 86 | { | 86 | { |
| 87 | - icon: 'playCircleFill', | 87 | + icon: '', |
| 88 | title: '团队介绍', | 88 | title: '团队介绍', |
| 89 | subtitle: '了解你的团队和主管' | 89 | subtitle: '了解你的团队和主管' |
| 90 | } | 90 | } | ... | ... |
-
Please register or login to post a comment