151 lines
4.3 KiB
Vue
151 lines
4.3 KiB
Vue
<template>
|
|
|
|
<!-- 主体部分 -->
|
|
<div class="xl:w-screen-xl m-auto py-4 mt-12 px-4 sm:px-0 sm:mt-2">
|
|
<el-page-header :icon="ArrowLeft" @back="goBack">
|
|
<template #content>
|
|
<span class="text-large font-600"> {{ page.title }} </span>
|
|
</template>
|
|
<template #extra>
|
|
<el-space class="flex items-center">
|
|
<el-input
|
|
v-model="where.keywords"
|
|
:placeholder="`搜索关键词`"
|
|
:suffix-icon="Search"
|
|
class="hidden-sm-and-down"
|
|
@change="reload"
|
|
/>
|
|
<el-button :icon="Search" class="hidden-sm-and-up" @click="showSearch = true"></el-button>
|
|
</el-space>
|
|
<el-dialog
|
|
v-model="showSearch"
|
|
fullscreen
|
|
>
|
|
<el-input
|
|
v-model="where.keywords"
|
|
:placeholder="`搜索关键词`"
|
|
:suffix-icon="Search"
|
|
class="w-full my-5"
|
|
size="large"
|
|
@change="reload"
|
|
/>
|
|
</el-dialog>
|
|
</template>
|
|
<el-row id="container" :gutter="24" class="clearfix">
|
|
<el-col v-for="(item,index) in list" :key="index" :sm="4" :xs="12" class="left mb-8">
|
|
<nuxt-link :to="`${item.url}`" class="flex-1 cursor-pointer flex flex-col text-center" target="_blank">
|
|
<el-card :body-style="{ padding: '0px' }" class="items-center flex justify-center" shadow="hover">
|
|
<el-popover
|
|
:content="item.comments"
|
|
:width="200"
|
|
placement="bottom"
|
|
trigger="hover"
|
|
>
|
|
<template #reference>
|
|
<div class="flex-1 py-5 sm:p-4 !p-4">
|
|
<el-space class="text-gray-700 dark:text-white text-base font-semibold h-[28px] flex justify-center items-center">
|
|
<el-image v-if="item.icon" :alt="item.name" :src="item.icon" style="height: 32px"/>
|
|
<span :title="item.name" class="text-lg line-clamp-1">{{ item.name }}</span>
|
|
</el-space>
|
|
</div>
|
|
</template>
|
|
</el-popover>
|
|
</el-card>
|
|
</nuxt-link>
|
|
</el-col>
|
|
</el-row>
|
|
</el-page-header>
|
|
<Pagination :total="total" @done="search" />
|
|
</div>
|
|
</template>
|
|
<script setup lang="ts">
|
|
import { ArrowLeft,View,Search } from '@element-plus/icons-vue'
|
|
import {useLayout, usePage} from "~/composables/configState";
|
|
import type {CmsNavigation} from "~/api/cms/cmsNavigation/model";
|
|
import type {CmsArticle, CmsArticleParam} from "~/api/cms/cmsArticle/model";
|
|
import {getNavIdByParamsId, getViews, paramsId} from "~/utils/common";
|
|
import {getCmsNavigation, listCmsNavigation} from "~/api/cms/cmsNavigation";
|
|
import {pageCmsLink} from "~/api/cms/cmsLink";
|
|
import type {CmsLink, CmsLinkParam} from "~/api/cms/cmsLink/model";
|
|
|
|
const route = useRoute();
|
|
const router = useRouter();
|
|
const navId = ref();
|
|
const list = ref<CmsLink[]>([]);
|
|
const category = ref<CmsNavigation[]>([]);
|
|
const total = ref<number>(0);
|
|
|
|
// 获取状态
|
|
const page = usePage();
|
|
const layout = useLayout();
|
|
const showSearch = ref<boolean>(false);
|
|
|
|
// 搜索表单
|
|
const where = reactive<CmsLinkParam>({
|
|
keywords: '',
|
|
page: 1,
|
|
categoryId: undefined
|
|
});
|
|
|
|
const id = ref<number>(0);
|
|
|
|
const showMenu = (item: CmsLink) => {
|
|
id.value = Number(item.id);
|
|
};
|
|
|
|
const hideMenu = () => {
|
|
id.value = 0;
|
|
};
|
|
|
|
// 加载页面数据
|
|
const reload = async () => {
|
|
getCmsNavigation(navId.value).then(data => {
|
|
// 获取栏目信息
|
|
page.value = data
|
|
layout.value.banner = data.banner;
|
|
if(navId.value){
|
|
where.categoryId = navId.value;
|
|
}
|
|
pageCmsLink(where).then(response => {
|
|
if(response){
|
|
total.value = response?.count;
|
|
list.value = response?.list;
|
|
}
|
|
}).finally(() => showSearch.value = false)
|
|
|
|
// 设置页面标题
|
|
useSeoMeta({
|
|
description: data.comments || data.title,
|
|
keywords: data.title,
|
|
titleTemplate: `${data?.title}` + ' - %s',
|
|
})
|
|
|
|
}).catch(err => {
|
|
console.log(err,'加载失败...')
|
|
})
|
|
}
|
|
|
|
const goBack = () => {
|
|
router.back(); // 返回上一页
|
|
}
|
|
|
|
/**
|
|
* 搜索
|
|
* @param data
|
|
*/
|
|
const search = (data: CmsArticleParam) => {
|
|
where.page = data.page;
|
|
reload();
|
|
}
|
|
|
|
watch(
|
|
() => route.params.id,
|
|
(id) => {
|
|
navId.value = getNavIdByParamsId(id);
|
|
reload();
|
|
},
|
|
{ immediate: true }
|
|
);
|
|
|
|
</script>
|