mirror of
https://github.com/donaldzou/WGDashboard.git
synced 2026-04-17 10:26:18 +00:00
Update prefix issue
This commit is contained in:
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user