|
@ -4,9 +4,33 @@ |
|
|
<div class="page-main md:w-screen-xl m-auto md:px-3" ref="container"> |
|
|
<div class="page-main md:w-screen-xl m-auto md:px-3" ref="container"> |
|
|
<el-row :gutter="24"> |
|
|
<el-row :gutter="24"> |
|
|
<el-col :xs="24" :sm="12" :md="12" :lg="18" class="min-w-xs"> |
|
|
<el-col :xs="24" :sm="12" :md="12" :lg="18" class="min-w-xs"> |
|
|
<div class="p-6 leading-7 bg-white md:rounded-lg text-lg line-height-loose text-gray-600 content" |
|
|
|
|
|
v-html="form?.content"> |
|
|
|
|
|
</div> |
|
|
|
|
|
|
|
|
<template v-if="form.permission === 0 || showContent"> |
|
|
|
|
|
<div class="p-6 leading-7 bg-white md:rounded-lg text-lg line-height-loose text-gray-600 content"> |
|
|
|
|
|
<p v-html="form?.content"></p> |
|
|
|
|
|
</div> |
|
|
|
|
|
</template> |
|
|
|
|
|
<template v-if="form.permission === 1"> |
|
|
|
|
|
<el-result |
|
|
|
|
|
v-if="!showContent && form.permission === 1" |
|
|
|
|
|
icon="warning" |
|
|
|
|
|
title="无访问权限" |
|
|
|
|
|
> |
|
|
|
|
|
</el-result> |
|
|
|
|
|
</template> |
|
|
|
|
|
<template v-if="form.permission === 2"> |
|
|
|
|
|
<el-result |
|
|
|
|
|
v-if="!showContent && form.permission === 2" |
|
|
|
|
|
icon="warning" |
|
|
|
|
|
title="请输入访问密码" |
|
|
|
|
|
> |
|
|
|
|
|
<template #extra> |
|
|
|
|
|
<el-space> |
|
|
|
|
|
<el-input type="password" v-model="form.password2" show-password placeholder="请输入查看密码">请输入查看密码</el-input> |
|
|
|
|
|
<el-button type="primary" @click="checkPassword">确定</el-button> |
|
|
|
|
|
</el-space> |
|
|
|
|
|
</template> |
|
|
|
|
|
</el-result> |
|
|
|
|
|
</template> |
|
|
<div class="page md:gap-xl gap-xs md:mt-4 m-auto md:p-0 p-4 flex justify-between"> |
|
|
<div class="page md:gap-xl gap-xs md:mt-4 m-auto md:p-0 p-4 flex justify-between"> |
|
|
<div v-if="previousArticle" class="bg-white text-gray-600 hover:shadow hover:text-gray-800 hover:font-bold rounded-lg p-4 cursor-pointer w-[50%]" |
|
|
<div v-if="previousArticle" class="bg-white text-gray-600 hover:shadow hover:text-gray-800 hover:font-bold rounded-lg p-4 cursor-pointer w-[50%]" |
|
|
@click="openSpmUrl(`/detail`,previousArticle,previousArticle?.articleId)"> |
|
|
@click="openSpmUrl(`/detail`,previousArticle,previousArticle?.articleId)"> |
|
@ -25,7 +49,6 @@ |
|
|
</el-col> |
|
|
</el-col> |
|
|
</el-row> |
|
|
</el-row> |
|
|
</div> |
|
|
</div> |
|
|
|
|
|
|
|
|
</template> |
|
|
</template> |
|
|
<script setup lang="ts"> |
|
|
<script setup lang="ts"> |
|
|
import type {ApiResult} from "~/api"; |
|
|
import type {ApiResult} from "~/api"; |
|
@ -45,7 +68,8 @@ const website = useWebsite(); |
|
|
const breadcrumb = ref<BreadcrumbItem>(); |
|
|
const breadcrumb = ref<BreadcrumbItem>(); |
|
|
const previousArticle = ref<Article>(); |
|
|
const previousArticle = ref<Article>(); |
|
|
const nextArticle = ref<Article>(); |
|
|
const nextArticle = ref<Article>(); |
|
|
|
|
|
|
|
|
|
|
|
const showContent = ref<boolean>(); |
|
|
|
|
|
const showPassword = ref<boolean>(); |
|
|
|
|
|
|
|
|
// 配置信息 |
|
|
// 配置信息 |
|
|
const {form, assignFields} = useFormData<Article>({ |
|
|
const {form, assignFields} = useFormData<Article>({ |
|
@ -82,6 +106,11 @@ const {form, assignFields} = useFormData<Article>({ |
|
|
virtualViews: undefined, |
|
|
virtualViews: undefined, |
|
|
// 实际阅读量 |
|
|
// 实际阅读量 |
|
|
actualViews: undefined, |
|
|
actualViews: undefined, |
|
|
|
|
|
// 访问权限 |
|
|
|
|
|
permission: undefined, |
|
|
|
|
|
// 访问密码 |
|
|
|
|
|
password: undefined, |
|
|
|
|
|
password2: undefined, |
|
|
// 用户ID |
|
|
// 用户ID |
|
|
userId: undefined, |
|
|
userId: undefined, |
|
|
// 用户昵称 |
|
|
// 用户昵称 |
|
@ -106,6 +135,22 @@ const {form, assignFields} = useFormData<Article>({ |
|
|
updateTime: undefined |
|
|
updateTime: undefined |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
// 验证密码 |
|
|
|
|
|
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 reload = async () => { |
|
|
const reload = async () => { |
|
|
|
|
|
|
|
@ -113,6 +158,15 @@ const reload = async () => { |
|
|
const {data: nav} = await useServerRequest<ApiResult<Navigation>>('/cms/cms-article/' + getIdBySpm(5)) |
|
|
const {data: nav} = await useServerRequest<ApiResult<Navigation>>('/cms/cms-article/' + getIdBySpm(5)) |
|
|
if (nav.value?.data) { |
|
|
if (nav.value?.data) { |
|
|
assignFields(nav.value.data) |
|
|
assignFields(nav.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); |
|
|
form.parentPath = getSpmUrl(`/category`,form,form.articleId); |
|
|
console.log(form.parentPath) |
|
|
console.log(form.parentPath) |
|
|
} |
|
|
} |
|
|