refactor: 新媒体账号状态重构

This commit is contained in:
rd
2025-07-25 10:26:53 +08:00
parent 458b4c0d60
commit a50234543b
10 changed files with 109 additions and 105 deletions

View File

@ -2,7 +2,7 @@
* @Author: RenXiaoDong
* @Date: 2025-07-04 11:18:11
*/
export enum EnumStatus {
export enum EnumAccountStatus {
UNAUTHORIZED = 0, // 未授权
NORMAL = 1, // 正常
PAUSE = 2, // 暂停同步
@ -19,55 +19,55 @@ export const STATUS_LIST = [
{
text: '正常',
label: '正常',
value: EnumStatus.NORMAL,
value: EnumAccountStatus.NORMAL,
},
{
text: '即将过期',
label: '即将过期',
value: EnumStatus.ABNORMAL_EXPIRED,
value: EnumAccountStatus.ABNORMAL_EXPIRED,
},
{
text: '暂停同步',
label: '暂停同步',
value: EnumStatus.PAUSE,
value: EnumAccountStatus.PAUSE,
},
{
text: '全部异常',
label: '异常',
value: EnumStatus.ABNORMAL,
value: EnumAccountStatus.ABNORMAL,
},
{
text: '异常(未授权)',
label: '异常',
value: EnumStatus.UNAUTHORIZED,
value: EnumAccountStatus.UNAUTHORIZED,
tooltip: '未授权',
class: '!pl-24px',
},
{
text: '异常(数据缺失)',
label: '异常',
value: EnumStatus.ABNORMAL_MISSING,
value: EnumAccountStatus.ABNORMAL_MISSING,
tooltip: '数据缺失',
class: '!pl-24px',
},
{
text: '异常(登录状态失效)',
label: '异常',
value: EnumStatus.ABNORMAL_LOGIN,
value: EnumAccountStatus.ABNORMAL_LOGIN,
tooltip: '登录状态失效',
class: '!pl-24px',
},
{
text: '异常(请求频繁)',
label: '异常',
value: EnumStatus.ABNORMAL_REQUEST,
value: EnumAccountStatus.ABNORMAL_REQUEST,
tooltip: '请求频繁等待24小时后重试',
class: '!pl-24px',
},
{
text: '异常(账号被封)',
label: '异常',
value: EnumStatus.ABNORMAL_FREEZE,
value: EnumAccountStatus.ABNORMAL_FREEZE,
tooltip: '账号被封',
class: '!pl-24px',
},

View File

@ -1,6 +1,6 @@
import { defineComponent, computed } from 'vue';
import { Tooltip } from '@arco-design/web-vue';
// import { STATUS_LIST } from '@/views/property-marketing/media-account/components/status-select/constants';
import iconWarn1 from '@/assets/img/media-account/icon-warn-1.png';
import iconWarn2 from '@/assets/img/media-account/icon-warn-2.png';
import icon1 from '@/assets/img/media-account/icon-schedule.png';
@ -41,13 +41,13 @@ const pauseStyle = {
background: '#fff7e5',
};
const tooltipMap = new Map([
[1, { tooltip: '未授权' }],
[2, { tooltip: '登录状态失效' }],
[3, { tooltip: '请求频繁等待24小时后重试', btnTooltip: '请求频繁等待24小时后重试' }],
[4, { tooltip: '账号被冻结', btnTooltip: '账号被封,解封后才能操作' }],
[5, { tooltip: '数据缺失' }],
[6, { tooltip: '未知错误' }],
export const errorStatusMap = new Map([
[1, { tooltip: '未授权', text: '未授权' }],
[2, { tooltip: '登录状态失效', text: '登录状态失效' }],
[3, { tooltip: '请求频繁等待24小时后重试', btnTooltip: '请求频繁等待24小时后重试', text: '请求过于频繁' }],
[4, { tooltip: '账号被冻结', btnTooltip: '账号被封,解封后才能操作', text: '账号被冻结' }],
[5, { tooltip: '数据缺失', text: '数据缺失' }],
[6, { tooltip: '未知错误', text: '未知错误' }],
]);
/**
@ -58,14 +58,18 @@ const tooltipMap = new Map([
* @returns
*/
export const getStatusInfo = (status: EnumStatus, error_status: EnumErrorStatus, to_be_expire_for_cookie: EnumExpireForCookie) => {
export const getStatusInfo = (
status: EnumStatus,
error_status: EnumErrorStatus,
to_be_expire_for_cookie: EnumExpireForCookie,
) => {
const statusInfo = { color: '', background: '', label: '', tooltip: '', disabledBtnTooltip: '' };
if (status === EnumStatus.ABNORMAL) {
statusInfo.color = abnormalStyle.color;
statusInfo.background = abnormalStyle.background;
statusInfo.label = '异常';
const target = tooltipMap.get(error_status);
const target = errorStatusMap.get(error_status);
statusInfo.tooltip = target?.tooltip ?? '';
statusInfo.disabledBtnTooltip = target?.btnTooltip ?? '';
}
@ -111,11 +115,11 @@ export default defineComponent({
const { background, color, label } = statusInfo.value;
if (status === EnumStatus.NORMAL) {
return (
<div class="flex items-center">
<div class="flex items-center status-box">
{to_be_expire_for_cookie === EnumExpireForCookie.EXPIRE && (
<div class="flex items-center rounded-2px px-8px mr-8px" style={{ background, color }}>
<img src={icon1} width="12" height="12" class="mr-4px" />
<span class="text-12px lh-20px font-400">{label}</span>
<span class="text-12px lh-20px font-400 label">{label}</span>
</div>
)}
<div
@ -129,8 +133,8 @@ export default defineComponent({
}
return (
<div class="flex items-center rounded-2px px-8px" style={{ background, color }}>
<span class="text-12px lh-20px font-400">{label}</span>
<div class="flex items-center rounded-2px px-8px status-box" style={{ background, color }}>
<span class="text-12px lh-20px font-400 label">{label}</span>
{status === EnumStatus.PAUSE ? (
<img src={iconWarn1} width="12" height="12" class="ml-4px" />
) : (