Selaa lähdekoodia

优化版本号显示

flyzto 2 viikkoa sitten
vanhempi
commit
0bfa266da1
1 muutettua tiedostoa jossa 29 lisäystä ja 1 poistoa
  1. 29 1
      web/apps/web-antd/src/views/match/data-sync/index.vue

+ 29 - 1
web/apps/web-antd/src/views/match/data-sync/index.vue

@@ -58,6 +58,7 @@ const CHAR_MAP: Record<string, Record<string, string>> = {
 const MARKET_TYPE_ORDER = ['2', '1', '0'];
 
 const clients = ref<SyncClient[]>([]);
+const latestClientVersion = ref('');
 const loading = ref(false);
 const autoRefresh = ref(true);
 const editClient = ref<SyncClient>();
@@ -147,6 +148,10 @@ const displayMappedValue = (
   return CHAR_MAP[type]?.[String(value)] ?? value;
 };
 
+const isClientVersionOutdated = (version?: string) => {
+  return !!version && !!latestClientVersion.value && version !== latestClientVersion.value;
+};
+
 const getDeviceUrl = (deviceId?: number) => {
   if (!Number.isInteger(deviceId)) {
     return '';
@@ -375,6 +380,20 @@ const fetchClients = async () => {
   }
 };
 
+const fetchLatestClientVersion = async () => {
+  try {
+    const response = await fetch('https://bwh.841024.xyz/chrome_update/versions?names=events_sync');
+    const data = await response.json();
+    const version = data?.data?.[0];
+    if (data?.state === 1 && typeof version === 'string') {
+      latestClientVersion.value = version;
+    }
+  }
+  catch (error) {
+    console.error('Failed to fetch latest client version:', error);
+  }
+};
+
 const openEditClient = (client: SyncClientRow) => {
   editClient.value = client;
   editDeviceId.value = client.deviceId;
@@ -426,6 +445,7 @@ const handleAutoRefreshChange = () => {
 };
 
 onMounted(() => {
+  fetchLatestClientVersion();
   fetchClients();
 });
 
@@ -468,7 +488,11 @@ onUnmounted(() => {
               {{ isOnline(record.lastRequestTime) ? '在线' : '离线' }}
             </Tag>
             <span>{{ record.title }}</span>
-            <span v-if="record.rowType === 'client' && record.version" class="version-text">
+            <span
+              v-if="record.rowType === 'client' && record.version"
+              class="version-text"
+              :class="{ outdated: isClientVersionOutdated(record.version) }"
+            >
               {{ record.version }}
             </span>
             <span v-if="record.rowType !== 'client'" class="group-count">
@@ -563,6 +587,10 @@ onUnmounted(() => {
   font-size: 12px;
 }
 
+.version-text.outdated {
+  color: #fa8c16;
+}
+
 .device-link {
   display: inline-flex;
   align-items: center;