Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 10 additions & 17 deletions src/GenTradeAgent/src/renderer/src/components/FootBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,18 @@
</div>
<n-space class="foot-status">
<span class="status-icon">Version v0.1</span>
<n-button
v-show="isServerConnected"
text
style="font-size: 18px"
@click="handlerClickNetwork"
>
<n-button v-show="isServerConnected" text style="font-size: 18px" @click="onClickNetwork">
<n-icon>
<PlugConnected20Filled />
</n-icon>
</n-button>
<n-button
v-show="!isServerConnected"
text
style="font-size: 18px"
@click="handlerClickNetwork"
>
<n-button v-show="!isServerConnected" text style="font-size: 18px" @click="onClickNetwork">
<n-icon>
<PlugDisconnected20Regular />
</n-icon>
</n-button>
<div style="width: 30px; max-width: 30px;">
<span style="align-items: center;">{{ serverLatency }}ms</span>
<div style="width: 30px; max-width: 30px">
<span style="align-items: center">{{ serverLatency }}ms</span>
</div>
</n-space>
<n-modal
Expand All @@ -42,6 +32,8 @@
<n-input v-model:value="serverAddress"></n-input>
API Key
<n-input v-model:value="apiKey"></n-input>
Ping Interval (seconds)
<n-input-number v-model:value="pingInterval"></n-input-number>
</n-space>
<template #footer>
<n-button @click="onPositiveClick">OK</n-button>
Expand All @@ -52,13 +44,14 @@
<script setup lang="ts">
import { ref } from 'vue'
import { PlugConnected20Filled, PlugDisconnected20Regular } from '@vicons/fluent'
import { NIcon, NSpace, NButton, NModal, NInput } from 'naive-ui'
import { NIcon, NSpace, NButton, NModal, NInput, NInputNumber } from 'naive-ui'
import { useStore } from '../store'
import { agentServer } from '@renderer/server'

const showServerModal = ref(false)
const serverAddress = ref(agentServer.serverAddress)
const apiKey = ref(agentServer.apiKey)
const pingInterval = ref(agentServer.pingInterval / 1000)

const store = useStore()

Expand All @@ -81,17 +74,17 @@ store.watch(
}
)

const handlerClickNetwork = () => {
const onClickNetwork = () => {
console.log('hehe')
showServerModal.value = true
}

const onPositiveClick = () => {
console.log('ok')
agentServer.serverAddress = serverAddress.value
agentServer.pingInterval = pingInterval.value * 1000
showServerModal.value = false
}

</script>
<style lang="scss" scoped>
.foot-main {
Expand Down
7 changes: 3 additions & 4 deletions src/GenTradeAgent/src/renderer/src/components/TradingMain.vue
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,11 @@ const handleUpdateCurrentInterval = (value: string) => {
}

agentServer.store = useStore()
const handlerPingServer = (() => {
const handlerPingServer = () => {
agentServer.ping()
setTimeout(handlerPingServer, 10000)
})
setTimeout(handlerPingServer, agentServer.pingInterval)
}
handlerPingServer()

</script>

<style lang="scss" scoped>
Expand Down
1 change: 1 addition & 0 deletions src/GenTradeAgent/src/renderer/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class AgentServer {
tzName: string = ''
tzOffset: number = 0
store: Store<IState> | null = null
pingInterval: number = 10000

ping() {
const tsStart = new Date().getTime()
Expand Down
Loading