Skip to content

Commit

Permalink
refactor: modify icons usage
Browse files Browse the repository at this point in the history
  • Loading branch information
chansee97 committed Apr 3, 2024
1 parent 609a26b commit 09e4d7d
Show file tree
Hide file tree
Showing 30 changed files with 69 additions and 81 deletions.
2 changes: 1 addition & 1 deletion .env.prod
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# 是否开启压缩资源
VITE_COMPRESS_OPEN=N
VITE_BUILD_COMPRESS=N

# 压缩算法 gzip | brotliCompress | deflate | deflateRaw
VITE_COMPRESS_TYPE=gzip
Expand Down
34 changes: 17 additions & 17 deletions build/plugins.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import path from 'node:path'
import UnoCSS from '@unocss/vite'
import vue from '@vitejs/plugin-vue'
import vueJsx from '@vitejs/plugin-vue-jsx'
Expand All @@ -7,13 +6,11 @@ import AutoImport from 'unplugin-auto-import/vite'
import { NaiveUiResolver } from 'unplugin-vue-components/resolvers'
import viteCompression from 'vite-plugin-compression'
import Icons from 'unplugin-icons/vite'
import { FileSystemIconLoader } from 'unplugin-icons/loaders'

// https://github.com/antfu/unplugin-icons
import IconsResolver from 'unplugin-icons/resolver'

// https://github.com/vbenjs/vite-plugin-svg-icons/blob/main/README.zh_CN.md
import { createSvgIconsPlugin } from 'vite-plugin-svg-icons'

/**
* @description: 设置vite插件配置
* @param {*} env - 环境变量配置
Expand Down Expand Up @@ -43,28 +40,31 @@ export function createVitePlugins(env: ImportMetaEnv) {
// auto import components lib
Components({
dts: 'src/typings/components.d.ts',
resolvers: [IconsResolver(), NaiveUiResolver()],
resolvers: [
IconsResolver({
prefix: false,
customCollections: [
'svg-icons',
],
}),
NaiveUiResolver(),
],
}),

// auto import iconify's icons
Icons({
defaultStyle: 'display:inline-block',
compiler: 'vue3',
customCollections: {
'svg-icons': FileSystemIconLoader(
'src/assets/svg-icons',
svg => svg.replace(/^<svg /, '<svg fill="currentColor" width="1.2em" height="1.2em"'),
),
},
}),

// auto use svg icon
createSvgIconsPlugin({
// 指定需要缓存的图标文件夹
iconDirs: [path.resolve(__dirname, '../src/assets/icons')],
// 指定symbolId格式
symbolId: 'icon-[dir]-[name]',
// inject: 'body-last',
// customDomId: '__svg__icons__dom__',
}),

]
// use compression
if (env.VITE_COMPRESS_OPEN === 'Y') {
if (env.VITE_BUILD_COMPRESS === 'Y') {
const { VITE_COMPRESS_TYPE = 'gzip' } = env
plugins.push(viteCompression({
algorithm: VITE_COMPRESS_TYPE, // 压缩算法
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@
"vite": "^5.1.6",
"vite-bundle-visualizer": "^1.1.0",
"vite-plugin-compression": "^0.5.1",
"vite-plugin-svg-icons": "^2.0.1",
"vue-tsc": "^2.0.6"
},
"simple-git-hooks": {
Expand Down
File renamed without changes
File renamed without changes
6 changes: 3 additions & 3 deletions src/components/common/DarkModeSwitch.vue
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ function renderLabel(option: any) {
<template>
<n-popselect :value="appStore.storeColorMode" :render-label="renderLabel" :options="options" trigger="click" @update:value="appStore.setColorMode">
<CommonWrapper>
<i-icon-park-outline-moon v-if="appStore.storeColorMode === 'dark'" />
<i-icon-park-outline-sun-one v-if="appStore.storeColorMode === 'light'" />
<i-icon-park-outline-laptop-computer v-if="appStore.storeColorMode === 'auto'" />
<icon-park-outline-moon v-if="appStore.storeColorMode === 'dark'" />
<icon-park-outline-sun-one v-if="appStore.storeColorMode === 'light'" />
<icon-park-outline-laptop-computer v-if="appStore.storeColorMode === 'auto'" />
</CommonWrapper>
</n-popselect>
</template>
Expand Down
2 changes: 1 addition & 1 deletion src/components/custom/CopyText.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const text = useVModel(props, 'modelValue', emit)
{{ text }}
</n-ellipsis>
<span v-copy="text" class="copy_icon">
<i-icon-park-outline-copy />
<icon-park-outline-copy />
</span>
</div>
</template>
Expand Down
4 changes: 2 additions & 2 deletions src/components/custom/IconSelect/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function handleSelectIcon(icon: string) {
<template #trigger>
<n-input v-model:value="currentIcon" readonly placeholder="选择目标图标">
<template #suffix>
<e-icon :icon="currentIcon || 'icon-park-outline:all-application'" />
<nova-icon :icon="currentIcon || 'icon-park-outline:all-application'" />
</template>
</n-input>
</template>
Expand All @@ -33,7 +33,7 @@ function handleSelectIcon(icon: string) {
class="border border-gray-200 m-2px p-5px flex-center"
@click="handleSelectIcon(item)"
>
<e-icon :icon="item" :size="24" />
<nova-icon :icon="item" :size="24" />
</div>
</div>
<n-empty v-else class="w-full" description="没有符合条件的图标" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,23 @@
import { Icon } from '@iconify/vue'
interface iconPorps {
/* 图标名称 */
icon?: string
/* 图标颜色 */
color?: string
/* 图标大小 */
size?: number
/* 图标深度 */
depth?: 1 | 2 | 3 | 4 | 5
}
const props = withDefaults(defineProps<iconPorps>(), {
size: 18,
icon: 'icon-park-outline:baby-feet',
})
</script>

<template>
<n-icon
v-if="props.icon"
:size="props.size"
:depth="props.depth"
:color="props.color"
Expand Down
2 changes: 1 addition & 1 deletion src/layouts/components/common/BackTop.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<n-tooltip placement="left" trigger="hover">
<template #trigger>
<div wh-full flex-center>
<i-icon-park-outline-to-top />
<icon-park-outline-to-top />
</div>
</template>
<span>返回顶部</span>
Expand Down
2 changes: 1 addition & 1 deletion src/layouts/components/common/NoticeList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ interface Emits {
</n-ellipsis>
</template>
<template #avatar>
<e-icon :icon="item.icon" :size="30" class="c-primary" />
<nova-icon :icon="item.icon" :size="30" class="c-primary" />
</template>
<template v-if="item.tagTitle" #header-extra>
<n-tag :bordered="false" :type="item.tagType" size="small">
Expand Down
2 changes: 1 addition & 1 deletion src/layouts/components/header/Breadcrumb.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const appStore = useAppStore()
class="flex-center gap-2 cursor-pointer split"
@click="router.push(item.path)"
>
<e-icon v-if="appStore.showBreadcrumbIcon" :icon="item.meta.icon" />
<nova-icon v-if="appStore.showBreadcrumbIcon" :icon="item.meta.icon" />
<span class="whitespace-nowrap">{{ item.meta.title }}</span>
</n-el>
</TransitionGroup>
Expand Down
4 changes: 2 additions & 2 deletions src/layouts/components/header/CollapaseButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ const appStore = useAppStore()
<n-tooltip placement="bottom" trigger="hover">
<template #trigger>
<CommonWrapper @click="appStore.toggleCollapse()">
<i-icon-park-outline-menu-unfold v-if="appStore.collapsed" />
<i-icon-park-outline-menu-fold v-else />
<icon-park-outline-menu-unfold v-if="appStore.collapsed" />
<icon-park-outline-menu-fold v-else />
</CommonWrapper>
</template>
<span>切换侧边栏</span>
Expand Down
4 changes: 2 additions & 2 deletions src/layouts/components/header/FullScreen.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ const appStore = useAppStore()
<n-tooltip placement="bottom" trigger="hover">
<template #trigger>
<CommonWrapper @click="appStore.toggleFullScreen()">
<i-icon-park-outline-off-screen-two v-if="appStore.fullScreen" />
<i-icon-park-outline-full-screen-two v-else />
<icon-park-outline-off-screen-two v-if="appStore.fullScreen" />
<icon-park-outline-full-screen-two v-else />
</CommonWrapper>
</template>
<span>全屏</span>
Expand Down
2 changes: 1 addition & 1 deletion src/layouts/components/header/Notices.vue
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ const groupMessage = computed(() => {
<template #trigger>
<CommonWrapper>
<n-badge :value="massageCount" :max="99" style="color: unset">
<i-icon-park-outline-remind />
<icon-park-outline-remind />
</n-badge>
</CommonWrapper>
</template>
Expand Down
2 changes: 1 addition & 1 deletion src/layouts/components/header/Search.vue
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ function handleSelect(value: string) {
>
<template #prefix>
<n-icon>
<i-icon-park-outline-search />
<icon-park-outline-search />
</n-icon>
</template>
</n-auto-complete>
Expand Down
2 changes: 1 addition & 1 deletion src/layouts/components/header/Setting.vue
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ function resetSetting() {
<template #trigger>
<CommonWrapper @click="openSetting">
<div>
<i-icon-park-outline-setting-two />
<icon-park-outline-setting-two />
<n-drawer v-model:show="drawerActive" :width="300">
<n-drawer-content title="系统设置" closable>
<n-space vertical>
Expand Down
5 changes: 1 addition & 4 deletions src/layouts/components/sider/Logo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@ const name = import.meta.env.VITE_APP_NAME
class="h-60px text-xl flex-center cursor-pointer"
@click="router.push('/')"
>
<SvgIcon
name="logo"
:size="32"
/>
<svg-icons-logo class="text-1.5em" />
<span
v-show="!appStore.collapsed"
class="mx-3 text-ellipsis overflow-hidden whitespace-nowrap"
Expand Down
2 changes: 1 addition & 1 deletion src/layouts/components/tab/Reload.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function handleReload() {
<n-tooltip placement="bottom" trigger="hover">
<template #trigger>
<CommonWrapper @click="handleReload">
<i-icon-park-outline-refresh :class="{ 'animate-spin': loading }" />
<icon-park-outline-refresh :class="{ 'animate-spin': loading }" />
</CommonWrapper>
</template>
<span>刷新页面</span>
Expand Down
4 changes: 2 additions & 2 deletions src/layouts/components/tab/TabBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ function handleDropTabs(key: string, option: any) {
@contextmenu="handleContextMenu($event, item)"
>
<div class="flex-x-center gap-2">
<e-icon :icon="item.meta.icon" /> {{ item.meta.title }}
<nova-icon :icon="item.meta.icon" /> {{ item.meta.title }}
</div>
</n-tab>
<template #suffix>
Expand All @@ -144,7 +144,7 @@ function handleDropTabs(key: string, option: any) {
@select="handleDropTabs"
>
<CommonWrapper>
<i-icon-park-outline-application-menu />
<icon-park-outline-application-menu />
</CommonWrapper>
</n-dropdown>
</template>
Expand Down
1 change: 0 additions & 1 deletion src/modules/assets.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import 'uno.css'
import '@/styles/index.css'
import 'virtual:svg-icons-register'

// 全局引入的静态资源
export function install() {
Expand Down
2 changes: 1 addition & 1 deletion src/typings/env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ interface ImportMetaEnv {
/** 开启请求代理 */
readonly VITE_HTTP_PROXY?: 'Y' | 'N'
/** 是否开启打包压缩 */
readonly VITE_COMPRESS_OPEN?: 'Y' | 'N'
readonly VITE_BUILD_COMPRESS?: 'Y' | 'N'
/** 压缩算法类型 */
readonly VITE_COMPRESS_TYPE?:
| 'gzip'
Expand Down
6 changes: 0 additions & 6 deletions src/typings/package.d.ts

This file was deleted.

8 changes: 4 additions & 4 deletions src/views/dashboard/monitor/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const tableData = [
color="#de4307"
size="42"
>
<i-icon-park-outline-chart-histogram />
<icon-park-outline-chart-histogram />
</n-icon>
</n-space>
<template #footer>
Expand Down Expand Up @@ -82,7 +82,7 @@ const tableData = [
color="#ffb549"
size="42"
>
<i-icon-park-outline-chart-graph />
<icon-park-outline-chart-graph />
</n-icon>
</n-space>
<template #footer>
Expand Down Expand Up @@ -114,7 +114,7 @@ const tableData = [
color="#1687a7"
size="42"
>
<i-icon-park-outline-average />
<icon-park-outline-average />
</n-icon>
</n-space>
<template #footer>
Expand Down Expand Up @@ -146,7 +146,7 @@ const tableData = [
color="#42218E"
size="42"
>
<i-icon-park-outline-chart-pie />
<icon-park-outline-chart-pie />
</n-icon>
</n-space>
<template #footer>
Expand Down
12 changes: 6 additions & 6 deletions src/views/dashboard/workbench/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const { userInfo } = useAuthStore()
<template #avatar>
<n-el>
<n-icon-wrapper :size="46" color="var(--success-color)" :border-radius="999">
<e-icon :size="26" icon="icon-park-outline:user" />
<nova-icon :size="26" icon="icon-park-outline:user" />
</n-icon-wrapper>
</n-el>
</template>
Expand All @@ -47,7 +47,7 @@ const { userInfo } = useAuthStore()
<template #avatar>
<n-el>
<n-icon-wrapper :size="46" color="var(--success-color)" :border-radius="999">
<e-icon :size="26" icon="icon-park-outline:every-user" />
<nova-icon :size="26" icon="icon-park-outline:every-user" />
</n-icon-wrapper>
</n-el>
</template>
Expand All @@ -65,7 +65,7 @@ const { userInfo } = useAuthStore()
<template #avatar>
<n-el>
<n-icon-wrapper :size="46" color="var(--success-color)" :border-radius="999">
<e-icon :size="26" icon="icon-park-outline:preview-open" />
<nova-icon :size="26" icon="icon-park-outline:preview-open" />
</n-icon-wrapper>
</n-el>
</template>
Expand All @@ -83,7 +83,7 @@ const { userInfo } = useAuthStore()
<template #avatar>
<n-el>
<n-icon-wrapper :size="46" color="var(--success-color)" :border-radius="999">
<e-icon :size="26" icon="icon-park-outline:star" />
<nova-icon :size="26" icon="icon-park-outline:star" />
</n-icon-wrapper>
</n-el>
</template>
Expand Down Expand Up @@ -237,7 +237,7 @@ const { userInfo } = useAuthStore()
订单数
</n-text>
<n-icon-wrapper :size="46" :border-radius="999">
<e-icon :size="26" icon="icon-park-outline:all-application" />
<nova-icon :size="26" icon="icon-park-outline:all-application" />
</n-icon-wrapper>
<n-text strong class="text-2xl">
1,234,123
Expand All @@ -253,7 +253,7 @@ const { userInfo } = useAuthStore()
</n-text>
<n-el>
<n-icon-wrapper :size="46" color="var(--warning-color)" :border-radius="999">
<e-icon :size="26" icon="icon-park-outline:list-bottom" />
<nova-icon :size="26" icon="icon-park-outline:list-bottom" />
</n-icon-wrapper>
</n-el>
<n-text strong class="text-2xl">
Expand Down
2 changes: 1 addition & 1 deletion src/views/list/cardList/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ const radioDate = [
color="#de4307"
size="24"
>
<i-icon-park-outline-chart-histogram />
<icon-park-outline-chart-histogram />
</n-icon>
</template>
<template #action>
Expand Down
Loading

0 comments on commit 09e4d7d

Please sign in to comment.