diff --git a/api/cms/article/model/index.ts b/api/cms/article/model/index.ts index 4f1acd9..549eac3 100644 --- a/api/cms/article/model/index.ts +++ b/api/cms/article/model/index.ts @@ -40,6 +40,12 @@ export interface Article { virtualViews?: number; // 实际阅读量 actualViews?: number; + // 浏览权限 + permission?: number; + // 访问密码 + password?: string; + // 访问密码(客户端传) + password2?: string; // 用户ID userId?: number; // 用户昵称 diff --git a/api/cms/navigation/model/index.ts b/api/cms/navigation/model/index.ts index 645feef..4a89e8d 100644 --- a/api/cms/navigation/model/index.ts +++ b/api/cms/navigation/model/index.ts @@ -14,6 +14,7 @@ export interface Navigation{ sortNumber?: number; hide?: number; permission?: number; + password?: string; home?: number; position?: number; meta?: string; diff --git a/components/AppHeader.vue b/components/AppHeader.vue index 9fc13f3..2924762 100644 --- a/components/AppHeader.vue +++ b/components/AppHeader.vue @@ -176,6 +176,7 @@ const reload = async () => { if (domain) { sysDomain.value = domain; } + // 获取用户信息 if (token && token != '') { const {data: response} = await useServerRequest>('/auth/user', {baseURL: runtimeConfig.public.apiServer}) if (response.value?.data) { @@ -183,6 +184,7 @@ const reload = async () => { } // 获取后台管理地址 const {data: company} = await useServerRequest>('/system/company/profile', {baseURL: runtimeConfig.public.apiServer}) + console.log(company.value,'>>>>90') if (company.value?.data?.domain) { sysDomain.value = company.value?.data?.domain; localStorage.setItem('SysDomain', `${company.value?.data?.domain}`); diff --git a/components/PageBanner.vue b/components/PageBanner.vue index 2e9033b..1769f3d 100644 --- a/components/PageBanner.vue +++ b/components/PageBanner.vue @@ -55,6 +55,23 @@ + + + 请输入查看密码 + + @@ -63,9 +80,11 @@ import {openSpmUrl} from "~/utils/common"; import {useServerRequest} from "~/composables/useServerRequest"; import type {ApiResult} from "~/api"; import type {Navigation} from "~/api/cms/navigation/model"; +import {ref} from 'vue' withDefaults( defineProps<{ + form?: any; layout?: any; title?: string; desc?: string; @@ -79,21 +98,62 @@ withDefaults( } ); +const emit = defineEmits<{ + (e: 'done', show: boolean): void; +}>(); + const route = useRoute(); +const token = useToken(); const form = ref(); const layout = ref(); +const password2 = ref(''); +// 密码弹窗 +const dialogVisible = ref(false) + +// 验证密码 +const checkPassword = async () => { + const {data: response} = await useServerRequest>('/cms/cms-navigation/checkNavigationPassword', { + query: { + password: form.value?.password, + password2: password2.value + } + }) + if(response.value?.code === 0){ + dialogVisible.value = false; + emit('done', true); + console.log(response.value.message); + }else { + ElMessage.error(response.value?.message); + } +} -const { data: nav } = await useServerRequest>('/cms/cms-navigation/getNavigationByPath',{query: {path: route.path}}) -if(nav.value?.data){ +// 校验密码 +const {data: nav} = await useServerRequest>('/cms/cms-navigation/getNavigationByPath', { + query: { + path: route.path + } +}) +if (nav.value?.data) { form.value = nav.value?.data; + console.log('PageBanner.vue => ', form.value) // 页面布局 - if(form.value?.layout){ + if (form.value?.layout) { layout.value = JSON.parse(form.value?.layout) } - // 是否需要登录 - if(form.value.permission === 1){ - // navigateTo(`/passport/login`) + // 允许直接访问 + if(form.value?.permission === 0){ + emit('done', true); + } + // 要求登录可见 + if (form.value?.permission === 1) { + navigateTo(`/passport/login`); + if(token && token.value.length > 0){ + emit('done', true); + } + } + // 要求密码可见 + if (form.value?.permission === 2) { + dialogVisible.value = true; } } - diff --git a/composables/useServerRequest.ts b/composables/useServerRequest.ts index a33f77a..d4b440e 100644 --- a/composables/useServerRequest.ts +++ b/composables/useServerRequest.ts @@ -20,11 +20,11 @@ export const useServerRequest = (url: string, opts?: UseFetchOptions = { baseURL: baseUrl.value, diff --git a/layouts/default.vue b/layouts/default.vue index 73d4710..dccd105 100644 --- a/layouts/default.vue +++ b/layouts/default.vue @@ -157,6 +157,12 @@ const reload = async () => { // title: `网宿软件首页`, // meta: [{ name: website.value.keywords, content: website.value.comments }] // }); + + + // TODO 是否需要登录 + // if(form.value.permission === 1){ + // // navigateTo(`/passport/login`) + // } } reload() diff --git a/nuxt.config.ts b/nuxt.config.ts index 7743b3c..9b8377c 100644 --- a/nuxt.config.ts +++ b/nuxt.config.ts @@ -33,12 +33,10 @@ export default defineNuxtConfig({ public: { // 开发环境配置 // tenantId: '5', - apiBase: 'http://127.0.0.1:9090/api', - apiServer: 'http://127.0.0.1:9090/api', + apiServer: 'http://127.0.0.1:30000/api', // 生产环境 - // apiBase: 'https://server.gxwebsoft.com/api', - // apiServer: 'https://server.gxwebsoft.com/api', + // apiServer: 'https://common-api.websoft.top/api', globalTitle: '网宿软件', domain: 'websoft.top' }, diff --git a/pages/ask/components/CardList.vue b/pages/ask/components/CardList.vue index cbccc2e..5b9332e 100644 --- a/pages/ask/components/CardList.vue +++ b/pages/ask/components/CardList.vue @@ -7,11 +7,13 @@

- {{ item.title }} + + {{ item.title }}

{{ item.nickname }} · {{ dayjs(item.createTime).format('MM-DD hh:mm') }} +

@@ -27,6 +29,7 @@