阶段九:清理账号兼容字段调用方
This commit is contained in:
1 parent
e5d4998e61
commit
190dc80cc0
9 files changed
+787
-803
No files matched your search
@@ -5,7 +5,7 @@ import { mergeAccountRuntimeStatuses } from './runtime';
|
||||
// account 创建运行状态测试使用的最小账号对象。
|
||||
const account = (overrides: Partial<AccountDetail> = {}): AccountDetail => ({
|
||||
id: 'account-1',
|
||||
cookie: 'cookie',
|
||||
value: 'cookie',
|
||||
enabled: true,
|
||||
auto_confirm: false,
|
||||
...overrides,
|
||||
|
||||
@@ -124,7 +124,7 @@ export const useAccountSubmodules = ({ editingAccount, setEditingAccount, setAct
|
||||
clearPasswordTimer();
|
||||
setPasswordLoginView({ sessionId: '', status: 'idle', message: '', qrCodeUrl: '' });
|
||||
setEditingAccount(account);
|
||||
setEditForm({ remark: account.remark || account.note || '', cookie: account.cookie || account.value || '', auto_confirm: account.auto_confirm || false, pause_duration: account.pause_duration || 0, username: account.username || '', login_password: account.login_password || '', show_browser: account.show_browser || false, showLoginPassword: false, clear_password: false });
|
||||
setEditForm({ remark: account.remark || '', cookie: account.value || '', auto_confirm: account.auto_confirm || false, pause_duration: account.pause_duration || 0, username: account.username || '', login_password: account.login_password || '', show_browser: account.show_browser || false, showLoginPassword: false, clear_password: false });
|
||||
setActiveModal('edit');
|
||||
setLongLogin({ loading: true, saving: false, canOpen: false, enabled: false, error: '' });
|
||||
// longLoginResult 保存长登录设置读取结果。
|
||||
@@ -199,8 +199,8 @@ export const useAccountSubmodules = ({ editingAccount, setEditingAccount, setAct
|
||||
try {
|
||||
// payload 保存需要提交的账号编辑补丁。
|
||||
const payload: Parameters<typeof updateAccountSettings>[1] = {};
|
||||
if (editForm.remark !== (editingAccount.remark || editingAccount.note || '')) payload.remark = editForm.remark;
|
||||
if (editForm.cookie && editForm.cookie !== (editingAccount.cookie || editingAccount.value || '')) payload.cookie = editForm.cookie;
|
||||
if (editForm.remark !== (editingAccount.remark || '')) payload.remark = editForm.remark;
|
||||
if (editForm.cookie && editForm.cookie !== (editingAccount.value || '')) payload.cookie = editForm.cookie;
|
||||
if (editForm.auto_confirm !== editingAccount.auto_confirm) payload.auto_confirm = editForm.auto_confirm;
|
||||
if (shouldUpdateAccountPause(editForm.pause_duration, editingAccount)) payload.pause_duration = editForm.pause_duration;
|
||||
// loginInfo 保存登录字段变更补丁。
|
||||
|
||||
@@ -318,7 +318,6 @@ const AccountList: React.FC = () => {
|
||||
account.id,
|
||||
account.nickname,
|
||||
account.remark,
|
||||
account.note,
|
||||
account.username,
|
||||
account.runtime_message,
|
||||
].some(value => (value || '').toLowerCase().includes(keyword));
|
||||
@@ -408,7 +407,7 @@ const AccountList: React.FC = () => {
|
||||
</div>
|
||||
<div className="mt-3 flex flex-wrap items-center justify-between gap-4">
|
||||
<div className="text-sm font-medium text-gray-500">
|
||||
<p>{account.remark || account.note || '暂无备注'}</p>
|
||||
<p>{account.remark || '暂无备注'}</p>
|
||||
<p className="font-mono text-xs text-gray-400">ID: {account.id}</p>
|
||||
</div>
|
||||
{account.runtime_message && account.runtime_state !== 'online' && account.runtime_state !== 'disabled' && (
|
||||
|
||||
@@ -77,11 +77,9 @@ export const getAccountDetails = async (options?: RequestControlOptions): Promis
|
||||
return data.map(item => ({
|
||||
id: item.id,
|
||||
value: '',
|
||||
cookie: '',
|
||||
enabled: item.enabled,
|
||||
auto_confirm: item.auto_confirm,
|
||||
remark: item.remark,
|
||||
note: item.remark,
|
||||
pause_duration: item.pause_duration,
|
||||
paused_until: Number(item.paused_until || 0),
|
||||
paused: item.paused === true,
|
||||
|
||||
@@ -24,11 +24,9 @@ export interface SessionResponse {
|
||||
export interface AccountDetail {
|
||||
id: string;
|
||||
value?: string; // cookie value from backend
|
||||
cookie?: string; // alias for value
|
||||
enabled: boolean;
|
||||
auto_confirm: boolean;
|
||||
remark?: string;
|
||||
note?: string; // alias for remark
|
||||
pause_duration?: number;
|
||||
paused_until?: number;
|
||||
paused?: boolean;
|
||||
|
||||
Reference in new issue
Block a user