Files
template-10490/pages/market/index.vue

134 lines
3.7 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<!-- 主体部分 -->
<div class="xl:w-screen-xl m-auto py-4 mt-20">
<el-page-header :icon="ArrowLeft" @back="goBack">
<template #content>
<span class="text-large font-600 mr-3"> 插件市场 </span>
</template>
<template #extra>
<span class="text-gray-400">基于WebSoft开发的应用和插件</span>
</template>
<!-- 搜索工具栏 -->
<SearchBar :where="where" id="search" />
<!-- 应用列表 -->
<el-row :gutter="24" id="container" class="clearfix">
<el-col v-for="(item,index) in list" :key="index" :span="8" class="left mb-8">
<el-card shadow="hover" :body-style="{ padding: '0px' }" class="cursor-pointer" @mouseover="showDomain(item)"
@mouseleave="hideDomain">
<nuxt-link :to="`/market/${item.websiteId}`">
<div class="flex-1 px-4 py-5 sm:p-4 !p-4">
<div class="text-gray-700 dark:text-white text-base font-semibold flex gap-1.5">
<el-avatar
:src="item.websiteLogo" shape="square" :size="55" style="background-color: white;"/>
<div class="flex-1 text-lg cursor-pointer flex flex-col">
{{ item.websiteName }}
<div class="flex justify-between items-center">
<sapn class="text-xs text-gray-400 font-normal line-clamp-1">
{{ id == item.websiteId ? item.domain : item.comments || '暂无描述' }}
</sapn>
<el-button size="small" round>获取</el-button>
</div>
</div>
</div>
<div class="item-image pt-3">
<el-image v-if="item.files" :src="`${JSON.parse(item.files)[0]}`" class="w-full h-1/2 max-h-[220px]"/>
<el-image v-else class="w-full h-[220px]"/>
</div>
</div>
</nuxt-link>
</el-card>
</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 {pageCmsWebsiteAll} from "~/api/cms/cmsWebsite";
import type {CmsWebsite, CmsWebsiteParam} from "~/api/cms/cmsWebsite/model";
import SearchBar from "./components/SearchBar.vue";
const route = useRoute();
const router = useRouter();
// 页面信息
const list = ref<CmsWebsite[]>([]);
const total = ref(0);
const id = ref<number>();
const loading = ref<boolean>(false)
const where = ref<CmsWebsiteParam>({
});
const goBack = () => {
router.back();
}
const showDomain = (item: CmsWebsite) => {
id.value = Number(item.websiteId);
};
const hideDomain = () => {
id.value = 0;
};
// 加载页面数据
const reload = async (where: any) => {
if (loading.value) return;
loading.value = true;
pageCmsWebsiteAll({
...where,
market: true,
limit: where.limit || 12
}).then(response => {
if (response?.list) {
list.value = response?.list.map(d => {
if (d.domain == '' || d.domain == null) {
d.domain = `${d.websiteCode}.wsdns.cn`;
}
return d;
});
total.value = response.count;
}
loading.value = false;
}).catch(() => {
loading.value = false;
}).finally(() => {
console.log('index>>>>')
})
}
/**
* 搜索
* @param data
*/
const search = (data: CmsWebsiteParam) => {
navigateTo({
path: '/market',
query: {
market: 1,
page: data.page,
limit: 12
}
})
window.scrollTo(0, 0)
}
watch(
() => route.query,
(query) => {
where.value = query;
console.log(where.value,'>>>>>')
reload(query);
},
{immediate: true}
);
</script>
<style lang="scss">
</style>