feat: 服务接口地址动态获取

This commit is contained in:
duanshuwen
2025-11-13 19:43:03 +08:00
parent 48932e3851
commit 1028e20d42
14 changed files with 44 additions and 55 deletions

View File

@@ -1,5 +1,5 @@
import { BASE_URL } from "@/request/base/baseUrl";
import { goLogin } from "@/hooks/useGoLogin";
import { useAppStore } from "@/store";
/// 请求流式数据的API
const API = "/agent/assistant/chat";
@@ -93,8 +93,9 @@ const agentChatStream = (params, onChunk) => {
};
// #ifdef MP-WEIXIN
const { serverConfig } = useAppStore();
requestTask = uni.request({
url: BASE_URL + API, // 替换为你的接口地址
url: serverConfig.baseUrl + API, // 替换为你的接口地址
method: "POST",
data: params,
enableChunked: true,

View File

@@ -1,8 +1,9 @@
import { BASE_URL } from "@/request/base/baseUrl";
import { getCurrentConfig } from "@/constant/base";
import { useAppStore } from "@/store";
export const updateImageFile = (file) => {
const url = BASE_URL + "/hotelBiz/hotBizCommon/upload";
const { serverConfig } = useAppStore();
const url = serverConfig.baseUrl + "/hotelBiz/hotBizCommon/upload";
const token = uni.getStorageSync("token");
const clientId = getCurrentConfig().clientId;

17
src/request/api/config.js Normal file
View File

@@ -0,0 +1,17 @@
import request from "../base/request";
import { isProd } from "@/constant/base";
import { useAppStore } from "@/store";
// 获取服务地址
const getEvnUrl = (args) => {
if (isProd) {
const appStore = useAppStore();
request.post("/hotelBiz/mainScene/getServiceUrl", args).then(({ data }) => {
console.log("🚀 ~ getEvnUrl ~ data:", data);
appStore.setServerConfig(data);
});
}
};
export { getEvnUrl };