HouYunFei commited on
Commit
d2c09fa
·
2 Parent(s): 8b70b1ee83469e

Merge branch 'fork/Jimmy-Bots/usermult'

Browse files
services/config.py CHANGED
@@ -187,6 +187,13 @@ class ConfigStore:
187
  except (TypeError, ValueError):
188
  return 120
189
 
 
 
 
 
 
 
 
190
  @property
191
  def auto_remove_invalid_accounts(self) -> bool:
192
  value = self.data.get("auto_remove_invalid_accounts", False)
@@ -265,6 +272,7 @@ class ConfigStore:
265
  data["refresh_account_interval_minute"] = self.refresh_account_interval_minute
266
  data["image_retention_days"] = self.image_retention_days
267
  data["image_poll_timeout_secs"] = self.image_poll_timeout_secs
 
268
  data["auto_remove_invalid_accounts"] = self.auto_remove_invalid_accounts
269
  data["auto_remove_rate_limited_accounts"] = self.auto_remove_rate_limited_accounts
270
  data["log_levels"] = self.log_levels
 
187
  except (TypeError, ValueError):
188
  return 120
189
 
190
+ @property
191
+ def image_account_concurrency(self) -> int:
192
+ try:
193
+ return max(1, int(self.data.get("image_account_concurrency", 3)))
194
+ except (TypeError, ValueError):
195
+ return 3
196
+
197
  @property
198
  def auto_remove_invalid_accounts(self) -> bool:
199
  value = self.data.get("auto_remove_invalid_accounts", False)
 
272
  data["refresh_account_interval_minute"] = self.refresh_account_interval_minute
273
  data["image_retention_days"] = self.image_retention_days
274
  data["image_poll_timeout_secs"] = self.image_poll_timeout_secs
275
+ data["image_account_concurrency"] = self.image_account_concurrency
276
  data["auto_remove_invalid_accounts"] = self.auto_remove_invalid_accounts
277
  data["auto_remove_rate_limited_accounts"] = self.auto_remove_rate_limited_accounts
278
  data["log_levels"] = self.log_levels
web/src/app/settings/components/config-card.tsx CHANGED
@@ -23,6 +23,7 @@ export function ConfigCard() {
23
  const setRefreshAccountIntervalMinute = useSettingsStore((state) => state.setRefreshAccountIntervalMinute);
24
  const setImageRetentionDays = useSettingsStore((state) => state.setImageRetentionDays);
25
  const setImagePollTimeoutSecs = useSettingsStore((state) => state.setImagePollTimeoutSecs);
 
26
  const setAutoRemoveInvalidAccounts = useSettingsStore((state) => state.setAutoRemoveInvalidAccounts);
27
  const setAutoRemoveRateLimitedAccounts = useSettingsStore((state) => state.setAutoRemoveRateLimitedAccounts);
28
  const setLogLevel = useSettingsStore((state) => state.setLogLevel);
@@ -150,6 +151,16 @@ export function ConfigCard() {
150
  />
151
  <p className="text-xs text-stone-500">单位秒,等待上游图片结果的最长时间。</p>
152
  </div>
 
 
 
 
 
 
 
 
 
 
153
  <label className="flex items-center gap-3 rounded-xl border border-stone-200 bg-white px-4 py-3 text-sm text-stone-700">
154
  <Checkbox
155
  checked={Boolean(config?.auto_remove_invalid_accounts)}
 
23
  const setRefreshAccountIntervalMinute = useSettingsStore((state) => state.setRefreshAccountIntervalMinute);
24
  const setImageRetentionDays = useSettingsStore((state) => state.setImageRetentionDays);
25
  const setImagePollTimeoutSecs = useSettingsStore((state) => state.setImagePollTimeoutSecs);
26
+ const setImageAccountConcurrency = useSettingsStore((state) => state.setImageAccountConcurrency);
27
  const setAutoRemoveInvalidAccounts = useSettingsStore((state) => state.setAutoRemoveInvalidAccounts);
28
  const setAutoRemoveRateLimitedAccounts = useSettingsStore((state) => state.setAutoRemoveRateLimitedAccounts);
29
  const setLogLevel = useSettingsStore((state) => state.setLogLevel);
 
151
  />
152
  <p className="text-xs text-stone-500">单位秒,等待上游图片结果的最长时间。</p>
153
  </div>
154
+ <div className="space-y-2">
155
+ <label className="text-sm text-stone-700">单账号图片并发</label>
156
+ <Input
157
+ value={String(config?.image_account_concurrency || "")}
158
+ onChange={(event) => setImageAccountConcurrency(event.target.value)}
159
+ placeholder="1"
160
+ className="h-10 rounded-xl border-stone-200 bg-white"
161
+ />
162
+ <p className="text-xs text-stone-500">限制每个账号同时处理的图片请求数量,默认 3。</p>
163
+ </div>
164
  <label className="flex items-center gap-3 rounded-xl border border-stone-200 bg-white px-4 py-3 text-sm text-stone-700">
165
  <Checkbox
166
  checked={Boolean(config?.auto_remove_invalid_accounts)}
web/src/app/settings/store.ts CHANGED
@@ -66,6 +66,7 @@ function normalizeConfig(config: SettingsConfig): SettingsConfig {
66
  refresh_account_interval_minute: Number(config.refresh_account_interval_minute || 5),
67
  image_retention_days: Number(config.image_retention_days || 30),
68
  image_poll_timeout_secs: Number(config.image_poll_timeout_secs || 120),
 
69
  auto_remove_invalid_accounts: Boolean(config.auto_remove_invalid_accounts),
70
  auto_remove_rate_limited_accounts: Boolean(config.auto_remove_rate_limited_accounts),
71
  log_levels: Array.isArray(config.log_levels) ? config.log_levels : [],
@@ -164,6 +165,7 @@ type SettingsStore = {
164
  setRefreshAccountIntervalMinute: (value: string) => void;
165
  setImageRetentionDays: (value: string) => void;
166
  setImagePollTimeoutSecs: (value: string) => void;
 
167
  setAutoRemoveInvalidAccounts: (value: boolean) => void;
168
  setAutoRemoveRateLimitedAccounts: (value: boolean) => void;
169
  setLogLevel: (level: string, enabled: boolean) => void;
@@ -293,6 +295,7 @@ export const useSettingsStore = create<SettingsStore>((set, get) => ({
293
  refresh_account_interval_minute: Math.max(1, Number(config.refresh_account_interval_minute) || 1),
294
  image_retention_days: Math.max(1, Number(config.image_retention_days) || 30),
295
  image_poll_timeout_secs: Math.max(1, Number(config.image_poll_timeout_secs) || 120),
 
296
  auto_remove_invalid_accounts: Boolean(config.auto_remove_invalid_accounts),
297
  auto_remove_rate_limited_accounts: Boolean(config.auto_remove_rate_limited_accounts),
298
  proxy: config.proxy.trim(),
@@ -346,6 +349,10 @@ export const useSettingsStore = create<SettingsStore>((set, get) => ({
346
  set((state) => state.config ? { config: { ...state.config, image_poll_timeout_secs: value } } : {});
347
  },
348
 
 
 
 
 
349
  setAutoRemoveInvalidAccounts: (value) => {
350
  set((state) => state.config ? { config: { ...state.config, auto_remove_invalid_accounts: value } } : {});
351
  },
 
66
  refresh_account_interval_minute: Number(config.refresh_account_interval_minute || 5),
67
  image_retention_days: Number(config.image_retention_days || 30),
68
  image_poll_timeout_secs: Number(config.image_poll_timeout_secs || 120),
69
+ image_account_concurrency: Number(config.image_account_concurrency || 3),
70
  auto_remove_invalid_accounts: Boolean(config.auto_remove_invalid_accounts),
71
  auto_remove_rate_limited_accounts: Boolean(config.auto_remove_rate_limited_accounts),
72
  log_levels: Array.isArray(config.log_levels) ? config.log_levels : [],
 
165
  setRefreshAccountIntervalMinute: (value: string) => void;
166
  setImageRetentionDays: (value: string) => void;
167
  setImagePollTimeoutSecs: (value: string) => void;
168
+ setImageAccountConcurrency: (value: string) => void;
169
  setAutoRemoveInvalidAccounts: (value: boolean) => void;
170
  setAutoRemoveRateLimitedAccounts: (value: boolean) => void;
171
  setLogLevel: (level: string, enabled: boolean) => void;
 
295
  refresh_account_interval_minute: Math.max(1, Number(config.refresh_account_interval_minute) || 1),
296
  image_retention_days: Math.max(1, Number(config.image_retention_days) || 30),
297
  image_poll_timeout_secs: Math.max(1, Number(config.image_poll_timeout_secs) || 120),
298
+ image_account_concurrency: Math.max(1, Number(config.image_account_concurrency) || 3),
299
  auto_remove_invalid_accounts: Boolean(config.auto_remove_invalid_accounts),
300
  auto_remove_rate_limited_accounts: Boolean(config.auto_remove_rate_limited_accounts),
301
  proxy: config.proxy.trim(),
 
349
  set((state) => state.config ? { config: { ...state.config, image_poll_timeout_secs: value } } : {});
350
  },
351
 
352
+ setImageAccountConcurrency: (value) => {
353
+ set((state) => state.config ? { config: { ...state.config, image_account_concurrency: value } } : {});
354
+ },
355
+
356
  setAutoRemoveInvalidAccounts: (value) => {
357
  set((state) => state.config ? { config: { ...state.config, auto_remove_invalid_accounts: value } } : {});
358
  },
web/src/lib/api.ts CHANGED
@@ -57,6 +57,7 @@ export type SettingsConfig = {
57
  refresh_account_interval_minute?: number | string;
58
  image_retention_days?: number | string;
59
  image_poll_timeout_secs?: number | string;
 
60
  auto_remove_invalid_accounts?: boolean;
61
  auto_remove_rate_limited_accounts?: boolean;
62
  log_levels?: string[];
 
57
  refresh_account_interval_minute?: number | string;
58
  image_retention_days?: number | string;
59
  image_poll_timeout_secs?: number | string;
60
+ image_account_concurrency?: number | string;
61
  auto_remove_invalid_accounts?: boolean;
62
  auto_remove_rate_limited_accounts?: boolean;
63
  log_levels?: string[];