li.shaoyi 2 éve
szülő
commit
a4e8448497

+ 9 - 3
app/main.js

@@ -89,6 +89,12 @@ const createWindow = () => {
     win.on('ready-to-show', () => updateHandle(win))
 }
 
-app.whenReady().then(() => {
-    createWindow()
-})
+// 阻止应用多开
+const gotTheLock = app.requestSingleInstanceLock()
+if (!gotTheLock) {
+    app.quit()
+} else {
+    app.whenReady().then(() => {
+        createWindow()
+    })
+}

+ 1 - 1
app/package.json

@@ -1,5 +1,5 @@
 {
-  "name": "muchinfo",
+  "name": "trading",
   "version": "1.0.0",
   "main": "main.js",
   "dependencies": {

+ 1 - 3
src/business/login/index.ts

@@ -1,7 +1,7 @@
 import { shallowRef, reactive } from 'vue'
 import { timerTask } from '@/utils/timer'
 import { login, logout } from '@/services/api/account'
-import { useLoginStore, useEnumStore, useErrorInfoStore, useUserStore, useFuturesStore, useAccountStore, usePositionStore, useNoticeStore } from '@/stores'
+import { useLoginStore, useEnumStore, useErrorInfoStore, useUserStore, useFuturesStore, useAccountStore, useNoticeStore } from '@/stores'
 import service from '@/services'
 import tradeSocket from '@/services/websocket/trade'
 import eventBus from '@/services/bus'
@@ -20,7 +20,6 @@ export function useLogin(persist = false) {
     const userStore = useUserStore()
     const accountStore = useAccountStore()
     const futuresStore = useFuturesStore()
-    const positionStore = usePositionStore()
     const noticeStore = useNoticeStore()
 
     const { logining, token } = loginStore.$toRefs()
@@ -47,7 +46,6 @@ export function useLogin(persist = false) {
             accountStore.getAccountList(),
         ])
         futuresStore.getGoodsList()
-        positionStore.getTradePosition()
         noticeStore.getNoticeList()
         tradeSocket.connect()
         checkTokenLoop()

+ 4 - 2
src/business/position/index.ts

@@ -22,8 +22,10 @@ export const usePosition = (...tradeMode: number[]) => {
     }
 
     onMounted(() => {
-        const goodsCodes = positionList.value.map((e) => e.goodscode)
-        subscribe.start(...goodsCodes)
+        store.getTradePosition().then(() => {
+            const goodsCodes = positionList.value.map((e) => e.goodscode)
+            subscribe.start(...goodsCodes)
+        })
     })
 
     onUnmounted(() => subscribe.stop())

+ 6 - 1
src/packages/gstj/views/mine/Index.vue

@@ -117,7 +117,7 @@
 </template>
 
 <script lang="ts" setup>
-import { shallowRef, onActivated } from 'vue'
+import { shallowRef, onMounted, onActivated } from 'vue'
 import { Cell, CellGroup, Button, Icon } from 'vant'
 import { fullloading, dialog } from '@/utils/vant'
 import { useNavigation } from '@mobile/router/navigation'
@@ -195,6 +195,11 @@ onActivated(() => {
         })
     }
 })
+
+onMounted(() => {
+    // 请求持仓列表,待优化---可用资金计算可能需要订阅行情
+    eventBus.$emit('PosChangedNtf')
+})
 </script>
 
 <style lang="less">

+ 6 - 1
src/packages/mobile/views/mine/Index.vue

@@ -117,7 +117,7 @@
 </template>
 
 <script lang="ts" setup>
-import { shallowRef, onActivated } from 'vue'
+import { shallowRef, onMounted, onActivated } from 'vue'
 import { Cell, CellGroup, Button, Icon } from 'vant'
 import { fullloading, dialog } from '@/utils/vant'
 import { useNavigation } from '@mobile/router/navigation'
@@ -195,6 +195,11 @@ onActivated(() => {
         })
     }
 })
+
+onMounted(() => {
+    // 请求持仓列表,待优化---可用资金计算可能需要订阅行情
+    eventBus.$emit('PosChangedNtf')
+})
 </script>
 
 <style lang="less">

+ 6 - 5
src/packages/mobile/views/transfer/listing/Index.vue

@@ -59,7 +59,8 @@ import { fullloading, dialog } from '@/utils/vant'
 import { useRequest } from '@/hooks/request'
 import { queryMineTradePositionExs } from '@/services/api/transfer'
 import { useOrder } from '@/business/trade'
-import { useAccountStore, useFuturesStore, usePositionStore } from '@/stores'
+import { usePosition } from '@/business/position'
+import { useAccountStore, useFuturesStore } from '@/stores'
 import AppModal from '@/components/base/modal/index.vue'
 import { BuyOrSell } from '@/constants/order'
 import { EPriceMode, EValidType, EListingSelectType, EBuildType, EDelistingType } from '@/constants/client'
@@ -81,7 +82,7 @@ const props = defineProps({
 const { formData, formSubmit } = useOrder()
 const accountStore = useAccountStore()
 const futuresStore = useFuturesStore()
-const positionStore = usePositionStore()
+const { positionList } = usePosition(16)
 const formRef = shallowRef<FormInstance>()
 const refresh = shallowRef(false) // 是否刷新父组件数据
 const showModal = shallowRef(true)
@@ -90,7 +91,7 @@ const qtyStepList = [1, 5, 10, 20, 30, 50] // 数量步长列表
 const qtyStep = shallowRef(qtyStepList[0]) // 数量步长
 
 // 获取转让持仓
-const { dataList: positionList, run: getMineTradePositionExs } = useRequest(queryMineTradePositionExs, {
+const { dataList, run: getMineTradePositionExs } = useRequest(queryMineTradePositionExs, {
     manual: true,
     params: {
         goodsid: quote.value?.goodsid,
@@ -131,10 +132,10 @@ const formRules: { [key in keyof Proto.OrderReq]?: FieldRule[] } = {
 // 可用数量
 const enableqty = computed(() => {
     if (quote.value?.trademode === 16) {
-        const item = positionStore.positionList.find((e) => e.trademode === 16 && e.goodsid === quote.value?.goodsid)
+        const item = positionList.value.find((e) => e.goodsid === quote.value?.goodsid)
         return item?.enableqty ?? 0
     } else {
-        const [firstItem] = positionList.value
+        const [firstItem] = dataList.value
         return firstItem ? firstItem.buycurpositionqty - firstItem.buyfrozenqty : 0
     }
 })

+ 2 - 2
src/packages/pc/components/base/table/index.vue

@@ -30,8 +30,8 @@
         <!-- 数据列 -->
         <template v-for="(item, index) in columns" :key="index">
           <el-table-column :align="item.align ?? 'center'" :min-width="120" :width="item.width" :label="item.label"
-            :prop="item.prop" :fixed="item.fixed || false" :sortable="item.sortable" show-overflow-tooltip
-            v-if="item.show ?? true">
+            :prop="item.prop" :fixed="item.fixed || false" :sortable="item.sortable"
+            :show-overflow-tooltip="item.prop !== 'operate'" v-if="item.show ?? true">
             <template #default="{ row, $index }">
               <slot :name="item.prop" :row="row" :value="row[item.prop]" :index="$index">
                 <span :class="item.className">{{ handleValue(row, item) }}</span>

+ 6 - 5
src/packages/pc/views/market/trade/presell/transfer/listing/index.vue

@@ -68,13 +68,14 @@ import { BuyOrSell, getBuyOrSellList } from '@/constants/order'
 import { useRequest } from '@/hooks/request'
 import { queryMineTradePositionExs } from '@/services/api/transfer'
 import { useOrder } from '@/business/trade'
-import { useFuturesStore, useSettingStore, usePositionStore } from '@/stores'
+import { usePosition } from '@/business/position'
+import { useFuturesStore, useSettingStore } from '@/stores'
 import Forex from '@pc/components/modules/quote/forex/index.vue'
 import Icon from '@pc/components/base/icon/index.vue'
 
 const settingStore = useSettingStore()
 const futuresStore = useFuturesStore()
-const positionStore = usePositionStore()
+const { positionList } = usePosition(16)
 const { selectedGoodsId, selectedGoods, marketGoodsList } = futuresStore.$toRefs()
 const { formData, loading, formSubmit } = useOrder()
 const formRef = shallowRef<FormInstance>()
@@ -86,7 +87,7 @@ const qtyRef = shallowRef()
 const submitRef = shallowRef()
 
 // 获取转让持仓
-const { dataList: positionList, run: getMineTradePositionExs } = useRequest(queryMineTradePositionExs, {
+const { dataList, run: getMineTradePositionExs } = useRequest(queryMineTradePositionExs, {
     manual: true,
     onSuccess: (res) => {
         const [firstItem] = res.data
@@ -99,10 +100,10 @@ const { dataList: positionList, run: getMineTradePositionExs } = useRequest(quer
 // 可用数量
 const enableqty = computed(() => {
     if (selectedGoods.value?.trademode === 16) {
-        const item = positionStore.positionList.find((e) => e.trademode === 16 && e.goodsid === selectedGoodsId.value)
+        const item = positionList.value.find((e) => e.goodsid === selectedGoodsId.value)
         return item?.enableqty ?? 0
     } else {
-        const [firstItem] = positionList.value
+        const [firstItem] = dataList.value
         return firstItem ? firstItem.buycurpositionqty - firstItem.buyfrozenqty : 0
     }
 })

+ 6 - 1
src/packages/qdhs/views/mine/Index.vue

@@ -114,7 +114,7 @@
 </template>
 
 <script lang="ts" setup>
-import { shallowRef, onActivated } from 'vue'
+import { shallowRef, onMounted, onActivated } from 'vue'
 import { Cell, CellGroup, Button, Icon } from 'vant'
 import { fullloading, dialog } from '@/utils/vant'
 import { useNavigation } from '@mobile/router/navigation'
@@ -192,6 +192,11 @@ onActivated(() => {
         })
     }
 })
+
+onMounted(() => {
+    // 请求持仓列表,待优化---可用资金计算可能需要订阅行情
+    eventBus.$emit('PosChangedNtf')
+})
 </script>
 
 <style lang="less">

+ 6 - 1
src/packages/qxst/views/mine/Index.vue

@@ -111,7 +111,7 @@
 </template>
 
 <script lang="ts" setup>
-import { shallowRef, onActivated } from 'vue'
+import { shallowRef, onMounted, onActivated } from 'vue'
 import { Cell, CellGroup, Button, Icon } from 'vant'
 import { fullloading, dialog } from '@/utils/vant'
 import { useNavigation } from '@mobile/router/navigation'
@@ -189,6 +189,11 @@ onActivated(() => {
         })
     }
 })
+
+onMounted(() => {
+    // 请求持仓列表,待优化---可用资金计算可能需要订阅行情
+    eventBus.$emit('PosChangedNtf')
+})
 </script>
 
 <style lang="less">

+ 6 - 1
src/packages/tc/views/mine/Index.vue

@@ -117,7 +117,7 @@
 </template>
 
 <script lang="ts" setup>
-import { shallowRef, onActivated } from 'vue'
+import { shallowRef, onMounted, onActivated } from 'vue'
 import { Cell, CellGroup, Button, Icon } from 'vant'
 import { fullloading, dialog } from '@/utils/vant'
 import { useNavigation } from '@mobile/router/navigation'
@@ -195,6 +195,11 @@ onActivated(() => {
         })
     }
 })
+
+onMounted(() => {
+    // 请求持仓列表,待优化---可用资金计算可能需要订阅行情
+    eventBus.$emit('PosChangedNtf')
+})
 </script>
 
 <style lang="less">

+ 6 - 1
src/packages/zrwyt/views/mine/Index.vue

@@ -117,7 +117,7 @@
 </template>
 
 <script lang="ts" setup>
-import { shallowRef, onActivated } from 'vue'
+import { shallowRef, onMounted, onActivated } from 'vue'
 import { Cell, CellGroup, Button, Icon } from 'vant'
 import { fullloading, dialog } from '@/utils/vant'
 import { useNavigation } from '@mobile/router/navigation'
@@ -195,6 +195,11 @@ onActivated(() => {
         })
     }
 })
+
+onMounted(() => {
+    // 请求持仓列表,待优化---可用资金计算可能需要订阅行情
+    eventBus.$emit('PosChangedNtf')
+})
 </script>
 
 <style lang="less">

+ 8 - 6
src/stores/modules/position.ts

@@ -18,12 +18,14 @@ export const usePositionStore = defineStore(() => {
 
     // 获取持仓汇总列表
     const getTradePosition = async () => {
-        try {
-            state.loading = true
-            const res = await queryTradePosition()
-            state.positionList = res.data
-        } finally {
-            state.loading = false
+        if (!state.loading) {
+            try {
+                state.loading = true
+                const res = await queryTradePosition()
+                state.positionList = res.data
+            } finally {
+                state.loading = false
+            }
         }
     }