搞定图标

This commit is contained in:
Kane 2023-01-07 11:57:10 +08:00
parent 0b79a94bda
commit 82edc407db
6 changed files with 3477 additions and 13 deletions

File diff suppressed because it is too large Load Diff

View File

@ -30,6 +30,7 @@
"@vue/cli-service": "~5.0.0", "@vue/cli-service": "~5.0.0",
"eslint": "^7.32.0", "eslint": "^7.32.0",
"eslint-plugin-vue": "^8.0.3", "eslint-plugin-vue": "^8.0.3",
"svg-sprite-loader": "^2.0.3",
"vue-cli-plugin-element-plus": "~0.0.13" "vue-cli-plugin-element-plus": "~0.0.13"
} }
} }

View File

@ -2,7 +2,7 @@
* @Author: Kane * @Author: Kane
* @Date: 2023-01-04 11:30:33 * @Date: 2023-01-04 11:30:33
* @LastEditors: Kane * @LastEditors: Kane
* @LastEditTime: 2023-01-06 19:24:41 * @LastEditTime: 2023-01-07 11:53:26
* @FilePath: \admin_system\src\layout\components\Aside.vue * @FilePath: \admin_system\src\layout\components\Aside.vue
* @Description: * @Description:
* *
@ -16,16 +16,23 @@
<template v-if="hasOnlyChild(route.children)"> <template v-if="hasOnlyChild(route.children)">
<!-- 当只有一个子路由时直接渲染子路由 --> <!-- 当只有一个子路由时直接渲染子路由 -->
<el-menu-item :index="route.children[0].path"> <el-menu-item :index="route.children[0].path">
<div>{{ route.children[0].meta && route.children[0].meta.title }}</div> <component :is="route.children[0].meta.icon" class="icons">
</component>
<!-- <el-icon v-html="route.children[0].meta && route.children[0].meta.icon"></el-icon> -->
<template #title>{{ route.children[0].meta && route.children[0].meta.title }}</template>
</el-menu-item> </el-menu-item>
</template> </template>
<template v-else> <template v-else>
<!-- 不是一个子路由时有可能没有子路由或者是多个子路由 --> <!-- 不是一个子路由时有可能没有子路由或者是多个子路由 -->
<el-sub-menu v-if="route.children && route.children.length" :index="route.path"> <el-sub-menu v-if="route.children && route.children.length" :index="route.path">
<template #title>{{ route.meta && route.meta.title }}</template> <template #title>
<component :is="route.children[0].meta.icon" class="icons"></component>
<span>{{ route.meta && route.meta.title }}</span>
</template>
<template v-for="child in route.children" :key="child.path"> <template v-for="child in route.children" :key="child.path">
<el-menu-item v-if="!child.hidden" :index="child.path"> <el-menu-item v-if="!child.hidden" :index="child.path">
<div>{{ child.meta && child.meta.title }}</div> <component :is="route.children[0].meta.icon" class="icons"></component>
<template #title>{{ child.meta && child.meta.title }}</template>
</el-menu-item> </el-menu-item>
</template> </template>
</el-sub-menu> </el-sub-menu>
@ -33,7 +40,6 @@
</template> </template>
</template> </template>
</el-menu> </el-menu>
<a href="#/newsedit">测试</a>
</template> </template>
<script> <script>
@ -99,6 +105,12 @@ export default {
/* background-color: #344a5f !important; */ /* background-color: #344a5f !important; */
} }
.icons {
width: 1em;
height: 1em;
margin-right: 8px;
}
/* .el-menu-item { /* .el-menu-item {
padding: 5px; padding: 5px;
border: 1px solid red; border: 1px solid red;

View File

@ -2,7 +2,7 @@
* @Author: Kane * @Author: Kane
* @Date: 2022-12-14 15:12:46 * @Date: 2022-12-14 15:12:46
* @LastEditors: Kane * @LastEditors: Kane
* @LastEditTime: 2023-01-06 20:57:02 * @LastEditTime: 2023-01-07 11:23:18
* @FilePath: \admin_system\src\main.js * @FilePath: \admin_system\src\main.js
* @Description: * @Description:
* *
@ -25,11 +25,17 @@ import("element-plus/dist/index.css");
// import "./assets/css/colors.css"; // import "./assets/css/colors.css";
import ElementPlus from "element-plus"; import ElementPlus from "element-plus";
import * as ElementPlusIconsVue from "@element-plus/icons-vue";
import SvgIcon from "./components/svg/SvgIcon"; import SvgIcon from "./components/svg/SvgIcon";
const app = createApp(App); const app = createApp(App);
app.component("SvgIcon", SvgIcon); app.component("SvgIcon", SvgIcon);
for (const [key, component] of Object.entries(ElementPlusIconsVue))
{
app.component(key, component);
}
app.use(ElementPlus); app.use(ElementPlus);
app.use(store).use(router).mount('#app'); app.use(store).use(router).mount('#app');

View File

@ -2,7 +2,7 @@
* @Author: Kane * @Author: Kane
* @Date: 2022-12-14 15:12:46 * @Date: 2022-12-14 15:12:46
* @LastEditors: Kane * @LastEditors: Kane
* @LastEditTime: 2023-01-06 19:06:51 * @LastEditTime: 2023-01-07 11:54:38
* @FilePath: \admin_system\src\router\index.js * @FilePath: \admin_system\src\router\index.js
* @Description: 定义应用路由配置 * @Description: 定义应用路由配置
* *
@ -38,14 +38,16 @@ const routes = [
path: "/console", path: "/console",
name: "Console", name: "Console",
meta: { meta: {
title: "总览" title: "总览",
icon: "house",
}, },
children: [ children: [
{ {
path: "/desktop", path: "/desktop",
name: "DeskTop", name: "DeskTop",
meta: { meta: {
title: "工作台" title: "工作台",
icon: "house",
}, },
component: () => import("../views/overview/OverView.vue"), component: () => import("../views/overview/OverView.vue"),
}, },
@ -57,13 +59,15 @@ const routes = [
name: "News", name: "News",
meta: { meta: {
title: "信息管理", title: "信息管理",
icon: "edit",
}, },
children: [ children: [
{ {
path: "/newsIndex", path: "/newsIndex",
name: "NewsIndex", name: "NewsIndex",
meta: { meta: {
title: "信息列表" title: "信息列表",
icon: "edit",
}, },
component: () => import("../views/news/News.vue"), component: () => import("../views/news/News.vue"),
}, },
@ -71,7 +75,8 @@ const routes = [
path: "/newsedit", path: "/newsedit",
name: "NewsEdit", name: "NewsEdit",
meta: { meta: {
title: "信息编辑" title: "信息编辑",
icon: "edit",
}, },
component: () => import("../views/news/NewsEdit.vue"), component: () => import("../views/news/NewsEdit.vue"),
}, },
@ -83,6 +88,7 @@ const routes = [
name: "User", name: "User",
meta: { meta: {
title: "人员管理", title: "人员管理",
icon: "edit",
}, },
component: () => import("../layout/Index.vue"), component: () => import("../layout/Index.vue"),
}, },

View File

@ -2,7 +2,7 @@
* @Author: Kane * @Author: Kane
* @Date: 2022-12-17 11:08:18 * @Date: 2022-12-17 11:08:18
* @LastEditors: Kane * @LastEditors: Kane
* @LastEditTime: 2022-12-22 23:47:51 * @LastEditTime: 2023-01-07 11:12:20
* @FilePath: \admin_system\vue.config.js * @FilePath: \admin_system\vue.config.js
* @Description: * @Description:
* *
@ -16,6 +16,6 @@ module.exports = defineConfig(
open: true, open: true,
host: "localhost", host: "localhost",
port: 8000, port: 8000,
} },
} }
); );