From 8f80b123339d3f7de2c72b0d0215dab4e9f8d766 Mon Sep 17 00:00:00 2001 From: "rx.wu" Date: Wed, 29 May 2024 11:50:49 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E5=90=8E=E7=AB=AF?= =?UTF-8?q?=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/defaultSettings.ts | 2 ++ src/consts/config.ts | 10 ++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/config/defaultSettings.ts b/config/defaultSettings.ts index a92b0f2..6a512b8 100644 --- a/config/defaultSettings.ts +++ b/config/defaultSettings.ts @@ -8,6 +8,7 @@ const Settings: LayoutSettings & { https?: boolean; logo?: string; apiUrl?: string; + backend?: boolean; } = { navTheme: 'light', // 拂晓蓝 @@ -23,6 +24,7 @@ const Settings: LayoutSettings & { iconfontUrl: '//at.alicdn.com/t/font_915840_kom9s5w2t6k.js', apiUrl: 'api.pity.fun', https: false, + backend: false, }; export default Settings; diff --git a/src/consts/config.ts b/src/consts/config.ts index 8a5d1f1..b7e6adc 100644 --- a/src/consts/config.ts +++ b/src/consts/config.ts @@ -6,17 +6,23 @@ import defaultSettings from "../../config/defaultSettings"; // } // const dev = isDev() +const getApiUrl = () => { + if (defaultSettings.backend) { + return window.location.host + } + return defaultSettings.apiUrl +} const getUrl = () => { const prefix = defaultSettings.https ? 'https://' : 'http://' - return `${prefix}${defaultSettings.apiUrl}` + return `${prefix}${getApiUrl()}` } const URL = getUrl(); const getWss = () => { const prefix = defaultSettings.https ? 'wss://' : 'ws://' - return `${prefix}${defaultSettings.apiUrl}` + return `${prefix}${getApiUrl()}` } const CONFIG = {