@refeain/dsh-xdpool 3.2.0 → 3.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/client.js CHANGED
@@ -40,6 +40,7 @@ window.__ModuleLoader__.load({
40
40
  //#endregion
41
41
  //#region src/status-paths.ts
42
42
  const POOL_STATUS_PATH = "/plugins/dsh-xdpool/status";
43
+ const POOL_RESCAN_PATH = "/plugins/dsh-xdpool/accounts/rescan";
43
44
  const POOL_CATALOG_REFRESH_PATH = "/plugins/dsh-xdpool/models/refresh";
44
45
  const POOL_CHECKIN_PATH = "/plugins/dsh-xdpool/checkin";
45
46
  const POOL_ACCOUNT_IGNORE_PATH = "/plugins/dsh-xdpool/accounts/ignored";
@@ -139,7 +140,7 @@ window.__ModuleLoader__.load({
139
140
  const POOL_NAV_ICON_MASK_URL = `data:image/svg+xml;utf8,${encodeURIComponent(POOL_NAV_ICON_SVG)}`;
140
141
  //#endregion
141
142
  //#region src/version.ts
142
- const POOL_VERSION = "3.2.0";
143
+ const POOL_VERSION = "3.3.0";
143
144
  function compareVersions(left, right) {
144
145
  const parse = (value) => {
145
146
  const [core, ...rest] = value.trim().replace(/^v/u, "").split("-");
@@ -9415,6 +9416,30 @@ window.__ModuleLoader__.load({
9415
9416
  }
9416
9417
  return rows;
9417
9418
  }
9419
+ function creditStatusesFrom(envelope) {
9420
+ const value = envelope.value;
9421
+ if (value === null || typeof value !== "object") return [];
9422
+ const accounts = value.accounts;
9423
+ if (!Array.isArray(accounts)) return [];
9424
+ const rows = [];
9425
+ for (const entry of accounts) {
9426
+ if (entry === null || typeof entry !== "object") continue;
9427
+ const accountId = entry.accountId;
9428
+ if (typeof accountId !== "string" || accountId === "") continue;
9429
+ const nickname = entry.nickname;
9430
+ const status = entry.status;
9431
+ const statusRow = status !== null && typeof status === "object" ? status : void 0;
9432
+ const todayCredit = statusRow?.["todayCredit"];
9433
+ const checkedIn = statusRow?.["todayCheckedIn"];
9434
+ rows.push({
9435
+ accountId,
9436
+ ...typeof nickname === "string" && nickname !== "" ? { nickname } : {},
9437
+ ...typeof checkedIn === "boolean" ? { todayCheckedIn: checkedIn } : {},
9438
+ ...typeof todayCredit === "number" && Number.isFinite(todayCredit) ? { todayCredit } : {}
9439
+ });
9440
+ }
9441
+ return rows;
9442
+ }
9418
9443
  async function fetchChannels() {
9419
9444
  const response = await fetch(POOL_CHANNELS_PATH, {
9420
9445
  headers: { accept: "application/json" },
@@ -9634,6 +9659,402 @@ window.__ModuleLoader__.load({
9634
9659
  });
9635
9660
  }
9636
9661
  //#endregion
9662
+ //#region src/client/account-view.ts
9663
+ const REGION_OF_CHANNEL = Object.freeze({
9664
+ buddy: "cn",
9665
+ workbuddy: "global"
9666
+ });
9667
+ function poolRegionOf(channelId) {
9668
+ return REGION_OF_CHANNEL[channelId];
9669
+ }
9670
+ function resolveAccountSource(channel) {
9671
+ const owned = channel.ownedByPool === true;
9672
+ const region = poolRegionOf(channel.id);
9673
+ if (!owned && region === void 0) return {
9674
+ ok: true,
9675
+ source: {
9676
+ kind: "channel",
9677
+ channelId: channel.id
9678
+ }
9679
+ };
9680
+ if (region === void 0) return {
9681
+ ok: false,
9682
+ problem: `渠道 ${channel.id} 归账号池管,但界面不认识它的区域,账号统计已停用`
9683
+ };
9684
+ return {
9685
+ ok: true,
9686
+ source: {
9687
+ kind: "pool",
9688
+ region,
9689
+ channelId: channel.id
9690
+ }
9691
+ };
9692
+ }
9693
+ function usableAmount(value) {
9694
+ return value !== void 0 && Number.isFinite(value) ? value : void 0;
9695
+ }
9696
+ function rowsFromPool(accounts) {
9697
+ return accounts.map((account) => {
9698
+ const total = usableAmount(account.credits?.total);
9699
+ const packages = account.credits?.packages ?? [];
9700
+ let fromPackages;
9701
+ for (const entry of packages) {
9702
+ const remain = usableAmount(entry.remain);
9703
+ if (remain === void 0) continue;
9704
+ fromPackages = (fromPackages ?? 0) + remain;
9705
+ }
9706
+ const balance = account.creditsError !== void 0 ? void 0 : total ?? fromPackages;
9707
+ const checkinError = account.checkinError;
9708
+ const checkin = checkinError !== void 0 || account.checkin === void 0 ? "unknown" : account.checkin.todayCheckedIn ? "checked" : "unchecked";
9709
+ const todayCredit = checkin === "checked" ? usableAmount(account.checkin?.todayCredit) : void 0;
9710
+ return {
9711
+ id: account.id,
9712
+ label: account.label,
9713
+ enabled: account.disabled !== true,
9714
+ balance,
9715
+ checkin,
9716
+ todayCredit,
9717
+ balanceError: account.creditsError,
9718
+ checkinError,
9719
+ activityActive: account.checkin === void 0 ? void 0 : account.checkin.active
9720
+ };
9721
+ });
9722
+ }
9723
+ function rowsFromChannel(snapshot) {
9724
+ const balanceOf = new Map();
9725
+ for (const row of snapshot.balances) balanceOf.set(row.accountId, row);
9726
+ const statusOf = new Map();
9727
+ for (const row of snapshot.statuses) statusOf.set(row.accountId, row);
9728
+ return snapshot.accounts.map((account) => {
9729
+ const balanceRow = balanceOf.get(account.id);
9730
+ const statusRow = statusOf.get(account.id);
9731
+ const balance = balanceRow?.error === void 0 ? usableAmount(balanceRow?.balance) : void 0;
9732
+ const checkin = statusRow?.todayCheckedIn === true ? "checked" : statusRow?.todayCheckedIn === false ? "unchecked" : "unknown";
9733
+ const todayCredit = checkin === "checked" ? usableAmount(statusRow?.todayCredit) : void 0;
9734
+ const enabled = account.disabled === true ? false : account.enabled !== false;
9735
+ const checkinError = snapshot.statusError;
9736
+ return {
9737
+ id: account.id,
9738
+ label: account.nickname ?? account.name ?? account.id,
9739
+ enabled,
9740
+ balance,
9741
+ checkin: checkinError === void 0 ? checkin : "unknown",
9742
+ todayCredit: checkinError === void 0 ? todayCredit : void 0,
9743
+ balanceError: balanceRow?.error,
9744
+ checkinError,
9745
+ activityActive: void 0
9746
+ };
9747
+ });
9748
+ }
9749
+ function buildAccountView(input) {
9750
+ const { rows } = input;
9751
+ let known = 0;
9752
+ let measured = 0;
9753
+ let enabled = 0;
9754
+ let checked = 0;
9755
+ let unchecked = 0;
9756
+ let unknown = 0;
9757
+ let todayCredit = 0;
9758
+ for (const row of rows) {
9759
+ if (row.balance !== void 0) {
9760
+ known += row.balance;
9761
+ measured += 1;
9762
+ }
9763
+ if (!row.enabled) continue;
9764
+ enabled += 1;
9765
+ if (row.checkin === "checked") {
9766
+ checked += 1;
9767
+ todayCredit += row.todayCredit ?? 0;
9768
+ } else if (row.checkin === "unchecked") unchecked += 1;
9769
+ else unknown += 1;
9770
+ }
9771
+ return {
9772
+ source: input.source,
9773
+ state: input.state,
9774
+ stale: input.stale === true,
9775
+ error: input.error,
9776
+ rows,
9777
+ total: rows.length,
9778
+ enabled,
9779
+ balance: {
9780
+ known,
9781
+ measured,
9782
+ total: rows.length,
9783
+ complete: rows.length > 0 && measured === rows.length
9784
+ },
9785
+ checkin: {
9786
+ checked,
9787
+ unchecked,
9788
+ unknown,
9789
+ denominator: enabled,
9790
+ todayCredit,
9791
+ allDone: enabled > 0 && checked === enabled
9792
+ }
9793
+ };
9794
+ }
9795
+ function buildPoolView(input) {
9796
+ const rows = input.status === void 0 ? [] : rowsFromPool(input.status.accounts);
9797
+ return buildAccountView({
9798
+ source: {
9799
+ kind: "pool",
9800
+ region: input.region,
9801
+ channelId: input.channelId
9802
+ },
9803
+ state: input.state,
9804
+ stale: input.stale,
9805
+ error: input.error,
9806
+ rows
9807
+ });
9808
+ }
9809
+ function buildChannelView(input) {
9810
+ const rows = input.snapshot === void 0 ? [] : rowsFromChannel(input.snapshot);
9811
+ return buildAccountView({
9812
+ source: {
9813
+ kind: "channel",
9814
+ channelId: input.channelId
9815
+ },
9816
+ state: input.state,
9817
+ stale: input.stale,
9818
+ error: input.error,
9819
+ rows
9820
+ });
9821
+ }
9822
+ function buildPageView(inputs) {
9823
+ const resolved = resolveAccountSource(inputs.channel);
9824
+ if (!resolved.ok) return buildAccountView({
9825
+ source: {
9826
+ kind: "channel",
9827
+ channelId: inputs.channel.id
9828
+ },
9829
+ state: "error",
9830
+ error: resolved.problem,
9831
+ rows: []
9832
+ });
9833
+ if (resolved.source.kind === "pool") return buildPoolView({
9834
+ channelId: inputs.channel.id,
9835
+ region: resolved.source.region,
9836
+ status: inputs.laneAccounts === void 0 ? void 0 : { accounts: inputs.laneAccounts },
9837
+ state: inputs.laneAccounts === void 0 ? "loading" : inputs.state,
9838
+ error: inputs.error
9839
+ });
9840
+ return buildChannelView({
9841
+ channelId: inputs.channel.id,
9842
+ snapshot: inputs.pack,
9843
+ state: inputs.state,
9844
+ error: inputs.error ?? inputs.packError
9845
+ });
9846
+ }
9847
+ function balanceDisplay(summary) {
9848
+ if (summary.total === 0 || summary.measured === 0) return { kind: "unknown" };
9849
+ if (summary.complete) return {
9850
+ kind: "complete",
9851
+ known: summary.known
9852
+ };
9853
+ return {
9854
+ kind: "partial",
9855
+ known: summary.known,
9856
+ measured: summary.measured,
9857
+ total: summary.total
9858
+ };
9859
+ }
9860
+ function createRegionGate() {
9861
+ const latest = new Map();
9862
+ let counter = 0;
9863
+ return {
9864
+ issue(region) {
9865
+ counter += 1;
9866
+ return counter;
9867
+ },
9868
+ accept(region, ticket) {
9869
+ const current = latest.get(region);
9870
+ if (current !== void 0 && ticket < current) return false;
9871
+ latest.set(region, ticket);
9872
+ return true;
9873
+ }
9874
+ };
9875
+ }
9876
+ //#endregion
9877
+ //#region src/client/pool-actions.ts
9878
+ const SKIP_REASON_TEXT = Object.freeze({
9879
+ disabled: "账号已停用",
9880
+ activityClosed: "签到活动未开启",
9881
+ unknownStatus: "签到状态未知,跳过(可先「重新检测」再试)",
9882
+ alreadyChecked: "今天已经签到"
9883
+ });
9884
+ function batchEligibility(row) {
9885
+ if (!row.enabled) return {
9886
+ ok: false,
9887
+ reason: "disabled"
9888
+ };
9889
+ if (row.activityActive === false) return {
9890
+ ok: false,
9891
+ reason: "activityClosed"
9892
+ };
9893
+ if (row.checkin === "unknown") return {
9894
+ ok: false,
9895
+ reason: "unknownStatus"
9896
+ };
9897
+ if (row.checkin === "checked") return {
9898
+ ok: false,
9899
+ reason: "alreadyChecked"
9900
+ };
9901
+ return { ok: true };
9902
+ }
9903
+ function planBatch(rows) {
9904
+ const ready = [];
9905
+ const recheck = [];
9906
+ const skipped = [];
9907
+ for (const row of rows) {
9908
+ const verdict = batchEligibility(row);
9909
+ if (verdict.ok) {
9910
+ ready.push(row);
9911
+ continue;
9912
+ }
9913
+ if (verdict.reason === "unknownStatus") {
9914
+ recheck.push(row);
9915
+ continue;
9916
+ }
9917
+ skipped.push({
9918
+ row,
9919
+ reason: verdict.reason
9920
+ });
9921
+ }
9922
+ return {
9923
+ ready,
9924
+ recheck,
9925
+ skipped
9926
+ };
9927
+ }
9928
+ async function runBatch(targets, options) {
9929
+ const results = [];
9930
+ for (const row of targets) {
9931
+ if (options.signal?.aborted === true) break;
9932
+ let result;
9933
+ try {
9934
+ const said = await options.run(row.id);
9935
+ result = {
9936
+ accountId: row.id,
9937
+ label: row.label,
9938
+ ...said
9939
+ };
9940
+ } catch (cause) {
9941
+ result = {
9942
+ accountId: row.id,
9943
+ label: row.label,
9944
+ outcome: "failed",
9945
+ error: cause instanceof Error ? cause.message : String(cause)
9946
+ };
9947
+ }
9948
+ results.push(result);
9949
+ options.onResult?.(result);
9950
+ }
9951
+ return results;
9952
+ }
9953
+ function claimedCount(results) {
9954
+ return results.filter((result) => result.outcome === "claimed" || result.outcome === "alreadyClaimed").length;
9955
+ }
9956
+ function failedCount(results) {
9957
+ return results.filter((result) => result.outcome === "failed").length;
9958
+ }
9959
+ async function claimAll(options) {
9960
+ const skip = options.skipIds;
9961
+ const plan = planBatch(skip === void 0 || skip.size === 0 ? options.rows : options.rows.filter((row) => !skip.has(row.id)));
9962
+ const skipped = plan.skipped.map(({ row, reason }) => ({
9963
+ accountId: row.id,
9964
+ label: row.label,
9965
+ outcome: "skipped",
9966
+ error: SKIP_REASON_TEXT[reason]
9967
+ }));
9968
+ const recovered = [];
9969
+ for (const row of plan.recheck) try {
9970
+ const fresh = await options.recheck(row.id);
9971
+ const verdict = fresh === void 0 ? void 0 : batchEligibility(fresh);
9972
+ if (fresh !== void 0 && verdict?.ok === true) recovered.push(fresh);
9973
+ else skipped.push({
9974
+ accountId: row.id,
9975
+ label: row.label,
9976
+ outcome: "skipped",
9977
+ error: fresh === void 0 ? "签到状态复查失败,跳过(可稍后重试)" : SKIP_REASON_TEXT[verdict !== void 0 && !verdict.ok ? verdict.reason : "unknownStatus"]
9978
+ });
9979
+ } catch (cause) {
9980
+ skipped.push({
9981
+ accountId: row.id,
9982
+ label: row.label,
9983
+ outcome: "skipped",
9984
+ error: `签到状态复查失败(${cause instanceof Error ? cause.message : String(cause)}),跳过`
9985
+ });
9986
+ }
9987
+ const results = await runBatch([...plan.ready, ...recovered], {
9988
+ run: options.claim,
9989
+ signal: options.signal,
9990
+ ...options.onResult === void 0 ? {} : { onResult: options.onResult }
9991
+ });
9992
+ let refresh;
9993
+ try {
9994
+ refresh = await options.refresh();
9995
+ } catch (cause) {
9996
+ refresh = {
9997
+ ok: false,
9998
+ error: cause instanceof Error ? cause.message : String(cause)
9999
+ };
10000
+ }
10001
+ return {
10002
+ results,
10003
+ skipped,
10004
+ refresh
10005
+ };
10006
+ }
10007
+ function summarizeBatch(report, labels) {
10008
+ const claimed = claimedCount(report.results);
10009
+ const failed = failedCount(report.results);
10010
+ const parts = [];
10011
+ if (claimed > 0) parts.push(labels.claimed(claimed));
10012
+ if (failed > 0) parts.push(labels.failed(failed));
10013
+ if (report.skipped.length > 0) parts.push(`跳过 ${String(report.skipped.length)} 个`);
10014
+ if (!report.refresh.ok) parts.push(`状态待刷新(${report.refresh.error ?? "回读失败"})`);
10015
+ return {
10016
+ text: parts.length === 0 ? "没有可领取的账号" : parts.join(","),
10017
+ tone: report.results.length === 0 ? "warn" : failed > 0 || !report.refresh.ok ? "warn" : "ok"
10018
+ };
10019
+ }
10020
+ function outcomeFromClaim(body, ok) {
10021
+ if (!ok) {
10022
+ const message = body?.error;
10023
+ return {
10024
+ outcome: "failed",
10025
+ error: typeof message === "string" ? message : "签到请求被拒绝"
10026
+ };
10027
+ }
10028
+ const typed = body;
10029
+ if (typed?.alreadyCheckedIn === true) return {
10030
+ outcome: "alreadyClaimed",
10031
+ credit: 0
10032
+ };
10033
+ const credit = typed?.claim?.credit;
10034
+ return {
10035
+ outcome: "claimed",
10036
+ ...typeof credit === "number" && Number.isFinite(credit) ? { credit } : {}
10037
+ };
10038
+ }
10039
+ async function rescanRegions(options) {
10040
+ const total = await options.rescan();
10041
+ const settled = await Promise.allSettled(options.regions.map((region) => options.refresh(region)));
10042
+ const byRegion = {};
10043
+ options.regions.forEach((region, index) => {
10044
+ const outcome = settled[index];
10045
+ byRegion[region] = outcome?.status === "fulfilled" ? outcome.value : void 0;
10046
+ });
10047
+ return {
10048
+ total,
10049
+ byRegion
10050
+ };
10051
+ }
10052
+ function claimRouteFor(input) {
10053
+ if (input.hasPoolLane) return "pool";
10054
+ if (input.hasOwnCheckinRoute) return "own";
10055
+ return "pack";
10056
+ }
10057
+ //#endregion
9637
10058
  //#region src/client/ChannelPoolSection.tsx
9638
10059
  let poolSnapshot;
9639
10060
  const COUNTS_STORE_KEY = "dsh-xdpool.channel-counts.v1";
@@ -10329,6 +10750,7 @@ window.__ModuleLoader__.load({
10329
10750
  facts: new Map(),
10330
10751
  balances: [],
10331
10752
  statuses: [],
10753
+ statusError: void 0,
10332
10754
  balancePending: wantBalances,
10333
10755
  balanceError: void 0,
10334
10756
  modelError: modelEmptyBecauseRefused ? models.error?.message ?? "model.list refused" : void 0
@@ -10341,6 +10763,7 @@ window.__ModuleLoader__.load({
10341
10763
  facts: new Map(),
10342
10764
  balances: [],
10343
10765
  statuses: [],
10766
+ statusError: void 0,
10344
10767
  balancePending: false,
10345
10768
  balanceError: void 0,
10346
10769
  modelError: void 0
@@ -10418,6 +10841,7 @@ window.__ModuleLoader__.load({
10418
10841
  for (const entry of next) {
10419
10842
  if (entry.channel.credits === void 0) continue;
10420
10843
  refreshBalances(entry.channel.id, false, true, seq);
10844
+ refreshStatuses(entry.channel.id, true);
10421
10845
  }
10422
10846
  const idsByProvider = {};
10423
10847
  for (const [provider, entry] of perProvider) if (entry.models.length > 0) idsByProvider[provider] = entry.models.map((model) => model.id);
@@ -10582,6 +11006,30 @@ window.__ModuleLoader__.load({
10582
11006
  await load();
10583
11007
  }
10584
11008
  };
11009
+ const refreshStatuses = async (provider, quiet = false) => {
11010
+ if ((entriesRef.current.find((entry) => entry.channel.id === provider)?.channel.credits)?.status !== true) return;
11011
+ if (!quiet) markBusy(provider, true);
11012
+ try {
11013
+ const envelope = await callPack("credits.status", { provider });
11014
+ if (!mountedRef.current) return;
11015
+ if (!envelope.ok) {
11016
+ const message = envelope.error?.message ?? "credits.status refused";
11017
+ setEntries((previous) => previous.map((entry) => entry.channel.id === provider ? {
11018
+ ...entry,
11019
+ statusError: message
11020
+ } : entry));
11021
+ return;
11022
+ }
11023
+ const rows = creditStatusesFrom(envelope);
11024
+ setEntries((previous) => previous.map((entry) => entry.channel.id === provider ? {
11025
+ ...entry,
11026
+ statuses: rows,
11027
+ statusError: void 0
11028
+ } : entry));
11029
+ } finally {
11030
+ if (mountedRef.current && !quiet) markBusy(provider, false);
11031
+ }
11032
+ };
10585
11033
  const refreshBalances = async (provider, force, quiet = false, seq) => {
10586
11034
  if (!quiet) markBusy(provider, true);
10587
11035
  setEntries((previous) => previous.map((entry) => entry.channel.id === provider ? {
@@ -10685,6 +11133,7 @@ window.__ModuleLoader__.load({
10685
11133
  }) ?? "Nothing to claim today.");
10686
11134
  if (result?.failed !== void 0 && result.failed > 0) setNotice(t?.("channelpool.claimFailed", { failed: result.failed }) ?? `${result.failed} failed.`);
10687
11135
  await refreshBalances(provider, true);
11136
+ await refreshStatuses(provider);
10688
11137
  } finally {
10689
11138
  if (mountedRef.current) markBusy(provider, false);
10690
11139
  }
@@ -10966,21 +11415,38 @@ window.__ModuleLoader__.load({
10966
11415
  }
10967
11416
  const chosenEntry = entries.find((entry) => entry.channel.id === chosen) ?? entries[0];
10968
11417
  const laneOf = (channelId) => poolLanes?.[channelId];
10969
- const rowAccountCount = (entry) => laneOf(entry.channel.id)?.accounts.length ?? entry.accounts.length;
10970
- const rowEnabledCount = (entry) => {
10971
- const lane = laneOf(entry.channel.id);
10972
- if (lane !== void 0) return lane.accounts.filter((account) => account.disabled !== true).length;
10973
- return entry.accounts.filter((account) => account.enabled !== false).length;
10974
- };
11418
+ const rowView = (entry) => buildPageView({
11419
+ channel: entry.channel,
11420
+ laneAccounts: laneOf(entry.channel.id)?.accounts,
11421
+ pack: {
11422
+ accounts: entry.accounts,
11423
+ balances: entry.balances.map((row) => ({
11424
+ accountId: row.accountId,
11425
+ balance: balanceAmount(row.balance),
11426
+ error: row.error
11427
+ })),
11428
+ statuses: entry.statuses,
11429
+ statusError: entry.statusError
11430
+ },
11431
+ state: "ready"
11432
+ });
11433
+ const rowAccountCount = (entry) => rowView(entry).total;
11434
+ const rowEnabledCount = (entry) => rowView(entry).enabled;
10975
11435
  const totalAccounts = entries.reduce((sum, entry) => sum + rowAccountCount(entry), 0);
10976
11436
  const liveAccounts = entries.reduce((sum, entry) => sum + rowEnabledCount(entry), 0);
10977
- const totalCredits = entries.reduce((sum, entry) => {
11437
+ const creditTotalOf = (entry) => {
10978
11438
  const credits = entry.channel.credits;
10979
- if (credits === void 0 || credits.unit !== void 0 || credits.quota === true) return sum;
10980
- const value = balancesTotal(entry.balances);
11439
+ if (credits !== void 0 && (credits.unit !== void 0 || credits.quota === true)) return void 0;
11440
+ const view = rowView(entry);
11441
+ if (view.source.kind === "pool") return view.balance.measured === 0 ? void 0 : view.balance.known;
11442
+ if (credits === void 0) return void 0;
11443
+ return balancesTotal(entry.balances);
11444
+ };
11445
+ const totalCredits = entries.reduce((sum, entry) => {
11446
+ const value = creditTotalOf(entry);
10981
11447
  return value === void 0 ? sum : sum + value;
10982
11448
  }, 0);
10983
- const anyCredits = entries.some((entry) => entry.channel.credits !== void 0 && entry.channel.credits.unit === void 0 && entry.channel.credits.quota !== true && balancesTotal(entry.balances) !== void 0);
11449
+ const anyCredits = entries.some((entry) => creditTotalOf(entry) !== void 0);
10984
11450
  const bound = entries.filter((entry) => rowAccountCount(entry) > 0);
10985
11451
  const unbound = entries.filter((entry) => rowAccountCount(entry) === 0);
10986
11452
  const channelRow = (entry, isBound) => {
@@ -11118,31 +11584,53 @@ window.__ModuleLoader__.load({
11118
11584
  })] });
11119
11585
  const { channel, accounts, models, facts, balances, statuses, status } = chosenEntry;
11120
11586
  const enabledIds = enabledFor(channel.id, models);
11121
- const isBusy = busy.has(channel.id);
11587
+ const isBusy = busy.has(channel.id) || laneOf(channel.id)?.batchBusy === true;
11122
11588
  const unit = creditUnitLabel(channel, t);
11123
- const chosenBalanceTotal = channel.credits === void 0 ? void 0 : balancesTotal(balances);
11124
- const chosenCredit = chosenEntry.balancePending && chosenBalanceTotal === void 0 ? t?.("channelpool.balanceLoading") ?? "…" : chosenBalanceTotal === void 0 ? "—" : amount(chosenBalanceTotal);
11125
11589
  const modelsEnabled = models.filter((model) => enabledIds.has(model.id)).length;
11126
11590
  const statusOf = (accountId) => statuses.find((row) => row.accountId === accountId);
11127
11591
  const balanceOf = (accountId) => balances.find((row) => row.accountId === accountId);
11128
11592
  const enabledAccounts = accounts.filter((account) => account.enabled !== false);
11129
11593
  const lane = laneOf(channel.id);
11594
+ const view = buildPageView({
11595
+ channel,
11596
+ laneAccounts: lane?.accounts,
11597
+ pack: {
11598
+ accounts,
11599
+ balances: balances.map((row) => ({
11600
+ accountId: row.accountId,
11601
+ balance: balanceAmount(row.balance),
11602
+ error: row.error
11603
+ })),
11604
+ statuses,
11605
+ statusError: chosenEntry.statusError
11606
+ },
11607
+ packError: chosenEntry.balanceError,
11608
+ state: "ready"
11609
+ });
11130
11610
  const poolExpiry = (iso) => {
11131
11611
  if (iso === void 0) return void 0;
11132
11612
  const at = Date.parse(iso);
11133
11613
  return Number.isFinite(at) ? expiryText(at, t) : void 0;
11134
11614
  };
11135
- const laneEnabled = lane === void 0 ? void 0 : lane.accounts.filter((account) => account.disabled !== true);
11136
- const shownAccounts = lane?.accounts.length ?? accounts.length;
11137
- const shownEnabled = laneEnabled?.length ?? enabledAccounts.length;
11138
- const checkedInToday = laneEnabled === void 0 ? enabledAccounts.filter((account) => statusOf(account.id)?.todayCheckedIn === true).length : laneEnabled.filter((account) => account.checkin?.todayCheckedIn === true).length;
11139
- const allClaimedToday = shownEnabled > 0 && checkedInToday === shownEnabled;
11615
+ lane === void 0 || lane.accounts.filter((account) => account.disabled !== true);
11616
+ const shownAccounts = view.total;
11617
+ const shownEnabled = view.enabled;
11618
+ const showCredit = channel.credits === void 0 ? view.source.kind === "pool" && view.balance.measured > 0 : true;
11619
+ const balanceLabel = (() => {
11620
+ const shown = balanceDisplay(view.balance);
11621
+ if (shown.kind === "unknown") return view.state === "loading" ? t?.("channelpool.balanceLoading") ?? "…" : "—";
11622
+ if (shown.kind === "complete") return amount(shown.known);
11623
+ return amount(shown.known);
11624
+ })();
11625
+ const balanceCoverage = view.balance.complete || view.balance.measured === 0 ? void 0 : `${String(view.balance.measured)}/${String(view.balance.total)}`;
11626
+ const checkedInToday = view.checkin.checked;
11627
+ const allClaimedToday = view.checkin.allDone;
11140
11628
  const claimedToday = checkedInToday;
11141
11629
  const canClaim = channel.credits?.claim === true || OWN_CHECKIN_CHANNELS[channel.id] !== void 0;
11142
11630
  const query = queryFor(channel.id);
11143
11631
  const visibleModels = modelsMatching(chosenEntry, query);
11144
11632
  const mode = modeOf(channel.id);
11145
- const showAutomation = canClaim && onAutoClaim !== void 0;
11633
+ const showAutomation = channel.ownedByPool === true && poolRegionOf(channel.id) === "cn" && onAutoClaim !== void 0;
11146
11634
  const isMarvis = channel.id === "marvis";
11147
11635
  const quotaOf = (accountId) => marvisQuotas?.find((row) => row.openid === accountId);
11148
11636
  const marvisRows = accounts.map((account) => quotaOf(account.id)).filter((row) => row !== void 0 && row.error === void 0);
@@ -11165,7 +11653,29 @@ window.__ModuleLoader__.load({
11165
11653
  }
11166
11654
  };
11167
11655
  const claimAllFor = async (provider) => {
11168
- if (OWN_CHECKIN_CHANNELS[provider] === void 0) {
11656
+ const lane = laneOf(provider);
11657
+ const route = claimRouteFor({
11658
+ hasPoolLane: lane?.actions !== void 0,
11659
+ hasOwnCheckinRoute: OWN_CHECKIN_CHANNELS[provider] !== void 0
11660
+ });
11661
+ if (route === "pool" && lane?.actions !== void 0) {
11662
+ markBusy(provider, true);
11663
+ try {
11664
+ const report = await lane.actions.claimAll();
11665
+ if (!mountedRef.current) return;
11666
+ const summary = summarizeBatch(report, {
11667
+ claimed: (n) => `已领取 ${String(n)} 个账号`,
11668
+ failed: (n) => `${String(n)} 个失败`
11669
+ });
11670
+ const detail = [...report.results.filter((row) => row.outcome === "failed"), ...report.skipped].map((row) => `${row.label}:${row.error ?? "失败"}`).join(";");
11671
+ setNotice(detail === "" ? summary.text : `${summary.text}(${detail})`);
11672
+ await refreshBalances(provider, true);
11673
+ } finally {
11674
+ if (mountedRef.current) markBusy(provider, false);
11675
+ }
11676
+ return;
11677
+ }
11678
+ if (route === "pack") {
11169
11679
  await claim(provider);
11170
11680
  return;
11171
11681
  }
@@ -11175,11 +11685,28 @@ window.__ModuleLoader__.load({
11175
11685
  if (!mountedRef.current) return;
11176
11686
  if (said !== void 0) setNotice(said);
11177
11687
  await refreshBalances(provider, true);
11688
+ await refreshStatuses(provider);
11178
11689
  } finally {
11179
11690
  if (mountedRef.current) markBusy(provider, false);
11180
11691
  }
11181
11692
  };
11182
11693
  const recheck = async (provider) => {
11694
+ const lane = laneOf(provider);
11695
+ if (lane?.actions !== void 0) {
11696
+ markBusy(provider, true);
11697
+ try {
11698
+ const outcome = await lane.actions.rescan();
11699
+ const region = poolRegionOf(channel.id);
11700
+ const here = region === void 0 ? void 0 : outcome.byRegion[region];
11701
+ if (mountedRef.current) setNotice(here === void 0 ? `已重新检测,全池 ${String(outcome.total)} 个账号(本区数量待刷新)` : `已重新检测,本区 ${String(here)} 个账号(全池 ${String(outcome.total)} 个)`);
11702
+ await refreshBalances(provider, true);
11703
+ } catch (cause) {
11704
+ if (mountedRef.current) setNotice(`重新检测失败:${cause instanceof Error ? cause.message : String(cause)}`);
11705
+ } finally {
11706
+ if (mountedRef.current) markBusy(provider, false);
11707
+ }
11708
+ return;
11709
+ }
11183
11710
  invalidatePoolSnapshot();
11184
11711
  setEnabled(new Map());
11185
11712
  await load();
@@ -11417,17 +11944,24 @@ window.__ModuleLoader__.load({
11417
11944
  ]
11418
11945
  }) : (0, react_jsx_runtime.jsxs)("div", {
11419
11946
  className: "kpis",
11420
- style: { gridTemplateColumns: `repeat(${channel.credits === void 0 ? "2" : "3"},minmax(0,1fr))` },
11947
+ style: { gridTemplateColumns: `repeat(${showCredit ? "3" : "2"},minmax(0,1fr))` },
11421
11948
  children: [
11422
11949
  (0, react_jsx_runtime.jsxs)("div", {
11423
11950
  className: "kpi",
11424
- children: [(0, react_jsx_runtime.jsx)("span", {
11425
- className: "kpi-k",
11426
- children: t?.("channelpool.statAccounts") ?? "账号"
11427
- }), (0, react_jsx_runtime.jsx)("span", {
11428
- className: "kpi-v num",
11429
- children: String(shownEnabled)
11430
- })]
11951
+ children: [
11952
+ (0, react_jsx_runtime.jsx)("span", {
11953
+ className: "kpi-k",
11954
+ children: t?.("channelpool.statAccounts") ?? "账号"
11955
+ }),
11956
+ (0, react_jsx_runtime.jsx)("span", {
11957
+ className: "kpi-v num",
11958
+ children: String(shownAccounts)
11959
+ }),
11960
+ shownAccounts === shownEnabled ? null : (0, react_jsx_runtime.jsx)("span", {
11961
+ className: "kpi-sub",
11962
+ children: `${String(shownEnabled)} ${t?.("channelpool.statEnabled") ?? "启用"}`
11963
+ })
11964
+ ]
11431
11965
  }),
11432
11966
  (0, react_jsx_runtime.jsxs)("div", {
11433
11967
  className: "kpi",
@@ -11442,19 +11976,26 @@ window.__ModuleLoader__.load({
11442
11976
  })]
11443
11977
  })]
11444
11978
  }),
11445
- channel.credits === void 0 ? null : (0, react_jsx_runtime.jsxs)("div", {
11979
+ showCredit ? (0, react_jsx_runtime.jsxs)("div", {
11446
11980
  className: "kpi",
11447
- children: [(0, react_jsx_runtime.jsx)("span", {
11448
- className: "kpi-k",
11449
- children: t?.("channelpool.statCredit") ?? "剩余积分"
11450
- }), (0, react_jsx_runtime.jsxs)("span", {
11451
- className: "kpi-v num",
11452
- children: [chosenCredit, (0, react_jsx_runtime.jsx)("span", {
11453
- className: "kpi-u",
11454
- children: unit
11455
- })]
11456
- })]
11457
- })
11981
+ children: [
11982
+ (0, react_jsx_runtime.jsx)("span", {
11983
+ className: "kpi-k",
11984
+ children: t?.("channelpool.statCredit") ?? "剩余积分"
11985
+ }),
11986
+ (0, react_jsx_runtime.jsxs)("span", {
11987
+ className: "kpi-v num",
11988
+ children: [balanceLabel, (0, react_jsx_runtime.jsx)("span", {
11989
+ className: "kpi-u",
11990
+ children: unit
11991
+ })]
11992
+ }),
11993
+ balanceCoverage === void 0 ? null : (0, react_jsx_runtime.jsx)("span", {
11994
+ className: "kpi-sub",
11995
+ children: `${t?.("channelpool.knownOnly") ?? "已知"} ${balanceCoverage}`
11996
+ })
11997
+ ]
11998
+ }) : null
11458
11999
  ]
11459
12000
  }),
11460
12001
  isMarvis ? null : (0, react_jsx_runtime.jsxs)("div", {
@@ -11488,7 +12029,7 @@ window.__ModuleLoader__.load({
11488
12029
  children: [
11489
12030
  (0, react_jsx_runtime.jsx)("span", {
11490
12031
  className: "policy-k",
11491
- children: t?.("channelpool.autoClaim") ?? "积分自动化"
12032
+ children: t?.("channelpool.poolAutomation") ?? "WorkBuddy 账号池自动化"
11492
12033
  }),
11493
12034
  (0, react_jsx_runtime.jsxs)("div", {
11494
12035
  className: "policy-v",
@@ -11498,7 +12039,7 @@ window.__ModuleLoader__.load({
11498
12039
  role: "switch",
11499
12040
  className: "sw",
11500
12041
  "aria-checked": autoClaim === true,
11501
- "aria-label": t?.("channelpool.autoClaim") ?? "积分自动化",
12042
+ "aria-label": t?.("channelpool.poolAutomation") ?? "WorkBuddy 账号池自动化",
11502
12043
  disabled: autoClaimBusy === true,
11503
12044
  onClick: () => {
11504
12045
  onAutoClaim?.(autoClaim !== true);
@@ -11519,7 +12060,7 @@ window.__ModuleLoader__.load({
11519
12060
  }),
11520
12061
  (0, react_jsx_runtime.jsx)("span", {
11521
12062
  className: "policy-hint",
11522
- children: t?.("channelpool.autoClaimHint") ?? "开着就会在后台领每天的积分,不用手动点。"
12063
+ children: t?.("channelpool.poolAutomationHint") ?? "只管 WorkBuddy 账号池:签到覆盖国内与国际,任务、活动、连续奖励、出行与补偿只跑国内。其他渠道的自动领取由各自的渠道卡控制。"
11523
12064
  }),
11524
12065
  autoClaimReport === void 0 ? null : (0, react_jsx_runtime.jsx)("span", {
11525
12066
  className: "sum-sub",
@@ -11853,9 +12394,10 @@ window.__ModuleLoader__.load({
11853
12394
  }),
11854
12395
  (0, react_jsx_runtime.jsx)("button", {
11855
12396
  type: "button",
11856
- className: "tiny",
11857
- disabled: busy || account.preferred,
11858
- title: t?.("channelpool.preferHint") ?? "优先用这个账号接下一次请求",
12397
+ className: account.preferred ? "tiny is-on" : "tiny",
12398
+ "aria-pressed": account.preferred === true,
12399
+ disabled: busy,
12400
+ title: account.preferred ? t?.("row.accountPreferClearHint") ?? "取消首选,交回按使用方式选号" : t?.("channelpool.preferHint") ?? "优先用这个账号接下一次请求",
11859
12401
  onClick: () => {
11860
12402
  lane.onPrefer(account.preferred ? null : account.id);
11861
12403
  },
@@ -11880,6 +12422,42 @@ window.__ModuleLoader__.load({
11880
12422
  }, account.id);
11881
12423
  })
11882
12424
  }),
12425
+ lane?.ignored === void 0 || lane.ignored.length === 0 ? null : (0, react_jsx_runtime.jsxs)("div", {
12426
+ className: "sec",
12427
+ children: [(0, react_jsx_runtime.jsxs)("div", {
12428
+ className: "sec-head",
12429
+ children: [(0, react_jsx_runtime.jsx)("span", {
12430
+ className: "sec-title",
12431
+ children: t?.("row.ignoredTitle") ?? "已移出的账号"
12432
+ }), (0, react_jsx_runtime.jsx)("span", {
12433
+ className: "sec-n num",
12434
+ children: String(lane.ignored.length)
12435
+ })]
12436
+ }), lane.ignored.map((entry) => (0, react_jsx_runtime.jsxs)("div", {
12437
+ className: "row",
12438
+ children: [
12439
+ (0, react_jsx_runtime.jsx)("span", {
12440
+ className: "ch-title",
12441
+ title: entry.id,
12442
+ children: entry.label
12443
+ }),
12444
+ (0, react_jsx_runtime.jsx)("span", {
12445
+ className: "hint",
12446
+ children: t?.("row.ignoredSummary", { count: 1 }) ?? "这个账号已不在池中"
12447
+ }),
12448
+ (0, react_jsx_runtime.jsx)("button", {
12449
+ type: "button",
12450
+ className: "tiny",
12451
+ disabled: isBusy || lane.busyId === entry.id,
12452
+ title: t?.("row.ignoredRestoreHint") ?? "把这个账号放回池子",
12453
+ onClick: () => {
12454
+ lane.onRestore?.(entry);
12455
+ },
12456
+ children: t?.("row.ignoredRestore") ?? "恢复"
12457
+ })
12458
+ ]
12459
+ }, entry.id))]
12460
+ }),
11883
12461
  lane !== void 0 ? null : accounts.length === 0 ? (0, react_jsx_runtime.jsx)("p", {
11884
12462
  className: "hint",
11885
12463
  children: t?.("channelpool.accountsEmpty") ?? "这个渠道还没有登录的账号。"
@@ -11991,7 +12569,12 @@ window.__ModuleLoader__.load({
11991
12569
  children: [(0, react_jsx_runtime.jsx)("dt", { children: t?.("channelpool.todayClaimed") ?? "今日签到" }), checkin?.todayCheckedIn === true ? (0, react_jsx_runtime.jsxs)("dd", {
11992
12570
  style: { color: "var(--accent)" },
11993
12571
  children: ["已领", typeof checkin.todayCredit === "number" ? ` +${amount(checkin.todayCredit)}` : ""]
11994
- }) : (0, react_jsx_runtime.jsx)("dd", { children: t?.("channelpool.notClaimed") ?? "未领" })]
12572
+ }) : checkin?.todayCheckedIn === false ? (0, react_jsx_runtime.jsx)("dd", { children: t?.("channelpool.notClaimed") ?? "未领" }) : (0, react_jsx_runtime.jsx)("dd", {
12573
+ "data-tone": chosenEntry.statusError === void 0 ? void 0 : "err",
12574
+ title: chosenEntry.statusError,
12575
+ style: chosenEntry.statusError === void 0 ? { color: "var(--faint)" } : { color: "var(--warn)" },
12576
+ children: chosenEntry.statusError === void 0 ? t?.("channelpool.checkinUnknown") ?? "状态未知" : t?.("channelpool.checkinUnreadable") ?? "状态读不到"
12577
+ })]
11995
12578
  })]
11996
12579
  }),
11997
12580
  (0, react_jsx_runtime.jsxs)("div", {
@@ -15353,6 +15936,59 @@ window.__ModuleLoader__.load({
15353
15936
  })
15354
15937
  });
15355
15938
  //#endregion
15939
+ //#region src/client/ignored-restore.ts
15940
+ function ignoredFrom(status) {
15941
+ if (status === null || typeof status !== "object") return [];
15942
+ const list = status.ignored;
15943
+ if (!Array.isArray(list)) return [];
15944
+ const rows = [];
15945
+ for (const raw of list) {
15946
+ if (raw === null || typeof raw !== "object") continue;
15947
+ const id = raw.id;
15948
+ if (typeof id !== "string" || id === "") continue;
15949
+ const label = raw.label;
15950
+ const ignoredAt = raw.ignoredAt;
15951
+ rows.push({
15952
+ id,
15953
+ label: typeof label === "string" && label !== "" ? label : id,
15954
+ ignoredAt: typeof ignoredAt === "string" ? ignoredAt : ""
15955
+ });
15956
+ }
15957
+ return rows;
15958
+ }
15959
+ function classifyRestore(input) {
15960
+ const { label, response, present } = input;
15961
+ if (!response.ok) return {
15962
+ kind: "failed",
15963
+ label,
15964
+ error: response.error ?? "恢复请求被拒绝"
15965
+ };
15966
+ if (present === void 0) return {
15967
+ kind: "scanFailed",
15968
+ label,
15969
+ error: input.refreshError ?? "状态回读失败"
15970
+ };
15971
+ if (!present) return {
15972
+ kind: "missingCredential",
15973
+ label
15974
+ };
15975
+ return {
15976
+ kind: "restored",
15977
+ label
15978
+ };
15979
+ }
15980
+ function restoreMessage(outcome) {
15981
+ switch (outcome.kind) {
15982
+ case "restored": return `已把 ${outcome.label} 放回池子`;
15983
+ case "missingCredential": return `已解除对 ${outcome.label} 的忽略,但没有找到它的凭据 —— 请重新登录这个账号,或点「重新检测」确认本机还有哪些账号`;
15984
+ case "scanFailed": return `${outcome.label} 的忽略已解除,但状态没能读回来(${outcome.error})。刷新后确认它是否已经回到池子`;
15985
+ case "failed": return `解除 ${outcome.label} 的忽略失败:${outcome.error}`;
15986
+ }
15987
+ }
15988
+ function restoreSucceeded(outcome) {
15989
+ return outcome.kind === "restored";
15990
+ }
15991
+ //#endregion
15356
15992
  //#region src/client/backup-crypto.ts
15357
15993
  const ENCRYPTED_FORMAT = "dsh-xdpool/backup-encrypted";
15358
15994
  const ITERATIONS = 31e4;
@@ -16304,6 +16940,8 @@ window.__ModuleLoader__.load({
16304
16940
  const [reserveBusy, setReserveBusy] = (0, react.useState)(void 0);
16305
16941
  const [flash, setFlash] = (0, react.useState)(void 0);
16306
16942
  const [checkinBusyId, setCheckinBusyId] = (0, react.useState)(void 0);
16943
+ const claimedIds = (0, react.useRef)(new Set());
16944
+ const [batchRegion, setBatchRegion] = (0, react.useState)(void 0);
16307
16945
  const [accountBusyId, setAccountBusyId] = (0, react.useState)(void 0);
16308
16946
  const [usage, setUsage] = (0, react.useState)(void 0);
16309
16947
  const [draftByRegion, setDraftByRegion] = (0, react.useState)({});
@@ -16315,6 +16953,7 @@ window.__ModuleLoader__.load({
16315
16953
  mounted.current = false;
16316
16954
  };
16317
16955
  }, []);
16956
+ const regionGate = (0, react.useRef)(createRegionGate());
16318
16957
  const [probes, setProbes] = (0, react.useState)({});
16319
16958
  const [probingModel, setProbingModel] = (0, react.useState)(void 0);
16320
16959
  (0, react.useCallback)(async (provider, model) => {
@@ -16359,6 +16998,7 @@ window.__ModuleLoader__.load({
16359
16998
  }
16360
16999
  }, [probingModel]);
16361
17000
  const refresh = (0, react.useCallback)(async (region, signal) => {
17001
+ const ticket = regionGate.current.issue(region);
16362
17002
  try {
16363
17003
  const response = await fetch(`${POOL_STATUS_PATH}?region=${region}`, {
16364
17004
  headers: { accept: "application/json" },
@@ -16367,7 +17007,7 @@ window.__ModuleLoader__.load({
16367
17007
  });
16368
17008
  const value = await response.json().catch(() => void 0);
16369
17009
  if (!response.ok) throw new Error(`HTTP ${response.status}`);
16370
- if (mounted.current && signal?.aborted !== true) {
17010
+ if (mounted.current && signal?.aborted !== true && regionGate.current.accept(region, ticket)) {
16371
17011
  setStatusByRegion((prev) => ({
16372
17012
  ...prev,
16373
17013
  [region]: value
@@ -16435,9 +17075,8 @@ window.__ModuleLoader__.load({
16435
17075
  controller.abort();
16436
17076
  };
16437
17077
  }, [refreshUsage]);
16438
- const claimCheckin = async (region, accountId) => {
16439
- setCheckinBusyId(accountId);
16440
- setFlash(void 0);
17078
+ const claimOne = (0, react.useCallback)(async (region, accountId) => {
17079
+ const label = statusByRegion[region]?.accounts.find((account) => account.id === accountId)?.label ?? accountId;
16441
17080
  try {
16442
17081
  const response = await fetch(POOL_CHECKIN_PATH, {
16443
17082
  method: "POST",
@@ -16448,18 +17087,95 @@ window.__ModuleLoader__.load({
16448
17087
  credentials: "same-origin",
16449
17088
  body: JSON.stringify({ accountId })
16450
17089
  });
16451
- const body = await response.json().catch(() => void 0);
16452
- if (!response.ok) throw new Error(body?.error ?? `HTTP ${response.status}`);
17090
+ return {
17091
+ accountId,
17092
+ label,
17093
+ ...outcomeFromClaim(await response.json().catch(() => void 0), response.ok)
17094
+ };
17095
+ } catch (cause) {
17096
+ return {
17097
+ accountId,
17098
+ label,
17099
+ outcome: "failed",
17100
+ error: cause instanceof Error ? cause.message : String(cause)
17101
+ };
17102
+ }
17103
+ }, [statusByRegion]);
17104
+ const claimCheckin = async (region, accountId) => {
17105
+ setCheckinBusyId(accountId);
17106
+ setFlash(void 0);
17107
+ try {
17108
+ const result = await claimOne(region, accountId);
17109
+ if (result.outcome === "failed") throw new Error(result.error ?? "签到失败");
16453
17110
  await refresh(region);
16454
- const credit = body?.claim?.credit ?? 0;
16455
- if (mounted.current) setFlash(t?.("row.checkinClaimedReward", { credit: formatNumber(credit) }) ?? `Claimed +${formatNumber(credit)} credits`);
17111
+ if (!mounted.current) return;
17112
+ if (result.outcome === "alreadyClaimed") {
17113
+ claimedIds.current.add(accountId);
17114
+ setFlash(t?.("row.checkinAlready") ?? "今天已经签到过了");
17115
+ return;
17116
+ }
17117
+ claimedIds.current.add(accountId);
17118
+ const credit = result.credit ?? 0;
17119
+ setFlash(t?.("row.checkinClaimedReward", { credit: formatNumber(credit) }) ?? `Claimed +${formatNumber(credit)} credits`);
16456
17120
  } catch (cause) {
16457
17121
  if (mounted.current) setError(cause instanceof Error ? cause.message : String(cause));
16458
17122
  } finally {
16459
17123
  if (mounted.current) setCheckinBusyId(void 0);
16460
17124
  }
16461
17125
  };
17126
+ const rowsOf = (0, react.useCallback)((region) => {
17127
+ const here = statusByRegion[region];
17128
+ if (here === void 0) return [];
17129
+ return buildPoolView({
17130
+ channelId: REGION_CHANNEL_BY_REGION[region],
17131
+ region,
17132
+ status: here,
17133
+ state: "ready"
17134
+ }).rows;
17135
+ }, [statusByRegion]);
17136
+ const refreshRegion = (0, react.useCallback)(async (region) => {
17137
+ return await refresh(region) === void 0 ? {
17138
+ ok: false,
17139
+ error: "状态回读失败"
17140
+ } : { ok: true };
17141
+ }, [refresh]);
17142
+ const runClaimAll = async (region) => {
17143
+ setBatchRegion(region);
17144
+ try {
17145
+ const report = await claimAll({
17146
+ rows: rowsOf(region),
17147
+ skipIds: claimedIds.current,
17148
+ claim: (accountId) => claimOne(region, accountId),
17149
+ recheck: (accountId) => recheckAccount(region, accountId),
17150
+ refresh: () => refreshRegion(region)
17151
+ });
17152
+ for (const result of report.results) if (result.outcome === "claimed" || result.outcome === "alreadyClaimed") claimedIds.current.add(result.accountId);
17153
+ if (report.refresh.ok) claimedIds.current.clear();
17154
+ return report;
17155
+ } finally {
17156
+ if (mounted.current) setBatchRegion(void 0);
17157
+ }
17158
+ };
17159
+ const recheckAccount = async (region, accountId) => {
17160
+ if (await refresh(region) === void 0) return void 0;
17161
+ return rowsOf(region).find((row) => row.id === accountId);
17162
+ };
17163
+ const rescanAll = async () => rescanRegions({
17164
+ rescan: async () => {
17165
+ const response = await fetch(POOL_RESCAN_PATH, {
17166
+ method: "POST",
17167
+ headers: { accept: "application/json" },
17168
+ credentials: "same-origin"
17169
+ });
17170
+ const body = await response.json();
17171
+ if (!response.ok) throw new Error(body.error ?? `HTTP ${response.status}`);
17172
+ return body.accounts ?? 0;
17173
+ },
17174
+ refresh: async (region) => (await refresh(region))?.accounts.length,
17175
+ regions: REGION_CARDS
17176
+ });
16462
17177
  const statusOf = (region) => statusByRegion[region];
17178
+ const ignoredOf = (region) => ignoredFrom(statusOf(region));
16463
17179
  const toggleAccountDisabled = async (region, accountId, disabled) => {
16464
17180
  const write = settingsScope?.set;
16465
17181
  if (write === void 0) {
@@ -16504,6 +17220,62 @@ window.__ModuleLoader__.load({
16504
17220
  if (mounted.current) setAccountBusyId(void 0);
16505
17221
  }
16506
17222
  };
17223
+ const restoreIgnored = async (entry) => {
17224
+ setAccountBusyId(entry.id);
17225
+ setFlash(void 0);
17226
+ try {
17227
+ let response;
17228
+ try {
17229
+ const answer = await fetch(POOL_ACCOUNT_IGNORE_PATH, {
17230
+ method: "POST",
17231
+ headers: { "Content-Type": "application/json" },
17232
+ body: JSON.stringify({
17233
+ accountId: entry.id,
17234
+ ignored: false
17235
+ })
17236
+ });
17237
+ if (!answer.ok) response = {
17238
+ ok: false,
17239
+ error: (await answer.json().catch(() => ({}))).error ?? `HTTP ${answer.status}`
17240
+ };
17241
+ else response = { ok: true };
17242
+ } catch (cause) {
17243
+ response = {
17244
+ ok: false,
17245
+ error: cause instanceof Error ? cause.message : String(cause)
17246
+ };
17247
+ }
17248
+ if (!response.ok) return {
17249
+ kind: "failed",
17250
+ label: entry.label,
17251
+ error: response.error ?? "恢复请求被拒绝"
17252
+ };
17253
+ const refreshed = (await Promise.all(REGION_CARDS.map(async (region) => ({
17254
+ ok: true,
17255
+ status: await refresh(region)
17256
+ })))).filter((read) => read.status !== void 0);
17257
+ if (refreshed.length === 0) return {
17258
+ kind: "scanFailed",
17259
+ label: entry.label,
17260
+ error: "两个区的状态都没能读回来"
17261
+ };
17262
+ const back = refreshed.some((read) => (read.status?.accounts ?? []).some((account) => account.id === entry.id));
17263
+ return classifyRestore({
17264
+ label: entry.label,
17265
+ response,
17266
+ present: back
17267
+ });
17268
+ } finally {
17269
+ if (mounted.current) setAccountBusyId(void 0);
17270
+ }
17271
+ };
17272
+ const restoreAccount = async (entry) => {
17273
+ const outcome = await restoreIgnored(entry);
17274
+ if (!mounted.current) return;
17275
+ const message = restoreMessage(outcome);
17276
+ if (restoreSucceeded(outcome)) setFlash(message);
17277
+ else setError(message);
17278
+ };
16507
17279
  const setPreferredAccount = async (region, accountId) => {
16508
17280
  setAccountBusyId(accountId ?? "none");
16509
17281
  setFlash(void 0);
@@ -16619,6 +17391,7 @@ window.__ModuleLoader__.load({
16619
17391
  activeAccountId: here?.activeAccountId,
16620
17392
  claimingId: checkinBusyId,
16621
17393
  busyId: accountBusyId,
17394
+ batchBusy: batchRegion === region,
16622
17395
  onClaim: (accountId) => {
16623
17396
  claimCheckin(region, accountId);
16624
17397
  },
@@ -16630,6 +17403,18 @@ window.__ModuleLoader__.load({
16630
17403
  },
16631
17404
  onIgnore: (accountId) => {
16632
17405
  setAccountIgnored(region, accountId, true);
17406
+ },
17407
+ ignored: ignoredOf(region),
17408
+ onRestore: (entry) => {
17409
+ restoreAccount(entry);
17410
+ },
17411
+ actions: {
17412
+ claim: (accountId) => claimOne(region, accountId),
17413
+ claimAll: () => runClaimAll(region),
17414
+ recheckAccount: (accountId) => recheckAccount(region, accountId),
17415
+ rescan: () => rescanAll(),
17416
+ rows: () => rowsOf(region),
17417
+ refresh: () => refreshRegion(region)
16633
17418
  }
16634
17419
  };
16635
17420
  };
@@ -19629,7 +20414,10 @@ label.sw:has(input:disabled) { opacity: .5; cursor: not-allowed }
19629
20414
  .app[data-w="narrow"] .ls{padding:3px var(--s2)}
19630
20415
  .app[data-w="narrow"] .ls-v{font-size:13px}
19631
20416
  .app[data-w="narrow"] .list-scroll{display:flex;flex-direction:row;align-items:center;gap:6px;padding:0 var(--s3) var(--s2);overflow-x:auto;overflow-y:hidden;scrollbar-width:thin}
19632
- .app[data-w="narrow"] .list-scroll>div{display:contents}
20417
+ /* 横滑条里要扁平化的是真正的包裹层;分组标题本身就是 div,必须排除,否则
20418
+ .list-scroll>div 的权重(0,3,1)压过下面 .list-group 的 display:none(0,3,0),
20419
+ 标题反而被拆成一个个 flex 项,"已登录"竖排成一列单字(390 实测到)。 */
20420
+ .app[data-w="narrow"] .list-scroll>div:not(.list-group){display:contents}
19633
20421
  .app[data-w="narrow"] .list-group{display:none}
19634
20422
  .app[data-w="narrow"] .ch{flex:0 0 auto;width:auto;max-width:180px;padding:4px 10px;min-height:28px;border:1px solid var(--line-2);border-radius:var(--r-pill);display:inline-flex;align-items:center;gap:6px}
19635
20423
  .app[data-w="narrow"] .ch[aria-current="true"]{border-color:transparent;background:var(--accent);color:var(--accent-ink)}
@@ -19728,7 +20516,8 @@ label.sw:has(input:disabled) { opacity: .5; cursor: not-allowed }
19728
20516
  .app[data-w="phone"] .list{grid-row:1;grid-column:1;min-width:0}
19729
20517
  .app[data-w="phone"] .main{grid-row:2;grid-column:1}
19730
20518
  .app-wide[data-w="phone"] .main{grid-row:1}
19731
- .app[data-w="phone"] .list-scroll>div{display:contents}
20519
+ /* 理由同 narrow:分组标题也是 div,那个后代选择器会把它的 display:none 压掉。 */
20520
+ .app[data-w="phone"] .list-scroll>div:not(.list-group){display:contents}
19732
20521
  .app[data-w="phone"] .list-stats{flex:0 0 auto;min-width:180px}
19733
20522
  .app[data-w="phone"] .rail-item>span.sw{display:none}
19734
20523
  .app[data-w="phone"] .sec-actions{margin-left:0;width:100%}
@@ -19997,6 +20786,8 @@ label.sw:has(input:disabled) { opacity: .5; cursor: not-allowed }
19997
20786
  "channelpool.statAccounts": "accounts",
19998
20787
  "channelpool.statModels": "models",
19999
20788
  "channelpool.statCredit": "credit left",
20789
+ "channelpool.statEnabled": "enabled",
20790
+ "channelpool.knownOnly": "known",
20000
20791
  "channelpool.autoOn": "Turn automation on",
20001
20792
  "channelpool.autoOff": "Turn automation off",
20002
20793
  "channelpool.claimCredits": "Claim credits",
@@ -20073,6 +20864,9 @@ label.sw:has(input:disabled) { opacity: .5; cursor: not-allowed }
20073
20864
  "row.checkinDaily": "+{credit} credits/day",
20074
20865
  "row.checkinStreakBonus": "day {days} bonus +{credit}",
20075
20866
  "row.checkinClaimedReward": "Claimed +{credit} credits",
20867
+ "row.checkinAlready": "Already checked in today",
20868
+ "row.checkinBatchClaimed": "Claimed for {count} accounts",
20869
+ "row.checkinBatchFailed": "{count} failed",
20076
20870
  "row.checkinError": "Check-in failed: {message}",
20077
20871
  "row.checkinUnavailable": "check-in unavailable",
20078
20872
  "row.checkinAllHint": "Collect every account’s daily reward here — no need to switch accounts first.",
@@ -20643,6 +21437,10 @@ label.sw:has(input:disabled) { opacity: .5; cursor: not-allowed }
20643
21437
  "channelpool.autoClaimRun": "Run now",
20644
21438
  "channelpool.autoClaimRunning": "Running…",
20645
21439
  "channelpool.autoClaimRunHint": "Run one collection pass now instead of waiting for the scheduled hour",
21440
+ "channelpool.checkinUnknown": "unknown",
21441
+ "channelpool.checkinUnreadable": "unreadable",
21442
+ "channelpool.poolAutomation": "WorkBuddy pool automation",
21443
+ "channelpool.poolAutomationHint": "Governs the WorkBuddy pool only: check-in covers both regions, while tasks, activities, streaks, travel and compensation run in CN only. Other channels have their own switch on their card.",
20646
21444
  "channelpool.autoEarned": "{credit} credits · {energy} energy · {count} task(s)",
20647
21445
  "channelpool.autoEarnedCredits": "{credit} credits",
20648
21446
  "channelpool.modePrefer": "Priority",
@@ -20722,6 +21520,8 @@ label.sw:has(input:disabled) { opacity: .5; cursor: not-allowed }
20722
21520
  "channelpool.statAccounts": "账号",
20723
21521
  "channelpool.statModels": "模型",
20724
21522
  "channelpool.statCredit": "剩余积分",
21523
+ "channelpool.statEnabled": "启用",
21524
+ "channelpool.knownOnly": "已知",
20725
21525
  "channelpool.autoOn": "开启自动化",
20726
21526
  "channelpool.autoOff": "关闭自动化",
20727
21527
  "channelpool.claimCredits": "领取积分",
@@ -20798,6 +21598,9 @@ label.sw:has(input:disabled) { opacity: .5; cursor: not-allowed }
20798
21598
  "row.checkinDaily": "每日 +{credit} 积分",
20799
21599
  "row.checkinStreakBonus": "第 {days} 天额外 +{credit}",
20800
21600
  "row.checkinClaimedReward": "已领取 +{credit} 积分",
21601
+ "row.checkinAlready": "今天已经签到过了",
21602
+ "row.checkinBatchClaimed": "已领取 {count} 个账号",
21603
+ "row.checkinBatchFailed": "{count} 个失败",
20801
21604
  "row.checkinError": "签到失败:{message}",
20802
21605
  "row.checkinUnavailable": "签到不可用",
20803
21606
  "row.checkinAllHint": "这里可以为每个账号分别领取每日签到奖励,无需先切换账号。",
@@ -21409,6 +22212,10 @@ label.sw:has(input:disabled) { opacity: .5; cursor: not-allowed }
21409
22212
  "channelpool.autoClaimRun": "立即执行",
21410
22213
  "channelpool.autoClaimRunning": "领取中…",
21411
22214
  "channelpool.autoClaimRunHint": "马上跑一轮领取,不用等到预定时间",
22215
+ "channelpool.checkinUnknown": "状态未知",
22216
+ "channelpool.checkinUnreadable": "状态读不到",
22217
+ "channelpool.poolAutomation": "WorkBuddy 账号池自动化",
22218
+ "channelpool.poolAutomationHint": "只管 WorkBuddy 账号池:签到覆盖国内与国际,任务、活动、连续奖励、出行与补偿只跑国内。其他渠道的自动领取由各自的渠道卡控制。",
21412
22219
  "channelpool.autoEarned": "{credit} 积分 · {energy} 能量 · {count} 个任务",
21413
22220
  "channelpool.autoEarnedCredits": "{credit} 积分",
21414
22221
  "channelpool.modePrefer": "优先",