feat: 应用分类功能

This commit is contained in:
胡双明
2024-09-14 11:05:49 +08:00
parent 38a0d00142
commit aaea23f785
8 changed files with 328 additions and 22 deletions

View File

@@ -1,6 +1,20 @@
<template>
<div>
<div class="page-apps custom-scroll">
<div class="apps-type-nav">
<el-scrollbar>
<ul class="scrollbar-type-nav">
<li :class="{active: typeId == ''}" @click="getAppList('')">全部分类</li>
<li v-for="item in appTypes" :key="item.id" :class="{active: typeId === item.id}" @click="getAppList(item.id)">
<div class="image">
<el-image :src="item.icon" fit="cover"/>
</div>
{{ item.name }}
</li>
</ul>
</el-scrollbar>
</div>
<div class="inner" :style="{height: listBoxHeight + 'px'}">
<ItemList :items="list" v-if="list.length > 0" :gap="15" :width="300">
<template #default="scope">
@@ -65,23 +79,17 @@ import {useRouter} from "vue-router";
import {useSharedStore} from "@/store/sharedata";
import ItemList from "@/components/ItemList.vue";
const listBoxHeight = window.innerHeight - 87
const listBoxHeight = window.innerHeight - 133
const typeId = ref('')
const appTypes = ref([])
const list = ref([])
const roles = ref([])
const store = useSharedStore();
onMounted(() => {
httpGet("/api/app/list").then((res) => {
const items = res.data
// 处理 hello message
for (let i = 0; i < items.length; i++) {
items[i].intro = substr(items[i].hello_msg, 80)
}
list.value = items
}).catch(e => {
ElMessage.error("获取应用失败:" + e.message)
})
getAppType()
getAppList()
getRoles()
})
@@ -93,6 +101,28 @@ const getRoles = () => {
})
}
const getAppType = () => {
httpGet("/api/app/type/list").then((res) => {
appTypes.value = res.data
}).catch(e => {
ElMessage.error("获取分类失败:" + e.message)
})
}
const getAppList = (tid = '') => {
typeId.value = tid;
httpGet("/api/app/list", { tid }).then((res) => {
const items = res.data
// 处理 hello message
for (let i = 0; i < items.length; i++) {
items[i].intro = substr(items[i].hello_msg, 80)
}
list.value = items
}).catch(e => {
ElMessage.error("获取应用失败:" + e.message)
})
}
const updateRole = (row, opt) => {
checkSession().then(() => {
const title = ref("")