收口账号页面子模块边界
This commit is contained in:
1 parent
afb7e2f0d9
commit
371bd9d17e
14 files changed
+500
-452
No files matched your search
@@ -9,19 +9,16 @@ import {
|
||||
completeQRVerification,
|
||||
refreshAccountProfile,
|
||||
} from '../app/features/accounts/api';
|
||||
import {
|
||||
Power, Edit2, Trash2, QrCode, X, Check, Loader2,
|
||||
RefreshCw, Save, User, Clock, MessageCircle,
|
||||
Bot, Settings, AlertCircle, CalendarClock, Sparkles
|
||||
} from 'lucide-react';
|
||||
import { Loader2, QrCode, User } from 'lucide-react';
|
||||
import { createLatestRequestGate, createQRLoginPoller } from './qrPolling';
|
||||
import { RiskVerificationPanel } from './RiskVerificationPanel';
|
||||
import { SquareQRCode } from './SquareQRCode';
|
||||
import AccountAutomationModal from './AccountAutomationModal';
|
||||
import { AccountEditModal } from '../app/features/accounts/components/AccountEditModal';
|
||||
import { AccountAISettingsModal } from '../app/features/accounts/components/AccountAISettingsModal';
|
||||
import { AccountCard } from '../app/features/accounts/components/AccountCard';
|
||||
import { AccountDeleteDialog } from '../app/features/accounts/components/AccountDeleteDialog';
|
||||
import { AccountQRCodeModal } from '../app/features/accounts/components/AccountQRCodeModal';
|
||||
import { useAccountsData } from '../app/features/accounts/hooks';
|
||||
import { useAccountSubmodules, type AccountModalType } from '../app/features/accounts/submoduleHooks';
|
||||
import { accountRuntimePresentation } from '../app/features/accounts/runtime';
|
||||
import type { AccountEditForm } from '../app/features/accounts/types';
|
||||
|
||||
// AccountList 渲染账号列表组件。
|
||||
@@ -358,140 +355,21 @@ const AccountList: React.FC = () => {
|
||||
|
||||
{/* Account Grid */}
|
||||
<div className="grid grid-cols-1 gap-6">
|
||||
{filteredAccounts.map(/* 当前回调处理集合中的单个元素。 */ (account) => {
|
||||
// runtime 运行状态。
|
||||
const runtime = accountRuntimePresentation(account);
|
||||
// requiresLogin 是否需要重新登录。
|
||||
const requiresLogin = account.runtime_state === 'auth_expired' || account.runtime_state === 'verification_required';
|
||||
return (
|
||||
<div key={account.id} className="ios-card rounded-xl p-6 group transition-all duration-300 hover:border-brand">
|
||||
<div className="flex min-w-0 items-start gap-5 sm:gap-8">
|
||||
<div className="relative">
|
||||
{account.avatar_url ? (
|
||||
<img
|
||||
src={account.avatar_url}
|
||||
alt={account.nickname || '账号头像'}
|
||||
className="w-20 h-20 rounded-full object-cover shadow-md ring-4 ring-white bg-gray-100"
|
||||
/>
|
||||
) : (
|
||||
<div className="w-20 h-20 rounded-full bg-gray-100 text-gray-400 shadow-md ring-4 ring-white flex items-center justify-center">
|
||||
<User className="w-9 h-9" />
|
||||
</div>
|
||||
)}
|
||||
<div className={`absolute -bottom-1 -right-1 w-6 h-6 rounded-full border-4 border-white flex items-center justify-center ${runtime.dot}`}>
|
||||
{account.runtime_state === 'online' && <Check className="w-3 h-3 text-white" />}
|
||||
</div>
|
||||
</div>
|
||||
<div className="min-w-0 flex-1">
|
||||
<div className="flex flex-wrap items-center gap-2.5 mb-1">
|
||||
<h3 className="text-xl font-extrabold text-gray-900 break-words">{account.nickname || account.remark || `账号 ${account.id.substring(0,6)}...`}</h3>
|
||||
<span className={`px-2.5 py-0.5 rounded-lg text-xs font-bold ${runtime.badge}`}>{runtime.label}</span>
|
||||
{account.ai_enabled && (
|
||||
<span className="px-2.5 py-0.5 rounded-lg bg-purple-100 text-purple-700 text-xs font-bold flex items-center gap-1">
|
||||
<Bot className="w-3 h-3" /> AI
|
||||
</span>
|
||||
)}
|
||||
{account.auto_rate_enabled && (
|
||||
<span className="flex items-center gap-1 rounded-lg bg-emerald-100 px-2.5 py-0.5 text-xs font-bold text-emerald-700">
|
||||
<MessageCircle className="h-3 w-3" /> 自动评价
|
||||
</span>
|
||||
)}
|
||||
{account.auto_polish_enabled && (
|
||||
<span className="flex items-center gap-1 rounded-lg bg-amber-100 px-2.5 py-0.5 text-xs font-bold text-amber-700">
|
||||
<Sparkles className="h-3 w-3" /> 每日擦亮
|
||||
</span>
|
||||
)}
|
||||
{account.auto_confirm && <span className="flex items-center gap-1 rounded-lg bg-blue-50 px-2.5 py-0.5 text-xs font-bold text-blue-700"><Check className="h-3 w-3" /> 自动确认发货</span>}
|
||||
{account.profile_error && (
|
||||
<span
|
||||
className="px-2.5 py-0.5 rounded-lg bg-amber-100 text-amber-700 text-xs font-bold flex items-center gap-1"
|
||||
title={account.profile_error}
|
||||
>
|
||||
<AlertCircle className="w-3 h-3" /> 资料未同步
|
||||
</span>
|
||||
)}
|
||||
</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 || '暂无备注'}</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' && (
|
||||
<div className={`mb-3 flex flex-wrap items-center gap-2 text-sm font-medium ${requiresLogin ? 'text-red-700' : 'text-amber-700'}`}>
|
||||
<AlertCircle className="w-4 h-4 flex-shrink-0" />
|
||||
<span>{account.runtime_message}</span>
|
||||
{requiresLogin && (
|
||||
<button
|
||||
type="button"
|
||||
onClick={/* 当前回调处理用户交互或异步状态变化。 */ () => startQRLogin(account)}
|
||||
className="inline-flex items-center gap-1.5 rounded-lg bg-red-50 px-2.5 py-1 text-xs font-bold text-red-700 hover:bg-red-100"
|
||||
>
|
||||
<QrCode className="w-3.5 h-3.5" /> 重新授权
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
{account.paused && <span className="flex items-center gap-1.5 rounded-lg bg-blue-50 px-3 py-1.5 text-xs font-bold text-blue-700"><Clock className="h-3 w-3" /> 暂停处理中</span>}
|
||||
<div className="mt-3 flex flex-wrap items-center justify-end gap-2">
|
||||
<button
|
||||
onClick={/* 当前回调处理用户交互或异步状态变化。 */ () => handleRefreshProfile(account)}
|
||||
disabled={refreshingProfileId === account.id}
|
||||
className="p-3 rounded-xl transition-colors text-gray-600 hover:bg-gray-100 disabled:opacity-50"
|
||||
title="刷新昵称和头像"
|
||||
>
|
||||
<RefreshCw className={`w-5 h-5 ${refreshingProfileId === account.id ? 'animate-spin' : ''}`} />
|
||||
</button>
|
||||
<button
|
||||
onClick={/* 当前回调处理用户交互或异步状态变化。 */ () => startQRLogin(account)}
|
||||
className={`p-3 rounded-xl transition-colors ${requiresLogin ? 'text-red-600 bg-red-50 hover:bg-red-100' : 'text-blue-600 hover:bg-blue-50'}`}
|
||||
title="重新扫码授权当前账号"
|
||||
>
|
||||
<QrCode className="w-5 h-5" />
|
||||
</button>
|
||||
<button
|
||||
onClick={/* 当前回调处理用户交互或异步状态变化。 */ () => openEditModal(account)}
|
||||
className="p-3 rounded-xl hover:bg-gray-100 transition-colors text-gray-600"
|
||||
title="编辑账号"
|
||||
>
|
||||
<Edit2 className="w-5 h-5" />
|
||||
</button>
|
||||
<button
|
||||
onClick={/* 当前回调处理用户交互或异步状态变化。 */ () => openAIModal(account)}
|
||||
className="p-3 rounded-xl hover:bg-purple-100 transition-colors text-purple-600"
|
||||
title="AI设置"
|
||||
>
|
||||
<Bot className="w-5 h-5" />
|
||||
</button>
|
||||
<button
|
||||
onClick={/* 当前回调处理用户交互或异步状态变化。 */ () => setTaskAccount(account)}
|
||||
className="p-3 rounded-xl hover:bg-amber-100 transition-colors text-amber-600"
|
||||
title="自动评价与每日擦亮"
|
||||
>
|
||||
<CalendarClock className="w-5 h-5" />
|
||||
</button>
|
||||
<button
|
||||
onClick={/* 当前回调处理用户交互或异步状态变化。 */ () => handleToggle(account.id, account.enabled)}
|
||||
className={`p-3 rounded-xl transition-colors ${account.enabled ? 'text-green-600 hover:bg-green-50' : 'text-gray-400 hover:bg-gray-100'}`}
|
||||
title={account.enabled ? '停用账号' : '启用账号'}
|
||||
>
|
||||
<Power className="w-5 h-5" />
|
||||
</button>
|
||||
<button
|
||||
onClick={/* 当前回调处理用户交互或异步状态变化。 */ () => openDeleteDialog(account)}
|
||||
disabled={deletingAccountId !== ''}
|
||||
className="p-3 rounded-xl hover:bg-red-100 transition-colors text-red-500 disabled:cursor-not-allowed disabled:opacity-40"
|
||||
title={deletingAccountId === account.id ? '删除中…' : `删除账号 ${account.nickname || account.remark || account.id}`}
|
||||
>
|
||||
{deletingAccountId === account.id
|
||||
? <Loader2 className="w-5 h-5 animate-spin" />
|
||||
: <Trash2 className="w-5 h-5" />}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)})}
|
||||
{filteredAccounts.map(/* 当前回调处理集合中的单个元素。 */ account => (
|
||||
<AccountCard
|
||||
key={account.id}
|
||||
account={account}
|
||||
refreshing={refreshingProfileId === account.id}
|
||||
deleting={deletingAccountId === account.id}
|
||||
onRefreshProfile={handleRefreshProfile}
|
||||
onReauthorize={startQRLogin}
|
||||
onEdit={openEditModal}
|
||||
onAI={openAIModal}
|
||||
onTasks={setTaskAccount}
|
||||
onToggle={handleToggle}
|
||||
onDelete={openDeleteDialog}
|
||||
/>
|
||||
))}
|
||||
|
||||
{accounts.length === 0 && (
|
||||
<div className="ios-card p-12 text-center">
|
||||
@@ -530,155 +408,26 @@ const AccountList: React.FC = () => {
|
||||
document.body
|
||||
)}
|
||||
|
||||
{/* 删除账号确认弹窗 */}
|
||||
{deleteDialogAccount && createPortal(
|
||||
<div className="modal-overlay-centered" role="presentation">
|
||||
<div
|
||||
className="h-fit w-full max-w-[400px] self-center overflow-hidden rounded-2xl border border-white/80 bg-white shadow-modal"
|
||||
role="dialog"
|
||||
aria-modal="true"
|
||||
aria-labelledby="delete-account-title"
|
||||
aria-describedby="delete-account-description"
|
||||
>
|
||||
<div className="relative overflow-hidden border-b border-red-100 bg-gradient-to-br from-red-50 via-white to-orange-50 px-5 py-5">
|
||||
<div className="absolute -right-12 -top-16 h-36 w-36 rounded-full bg-red-200/35 blur-2xl" />
|
||||
<div className="relative flex items-start gap-4">
|
||||
<div className="flex h-10 w-10 flex-shrink-0 items-center justify-center rounded-xl bg-red-600 text-white shadow-md shadow-red-200">
|
||||
<Trash2 className="h-5 w-5" />
|
||||
</div>
|
||||
<div className="min-w-0 flex-1">
|
||||
<h3 id="delete-account-title" className="text-lg font-extrabold tracking-tight text-gray-950">
|
||||
删除这个账号?
|
||||
</h3>
|
||||
<p id="delete-account-description" className="mt-1 text-xs leading-5 text-gray-600">
|
||||
删除后,该账号的关联配置也会一并清理,此操作无法撤销。
|
||||
</p>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
onClick={closeDeleteDialog}
|
||||
disabled={deletingAccountId !== ''}
|
||||
className="flex h-9 w-9 flex-shrink-0 items-center justify-center rounded-full text-gray-400 transition-colors hover:bg-white hover:text-gray-700 disabled:cursor-not-allowed disabled:opacity-40"
|
||||
aria-label="关闭删除确认"
|
||||
>
|
||||
<X className="h-5 w-5" />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="px-5 py-4">
|
||||
<div className="rounded-xl border border-gray-100 bg-gray-50/80 px-4 py-3">
|
||||
<div className="text-sm font-extrabold text-gray-900">
|
||||
{deleteDialogAccount.nickname || deleteDialogAccount.remark || '未命名账号'}
|
||||
</div>
|
||||
{deleteDialogAccount.remark && deleteDialogAccount.nickname && (
|
||||
<div className="mt-1 text-sm text-gray-500">备注:{deleteDialogAccount.remark}</div>
|
||||
)}
|
||||
<div className="mt-1.5 break-all font-mono text-[11px] text-gray-400">ID: {deleteDialogAccount.id}</div>
|
||||
</div>
|
||||
|
||||
{deletingAccountId === deleteDialogAccount.id && (
|
||||
<div
|
||||
className="mt-4 flex items-center gap-3 rounded-xl border border-blue-100 bg-blue-50 px-4 py-3"
|
||||
role="progressbar"
|
||||
aria-label="正在删除账号"
|
||||
>
|
||||
<Loader2 className="h-5 w-5 flex-shrink-0 animate-spin text-brand" />
|
||||
<div>
|
||||
<div className="text-sm font-extrabold text-blue-950">正在删除账号</div>
|
||||
<div className="mt-0.5 text-xs text-blue-700">正在清理关联数据,请保持页面打开…</div>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{deleteError && (
|
||||
<div className="mt-4 flex items-start gap-3 rounded-xl border border-red-100 bg-red-50 px-4 py-3" role="alert">
|
||||
<AlertCircle className="mt-0.5 h-5 w-5 flex-shrink-0 text-red-600" />
|
||||
<div>
|
||||
<div className="text-sm font-extrabold text-red-800">删除失败</div>
|
||||
<div className="mt-1 text-xs leading-5 text-red-700">{deleteError}</div>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="flex gap-3 border-t border-gray-100 bg-gray-50/70 px-5 py-4">
|
||||
<button
|
||||
type="button"
|
||||
onClick={closeDeleteDialog}
|
||||
disabled={deletingAccountId !== ''}
|
||||
className="flex-1 rounded-xl bg-white px-5 py-3 text-sm font-extrabold text-gray-700 ring-1 ring-gray-200 transition-colors hover:bg-gray-100 disabled:cursor-not-allowed disabled:opacity-50"
|
||||
>
|
||||
取消
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
onClick={/* 当前回调处理用户交互或异步状态变化。 */ () => void confirmDeleteAccount()}
|
||||
disabled={deletingAccountId !== ''}
|
||||
className="flex flex-1 items-center justify-center gap-2 rounded-xl bg-red-600 px-5 py-3 text-sm font-extrabold text-white shadow-lg shadow-red-200 transition-colors hover:bg-red-700 disabled:cursor-not-allowed disabled:bg-red-400"
|
||||
>
|
||||
{deletingAccountId === deleteDialogAccount.id ? (
|
||||
<><Loader2 className="h-4 w-4 animate-spin" />处理中</>
|
||||
) : (
|
||||
<><Trash2 className="h-4 w-4" />确认删除</>
|
||||
)}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>,
|
||||
document.body
|
||||
{deleteDialogAccount && (
|
||||
<AccountDeleteDialog
|
||||
account={deleteDialogAccount}
|
||||
deleting={deletingAccountId === deleteDialogAccount.id}
|
||||
error={deleteError}
|
||||
onClose={closeDeleteDialog}
|
||||
onConfirm={confirmDeleteAccount}
|
||||
/>
|
||||
)}
|
||||
|
||||
{/* QR Code Modal */}
|
||||
{showQRModal && createPortal(
|
||||
<div className="modal-overlay-centered">
|
||||
<div className="modal-container relative" style={{maxWidth: '26rem'}}>
|
||||
<button
|
||||
onClick={closeQRModal}
|
||||
className="absolute top-4 right-4 z-10 w-9 h-9 flex items-center justify-center bg-gray-100 hover:bg-gray-200 rounded-full transition-colors"
|
||||
>
|
||||
<X className="w-5 h-5 text-gray-600" />
|
||||
</button>
|
||||
|
||||
<div className="modal-body">
|
||||
<div className="text-center">
|
||||
<h3 className="text-2xl font-extrabold text-gray-900 mb-2">
|
||||
{qrReauthTarget ? '重新授权账号' : '扫码添加账号'}
|
||||
</h3>
|
||||
<p className="text-gray-500 mb-8 font-medium">
|
||||
{qrReauthTarget
|
||||
? `请用闲鱼APP扫码,为「${qrReauthTarget.nickname || qrReauthTarget.remark || qrReauthTarget.id}」刷新授权`
|
||||
: '请打开闲鱼APP扫描下方二维码'}
|
||||
</p>
|
||||
|
||||
<div className={`w-full bg-surface-subtle rounded-xl mx-auto flex items-center justify-center overflow-hidden border-4 border-white shadow-inner mb-6 relative ${qrStatus === 'verification' ? 'max-w-72 min-h-64 h-auto p-2' : 'max-w-64 aspect-square'}`}>
|
||||
{qrStatus === 'loading' && <Loader2 className="w-10 h-10 text-brand animate-spin" />}
|
||||
{qrStatus === 'waiting' && <SquareQRCode src={qrCodeUrl} alt="闲鱼登录二维码" className="p-2" />}
|
||||
{qrStatus === 'success' && (
|
||||
<div className="absolute inset-0 bg-white/95 flex flex-col items-center justify-center text-green-600 animate-fade-in">
|
||||
<div className="w-16 h-16 bg-green-100 rounded-full flex items-center justify-center mb-4">
|
||||
<Check className="w-8 h-8" />
|
||||
</div>
|
||||
<span className="font-bold text-lg">登录成功</span>
|
||||
</div>
|
||||
)}
|
||||
{qrStatus === 'error' && (
|
||||
<div className="px-5 text-center">
|
||||
<span className="block text-red-600 font-bold">二维码获取失败</span>
|
||||
<span className="mt-2 block text-xs leading-5 text-gray-500">{qrErrorMessage || '请关闭窗口后重新发起扫码登录。'}</span>
|
||||
</div>
|
||||
)}
|
||||
{qrStatus === 'verification' && (
|
||||
<RiskVerificationPanel faceQrUrl={faceQrUrl} verificationScreenshot={verificationScreenshot} />
|
||||
)}
|
||||
</div>
|
||||
|
||||
{qrStatus !== 'verification' && <p className="text-xs text-gray-400 font-medium bg-gray-50 py-2 rounded-xl">二维码有效期为5分钟,请尽快扫码。</p>}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>,
|
||||
document.body
|
||||
{showQRModal && (
|
||||
<AccountQRCodeModal
|
||||
target={qrReauthTarget}
|
||||
status={qrStatus}
|
||||
codeUrl={qrCodeUrl}
|
||||
errorMessage={qrErrorMessage}
|
||||
faceQrUrl={faceQrUrl}
|
||||
verificationScreenshot={verificationScreenshot}
|
||||
onClose={closeQRModal}
|
||||
/>
|
||||
)}
|
||||
|
||||
{/* 编辑账号弹窗由 accounts feature 组件负责渲染和表单交互。 */}
|
||||
@@ -708,141 +457,15 @@ const AccountList: React.FC = () => {
|
||||
)}
|
||||
|
||||
|
||||
{/* AI设置弹窗 */}
|
||||
{activeModal === 'ai-settings' && editingAccount && createPortal(
|
||||
<div className="modal-overlay-centered">
|
||||
<div className="modal-container" style={{maxWidth: '600px'}}>
|
||||
<div className="modal-header">
|
||||
<div>
|
||||
<h3 className="text-2xl font-extrabold text-gray-900 flex items-center gap-2">
|
||||
<Bot className="w-6 h-6 text-purple-500" />
|
||||
AI助手设置
|
||||
</h3>
|
||||
<p className="text-sm text-gray-500 mt-1">{editingAccount.nickname || editingAccount.remark || editingAccount.id}</p>
|
||||
</div>
|
||||
<button
|
||||
onClick={closeAIModal}
|
||||
className="p-2 rounded-xl hover:bg-gray-100 transition-colors flex-shrink-0"
|
||||
>
|
||||
<X className="w-5 h-5 text-gray-500" />
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div className="modal-body space-y-6">
|
||||
{/* 启用AI */}
|
||||
<div className="flex items-center justify-between p-4 bg-purple-50 rounded-xl">
|
||||
<div>
|
||||
<div className="font-bold text-gray-900 flex items-center gap-2">
|
||||
<Bot className="w-4 h-4 text-purple-500" />
|
||||
启用AI自动回复
|
||||
</div>
|
||||
<div className="text-xs text-gray-500">AI将自动处理买家的砍价消息</div>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
onClick={/* 当前回调处理用户交互或异步状态变化。 */ () => setAiSettings({ ...aiSettings, ai_enabled: !aiSettings.ai_enabled })}
|
||||
className={`w-14 h-8 rounded-full transition-colors duration-300 relative ${
|
||||
aiSettings.ai_enabled ? 'bg-brand' : 'bg-gray-300'
|
||||
}`}
|
||||
>
|
||||
<span
|
||||
className={`absolute left-1 top-1 w-6 h-6 bg-white rounded-full shadow-md transition-transform duration-300 ${
|
||||
aiSettings.ai_enabled ? 'translate-x-6' : 'translate-x-0'
|
||||
}`}
|
||||
/>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{/* 砍价策略 */}
|
||||
<div className="border-t border-gray-200 pt-6">
|
||||
<h3 className="text-lg font-bold text-gray-900 mb-4">砍价策略</h3>
|
||||
<div className="grid grid-cols-3 gap-4">
|
||||
<div>
|
||||
<label className="block text-sm font-bold text-gray-700 mb-2">最大折扣比例 (%)</label>
|
||||
<input
|
||||
type="number"
|
||||
value={aiSettings.max_discount_percent}
|
||||
onChange={/* 当前回调处理用户交互或异步状态变化。 */ (e) => setAiSettings({ ...aiSettings, max_discount_percent: parseInt(e.target.value) || 0 })}
|
||||
className="w-full ios-input px-4 py-3 rounded-xl"
|
||||
min="0"
|
||||
max="100"
|
||||
/>
|
||||
<p className="text-xs text-gray-500 mt-1">例如:10 表示最多降价 10%;设为 0 表示不允许降价</p>
|
||||
</div>
|
||||
<div>
|
||||
<label className="block text-sm font-bold text-gray-700 mb-2">最大折扣金额 (元)</label>
|
||||
<input
|
||||
type="number"
|
||||
value={aiSettings.max_discount_amount}
|
||||
onChange={/* 当前回调处理用户交互或异步状态变化。 */ (e) => setAiSettings({ ...aiSettings, max_discount_amount: parseInt(e.target.value) || 0 })}
|
||||
className="w-full ios-input px-4 py-3 rounded-xl"
|
||||
min="0"
|
||||
/>
|
||||
<p className="text-xs text-gray-500 mt-1">例如:100 表示最多降价 100 元;设为 0 表示不允许降价</p>
|
||||
</div>
|
||||
<div>
|
||||
<label className="block text-sm font-bold text-gray-700 mb-2">最大砍价轮次</label>
|
||||
<input
|
||||
type="number"
|
||||
value={aiSettings.max_bargain_rounds}
|
||||
onChange={/* 当前回调处理用户交互或异步状态变化。 */ (e) => setAiSettings({ ...aiSettings, max_bargain_rounds: parseInt(e.target.value) || 1 })}
|
||||
className="w-full ios-input px-4 py-3 rounded-xl"
|
||||
min="1"
|
||||
max="10"
|
||||
/>
|
||||
<p className="text-xs text-gray-500 mt-1">买家最多可以砍价的次数</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* 自定义提示词 */}
|
||||
<div>
|
||||
<label className="block text-sm font-bold text-gray-700 mb-2">自定义提示词(可选)</label>
|
||||
<textarea
|
||||
value={aiSettings.custom_prompts}
|
||||
onChange={/* 当前回调处理用户交互或异步状态变化。 */ (e) => setAiSettings({ ...aiSettings, custom_prompts: e.target.value })}
|
||||
placeholder="输入自定义的AI回复规则或风格指引... 例如:回复时保持礼貌专业、使用简洁的语言、强调产品质量等"
|
||||
className="w-full ios-input px-4 py-3 rounded-xl h-40 resize-none"
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* AI如何工作 */}
|
||||
<div className="bg-blue-50 border border-blue-200 rounded-xl p-4">
|
||||
<h4 className="font-bold text-blue-900 mb-2 flex items-center gap-2">
|
||||
<Settings className="w-4 h-4" />
|
||||
AI如何工作
|
||||
</h4>
|
||||
<ul className="text-xs text-blue-800 space-y-1">
|
||||
<li>• 自动识别买家的砍价请求</li>
|
||||
<li>• 根据设定的策略智能回复</li>
|
||||
<li>• 在合理范围内同意降价或礼貌拒绝</li>
|
||||
<li>• 保持专业友好的沟通风格</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="modal-footer">
|
||||
<div className="flex gap-3 w-full">
|
||||
<button
|
||||
onClick={closeAIModal}
|
||||
className="flex-1 px-6 py-3 rounded-xl font-bold bg-gray-100 text-gray-700 hover:bg-gray-200 transition-colors"
|
||||
disabled={saving}
|
||||
>
|
||||
取消
|
||||
</button>
|
||||
<button
|
||||
onClick={handleSaveAISettings}
|
||||
className="flex-1 ios-btn-primary px-6 py-3 rounded-xl font-bold flex items-center justify-center gap-2"
|
||||
disabled={saving}
|
||||
>
|
||||
{saving ? <Loader2 className="w-4 h-4 animate-spin" /> : <Save className="w-4 h-4" />}
|
||||
{saving ? '保存中...' : '保存'}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>,
|
||||
document.body
|
||||
{activeModal === 'ai-settings' && editingAccount && (
|
||||
<AccountAISettingsModal
|
||||
account={editingAccount}
|
||||
settings={aiSettings}
|
||||
saving={saving}
|
||||
onChange={setAiSettings}
|
||||
onClose={closeAIModal}
|
||||
onSave={handleSaveAISettings}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
|
||||
Reference in new issue
Block a user