|
@@ -229,7 +229,7 @@
|
|
|
</template>
|
|
</template>
|
|
|
|
|
|
|
|
<script setup>
|
|
<script setup>
|
|
|
-import { ref, reactive, h } from 'vue'
|
|
|
|
|
|
|
+import { ref, reactive, onUnmounted, onMounted, h } from 'vue'
|
|
|
import { accountList, deleteAccount, addAccount, changeAutoRun, singleRun } from '@/api/lepao'
|
|
import { accountList, deleteAccount, addAccount, changeAutoRun, singleRun } from '@/api/lepao'
|
|
|
import { Modal, Notification, Message } from '@arco-design/web-vue'
|
|
import { Modal, Notification, Message } from '@arco-design/web-vue'
|
|
|
import { IconSearch } from '@arco-design/web-vue/es/icon'
|
|
import { IconSearch } from '@arco-design/web-vue/es/icon'
|
|
@@ -385,7 +385,6 @@ const handleCancel = () => {
|
|
|
|
|
|
|
|
const getAccounts = async () => {
|
|
const getAccounts = async () => {
|
|
|
try {
|
|
try {
|
|
|
- loading.value = true
|
|
|
|
|
const res = await accountList()
|
|
const res = await accountList()
|
|
|
if (!res || res.code !== 0)
|
|
if (!res || res.code !== 0)
|
|
|
return Notification.error({
|
|
return Notification.error({
|
|
@@ -398,8 +397,6 @@ const getAccounts = async () => {
|
|
|
title: '获取账号列表失败!',
|
|
title: '获取账号列表失败!',
|
|
|
content: error.message || '请稍后再试'
|
|
content: error.message || '请稍后再试'
|
|
|
})
|
|
})
|
|
|
- } finally {
|
|
|
|
|
- loading.value = false
|
|
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -467,7 +464,36 @@ const stramptoTime = (time) => {
|
|
|
return new Date(time).toLocaleString('zh-CN', { year: 'numeric', month: '2-digit', day: '2-digit', hour: '2-digit', minute: '2-digit', second: '2-digit' })
|
|
return new Date(time).toLocaleString('zh-CN', { year: 'numeric', month: '2-digit', day: '2-digit', hour: '2-digit', minute: '2-digit', second: '2-digit' })
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-getAccounts()
|
|
|
|
|
|
|
+let timer = null
|
|
|
|
|
+
|
|
|
|
|
+// 轮询
|
|
|
|
|
+const startPolling = () => {
|
|
|
|
|
+ if (!timer) {
|
|
|
|
|
+ timer = setInterval(async () => {
|
|
|
|
|
+ await getAccounts()
|
|
|
|
|
+ }, 5000)
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+// 停止轮询
|
|
|
|
|
+const stopPolling = () => {
|
|
|
|
|
+ if (timer) {
|
|
|
|
|
+ clearInterval(timer)
|
|
|
|
|
+ timer = null
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+onMounted(async () => {
|
|
|
|
|
+ loading.value = true
|
|
|
|
|
+ await getAccounts()
|
|
|
|
|
+ loading.value = false
|
|
|
|
|
+ startPolling()
|
|
|
|
|
+})
|
|
|
|
|
+
|
|
|
|
|
+// 组件销毁时停止轮询
|
|
|
|
|
+onUnmounted(() => {
|
|
|
|
|
+ stopPolling()
|
|
|
|
|
+})
|
|
|
</script>
|
|
</script>
|
|
|
|
|
|
|
|
<style scoped lang="less">
|
|
<style scoped lang="less">
|