Update prefix issue

This commit is contained in:
Donald Zou
2025-12-25 16:49:32 +08:00
parent 53f7a32202
commit a0bbace7ee
157 changed files with 163 additions and 294 deletions

View File

@@ -5,6 +5,7 @@
<link rel="icon" href="./img/Logo-2-128x128.png">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>WGDashboard Client</title>
<base href="./client/">
<style>
*{
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
@@ -29,19 +30,11 @@
}
</style>
<script>
let appPrefix = "{{ APP_PREFIX if APP_PREFIX else '' }}";
if (appPrefix.includes('{' + '{')) {
appPrefix = '';
}
window.APP_PREFIX = appPrefix;
const isViteDevMode = document.querySelector('script[src*="@vite/client"]') !== null;
const base = document.createElement('base');
if (isViteDevMode) {
const base = document.querySelector('base');
if (base && isViteDevMode) {
base.href = '/';
} else {
base.href = (window.APP_PREFIX || '') + '/client/';
}
document.head.insertBefore(base, document.head.firstChild);
</script>
</head>
<body>

View File

@@ -2,11 +2,13 @@
import './assets/main.css'
import NotificationList from "@/components/Notification/notificationList.vue";
import {clientStore} from "@/stores/clientStore.js";
import {axiosGet} from "@/utilities/request.js";
const store = clientStore()
fetch("/client/api/serverInformation")
.then(res => res.json())
.then(res => store.serverInformation = res.data)
const serverInformation = axiosGet("/api/serverInformation", {})
if (serverInformation){
store.serverInformation = serverInformation;
}
</script>
<template>

View File

@@ -1,26 +1,18 @@
import axios from "axios";
import {useRouter} from "vue-router";
export const requestURl = (url) => {
if (import.meta.env.MODE === 'development') {
return '/client' + url;
}
const appPrefix = window.APP_PREFIX || '';
return `${window.location.protocol}//${window.location.host}${appPrefix}/client${url}`;
return `./.${url}`;
}
// const router = useRouter()
export const axiosPost = async (URL, body = {}) => {
try{
const res = await axios.post(requestURl(URL), body)
return res.data
} catch (error){
console.log(error)
// if (error.status === 401){
// await router.push('/signin')
// }
return undefined
}
}
@@ -31,9 +23,6 @@ export const axiosGet = async (URL, query = {}) => {
return res.data
} catch (error){
console.log(error)
// if (error.status === 401){
// await router.push('/signin')
// }
return undefined
}
}