|
@ -1,17 +1,17 @@ |
|
|
<template> |
|
|
<template> |
|
|
<!-- 运行中 --> |
|
|
|
|
|
<template v-if="website.status == 0"> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<!-- 加载应用 --> |
|
|
|
|
|
<template v-if="!loading"> |
|
|
<app-header /> |
|
|
<app-header /> |
|
|
<slot /> |
|
|
<slot /> |
|
|
<app-footer /> |
|
|
<app-footer /> |
|
|
</template> |
|
|
</template> |
|
|
<template v-else> |
|
|
|
|
|
<UnderMaintenance /> |
|
|
|
|
|
</template> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<!-- 异常状态 --> |
|
|
|
|
|
<UnderMaintenance v-if="loading" /> |
|
|
|
|
|
|
|
|
</template> |
|
|
</template> |
|
|
<script setup lang="ts"> |
|
|
<script setup lang="ts"> |
|
|
import {getLoacl, setLocal} from "~/utils/common"; |
|
|
|
|
|
import {listWebsite} from "~/api/cms/website"; |
|
|
|
|
|
import {useServerRequest} from "~/composables/useServerRequest"; |
|
|
import {useServerRequest} from "~/composables/useServerRequest"; |
|
|
import type {ApiResult} from "~/api"; |
|
|
import type {ApiResult} from "~/api"; |
|
|
import type {Domain} from "~/api/cms/domain/model"; |
|
|
import type {Domain} from "~/api/cms/domain/model"; |
|
@ -19,21 +19,17 @@ |
|
|
import type {Website} from "~/api/cms/website/model"; |
|
|
import type {Website} from "~/api/cms/website/model"; |
|
|
import type {Navigation} from "~/api/cms/navigation/model"; |
|
|
import type {Navigation} from "~/api/cms/navigation/model"; |
|
|
import type {Config} from "~/types/global"; |
|
|
import type {Config} from "~/types/global"; |
|
|
|
|
|
import {getLoacl, setLocal} from "~/utils/common"; |
|
|
import UnderMaintenance from "~/components/UnderMaintenance.vue"; |
|
|
import UnderMaintenance from "~/components/UnderMaintenance.vue"; |
|
|
|
|
|
|
|
|
// TODO 1 查询当前域名是否有绑定域名,绑定则解构出租户ID放入缓存 |
|
|
|
|
|
localStorage.removeItem('TID_DOMAIN'); |
|
|
|
|
|
if (!localStorage.getItem('TID_DOMAIN')) { |
|
|
|
|
|
const domain = window.location.hostname; |
|
|
|
|
|
const {data: domainInfo } = await useServerRequest<ApiResult<Domain>>('/cms/domain/getByDomain/' + domain); |
|
|
|
|
|
const data = domainInfo.value?.data; |
|
|
|
|
|
console.log(data,'当前域名是否有绑定') |
|
|
|
|
|
if (data) { |
|
|
|
|
|
localStorage.setItem('TID_DOMAIN',`${data?.tenantId}`) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
// 加载状态 |
|
|
|
|
|
const loading = ref<boolean>(false) |
|
|
|
|
|
const website = useWebsite() |
|
|
|
|
|
const config = useConfigInfo(); |
|
|
|
|
|
const menu = useMenu() |
|
|
|
|
|
const subMenu = useSubMenu() |
|
|
|
|
|
|
|
|
// TODO 2 挂载钩子 |
|
|
|
|
|
|
|
|
// 挂载钩子 |
|
|
onMounted(() => { |
|
|
onMounted(() => { |
|
|
//必须在onMounted的时候才能用local和window |
|
|
//必须在onMounted的时候才能用local和window |
|
|
// getLoacl(); |
|
|
// getLoacl(); |
|
@ -43,44 +39,69 @@ |
|
|
}; |
|
|
}; |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
// TODO 3 读取服务器缓存数据 |
|
|
|
|
|
const website = useWebsite() |
|
|
|
|
|
const {data: websiteInfo } = await useServerRequest<ApiResult<Website>>('/cms/website/getSiteInfo'); |
|
|
|
|
|
if(websiteInfo.value?.data){ |
|
|
|
|
|
website.value = websiteInfo.value?.data; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
// 加载数据 |
|
|
|
|
|
const reload = async () => { |
|
|
|
|
|
// const loading = ElLoading.service({ |
|
|
|
|
|
// lock: true, |
|
|
|
|
|
// text: 'Loading' |
|
|
|
|
|
// }) |
|
|
|
|
|
|
|
|
// TODO 4 读取网站状态 |
|
|
|
|
|
const {data: websiteRealTime } = await useServerRequest<ApiResult<Website>>('/cms/website/' + website.value.websiteId); |
|
|
|
|
|
website.value = Object.assign({},website.value,websiteRealTime.value?.data) |
|
|
|
|
|
|
|
|
// TODO 1 查询当前域名是否有绑定域名,绑定则解构出租户ID放入缓存 |
|
|
|
|
|
localStorage.removeItem('TID_DOMAIN'); |
|
|
|
|
|
if (!localStorage.getItem('TID_DOMAIN')) { |
|
|
|
|
|
const domain = window.location.hostname; |
|
|
|
|
|
const {data: domainInfo } = await useServerRequest<ApiResult<Domain>>('/cms/domain/getByDomain/' + domain); |
|
|
|
|
|
const data = domainInfo.value?.data; |
|
|
|
|
|
if (data) { |
|
|
|
|
|
localStorage.setItem('TID_DOMAIN',`${data?.tenantId}`) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
// TODO 5 读取网站配置信息 |
|
|
|
|
|
const config = useConfigInfo(); |
|
|
|
|
|
const { data: fields } = await useServerRequest<ApiResult<Config>>('/cms/website-field/config', {}); |
|
|
|
|
|
if (fields.value?.data) { |
|
|
|
|
|
config.value = fields.value?.data; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
// TODO 2 读取服务器缓存数据 |
|
|
|
|
|
const {data: websiteInfo } = await useServerRequest<ApiResult<Website>>('/cms/website/getSiteInfo'); |
|
|
|
|
|
if(!websiteInfo.value){ |
|
|
|
|
|
ElMessage.error('require is not defined.') |
|
|
|
|
|
return false; |
|
|
|
|
|
} |
|
|
|
|
|
if(websiteInfo.value?.data){ |
|
|
|
|
|
website.value = websiteInfo.value?.data; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
// TODO 6 获取网站顶部菜单 |
|
|
|
|
|
const menu = useMenu() |
|
|
|
|
|
const { data: menuInfo } = await useServerRequest<ApiResult<Navigation[]>>('/cms/navigation/tree', { |
|
|
|
|
|
query: { |
|
|
|
|
|
position: 1 |
|
|
|
|
|
|
|
|
// TODO 4 读取网站状态 |
|
|
|
|
|
const {data: websiteRealTime } = await useServerRequest<ApiResult<Website>>('/cms/website/' + website.value.websiteId); |
|
|
|
|
|
website.value = Object.assign({},website.value,websiteRealTime.value?.data) |
|
|
|
|
|
if (website.value?.status != 1) { |
|
|
|
|
|
useHead({title: ''}) |
|
|
|
|
|
loading.value = true; |
|
|
|
|
|
return false; |
|
|
} |
|
|
} |
|
|
}); |
|
|
|
|
|
if(menuInfo.value?.data){ |
|
|
|
|
|
menu.value = menuInfo.value?.data |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// TODO 7 获取网站底部菜单 |
|
|
|
|
|
const subMenu = useSubMenu() |
|
|
|
|
|
const { data: subMenuInfo } = await useServerRequest<ApiResult<Navigation[]>>('/cms/navigation/tree', { |
|
|
|
|
|
query: { |
|
|
|
|
|
position: 2 |
|
|
|
|
|
|
|
|
// TODO 5 读取网站配置信息 |
|
|
|
|
|
const { data: fields } = await useServerRequest<ApiResult<Config>>('/cms/website-field/config', {}); |
|
|
|
|
|
if (fields.value?.data) { |
|
|
|
|
|
config.value = fields.value?.data; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// TODO 6 获取网站顶部菜单 |
|
|
|
|
|
const { data: menuInfo } = await useServerRequest<ApiResult<Navigation[]>>('/cms/navigation/tree', { |
|
|
|
|
|
query: { |
|
|
|
|
|
top: 0 |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
if(menuInfo.value?.data){ |
|
|
|
|
|
menu.value = menuInfo.value?.data |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// TODO 7 获取网站底部菜单 |
|
|
|
|
|
const { data: subMenuInfo } = await useServerRequest<ApiResult<Navigation[]>>('/cms/navigation/tree', { |
|
|
|
|
|
query: { |
|
|
|
|
|
bottom: 0 |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
if(subMenuInfo.value?.data){ |
|
|
|
|
|
subMenu.value = subMenuInfo.value?.data |
|
|
} |
|
|
} |
|
|
}); |
|
|
|
|
|
if(subMenuInfo.value?.data){ |
|
|
|
|
|
subMenu.value = subMenuInfo.value?.data |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
reload() |
|
|
</script> |
|
|
</script> |
|
|