|
@@ -1,35 +1,6 @@
|
|
|
// uniapp封装的请求方法
|
|
// uniapp封装的请求方法
|
|
|
let timeout = 60 * 1000;
|
|
let timeout = 60 * 1000;
|
|
|
|
|
|
|
|
-// 获取当前应该使用的 base URL
|
|
|
|
|
-const getBaseUrl = (): string => {
|
|
|
|
|
- try {
|
|
|
|
|
- // 获取当前页面栈
|
|
|
|
|
- const pages = getCurrentPages();
|
|
|
|
|
- if (pages.length === 0) {
|
|
|
|
|
- // 默认使用 VITE_API_BASE_URL
|
|
|
|
|
- return import.meta.env.VITE_API_BASE_URL || 'http://localhost:3000';
|
|
|
|
|
- }
|
|
|
|
|
- // 获取当前页面路由
|
|
|
|
|
- const currentPage = pages[pages.length - 1];
|
|
|
|
|
- const route = currentPage.route || '';
|
|
|
|
|
- console.log(route, 'route');
|
|
|
|
|
-
|
|
|
|
|
- // 判断路由路径
|
|
|
|
|
- if (route.includes('plant/')) {
|
|
|
|
|
- return import.meta.env.VITE_API_BASE_URL || 'http://localhost:3000';
|
|
|
|
|
- } else if (route.includes('production/')) {
|
|
|
|
|
- return import.meta.env.VITE_API_OTHER_BASE_URL || 'http://localhost:3000';
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- // 默认情况
|
|
|
|
|
- return import.meta.env.VITE_API_BASE_URL || 'http://localhost:3000';
|
|
|
|
|
- } catch (error) {
|
|
|
|
|
- // 出错时使用默认值
|
|
|
|
|
- return import.meta.env.VITE_API_BASE_URL || 'http://localhost:3000';
|
|
|
|
|
- }
|
|
|
|
|
-};
|
|
|
|
|
-
|
|
|
|
|
// 获取全局请求头方法
|
|
// 获取全局请求头方法
|
|
|
const getHeader = () => {
|
|
const getHeader = () => {
|
|
|
let header = {
|
|
let header = {
|