From e9c9dcd9c59df1d388689aff606aa1afe500560b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8?= Date: Wed, 1 Jul 2026 14:18:27 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=90=9C=E7=B4=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.production | 5 ++- .env.test | 6 ++- src/api/modules/config.ts | 60 ++++++++++++++++++++++++++++++ src/components/common/Search.vue | 6 ++- src/views/order/position/index.vue | 11 ++++-- src/views/trade/exe/index.vue | 58 +++++++++++++++++++++++++---- vite.config.ts | 6 +++ 7 files changed, 138 insertions(+), 14 deletions(-) create mode 100644 src/api/modules/config.ts diff --git a/.env.production b/.env.production index 4497a3e..91b21b8 100644 --- a/.env.production +++ b/.env.production @@ -14,4 +14,7 @@ VITE_DEBUG = false VITE_MQTT_TRANSACTION_HOST=wss://adminapi.apimcapital.top/mqtt # exe 下载基础地址 -VITE_EXE_DOWNLOAD_BASE_URL = https://adminh5.apimcapital.top \ No newline at end of file +VITE_EXE_DOWNLOAD_BASE_URL = https://adminh5.apimcapital.top + +# config.json 独立部署在 h5 域名下,需要该域名侧配置 CORS +VITE_UPDATE_URL = https://adminh5.apimcapital.top/config.json \ No newline at end of file diff --git a/.env.test b/.env.test index 8cd4893..7a0080e 100644 --- a/.env.test +++ b/.env.test @@ -14,4 +14,8 @@ VITE_DEBUG = true VITE_MQTT_TRANSACTION_HOST = wss://adminapi.duxiang.wiki/mqtt # exe 下载基础地址 -VITE_EXE_DOWNLOAD_BASE_URL = https://adminh5.duxiang.wiki \ No newline at end of file +VITE_EXE_DOWNLOAD_BASE_URL = https://adminh5.duxiang.wiki + + +# config.json 独立部署在 h5 域名下,需要该域名侧配置 CORS +VITE_UPDATE_URL = https://adminh5.duxiang.wiki/config.json \ No newline at end of file diff --git a/src/api/modules/config.ts b/src/api/modules/config.ts new file mode 100644 index 0000000..98036fc --- /dev/null +++ b/src/api/modules/config.ts @@ -0,0 +1,60 @@ +import axios from 'axios' +import { request as baseRequest } from '@/api' + +// 抑制未使用导入告警 +void baseRequest + +/** + * config.json 中与 ios 相关的配置结构 + */ +export type IosConfig = { + /** iOS 下载地址(跳转目标) */ + upload_url?: string +} + +/** + * /config.json 整体结构(按需扩展字段) + */ +export type AppConfig = { + ios?: IosConfig + // 后续若有 android / pc / 版本号等配置也可在此扩展 + [key: string]: unknown +} + +/** + * 静态文件请求专用的 axios 实例: + * - 不带 baseURL(绕开 src/api/index.ts 的 VITE_API_BASE_URL) + * - 不带业务 token、不触发全局 loading / 错误通知 + * - 与项目里 request 拦截器彻底解耦 + */ +const staticRequest = axios.create({ + timeout: 10000, + headers: { 'Content-Type': 'application/json;charset=utf-8' }, +}) + +/** + * 获取当前环境下的 config.json + * + * 关键说明: + * 1. 项目里 src/api/index.ts 的 service 默认 baseURL = VITE_API_BASE_URL(业务后端), + * 直接 request.get('/config.json') 会请求业务后端下的 /config.json,自然 404。 + * 2. config.json 通常独立部署在 h5 域名(如 https://adminh5.xxx.com/config.json), + * 需要直接请求该地址。这里用 VITE_UPDATE_URL(无协议/域名兜底为 VITE_EXE_DOWNLOAD_BASE_URL)作为基础域名。 + * 3. 跨域:若管理后台与 config.json 部署不同源,需要 h5 域名侧 Nginx / CDN 配置 CORS 头: + * Access-Control-Allow-Origin: <管理后台域名> + * Access-Control-Allow-Methods: GET + * 否则浏览器会拦截请求。 + * + * @returns Promise 配置文件内容(业务调用方按需取字段) + */ +export async function getConfigApi(): Promise { + // 使用相对路径 /config.json: + // - 开发环境由 vite.config.ts 的 server.proxy 转发到 h5 域名,避免 CORS + // - 生产环境需要运维在 Nginx / 网关上做同等代理(例如把 /config.json 反代到 h5 域名) + const url = '/config.json' + const sep = url.includes('?') ? '&' : '?' + const finalUrl = `${url}${sep}t=${new Date().getTime()}&channel=web` + + const res = await staticRequest.get(finalUrl) + return res.data +} \ No newline at end of file diff --git a/src/components/common/Search.vue b/src/components/common/Search.vue index 5c06c1e..375f7d3 100644 --- a/src/components/common/Search.vue +++ b/src/components/common/Search.vue @@ -47,7 +47,7 @@ {{ buttonConfig.searchText || '搜索' }} - + {{ buttonConfig.resetText || '重置' }} @@ -97,6 +97,10 @@ const props = defineProps({ type: Array as () => SearchOption[], required: true, }, + isShowReset:{ + type: Boolean, + default: true, + }, buttonConfig: { type: Object as () => ButtonConfig, default: () => ({}), diff --git a/src/views/order/position/index.vue b/src/views/order/position/index.vue index c0e0311..9f1c27e 100644 --- a/src/views/order/position/index.vue +++ b/src/views/order/position/index.vue @@ -1,9 +1,8 @@