添加搜索

This commit is contained in:
2026-07-01 14:18:27 +08:00
parent 242cc83843
commit e9c9dcd9c5
7 changed files with 138 additions and 14 deletions

View File

@ -14,4 +14,7 @@ VITE_DEBUG = false
VITE_MQTT_TRANSACTION_HOST=wss://adminapi.apimcapital.top/mqtt VITE_MQTT_TRANSACTION_HOST=wss://adminapi.apimcapital.top/mqtt
# exe 下载基础地址 # exe 下载基础地址
VITE_EXE_DOWNLOAD_BASE_URL = https://adminh5.apimcapital.top VITE_EXE_DOWNLOAD_BASE_URL = https://adminh5.apimcapital.top
# config.json 独立部署在 h5 域名下,需要该域名侧配置 CORS
VITE_UPDATE_URL = https://adminh5.apimcapital.top/config.json

View File

@ -14,4 +14,8 @@ VITE_DEBUG = true
VITE_MQTT_TRANSACTION_HOST = wss://adminapi.duxiang.wiki/mqtt VITE_MQTT_TRANSACTION_HOST = wss://adminapi.duxiang.wiki/mqtt
# exe 下载基础地址 # exe 下载基础地址
VITE_EXE_DOWNLOAD_BASE_URL = https://adminh5.duxiang.wiki VITE_EXE_DOWNLOAD_BASE_URL = https://adminh5.duxiang.wiki
# config.json 独立部署在 h5 域名下,需要该域名侧配置 CORS
VITE_UPDATE_URL = https://adminh5.duxiang.wiki/config.json

60
src/api/modules/config.ts Normal file
View File

@ -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<AppConfig>
*/
export async function getConfigApi(): Promise<AppConfig> {
// 使用相对路径 /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<AppConfig>(finalUrl)
return res.data
}

View File

@ -47,7 +47,7 @@
<el-button type="primary" :loading="buttonLoading" @click="$emit('search')"> <el-button type="primary" :loading="buttonLoading" @click="$emit('search')">
{{ buttonConfig.searchText || '搜索' }} {{ buttonConfig.searchText || '搜索' }}
</el-button> </el-button>
<el-button :loading="buttonLoading" @click="$emit('reset')"> <el-button :loading="buttonLoading" @click="$emit('reset')" v-if="isShowReset">
{{ buttonConfig.resetText || '重置' }} {{ buttonConfig.resetText || '重置' }}
</el-button> </el-button>
<!-- 按钮区插槽 --> <!-- 按钮区插槽 -->
@ -97,6 +97,10 @@ const props = defineProps({
type: Array as () => SearchOption[], type: Array as () => SearchOption[],
required: true, required: true,
}, },
isShowReset:{
type: Boolean,
default: true,
},
buttonConfig: { buttonConfig: {
type: Object as () => ButtonConfig, type: Object as () => ButtonConfig,
default: () => ({}), default: () => ({}),

View File

@ -1,9 +1,8 @@
<template> <template>
<div class="position-stat table_form-container"> <div class="position-stat table_form-container">
<!-- 搜索 --> <!-- 搜索 -->
<PositionStatSearch <PositionStatSearch :buttonLoading="loading" :search-form="searchForm" :search-options="searchOptions"
:buttonLoading="loading" :search-form="searchForm" :search-options="searchOptions" @search="handleSearch" @search="handleSearch" @reset="handleReset" :isShowReset="false">
@reset="handleReset">
<!-- <template #button="{ form }">--> <!-- <template #button="{ form }">-->
<!-- <el-button type="primary" @click="handleExport()">--> <!-- <el-button type="primary" @click="handleExport()">-->
<!-- 导出--> <!-- 导出-->
@ -55,6 +54,9 @@ const tableColumnsOptions = ref(tableColumns)
* @description: 定义搜索方法 * @description: 定义搜索方法
*/ */
const handleSearch = async () => { const handleSearch = async () => {
if (!searchForm.value.account_id) {
return ElMessage.warning('请输入账户ID')
}
try { try {
startLoading() startLoading()
const data = await checkAccountIdIsSonForUser({ account_id: searchForm.value.account_id }) const data = await checkAccountIdIsSonForUser({ account_id: searchForm.value.account_id })
@ -66,6 +68,7 @@ const handleSearch = async () => {
} finally { stopLoading() } } finally { stopLoading() }
} }
const handleReset = () => { const handleReset = () => {
searchForm.value.account_id = ''
console.log('重置搜索') console.log('重置搜索')
} }
const handleExport = () => { const handleExport = () => {
@ -80,7 +83,7 @@ onMounted(() => {
transactionStore?.disconnect() transactionStore?.disconnect()
transactionStore.initMarketConditionsMQTT() transactionStore.initMarketConditionsMQTT()
}) })
onUnmounted(()=>{ onUnmounted(() => {
transactionStore?.disconnect() transactionStore?.disconnect()
}) })

View File

@ -1,5 +1,5 @@
<template> <template>
<div class="download-wrapper table_form-container"> <div class="download-wrapper table_formcontainer">
<!-- PC端 --> <!-- PC端 -->
<div class="download-item"> <div class="download-item">
<div class="item-left"> <div class="item-left">
@ -45,7 +45,7 @@
</div> </div>
<!-- IOS --> <!-- IOS -->
<div class="download-item" v-if="false"> <div class="download-item" v-if="iosUploadUrl">
<div class="item-left"> <div class="item-left">
<div class="icon-box ios"> <div class="icon-box ios">
<svg viewBox="0 0 1024 1024" width="32" height="32"> <svg viewBox="0 0 1024 1024" width="32" height="32">
@ -58,11 +58,11 @@
</div> </div>
</div> </div>
<div class="item-center"> <div class="item-center">
<span class="desc">前往App Store搜索 InTrade 安装</span> <span class="desc">点击跳转至iOS下载页安装</span>
</div> </div>
<div class="item-right"> <div class="item-right">
<el-button type="warning" :icon="Link" @click="handleDownload('ios')"> <el-button type="warning" :icon="Link" :loading="iosLoading" @click="handleDownload('ios')">
前往商店 前往下载
</el-button> </el-button>
</div> </div>
</div> </div>
@ -71,6 +71,8 @@
<script setup lang="ts"> <script setup lang="ts">
import { Monitor, Download, Link } from '@element-plus/icons-vue' import { Monitor, Download, Link } from '@element-plus/icons-vue'
import { ref, onMounted } from 'vue'
import { getConfigApi } from '@/api/modules/config'
defineOptions({ name: 'Exe' }) defineOptions({ name: 'Exe' })
type DownloadType = 'pc' | 'android' | 'ios' type DownloadType = 'pc' | 'android' | 'ios'
@ -86,10 +88,51 @@ const androidApkName = isTestEnv ? 'app-production-debug.apk' : 'app-production-
const downloadUrlMap: Record<DownloadType, string> = { const downloadUrlMap: Record<DownloadType, string> = {
pc: `${exeBaseUrl}/pc/Apim Capital-1.0.27.exe`, pc: `${exeBaseUrl}/pc/Apim Capital-1.0.27.exe`,
android: `${exeBaseUrl}/app/${androidApkName}`, android: `${exeBaseUrl}/app/${androidApkName}`,
ios: `${exeBaseUrl}/app/xxxx.apk` ios: ''
} }
// config.json ios.upload_url
// config.json /prod/test /config.json
const iosUploadUrl = ref<string>('')
const iosLoading = ref(false)
/**
* 调用统一封装在 src/api/modules/config.ts 的接口获取 /config.json
* 从中读取 ios.upload_url 作为 iOS 下载跳转地址
*/
const fetchIosUploadUrl = async (): Promise<string> => {
try {
const data = await getConfigApi()
console.log('data:', data);
const url = data?.ios?.upload_url
if (typeof url === 'string' && url.trim()) {
return url.trim()
}
console.warn('[Exe] /config.json 中未找到 ios.upload_url 字段')
return ''
} catch (err) {
console.error('[Exe] 请求 /config.json 出错:', err)
return ''
}
}
onMounted(async () => {
iosLoading.value = true
iosUploadUrl.value = await fetchIosUploadUrl()
iosLoading.value = false
})
const handleDownload = (type: DownloadType) => { const handleDownload = (type: DownloadType) => {
if (type === 'ios') {
if (!iosUploadUrl.value) {
//
return
}
// iOS App Store /
window.open(iosUploadUrl.value, '_blank', 'noopener,noreferrer')
return
}
const url: string = downloadUrlMap[type] const url: string = downloadUrlMap[type]
// 使 window.open , // 使 window.open ,
// a.download SPA // a.download SPA
@ -113,7 +156,8 @@ const handleDownload = (type: DownloadType) => {
.download-wrapper { .download-wrapper {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
gap: 16px; gap: 16px;
padding: 10px 20px 0;
width: 100%; width: 100%;
.download-item { .download-item {

View File

@ -115,6 +115,12 @@ export default defineConfig(({ mode }: ConfigEnv): UserConfig => {
changeOrigin: true, changeOrigin: true,
rewrite: (path) => path.replace(/^\/api/, ''), rewrite: (path) => path.replace(/^\/api/, ''),
}, },
// 将 /config.json 代理到 h5 域名,避免开发环境跨域
'/config.json': {
target: env.VITE_EXE_DOWNLOAD_BASE_URL || env.VITE_UPDATE_URL,
changeOrigin: true,
secure: true,
},
}, },
}, },
} }