Files
Smail/fe/src/components/HomeAside.vue
T
HuangZheandzhe28 ad0167f6fd 代码分离,功能优化 (#204)
* feat: 代码分离,功能优化

1. 代码迁移到 ts.
2. 分离 axios 部分代码.
3. 增加 pinia 支持,全局状态代码迁移到相对应的 store.
4. 代码格式优化, 用 === 代替 ==.
5. 代码声明更改,用 const 代替 var 声明.
6. Header 使用 Router 导航.
7. v-for 增加 key.

* fix[fe]: 移除过时的 prop 引用

* fix[fe]: 移除过时的 prop 引用

* fix[fe]: 修复 logo 上面有横线的问题

* fix[fe]: 修复 logo 上面有横线的问题

---------

Co-authored-by: zhe28 <huangze28@foxmail.com>
2024-09-23 10:24:49 +08:00

64 lines
1.1 KiB
Vue

<template>
<div id="main">
<input id="search" :placeholder="lang.search" />
<el-tree
:data="data"
:defaultExpandAll="true"
@node-click="handleNodeClick"
/>
</div>
</template>
<script setup>
import { useRouter } from "vue-router";
import { ref } from "vue";
import useGroupStore from "../stores/group";
import lang from "../i18n/i18n";
import { http } from "@/utils/axios";
const groupStore = useGroupStore();
const router = useRouter();
const data = ref([]);
http.get("/api/group").then((res) => {
if (res.data) data.value = res.data;
});
const handleNodeClick = function (data) {
if (data.tag != null) {
groupStore.name = data.label;
groupStore.tag = data.tag;
router.push({
name: "list",
});
}
};
</script>
<style scoped>
#main {
width: 243px;
background-color: #f1f1f1;
height: 100%;
}
#search {
background-color: #d6e7f7;
width: 100%;
height: 40px;
padding-left: 10px;
border: none;
outline: none;
font-size: 16px;
}
.el-tree {
background-color: #f1f1f1;
}
.add_group {
font-size: 14px;
text-align: left;
padding-left: 15px;
}
</style>