Parcourir la source

Merge fix/bug-6154-6155: 修复IP代理城市为空和作品数据无变化

ethanfly il y a 3 jours
Parent
commit
2b7f64dbe8
2 fichiers modifiés avec 18 ajouts et 1 suppressions
  1. 6 1
      client/src/views/Publish/index.vue
  2. 12 0
      server/src/services/WorkService.ts

+ 6 - 1
client/src/views/Publish/index.vue

@@ -665,13 +665,18 @@ function resolvePublishProxyFromRegionPath(regionPath: string[]) {
   const path = Array.isArray(regionPath) ? regionPath.map(v => String(v)) : [];
   if (!path.length) return null;
 
+  // Bug #6155: 如果区域数据尚未加载(publishProxyRegions 为空),返回 null 让调用方知道解析失败
+  if (!publishProxyRegions.value || publishProxyRegions.value.length === 0) {
+    return null;
+  }
+
   const labels = getRegionLabelsByPath(publishProxyRegions.value, path);
   const regionCode = path[path.length - 1];
   const regionName = labels[labels.length - 1] || '';
 
   const specialCityLabels = new Set(['市辖区', '县', '省直辖县级行政区划', '自治区直辖县级行政区划']);
   let city = '';
-  if (labels.length >= 2) {
+  if (labels.length >= 2 && labels[1]) {
     city = labels[1];
     if (specialCityLabels.has(city)) city = labels[0] || city;
   } else {

+ 12 - 0
server/src/services/WorkService.ts

@@ -392,6 +392,12 @@ export class WorkService {
             commentCount: workItem.commentCount ?? work.commentCount,
             shareCount: workItem.shareCount ?? work.shareCount,
             collectCount: workItem.collectCount ?? work.collectCount,
+            // Bug #6154: 同步作品时同步更新 yesterday_* 字段,确保「作品数据」页能立即看到最新数据
+            yesterdayPlayCount: workItem.playCount ?? work.playCount,
+            yesterdayLikeCount: workItem.likeCount ?? work.likeCount,
+            yesterdayCommentCount: workItem.commentCount ?? work.commentCount,
+            yesterdayShareCount: workItem.shareCount ?? work.shareCount,
+            yesterdayCollectCount: workItem.collectCount ?? work.collectCount,
           });
         } else {
           // 创建新作品
@@ -411,6 +417,12 @@ export class WorkService {
             commentCount: workItem.commentCount || 0,
             shareCount: workItem.shareCount || 0,
             collectCount: workItem.collectCount || 0,
+            // Bug #6154: 创建作品时初始化 yesterday_* 字段,确保「作品数据」页能显示数据
+            yesterdayPlayCount: workItem.playCount || 0,
+            yesterdayLikeCount: workItem.likeCount || 0,
+            yesterdayCommentCount: workItem.commentCount || 0,
+            yesterdayShareCount: workItem.shareCount || 0,
+            yesterdayCollectCount: workItem.collectCount || 0,
           });
 
           await this.workRepository.save(work);