feat: 授权账户成功后更新数据

This commit is contained in:
rd
2025-07-22 18:24:24 +08:00
parent 39c1f5d3d0
commit 95fc8c7fc0

View File

@ -12,7 +12,7 @@
:footer="!isLoading"
@close="close"
>
<div v-if="showSyncTip">
<!-- <div v-if="showSyncTip">
<div class="flex items-center mb-20px">
<img :src="icon1" width="16" height="16" class="mr-16px" />
<p class="s2">
@ -25,8 +25,8 @@
<a-radio value="sync" class="mb-16px">立即同步遗漏数据 - 获取完整的最新数据 推荐</a-radio>
<a-radio value="no_sync">仅授权不更新 - 继续使用当前不完全的数据</a-radio>
</a-radio-group>
</div>
<div v-else class="flex flex-col items-center">
</div> -->
<div class="flex flex-col items-center">
<template v-if="isLoading">
<a-progress
:percent="progress"
@ -81,7 +81,7 @@ import icon2 from '@/assets/img/media-account/icon-feedback-success.png';
import icon3 from '@/assets/img/media-account/icon-feedback-fail.png';
const update = inject('update');
const INITIAL_SYNC_TYPE = 'sync';
// const INITIAL_SYNC_TYPE = 'sync';
const visible = ref(false);
const isLoading = ref(false);
const isCompleted = ref(false);
@ -92,10 +92,10 @@ const progress = ref(0);
const id = ref('');
const selectSubAccountModalRef = ref(null);
const lastSyncedAt = ref(null); // 上次同步时间戳
const showSyncTip = ref(false);
// const lastSyncedAt = ref(null); // 上次同步时间戳
// const showSyncTip = ref(false);
const shouldSelectSubAccount = ref(false);
const syncType = ref(INITIAL_SYNC_TYPE); // sync no_sync
// const syncType = ref(INITIAL_SYNC_TYPE); // sync no_sync
const addAccountFormData = ref(null); // 添加账户表单数据
const INITIAL_FORM = {
@ -124,20 +124,20 @@ const confirmBtnText = computed(() => {
return isSuccess.value ? '继续添加' : '重试';
});
const getDaysDiffText = (lastSyncedAt) => {
if (!lastSyncedAt) return '0天';
// const getDaysDiffText = (lastSyncedAt) => {
// if (!lastSyncedAt) return '0天';
const daysDiff = dayjs().diff(dayjs(lastSyncedAt * 1000), 'day');
// const daysDiff = dayjs().diff(dayjs(lastSyncedAt * 1000), 'day');
if (daysDiff === 0) return '不到1天';
return `${daysDiff}`;
};
// if (daysDiff === 0) return '不到1天';
// return `${daysDiff}天`;
// };
const open = ({ accountId, last_synced_at = null, form = null, needSelectSubAccount = false }) => {
reset();
id.value = accountId;
lastSyncedAt.value = last_synced_at;
// lastSyncedAt.value = last_synced_at;
addAccountFormData.value = form;
shouldSelectSubAccount.value = needSelectSubAccount;
visible.value = true;
@ -154,9 +154,9 @@ const reset = () => {
failReason.value = '';
progress.value = 0;
id.value = '';
lastSyncedAt.value = null;
syncType.value = INITIAL_SYNC_TYPE;
showSyncTip.value = false;
// lastSyncedAt.value = null;
// syncType.value = INITIAL_SYNC_TYPE;
// showSyncTip.value = false;
shouldSelectSubAccount.value = false;
addAccountFormData.value = null;
clearFakeProgressTimer();
@ -191,6 +191,8 @@ const startStatusPolling = () => {
clearFakeProgressTimer();
clearStatusPollingTimer();
isLoading.value = false;
isSuccess.value && postPlacementAccountsSync(id.value);
}
}
}, 2000);
@ -237,34 +239,34 @@ const clearFakeProgressTimer = () => {
}
};
const handleSyncData = () => {
if (!showSyncTip.value) {
formRef.value.validate(async (errors) => {
if (!errors) {
showSyncTip.value = true;
}
});
return;
}
// const handleSyncData = () => {
// if (!showSyncTip.value) {
// formRef.value.validate(async (errors) => {
// if (!errors) {
// showSyncTip.value = true;
// }
// });
// return;
// }
if (syncType.value === INITIAL_SYNC_TYPE) {
postPlacementAccountsSync(id.value).then((res) => {
if (res.code === 200) {
update();
close();
}
});
} else {
startLoading();
}
};
// if (syncType.value === INITIAL_SYNC_TYPE) {
// postPlacementAccountsSync(id.value).then((res) => {
// if (res.code === 200) {
// update();
// close();
// }
// });
// } else {
// close();
// }
// };
const handleOk = () => {
// n天未同步更新
if (lastSyncedAt.value && lastSyncedAt.value < dayjs().startOf('day').valueOf()) {
handleSyncData();
return;
}
// // n天未同步更新
// if (lastSyncedAt.value && lastSyncedAt.value < dayjs().startOf('day').valueOf()) {
// handleSyncData();
// return;
// }
// 已完成
if (isCompleted.value) {