From d054f67652c35d4ab3aa62db713161aebc158788 Mon Sep 17 00:00:00 2001
From: rd <1344903914@qq.com>
Date: Mon, 7 Jul 2025 10:33:42 +0800
Subject: [PATCH] =?UTF-8?q?perf:=20=E6=8A=95=E6=94=BE=E8=B4=A6=E5=8F=B7-?=
=?UTF-8?q?=E5=90=8C=E6=AD=A5=E6=95=B0=E6=8D=AE?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/api/all/propertyMarketing.ts | 8 ++-
.../authorized-account-modal/index.vue | 51 +++++++++++++++----
2 files changed, 47 insertions(+), 12 deletions(-)
diff --git a/src/api/all/propertyMarketing.ts b/src/api/all/propertyMarketing.ts
index 4495d02..e617401 100644
--- a/src/api/all/propertyMarketing.ts
+++ b/src/api/all/propertyMarketing.ts
@@ -285,7 +285,6 @@ export const getPlacementAccountsTrend = (params = {}) => {
return Http.get(`/v1/placement-accounts/trend`, params);
};
-
// 投放账号计划数据-趋势
export const getPlacementAccountProjectsTrend = (params = {}) => {
return Http.get(`/v1/placement-account-projects/trend`, params);
@@ -293,7 +292,7 @@ export const getPlacementAccountProjectsTrend = (params = {}) => {
// 投放指南查询
export const getPlacementGuide = (params: {}) => {
- return Http.get(`/v1/placement-account-projects/getGuideList`,params);
+ return Http.get(`/v1/placement-account-projects/getGuideList`, params);
};
// 前端定时轮询获取ai检测结果
@@ -305,3 +304,8 @@ export const getAiResult = (params: {}) => {
export const getPlacementAccountsList = (params = {}) => {
return Http.get('/v1/placement-accounts/list', params);
};
+
+// 投放账号-同步数据
+export const postPlacementAccountsSync = (id: string) => {
+ return Http.post(`/v1/placement-accounts/${id}/sync-data`);
+};
diff --git a/src/views/property-marketing/put-account/account-manage/components/authorized-account-modal/index.vue b/src/views/property-marketing/put-account/account-manage/components/authorized-account-modal/index.vue
index 6f8efa2..4f5bb36 100644
--- a/src/views/property-marketing/put-account/account-manage/components/authorized-account-modal/index.vue
+++ b/src/views/property-marketing/put-account/account-manage/components/authorized-account-modal/index.vue
@@ -16,9 +16,9 @@
- 检测到该账户最后更新日期为{{ exactFormatTime(lastSyncedAt, 'MM-DD', 'YYYY-MM-DD') }},已有{{
- dayjs().diff(dayjs(lastSyncedAt * 1000), 'day')
- }}天未同步最新数据。
+ 检测到该账户最后更新日期为{{ exactFormatTime(lastSyncedAt, 'MM月DD日HH:mm', 'YYYY年MM月DD日 HH:mm') }},已有{{
+ getDaysDiffText(lastSyncedAt)
+ }}未同步最新数据。
@@ -65,14 +65,18 @@
import dayjs from 'dayjs';
import { defineExpose, ref, computed, defineEmits } from 'vue';
import { exactFormatTime } from '@/utils/tools';
-import { putPlacementAccountsAuthorized, getPlacementAccountsAuthorizedStatus } from '@/api/all/propertyMarketing';
+import {
+ putPlacementAccountsAuthorized,
+ getPlacementAccountsAuthorizedStatus,
+ postPlacementAccountsSync,
+} from '@/api/all/propertyMarketing';
import icon1 from '@/assets/img/media-account/icon-warn-1.png';
import icon2 from '@/assets/img/media-account/icon-feedback-success.png';
import icon3 from '@/assets/img/media-account/icon-feedback-fail.png';
const emits = defineEmits(['update']);
-
+const INITIAL_SYNC_TYPE = 'sync';
const visible = ref(false);
const isLoading = ref(false);
const isCompleted = ref(false);
@@ -81,9 +85,10 @@ const formRef = ref(null);
const failReason = ref('');
const progress = ref(0);
const id = ref('');
-const lastSyncedAt = ref(null);
-const syncType = ref('sync'); // sync | no_sync
+
+const lastSyncedAt = ref(null); // 上次同步时间戳
const showSyncTip = ref(false);
+const syncType = ref(INITIAL_SYNC_TYPE); // sync | no_sync
const INITIAL_FORM = {
account: '',
@@ -111,6 +116,15 @@ const confirmBtnText = computed(() => {
return isSuccess.value ? '继续添加' : '重试';
});
+const getDaysDiffText = (lastSyncedAt) => {
+ if (!lastSyncedAt) return '0天';
+
+ const daysDiff = dayjs().diff(dayjs(lastSyncedAt * 1000), 'day');
+
+ if (daysDiff === 0) return '不到1天';
+ return `${daysDiff}天`;
+};
+
const open = (accountId, last_synced_at = null) => {
id.value = accountId;
lastSyncedAt.value = last_synced_at;
@@ -129,7 +143,7 @@ const close = () => {
progress.value = 0;
id.value = '';
lastSyncedAt.value = null;
- syncType.value = 'sync';
+ syncType.value = INITIAL_SYNC_TYPE;
showSyncTip.value = false;
clearFakeProgressTimer();
clearStatusPollingTimer();
@@ -206,8 +220,8 @@ const clearFakeProgressTimer = () => {
}
};
-const handleOk = () => {
- if (lastSyncedAt.value) {
+const handleSyncData = () => {
+ if (!showSyncTip.value) {
formRef.value.validate(async (errors) => {
if (!errors) {
showSyncTip.value = true;
@@ -216,6 +230,23 @@ const handleOk = () => {
return;
}
+ if (syncType.value === INITIAL_SYNC_TYPE) {
+ postPlacementAccountsSync(id.value).then((res) => {
+ if (res.code === 200) {
+ close();
+ }
+ });
+ } else {
+ close();
+ }
+};
+
+const handleOk = () => {
+ if (lastSyncedAt.value && lastSyncedAt.value < dayjs().startOf('day').valueOf()) {
+ handleSyncData();
+ return;
+ }
+
if (isCompleted.value) {
if (isSuccess.value) {
emits('update');