|
@@ -14,8 +14,20 @@ const useStore = useUserStore();
|
|
|
|
|
|
export const url = import.meta.env.VITE_BASE_URL;
|
|
|
export const prefix = import.meta.env.VITE_BASE_PREFIX;
|
|
|
-export const baseURL = url + prefix;
|
|
|
+export let baseURL = url + prefix;
|
|
|
+function isIPAddress(hostname:string) {
|
|
|
+ const ipRegex = /^(?:\d{1,3}\.){3}\d{1,3}$|^(?:[0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}$/;
|
|
|
+ return ipRegex.test(hostname);
|
|
|
+}
|
|
|
+
|
|
|
|
|
|
+const hostname = window.location.hostname;
|
|
|
+
|
|
|
+if (isIPAddress(hostname)) {
|
|
|
+ baseURL= `http://${hostname}:8080/`
|
|
|
+} else {
|
|
|
+ baseURL= `/apiServe`
|
|
|
+}
|
|
|
enum errorCode {
|
|
|
'请求错误' = 400,
|
|
|
'未授权,请重新登录' = 401,
|