Skip to content

Commit

Permalink
refactor: 更改 svg icons 目录结构
Browse files Browse the repository at this point in the history
pany-ang committed Nov 22, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 17b9ebb commit 23f5dc9
Showing 21 changed files with 8 additions and 9 deletions.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
3 changes: 0 additions & 3 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -5,7 +5,6 @@ import { router } from "@/router"
import { createApp } from "vue"
import "@/router/permission"
// load
import { loadSvg } from "@/assets/icons"
import { loadDirectives } from "@/directives"
import { loadPlugins } from "@/plugins"
// css
@@ -21,8 +20,6 @@ const app = createApp(App)

// 加载插件
loadPlugins(app)
// 加载全局 SVG
loadSvg(app)
// 加载自定义指令
loadDirectives(app)

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { App } from "vue"
import * as ElementPlusIconsVue from "@element-plus/icons-vue"

export function loadElementPlusIcon(app: App) {
export function loadElementPlusIcons(app: App) {
// 注册所有 Element Plus Icon
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
app.component(key, component)
6 changes: 4 additions & 2 deletions src/plugins/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import type { App } from "vue"
import { loadElementPlus } from "./element-plus"
import { loadElementPlusIcon } from "./element-plus-icon"
import { loadElementPlusIcons } from "./element-plus-icons"
import { loadSvgIcons } from "./svg-icons"
import { loadVxeTable } from "./vxe-table"

export function loadPlugins(app: App) {
loadElementPlus(app)
loadElementPlusIcon(app)
loadElementPlusIcons(app)
loadVxeTable(app)
loadSvgIcons(app)
}
Original file line number Diff line number Diff line change
@@ -2,6 +2,6 @@ import type { App } from "vue"
import SvgIcon from "@/components/SvgIcon/index.vue" // Svg Component
import "virtual:svg-icons-register"

export function loadSvg(app: App) {
export function loadSvgIcons(app: App) {
app.component("SvgIcon", SvgIcon)
}
2 changes: 1 addition & 1 deletion types/vue-router.d.ts
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@ declare module "vue-router" {
*/
title?: string
/**
* 设置该路由的图标,记得将 svg 导入 @/assets/icons/svg
* 设置该路由的图标,记得将 svg 导入 @/assets/icons
*/
svgIcon?: string
/**
2 changes: 1 addition & 1 deletion vite.config.ts
Original file line number Diff line number Diff line change
@@ -91,7 +91,7 @@ export default defineConfig(({ mode }) => {
svgLoader({ defaultImport: "url" }),
// 生成 SVG 雪碧图
createSvgIconsPlugin({
iconDirs: [resolve(root, "src/assets/icons/svg")],
iconDirs: [resolve(root, "src/assets/icons")],
symbolId: "icon-[dir]-[name]"
}),
// 原子化 CSS

0 comments on commit 23f5dc9

Please sign in to comment.