feat:对接首页字典接口
This commit is contained in:
13
Yi.Bbs.Vue3/src/apis/dictionaryApi.js
Normal file
13
Yi.Bbs.Vue3/src/apis/dictionaryApi.js
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
import request from "@/config/axios/service";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据字典类型获取字典列表
|
||||||
|
* @param {*} dicType 字典类型
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
export function getDictionaryList(dicType) {
|
||||||
|
return request({
|
||||||
|
url: `/dictionary/dic-type/${dicType}`,
|
||||||
|
method: "get",
|
||||||
|
});
|
||||||
|
}
|
||||||
@@ -1,28 +1,51 @@
|
|||||||
<template>
|
<template>
|
||||||
<el-scrollbar>
|
<el-scrollbar>
|
||||||
<div class="scrollbar-flex-content">
|
<div class="scrollbar-flex-content">
|
||||||
<p v-for="item in 50" :key="item" class="scrollbar-item">
|
<div v-for="item in recommendList" :key="item.id" class="scrollbar-item">
|
||||||
推荐
|
<el-tooltip
|
||||||
</p>
|
class="box-item"
|
||||||
|
effect="dark"
|
||||||
|
:content="item.dictLabel"
|
||||||
|
placement="top"
|
||||||
|
v-if="item.dictLabel.length > 5"
|
||||||
|
>
|
||||||
|
{{ item.dictLabel.slice(0, 5) + "..." }}
|
||||||
|
</el-tooltip>
|
||||||
|
<span v-else>
|
||||||
|
{{ item.dictLabel }}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</el-scrollbar>
|
</el-scrollbar>
|
||||||
</template>
|
</template>
|
||||||
<style scoped>
|
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import { onMounted, ref } from "vue";
|
||||||
|
import { getDictionaryList } from "@/apis/dictionaryApi.js";
|
||||||
|
|
||||||
|
const recommendList = ref([]);
|
||||||
|
onMounted(async () => {
|
||||||
|
const { data } = await getDictionaryList("bbs_type_lable");
|
||||||
|
recommendList.value = data;
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
.scrollbar-flex-content {
|
.scrollbar-flex-content {
|
||||||
display: flex;
|
display: flex;
|
||||||
}
|
}
|
||||||
.scrollbar-item {
|
.scrollbar-item {
|
||||||
|
cursor: pointer;
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
width: 4rem;
|
width: 4rem;
|
||||||
height: 2.6rem;
|
height: 2.6rem;
|
||||||
margin: 0 0.2rem ;
|
margin: 0 0.2rem;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
background-color:#FAFAFA;
|
background-color: #fafafa;
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import App from "./App.vue";
|
|||||||
import router from "./router";
|
import router from "./router";
|
||||||
import piniaPluginPersistedstate from "pinia-plugin-persistedstate";
|
import piniaPluginPersistedstate from "pinia-plugin-persistedstate";
|
||||||
|
|
||||||
|
import "element-plus/dist/index.css";
|
||||||
import "./assets/main.css";
|
import "./assets/main.css";
|
||||||
import "@/assets/styles/index.scss"; // global css
|
import "@/assets/styles/index.scss"; // global css
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user