新版本官网优化完成
This commit is contained in:
@@ -1,211 +0,0 @@
|
||||
<template>
|
||||
<UserCard :form="form" title="社区" desc="分享研发成果 交流技术经验" :avatar="user?.avatar"/>
|
||||
<CardList :list="list" :disabled="disabled" @done="onSearch" />
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import type {ApiResult, PageResult} from "~/api";
|
||||
import {useServerRequest} from "~/composables/useServerRequest";
|
||||
import {useWebsite} from "~/composables/configState";
|
||||
import type {BreadcrumbItem} from "~/types/global";
|
||||
import type {Navigation} from "~/api/cms/navigation/model";
|
||||
import {getIdBySpm, openSpmUrl} from "~/utils/common";
|
||||
import type {Article} from "~/api/cms/article/model";
|
||||
import useFormData from "~/utils/use-form-data";
|
||||
import LikeArticle from "~/pages/detail/components/LikeArticle.vue";
|
||||
import CardList from "~/pages/ask/components/CardList.vue";
|
||||
import type {Company, CompanyParam} from "~/api/system/company/model";
|
||||
import type {User} from "~/api/system/user/model";
|
||||
|
||||
// 引入状态管理
|
||||
const route = useRoute();
|
||||
const website = useWebsite();
|
||||
const user = useUser();
|
||||
const breadcrumb = ref<BreadcrumbItem>();
|
||||
const previousArticle = ref<Article>();
|
||||
const nextArticle = ref<Article>();
|
||||
const disabled = ref<boolean>(false);
|
||||
const showContent = ref<boolean>();
|
||||
const showPassword = ref<boolean>();
|
||||
const list = ref<Article[]>([]);
|
||||
const page = ref<number>(1);
|
||||
|
||||
// 配置信息
|
||||
const {form, assignFields} = useFormData<Article>({
|
||||
// 文章id
|
||||
articleId: undefined,
|
||||
// 文章标题
|
||||
title: undefined,
|
||||
// 分类类型
|
||||
type: undefined,
|
||||
// 展现方式
|
||||
showType: undefined,
|
||||
// 文章类型
|
||||
categoryId: undefined,
|
||||
// 文章分类
|
||||
categoryName: undefined,
|
||||
parentId: undefined,
|
||||
parentName: undefined,
|
||||
parentPath: undefined,
|
||||
// 封面图
|
||||
image: undefined,
|
||||
// 附件
|
||||
files: undefined,
|
||||
// 缩列图
|
||||
thumbnail: undefined,
|
||||
// 视频地址
|
||||
video: undefined,
|
||||
// 上传的文件类型
|
||||
accept: undefined,
|
||||
// 来源
|
||||
source: undefined,
|
||||
// 文章内容
|
||||
content: undefined,
|
||||
// 虚拟阅读量
|
||||
virtualViews: undefined,
|
||||
// 实际阅读量
|
||||
actualViews: undefined,
|
||||
// 访问权限
|
||||
permission: undefined,
|
||||
// 访问密码
|
||||
password: undefined,
|
||||
password2: undefined,
|
||||
// 用户ID
|
||||
userId: undefined,
|
||||
// 用户昵称
|
||||
nickname: undefined,
|
||||
// 账号
|
||||
username: undefined,
|
||||
// 用户头像
|
||||
// userAvatar: undefined,
|
||||
author: undefined,
|
||||
// 所属门店ID
|
||||
shopId: undefined,
|
||||
//
|
||||
likes: undefined,
|
||||
// 排序
|
||||
sortNumber: undefined,
|
||||
// 备注
|
||||
comments: undefined,
|
||||
// 状态
|
||||
status: undefined,
|
||||
// 创建时间
|
||||
createTime: undefined,
|
||||
// 更新时间
|
||||
updateTime: undefined
|
||||
});
|
||||
|
||||
// 搜索表单
|
||||
const where = reactive<CompanyParam>({
|
||||
keywords: ''
|
||||
});
|
||||
|
||||
// 验证密码
|
||||
const checkPassword = async () => {
|
||||
const {data: response} = await useServerRequest<ApiResult<unknown>>('/cms/cms-article/checkArticlePassword', {
|
||||
query: {
|
||||
password: form?.password,
|
||||
password2: form.password2
|
||||
}
|
||||
})
|
||||
if (response.value?.code === 0) {
|
||||
showPassword.value = false;
|
||||
showContent.value = true;
|
||||
} else {
|
||||
ElMessage.error(response.value?.message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const onSearch = () => {
|
||||
if(!disabled.value){
|
||||
page.value++;
|
||||
reload(route.path);
|
||||
}
|
||||
}
|
||||
|
||||
// 请求数据
|
||||
// const reload = async (path: string) => {
|
||||
//
|
||||
// if (response.value?.data) {
|
||||
// if (list.value.length < response.value?.data.count) {
|
||||
// disabled.value = false;
|
||||
// if (response.value?.data.list) {
|
||||
// list.value = list.value.concat(response.value?.data.list);
|
||||
// }
|
||||
// } else {
|
||||
// disabled.value = true;
|
||||
// }
|
||||
// if (response.value.data.count == 0) {
|
||||
// resultText.value = '暂无相关结果'
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// 请求数据
|
||||
const reload = async () => {
|
||||
|
||||
const {data: response} = await useServerRequest<ApiResult<PageResult<Article>>>('/cms/cms-article/page', {
|
||||
params: {
|
||||
page: page.value,
|
||||
limit: 8,
|
||||
userId: route.params.userId,
|
||||
keywords: where.keywords
|
||||
}
|
||||
})
|
||||
if(response.value?.data){
|
||||
if (list.value.length < response.value?.data.count) {
|
||||
disabled.value = false;
|
||||
if (response.value?.data.list) {
|
||||
list.value = list.value.concat(response.value?.data.list);
|
||||
}
|
||||
}else {
|
||||
disabled.value = true;
|
||||
}
|
||||
}
|
||||
|
||||
const { data: userInfo } = await useServerRequest<ApiResult<User>>(`/system/user/getByUserId/${getIdBySpm(5)}`)
|
||||
console.log(userInfo.value)
|
||||
// if (response.value?.data) {
|
||||
// assignFields(response.value.data)
|
||||
// if (form.permission === 1) {
|
||||
// console.log('登录可见')
|
||||
// return;
|
||||
// }
|
||||
// if (form.permission === 2) {
|
||||
// console.log('需要密码')
|
||||
// showPassword.value = true;
|
||||
// return;
|
||||
// }
|
||||
// form.parentPath = getSpmUrl(`/category`, form, form.articleId);
|
||||
// console.log(form.parentPath)
|
||||
// }
|
||||
|
||||
// seo
|
||||
useHead({
|
||||
title: `${form.title} - ${website.value.websiteName}`,
|
||||
bodyAttrs: {
|
||||
class: "page-container",
|
||||
}
|
||||
});
|
||||
// 面包屑
|
||||
breadcrumb.value = form
|
||||
}
|
||||
|
||||
watch(
|
||||
() => route.path,
|
||||
(path) => {
|
||||
console.log(path, '=>Path')
|
||||
|
||||
reload();
|
||||
},
|
||||
{immediate: true}
|
||||
);
|
||||
</script>
|
||||
|
||||
<style lang="less">
|
||||
.content {
|
||||
img {
|
||||
max-width: 100%;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -1,55 +0,0 @@
|
||||
<template>
|
||||
<div class="xl:w-screen-xl sm:flex xl:p-0 p-4 m-auto relative" v-infinite-scroll="load">
|
||||
<el-row :gutter="24" class="flex">
|
||||
<template v-for="(item,index) in list" :key="index">
|
||||
<el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="6" class="mb-5 min-w-xs">
|
||||
<el-card shadow="hover" :body-style="{ padding: '0px' }" class="hover:bg-gray-50 cursor-pointer"
|
||||
@click="openSpmUrl(`/detail`,item,item.articleId,true)">
|
||||
<el-image :src="item.image" fit="fill" :lazy="true" class="w-full md:h-[150px] h-[199px] cursor-pointer"/>
|
||||
<div class="flex-1 px-4 py-5 sm:p-6 !p-4">
|
||||
<!-- <div class="text-gray-700 dark:text-white text-base font-semibold flex items-center gap-1.5">-->
|
||||
<!-- <div class="flex items-center text-xl cursor-pointer max-w-md line-clamp-2"><el-icon-->
|
||||
<!-- v-if="item.permission > 0"><Lock class="text-gray-400 pr-1"/></el-icon>{{ item.title }}</div>-->
|
||||
<!-- </div>-->
|
||||
<div class="line-clamp-2 font-semibold text-gray-700 dark:text-white text-base gap-1.5 text-xl">
|
||||
{{ item.title }}
|
||||
</div>
|
||||
<div class="flex items-center gap-1.5 py-2 text-gray-500">
|
||||
<el-avatar :src="item.logo" :size="20" @click.stop="openSpmUrl(`/ask/${item.userId}`,item,item.userId)"/>
|
||||
<span>{{ item.tenantName }} · {{ dayjs(item.createTime).format('MM-DD hh:mm') }}</span>
|
||||
<el-icon v-if="item.permission > 0" :size="24"><Lock class="text-gray-400 px-1"/></el-icon>
|
||||
</div>
|
||||
</div>
|
||||
</el-card>
|
||||
</el-col>
|
||||
</template>
|
||||
</el-row>
|
||||
</div>
|
||||
<div v-if="disabled" class="px-1 text-center text-gray-500 min-h-xs">
|
||||
没有更多了
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import {openSpmUrl} from "~/utils/common";
|
||||
import dayjs from "dayjs";
|
||||
import {Lock} from '@element-plus/icons-vue'
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
list?: any[];
|
||||
disabled?: boolean;
|
||||
}>(),
|
||||
{}
|
||||
);
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'done'): void;
|
||||
}>();
|
||||
|
||||
const load = () => {
|
||||
if (!props.disabled) {
|
||||
emit('done')
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -1,103 +0,0 @@
|
||||
<template>
|
||||
<PageBanner :layout="layout" title="社区" desc="分享研发成果 交流技术经验" />
|
||||
<el-tabs v-model="activeName" class="xl:w-screen-xl sm:flex xl:p-0 p-4 m-auto relative pb-2" @tab-click="handleClick">
|
||||
<el-tab-pane label="轻松一刻" name="happy"></el-tab-pane>
|
||||
<el-tab-pane label="企业官网" name="website"></el-tab-pane>
|
||||
<el-tab-pane label="企业商城" name="weShop"></el-tab-pane>
|
||||
<el-tab-pane label="内容管理" name="cms"></el-tab-pane>
|
||||
<el-tab-pane label="点餐外卖" name="food"></el-tab-pane>
|
||||
<el-tab-pane label="派单系统" name="task"></el-tab-pane>
|
||||
<el-tab-pane label="办公OA" name="oa"></el-tab-pane>
|
||||
<el-tab-pane label="问答" name="ask"></el-tab-pane>
|
||||
<el-tab-pane label="分享" name="share"></el-tab-pane>
|
||||
</el-tabs>
|
||||
<CardList :list="list" :disabled="disabled" @done="onSearch" />
|
||||
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import type {ApiResult, PageResult} from "~/api";
|
||||
import {useServerRequest} from "~/composables/useServerRequest";
|
||||
import {useWebsite} from "~/composables/configState";
|
||||
import type {Navigation} from "~/api/cms/navigation/model";
|
||||
import type {CompanyParam} from "~/api/system/company/model";
|
||||
import type {Article} from "~/api/cms/article/model";
|
||||
import CardList from './components/CardList.vue';
|
||||
|
||||
const route = useRoute();
|
||||
|
||||
// 页面信息
|
||||
const runtimeConfig = useRuntimeConfig();
|
||||
const list = ref<Article[]>([]);
|
||||
const page = ref<number>(1);
|
||||
const resultText = ref('');
|
||||
const layout = ref<any>();
|
||||
const disabled = ref<boolean>(false);
|
||||
const activeName = ref(undefined)
|
||||
|
||||
// 获取状态
|
||||
const form = ref<Navigation>();
|
||||
const website = useWebsite();
|
||||
|
||||
// 搜索表单
|
||||
const where = reactive<CompanyParam>({
|
||||
keywords: ''
|
||||
});
|
||||
|
||||
const handleClick = (e:any) => {
|
||||
console.log(e.index)
|
||||
}
|
||||
|
||||
const onSearch = () => {
|
||||
if(!disabled.value){
|
||||
page.value++;
|
||||
reload(route.path);
|
||||
}
|
||||
}
|
||||
|
||||
// 请求数据
|
||||
const reload = async (path: string) => {
|
||||
const {data: response} = await useServerRequest<ApiResult<PageResult<Article>>>('/cms/cms-article/page',{baseURL: runtimeConfig.public.apiServer, params: {
|
||||
page: page.value,
|
||||
limit: 8,
|
||||
tenantId: getIdBySpm(1),
|
||||
keywords: where.keywords
|
||||
}})
|
||||
if(response.value?.data){
|
||||
if (list.value.length < response.value?.data.count) {
|
||||
disabled.value = false;
|
||||
if (response.value?.data.list) {
|
||||
list.value = list.value.concat(response.value?.data.list);
|
||||
}
|
||||
}else {
|
||||
disabled.value = true;
|
||||
}
|
||||
if(response.value.data.count == 0){
|
||||
resultText.value = '暂无相关结果'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const { data: nav } = await useServerRequest<ApiResult<Navigation>>('/cms/cms-navigation/getNavigationByPath',{query: {path: route.path}})
|
||||
if(nav.value?.data){
|
||||
form.value = nav.value?.data;
|
||||
}
|
||||
// 页面布局
|
||||
if(form.value?.layout){
|
||||
layout.value = JSON.parse(form.value?.layout)
|
||||
}
|
||||
|
||||
useHead({
|
||||
title: `社区 - ${website.value.websiteName}`,
|
||||
bodyAttrs: {
|
||||
class: "page-container",
|
||||
}
|
||||
});
|
||||
|
||||
watch(
|
||||
() => route.path,
|
||||
(path) => {
|
||||
reload(path);
|
||||
},
|
||||
{ immediate: true }
|
||||
);
|
||||
</script>
|
||||
Reference in New Issue
Block a user