feat(upload): Persist team process configuration to localStorage
- Add localStorage persistence for team process configuration settings - Initialize state values from saved configuration on component mount - Implement useEffect hook to automatically save configuration changes to localStorage - Preserve user preferences for membersPerTeam, concurrentTeams, concurrentS2A, useProxy, includeOwner, and processCount across sessions - Improve user experience by restoring previous settings when returning to Upload page
This commit is contained in:
@@ -68,16 +68,24 @@ export default function Upload() {
|
|||||||
} | null>(null)
|
} | null>(null)
|
||||||
const [batchCount, setBatchCount] = useState(0)
|
const [batchCount, setBatchCount] = useState(0)
|
||||||
|
|
||||||
// 配置
|
// 配置(从 localStorage 恢复上次设置)
|
||||||
const [membersPerTeam, setMembersPerTeam] = useState(4)
|
const savedConfig = JSON.parse(localStorage.getItem('team_process_config') || '{}')
|
||||||
const [concurrentTeams, setConcurrentTeams] = useState(2)
|
const [membersPerTeam, setMembersPerTeam] = useState(savedConfig.membersPerTeam ?? 4)
|
||||||
const [concurrentS2A, setConcurrentS2A] = useState(2) // 入库并发数
|
const [concurrentTeams, setConcurrentTeams] = useState(savedConfig.concurrentTeams ?? 2)
|
||||||
const [useProxy, setUseProxy] = useState(false) // 是否使用代理池
|
const [concurrentS2A, setConcurrentS2A] = useState(savedConfig.concurrentS2A ?? 2) // 入库并发数
|
||||||
const [includeOwner, setIncludeOwner] = useState(false) // 母号也入库
|
const [useProxy, setUseProxy] = useState(savedConfig.useProxy ?? false) // 是否使用代理池
|
||||||
const [processCount, setProcessCount] = useState(0) // 处理数量,0表示全部
|
const [includeOwner, setIncludeOwner] = useState(savedConfig.includeOwner ?? false) // 母号也入库
|
||||||
|
const [processCount, setProcessCount] = useState(savedConfig.processCount ?? 0) // 处理数量,0表示全部
|
||||||
const [authMethod, setAuthMethod] = useState<'api' | 'browser'>('browser') // 授权方式
|
const [authMethod, setAuthMethod] = useState<'api' | 'browser'>('browser') // 授权方式
|
||||||
const [proxyPoolStats, setProxyPoolStats] = useState<{ total: number; enabled: number } | null>(null)
|
const [proxyPoolStats, setProxyPoolStats] = useState<{ total: number; enabled: number } | null>(null)
|
||||||
|
|
||||||
|
// 配置变化时自动保存到 localStorage
|
||||||
|
useEffect(() => {
|
||||||
|
localStorage.setItem('team_process_config', JSON.stringify({
|
||||||
|
membersPerTeam, concurrentTeams, concurrentS2A, useProxy, includeOwner, processCount,
|
||||||
|
}))
|
||||||
|
}, [membersPerTeam, concurrentTeams, concurrentS2A, useProxy, includeOwner, processCount])
|
||||||
|
|
||||||
// 加载全局配置中的授权方式和代理池统计
|
// 加载全局配置中的授权方式和代理池统计
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const fetchConfig = async () => {
|
const fetchConfig = async () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user