Skip to content

Commit

Permalink
feat(projects): 新增自定义svg图标动态渲染
Browse files Browse the repository at this point in the history
  • Loading branch information
honghuangdc committed Mar 12, 2022
1 parent f5a043b commit f83c7b5
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 60 deletions.
1 change: 0 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,4 @@ lib
.vscode
.local
package.json
components.d.ts
!.env-config.ts
21 changes: 0 additions & 21 deletions build/plugins/iconify.ts

This file was deleted.

4 changes: 2 additions & 2 deletions components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ declare module 'vue' {
IconAntDesignCloseOutlined: typeof import('~icons/ant-design/close-outlined')['default'];
IconAntDesignEnterOutlined: typeof import('~icons/ant-design/enter-outlined')['default'];
IconAntDesignSettingOutlined: typeof import('~icons/ant-design/setting-outlined')['default'];
IconCustomActivity: typeof import('~icons/custom/activity')['default'];
IconCustomAvatar: typeof import('~icons/custom/avatar')['default'];
IconCustomEmptyData: typeof import('~icons/custom/empty-data')['default'];
IconCustomCast: typeof import('~icons/custom/cast')['default'];
IconCustomLogo: typeof import('~icons/custom/logo')['default'];
IconCustomLogoFill: typeof import('~icons/custom/logo-fill')['default'];
IconCustomNetworkError: typeof import('~icons/custom/network-error')['default'];
IconGridiconsFullscreen: typeof import('~icons/gridicons/fullscreen')['default'];
IconGridiconsFullscreenExit: typeof import('~icons/gridicons/fullscreen-exit')['default'];
IconIcOutlineCheck: typeof import('~icons/ic/outline-check')['default'];
Expand Down
4 changes: 0 additions & 4 deletions src/components/business/index.ts

This file was deleted.

7 changes: 0 additions & 7 deletions src/components/common/index.ts

This file was deleted.

8 changes: 0 additions & 8 deletions src/components/custom/index.ts

This file was deleted.

3 changes: 0 additions & 3 deletions src/components/index.ts

This file was deleted.

29 changes: 15 additions & 14 deletions src/views/plugin/icon/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,18 @@
</template>
</n-card>
<n-card title="SvgIcon 示例" class="mt-10px shadow-sm rounded-16px">
<div class="pb-12px text-16px">在src/assets下的svg文件,通过在template里面以 icon-custom-{文件名} 渲染</div>
<div class="pb-12px text-16px">
在src/assets/svg文件夹下的svg文件,通过在template里面以 icon-custom-{文件名} 直接渲染,动态渲染需要import组件
</div>
<div class="grid grid-cols-10">
<div class="mt-5px flex-x-center">
<icon-custom-activity class="text-30px" />
<icon-custom-activity class="text-40px text-success" />
</div>
<div class="mt-5px flex-x-center">
<icon-custom-at-sign class="text-30px text-primary" />
<icon-custom-cast class="text-20px text-error" />
</div>
<div class="mt-5px flex-x-center">
<icon-custom-cast class="text-18px text-info" />
</div>
<div class="mt-5px flex-x-center">
<icon-custom-chrome class="text-48px text-success" />
</div>
<div class="mt-5px flex-x-center">
<icon-custom-copy class="text-30px text-error" />
</div>
<div class="mt-5px flex-x-center">
<icon-custom-wind class="text-30px text-warning" />
<div v-for="(item, index) in customIcons" :key="index" class="mt-5px flex-x-center">
<component :is="item" class="text-30px text-primary" />
</div>
</div>
</n-card>
Expand All @@ -46,7 +39,15 @@
import { ref } from 'vue';
import { Icon } from '@iconify/vue';
import { icons } from './icons';
import CustomActivity from '~icons/custom/activity';
import CustomAtSign from '~icons/custom/at-sign';
import CustomCast from '~icons/custom/cast';
import CustomChrome from '~icons/custom/chrome';
import CustomCopy from '~icons/custom/copy';
import CustomWind from '~icons/custom/wind';
const selectValue = ref('');
const customIcons = [CustomActivity, CustomAtSign, CustomCast, CustomChrome, CustomCopy, CustomWind];
</script>
<style scoped></style>

0 comments on commit f83c7b5

Please sign in to comment.