1
This commit is contained in:
142
pages/links/index.vue
Normal file
142
pages/links/index.vue
Normal file
@@ -0,0 +1,142 @@
|
||||
<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 line-clamp-1"> 网址导航 </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 :page-size="48" :total="total" @done="search"/>
|
||||
</div>
|
||||
|
||||
</template>
|
||||
<script lang="ts" setup>
|
||||
import {ArrowLeft, Search} from '@element-plus/icons-vue'
|
||||
import type {CmsArticleParam} from "~/api/cms/cmsArticle/model";
|
||||
import {pageCmsWebsiteAll} from "~/api/cms/cmsWebsite";
|
||||
import type {CmsWebsite, CmsWebsiteParam} from "~/api/cms/cmsWebsite/model";
|
||||
import type {CmsLink, CmsLinkParam} from "~/api/cms/cmsLink/model";
|
||||
import {pageCmsLink} from "~/api/cms/cmsLink";
|
||||
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
// 页面信息
|
||||
const list = ref<CmsLink[]>([]);
|
||||
const total = ref(0);
|
||||
const id = ref<number>();
|
||||
const inputWidth = ref<string>('180px');
|
||||
const showSearch = ref<boolean>(false);
|
||||
|
||||
// 搜索表单
|
||||
const where = reactive<CmsLinkParam>({
|
||||
keywords: '',
|
||||
page: 1,
|
||||
limit: 48,
|
||||
categoryId: undefined
|
||||
});
|
||||
|
||||
const goBack = () => {
|
||||
router.back();
|
||||
}
|
||||
const handleFocus = () => {
|
||||
inputWidth.value = '400px'; // 聚焦时宽度
|
||||
}
|
||||
const handleBlur = () => {
|
||||
inputWidth.value = '180px'; // 聚焦时宽度
|
||||
}
|
||||
|
||||
const showDomain = (item: CmsWebsite) => {
|
||||
id.value = Number(item.websiteId);
|
||||
};
|
||||
|
||||
const hideDomain = () => {
|
||||
id.value = 0;
|
||||
};
|
||||
|
||||
// 加载页面数据
|
||||
const reload = async () => {
|
||||
await pageCmsLink({
|
||||
...where
|
||||
}).then(response => {
|
||||
if (response?.list) {
|
||||
list.value = response?.list;
|
||||
total.value = response.count;
|
||||
}
|
||||
}).catch(() => {
|
||||
}).finally(() => showSearch.value = false)
|
||||
}
|
||||
|
||||
/**
|
||||
* 搜索
|
||||
* @param data
|
||||
*/
|
||||
const search = (data: CmsArticleParam) => {
|
||||
where.page = data.page;
|
||||
reload();
|
||||
}
|
||||
|
||||
watch(
|
||||
() => route.params.id,
|
||||
() => {
|
||||
reload();
|
||||
},
|
||||
{immediate: true}
|
||||
);
|
||||
</script>
|
||||
<style lang="scss">
|
||||
.el-input {
|
||||
transition: width 0.3s ease;
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user