feat:板块页文章置顶样式更改
This commit is contained in:
84
Yi.Bbs.Vue3/src/views/discuss/components/tabs.vue
Normal file
84
Yi.Bbs.Vue3/src/views/discuss/components/tabs.vue
Normal file
@@ -0,0 +1,84 @@
|
||||
<template>
|
||||
<div class="tabs">
|
||||
<div class="left">
|
||||
<div
|
||||
class="items"
|
||||
v-for="item in leftList"
|
||||
@click="handleClick(item)"
|
||||
:class="[modelValue === item.name ? 'active-tab' : '']"
|
||||
>
|
||||
{{ item.label }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="center"></div>
|
||||
<div class="right">
|
||||
<template v-for="(item, index) in rightList">
|
||||
<div
|
||||
class="items"
|
||||
@click="handleClick(item)"
|
||||
:class="[modelValue === item.name ? 'active-tab' : '']"
|
||||
>
|
||||
{{ item.label }}
|
||||
</div>
|
||||
<div class="line" v-if="index < rightList.length - 1">|</div>
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed, defineProps, defineEmits } from "vue";
|
||||
|
||||
const props = defineProps({
|
||||
modelValue: {
|
||||
type: String,
|
||||
default: "",
|
||||
},
|
||||
tabList: {
|
||||
type: Array,
|
||||
default: () => [],
|
||||
},
|
||||
});
|
||||
|
||||
const emit = defineEmits(["update:modelValue"], ["tab-change"]);
|
||||
|
||||
const leftList = computed(() =>
|
||||
props.tabList.filter((item) => item.position === "left")
|
||||
);
|
||||
const rightList = computed(() =>
|
||||
props.tabList.filter((item) => item.position === "right")
|
||||
);
|
||||
const handleClick = (item) => {
|
||||
emit("update:modelValue", item.name);
|
||||
emit("tab-change", item);
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.tabs {
|
||||
display: flex;
|
||||
background-color: #fff;
|
||||
padding: 1rem;
|
||||
margin: 1rem 0rem;
|
||||
color: #8c8c8c;
|
||||
.left {
|
||||
width: 100px;
|
||||
}
|
||||
.center {
|
||||
flex: 3;
|
||||
}
|
||||
.right {
|
||||
width: 200px;
|
||||
display: flex;
|
||||
.line {
|
||||
margin: 0 10px;
|
||||
}
|
||||
}
|
||||
.items {
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
.active-tab {
|
||||
color: #409eff;
|
||||
}
|
||||
</style>
|
||||
@@ -47,28 +47,10 @@
|
||||
</div>
|
||||
</el-form>
|
||||
</div>
|
||||
|
||||
<el-tabs v-model="activeName" @tab-change="handleClick">
|
||||
<el-tab-pane label="最新" name="new"> </el-tab-pane>
|
||||
<el-tab-pane label="推荐" name="suggest"> </el-tab-pane>
|
||||
<el-tab-pane label="最热" name="host"> </el-tab-pane>
|
||||
</el-tabs>
|
||||
|
||||
<el-collapse class="collapse-list" style="background-color: #f0f2f5">
|
||||
<el-collapse-item>
|
||||
<template #title>
|
||||
<div class="collapse-top">
|
||||
已置顶主题<el-icon class="header-icon">
|
||||
<info-filled />
|
||||
</el-icon>
|
||||
</div>
|
||||
</template>
|
||||
<div class="div-item" v-for="i in topDiscussList">
|
||||
<DisscussCard :discuss="i" badge="置顶" />
|
||||
</div>
|
||||
</el-collapse-item>
|
||||
</el-collapse>
|
||||
<el-divider v-show="topDiscussList.length > 0" />
|
||||
<Tabs v-model="activeName" :tabList="tabList" @tab-change="handleClick" />
|
||||
<div class="div-item" v-for="i in topDiscussList">
|
||||
<DisscussCard :discuss="i" badge="置顶" />
|
||||
</div>
|
||||
<template v-if="isDiscussFinished">
|
||||
<div class="div-item" v-for="i in discussList">
|
||||
<DisscussCard :discuss="i" />
|
||||
@@ -77,6 +59,9 @@
|
||||
<template v-else>
|
||||
<Skeleton :isBorder="true" />
|
||||
</template>
|
||||
<div class="div-item" v-for="i in discussList">
|
||||
<DisscussCard :discuss="i" />
|
||||
</div>
|
||||
<div>
|
||||
<el-pagination
|
||||
v-model:current-page="query.skipCount"
|
||||
@@ -113,12 +98,13 @@ import { getPermission } from "@/utils/auth";
|
||||
import useAuths from "@/hooks/useAuths";
|
||||
import { Session } from "@/utils/storage";
|
||||
import Skeleton from "@/components/Skeleton/index.vue";
|
||||
import Tabs from "./components/tabs.vue";
|
||||
|
||||
const { getToken, clearStorage } = useAuths();
|
||||
//数据定义
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
const activeName = ref("new");
|
||||
const activeName = ref("suggest");
|
||||
//主题内容
|
||||
const discussList = ref([]);
|
||||
const isDiscussFinished = ref(false);
|
||||
@@ -133,7 +119,7 @@ const query = reactive({
|
||||
type: activeName.value,
|
||||
});
|
||||
|
||||
const handleClick = async (tab, event) => {
|
||||
const handleClick = async (item) => {
|
||||
query.type = activeName.value;
|
||||
await loadDiscussList();
|
||||
};
|
||||
@@ -212,6 +198,12 @@ watch(
|
||||
},
|
||||
{ immediate: true }
|
||||
);
|
||||
|
||||
const tabList = ref([
|
||||
{ label: "全部文章", name: "suggest", position: "left" },
|
||||
{ label: "最新", name: "new", position: "right" },
|
||||
{ label: "最热", name: "host", position: "right" },
|
||||
]);
|
||||
</script>
|
||||
<style scoped lang="scss">
|
||||
.discuss-box {
|
||||
@@ -235,6 +227,10 @@ watch(
|
||||
padding: 1rem;
|
||||
margin: 1rem 0rem;
|
||||
}
|
||||
|
||||
.header-tab {
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
.collapse-top {
|
||||
padding-left: 2rem;
|
||||
}
|
||||
@@ -278,6 +274,7 @@ watch(
|
||||
margin: 0.5rem 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* 禁用状态下的样式 */
|
||||
.el-button.el-button--disabled {
|
||||
opacity: 0.6;
|
||||
Reference in New Issue
Block a user