更新网站架构

This commit is contained in:
李志强 2026-03-09 16:35:38 +08:00
parent b6294200a7
commit 8a33f6cd9f
4 changed files with 59 additions and 71 deletions

View File

@ -1,6 +1,5 @@
import { createRouter, createWebHistory } from 'vue-router';
import { constantRoute, registerDynamicRoutes } from './routes';
import { getHeadMenu } from '@/api/index';
// 先创建路由,但不立即匹配
const router = createRouter({
@ -25,21 +24,6 @@ export async function loadAndRegisterRoutes() {
return routesLoadingPromise;
}
// 开始加载
routesLoadingPromise = (async () => {
try {
const response = await getHeadMenu();
if (response.code === 200 && response.data) {
registerDynamicRoutes(router, response.data);
routesLoaded = true;
}
} catch (error) {
console.error('Failed to load menus and register routes:', error);
} finally {
routesLoadingPromise = null;
}
})();
return routesLoadingPromise;
}
@ -47,9 +31,7 @@ export async function loadAndRegisterRoutes() {
router.beforeEach(async (to, _from, next) => {
// 如果路由还未加载,先加载路由
if (!routesLoaded) {
if (!routesLoadingPromise) {
routesLoadingPromise = loadAndRegisterRoutes();
}
// 等待路由加载完成
await routesLoadingPromise;

View File

@ -18,12 +18,11 @@
import { ref, onMounted } from 'vue'
import axios from 'axios'
const API_BASE = 'http://localhost:8000'
const VITE_API_BASE_URL = import.meta.env.VITE_API_BASE_URL
const loading = ref(true)
const error = ref('')
const iframeSrc = ref('')
const siteData = ref<Record<string, any>>({})
const fetchData = async () => {
loading.value = true
@ -31,12 +30,11 @@ const fetchData = async () => {
try {
// axios
const res = await axios.get(`${API_BASE}/index/init`)
const res = await axios.get(`${VITE_API_BASE_URL}/index/init`)
console.log('API响应:', res.data)
if (res.data.code === 200) {
iframeSrc.value = API_BASE + res.data.data.theme_path
siteData.value = res.data.data.data || {}
iframeSrc.value = VITE_API_BASE_URL + res.data.data.theme_path
console.log('iframe地址:', iframeSrc.value)
} else {
error.value = res.data.msg || '获取模板失败'
@ -50,13 +48,7 @@ const fetchData = async () => {
}
const onLoad = () => {
const iframe = document.querySelector('.theme-iframe') as HTMLIFrameElement
if (iframe?.contentWindow) {
iframe.contentWindow.postMessage({
type: 'SET_SITE_DATA',
data: { ...siteData.value, _t: Date.now() }
}, '*')
}
console.log('模板加载完成')
}
onMounted(() => {

View File

@ -585,6 +585,12 @@ onMounted(async () => {
line-height: 25px;
color: #606266;
}
:deep(span) {
padding: 3px 4px;
margin:5px;
border-radius:4px;
}
}
.theend {

View File

@ -43,7 +43,7 @@
v-if="footerData && footerData.logow"
:src="getenvurl(footerData.logow)"
alt="logo"
>
/>
</div>
<div class="footer-column">
<div class="title">订阅我们</div>
@ -51,11 +51,19 @@
</div>
</div>
</div>
<div class="footer-bottom" v-if="footerData" >
<div class="footer-bottom" v-if="footerData">
<div class="left">
<span class="mr-3">{{ footerData.description }}</span>
<span class="mr-3">{{ footerData.companyname }}&nbsp;&nbsp;&nbsp;&nbsp;{{ footerData.copyright }}</span>
<span class="mr-3"><a href="https://beian.miit.gov.cn/" target="_blank">{{ footerData.icp }}</a></span>
<span class="mr-3">
{{ footerData.companyname }}&nbsp;&nbsp;&nbsp;&nbsp;{{
footerData.copyright
}}
</span>
<span class="mr-3">
<a href="https://beian.miit.gov.cn/" target="_blank">
{{ footerData.icp }}
</a>
</span>
</div>
<div class="right">
<span>法律声明 | 隐私条款</span>
@ -92,7 +100,7 @@ const handleScroll = () => {
const goToTop = () => {
window.scrollTo({
top: 0,
behavior: 'smooth'
behavior: 'smooth',
})
}
@ -137,7 +145,7 @@ onUnmounted(() => {
z-index: 99;
.footer-content {
width:1200px;
width: 1200px;
margin: 0 auto;
}
@ -177,7 +185,7 @@ onUnmounted(() => {
flex: 1;
padding: 0 15px;
li{
li {
font-size: 1rem;
}
}
@ -186,9 +194,9 @@ onUnmounted(() => {
.right {
width: 20%;
.logo-w{
.logo-w {
margin-bottom: 20px;
img{
img {
height: 45px;
object-fit: contain;
}