poi-plugin-kca-next 1.0.3 → 1.0.5
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/dist/index.js +397 -86
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -56,8 +56,8 @@ __export(index_exports, {
|
|
|
56
56
|
scoreTemplateAgainstRoi: () => scoreTemplateAgainstRoi
|
|
57
57
|
});
|
|
58
58
|
module.exports = __toCommonJS(index_exports);
|
|
59
|
-
var
|
|
60
|
-
var
|
|
59
|
+
var import_node_fs5 = __toESM(require("fs"));
|
|
60
|
+
var import_node_path4 = __toESM(require("path"));
|
|
61
61
|
var import_react12 = __toESM(require("react"));
|
|
62
62
|
|
|
63
63
|
// src/data/coords.ts
|
|
@@ -873,7 +873,9 @@ function createDefaultSettings() {
|
|
|
873
873
|
minLevel: 0,
|
|
874
874
|
reservedDocks: 1,
|
|
875
875
|
sortOrder: "shortest",
|
|
876
|
-
batchAllFreeDocks: true
|
|
876
|
+
batchAllFreeDocks: true,
|
|
877
|
+
damageThreshold: "light",
|
|
878
|
+
avoidSortieConflict: true
|
|
877
879
|
},
|
|
878
880
|
develop: {
|
|
879
881
|
remainingCount: 0,
|
|
@@ -2681,8 +2683,8 @@ var ActionScheduler = class {
|
|
|
2681
2683
|
};
|
|
2682
2684
|
|
|
2683
2685
|
// src/core/primitives.ts
|
|
2684
|
-
function normalizeApiPath(
|
|
2685
|
-
const trimmed =
|
|
2686
|
+
function normalizeApiPath(path5) {
|
|
2687
|
+
const trimmed = path5.trim();
|
|
2686
2688
|
if (trimmed.startsWith("/kcsapi/")) return trimmed;
|
|
2687
2689
|
if (trimmed.startsWith("kcsapi/")) return `/${trimmed}`;
|
|
2688
2690
|
if (trimmed.startsWith("/api_")) return `/kcsapi${trimmed}`;
|
|
@@ -4313,42 +4315,98 @@ async function executeRepair(bridge, actions, logger, shipIds, bucketThresholdSe
|
|
|
4313
4315
|
);
|
|
4314
4316
|
return repairedCount;
|
|
4315
4317
|
}
|
|
4318
|
+
function planAutoRepair(state, settings, ctx) {
|
|
4319
|
+
const cfg = settings.repair;
|
|
4320
|
+
const avoidConflict = cfg.avoidSortieConflict !== false;
|
|
4321
|
+
const damageThreshold = cfg.damageThreshold ?? "light";
|
|
4322
|
+
const freeDocks = getFreeRepairDocks(state, settings.general.operationAdvanceSec);
|
|
4323
|
+
const effectiveReservedDocks = avoidConflict && ctx.isSortieEnabled ? Math.max(cfg.reservedDocks, 1) : cfg.reservedDocks;
|
|
4324
|
+
const usableCount = Math.max(0, freeDocks.length - effectiveReservedDocks);
|
|
4325
|
+
const excludedShipIds = /* @__PURE__ */ new Set();
|
|
4326
|
+
for (const f of Object.values(state.fleets)) {
|
|
4327
|
+
for (const sid of f.shipIds) excludedShipIds.add(sid);
|
|
4328
|
+
}
|
|
4329
|
+
if (avoidConflict && ctx.isSortieEnabled) {
|
|
4330
|
+
const activeProfile = settings.sortie.profiles.find((p) => p.id === settings.sortie.activeProfileId) ?? settings.sortie.profiles[0];
|
|
4331
|
+
if (activeProfile?.autoChangeShip) {
|
|
4332
|
+
for (const slotList of activeProfile.candidateShips) {
|
|
4333
|
+
for (const sid of slotList ?? []) {
|
|
4334
|
+
if (sid > 0) excludedShipIds.add(sid);
|
|
4335
|
+
}
|
|
4336
|
+
}
|
|
4337
|
+
}
|
|
4338
|
+
}
|
|
4339
|
+
const candidates = Object.values(state.ships).filter(
|
|
4340
|
+
(s) => s.hp < s.maxHp && matchesDamageThreshold(s, damageThreshold) && !s.isRepairing && s.level >= cfg.minLevel && !excludedShipIds.has(s.id) && !ctx.isShipReservedByKira(s.id)
|
|
4341
|
+
).sort(
|
|
4342
|
+
(a, b) => cfg.sortOrder === "shortest" ? a.repairTimeMs - b.repairTimeMs : b.repairTimeMs - a.repairTimeMs
|
|
4343
|
+
);
|
|
4344
|
+
return {
|
|
4345
|
+
usableCount,
|
|
4346
|
+
effectiveReservedDocks,
|
|
4347
|
+
freeDockCount: freeDocks.length,
|
|
4348
|
+
candidates
|
|
4349
|
+
};
|
|
4350
|
+
}
|
|
4351
|
+
var REPAIR_ERROR_BACKOFF_MS = 6e4;
|
|
4316
4352
|
var AutoRepairModule = class extends AutomationModule {
|
|
4317
|
-
constructor(runtime,
|
|
4353
|
+
constructor(runtime, hooks) {
|
|
4318
4354
|
super(runtime);
|
|
4319
|
-
this.
|
|
4355
|
+
this.hooks = hooks;
|
|
4320
4356
|
}
|
|
4321
4357
|
id = "repair";
|
|
4322
4358
|
category = "repair";
|
|
4323
4359
|
displayName = "\u81EA\u52A8\u5165\u6E20";
|
|
4360
|
+
backoffUntilMs = 0;
|
|
4361
|
+
onEnabled() {
|
|
4362
|
+
this.backoffUntilMs = 0;
|
|
4363
|
+
}
|
|
4364
|
+
/**
|
|
4365
|
+
* Returns true when AutoRepair has both spare docks (beyond sortie reserve) and eligible
|
|
4366
|
+
* damaged standby ships ready to dock at Homeport. Used by AutoSortie to yield cleanly
|
|
4367
|
+
* between sorties so both modules work side-by-side without conflict.
|
|
4368
|
+
*/
|
|
4369
|
+
needsAction() {
|
|
4370
|
+
if (!this.enabled) return false;
|
|
4371
|
+
if (Date.now() < this.backoffUntilMs) return false;
|
|
4372
|
+
const state = this.runtime.bridge.getState();
|
|
4373
|
+
if (!state.loaded || state.inSortie) return false;
|
|
4374
|
+
if (this.runtime.scheduler.isSortieClickLockActive) return false;
|
|
4375
|
+
if (this.hooks.hasHigherPriorityWork?.()) return false;
|
|
4376
|
+
const settings = this.runtime.getSettings();
|
|
4377
|
+
const plan = planAutoRepair(state, settings, {
|
|
4378
|
+
isSortieEnabled: this.runtime.isModuleEnabled("sortie"),
|
|
4379
|
+
isShipReservedByKira: this.hooks.isShipReservedByKira
|
|
4380
|
+
});
|
|
4381
|
+
return plan.usableCount > 0 && plan.candidates.length > 0;
|
|
4382
|
+
}
|
|
4324
4383
|
async tick() {
|
|
4325
4384
|
if (!this.enabled || !this.runtime.scheduler.canAcquire(this.id)) return;
|
|
4385
|
+
if (Date.now() < this.backoffUntilMs) return;
|
|
4326
4386
|
const state = this.runtime.bridge.getState();
|
|
4327
4387
|
if (!state.loaded || state.inSortie) return;
|
|
4388
|
+
if (this.runtime.scheduler.isSortieClickLockActive) return;
|
|
4389
|
+
if (this.hooks.hasHigherPriorityWork?.()) return;
|
|
4328
4390
|
const settings = this.runtime.getSettings();
|
|
4329
4391
|
const cfg = settings.repair;
|
|
4330
|
-
const
|
|
4331
|
-
|
|
4332
|
-
|
|
4333
|
-
|
|
4392
|
+
const plan = planAutoRepair(state, settings, {
|
|
4393
|
+
isSortieEnabled: this.runtime.isModuleEnabled("sortie"),
|
|
4394
|
+
isShipReservedByKira: this.hooks.isShipReservedByKira
|
|
4395
|
+
});
|
|
4396
|
+
if (plan.usableCount <= 0) {
|
|
4397
|
+
this.setStatus(
|
|
4398
|
+
`\u7B49\u5F85\u7A7A\u6E20\u4F4D (\u7A7A\u95F2 ${plan.freeDockCount} / \u4FDD\u7559 ${plan.effectiveReservedDocks})`,
|
|
4399
|
+
"idle"
|
|
4400
|
+
);
|
|
4334
4401
|
return;
|
|
4335
4402
|
}
|
|
4336
|
-
|
|
4337
|
-
|
|
4338
|
-
for (const sid of f.shipIds) inFleetIds.add(sid);
|
|
4339
|
-
}
|
|
4340
|
-
const candidates = Object.values(state.ships).filter(
|
|
4341
|
-
(s) => s.hp < s.maxHp && !s.isRepairing && s.level >= cfg.minLevel && !inFleetIds.has(s.id) && !this.isShipReservedByKira(s.id)
|
|
4342
|
-
).sort(
|
|
4343
|
-
(a, b) => cfg.sortOrder === "shortest" ? a.repairTimeMs - b.repairTimeMs : b.repairTimeMs - a.repairTimeMs
|
|
4344
|
-
);
|
|
4345
|
-
if (candidates.length === 0) {
|
|
4346
|
-
this.setStatus("\u6682\u65E0\u9700\u8981\u4FEE\u7406\u7684\u5F85\u547D\u8230\u5A18", "idle");
|
|
4403
|
+
if (plan.candidates.length === 0) {
|
|
4404
|
+
this.setStatus("\u6682\u65E0\u7B26\u5408\u635F\u4F24\u6761\u4EF6\u7684\u5F85\u547D\u8230\u5A18", "idle");
|
|
4347
4405
|
return;
|
|
4348
4406
|
}
|
|
4349
|
-
const batchSize = cfg.batchAllFreeDocks ? usableCount : 1;
|
|
4350
|
-
const shipIds = candidates.slice(0, batchSize).map((s) => s.id);
|
|
4351
|
-
await this.runLocked(async (ctx) => {
|
|
4407
|
+
const batchSize = cfg.batchAllFreeDocks ? plan.usableCount : 1;
|
|
4408
|
+
const shipIds = plan.candidates.slice(0, batchSize).map((s) => s.id);
|
|
4409
|
+
const ok = await this.runLocked(async (ctx) => {
|
|
4352
4410
|
this.setStatus(`\u6B63\u5728\u5B89\u6392\u5165\u6E20 (${shipIds.length} \u8258)`);
|
|
4353
4411
|
await executeRepair(
|
|
4354
4412
|
this.runtime.bridge,
|
|
@@ -4361,6 +4419,9 @@ var AutoRepairModule = class extends AutomationModule {
|
|
|
4361
4419
|
);
|
|
4362
4420
|
this.setStatus("\u5165\u6E20\u5B8C\u6210", "idle");
|
|
4363
4421
|
});
|
|
4422
|
+
if (!ok && this.lastError) {
|
|
4423
|
+
this.backoffUntilMs = Date.now() + REPAIR_ERROR_BACKOFF_MS;
|
|
4424
|
+
}
|
|
4364
4425
|
}
|
|
4365
4426
|
};
|
|
4366
4427
|
|
|
@@ -4959,12 +5020,12 @@ var BattleSimulator = class {
|
|
|
4959
5020
|
}
|
|
4960
5021
|
return taiha;
|
|
4961
5022
|
}
|
|
4962
|
-
processDayOrSpMidnight(
|
|
5023
|
+
processDayOrSpMidnight(path5, body) {
|
|
4963
5024
|
try {
|
|
4964
|
-
const isCombined =
|
|
4965
|
-
const isWater =
|
|
4966
|
-
const isEach =
|
|
4967
|
-
const isSpMidnight =
|
|
5025
|
+
const isCombined = path5.includes("combined_battle") && !path5.includes("/ec_battle") && !path5.includes("/ec_night_to_day");
|
|
5026
|
+
const isWater = path5.includes("battle_water");
|
|
5027
|
+
const isEach = path5.includes("each_battle") || path5.includes("ec_battle") || path5.includes("ec_night_to_day");
|
|
5028
|
+
const isSpMidnight = path5.includes("sp_midnight");
|
|
4968
5029
|
const fNow = toNumArray(body.api_f_nowhps);
|
|
4969
5030
|
const fMax = toNumArray(body.api_f_maxhps);
|
|
4970
5031
|
const eNow = toNumArray(body.api_e_nowhps);
|
|
@@ -5138,7 +5199,7 @@ var BattleSimulator = class {
|
|
|
5138
5199
|
this.state.parseError = err instanceof Error ? err.message : String(err);
|
|
5139
5200
|
}
|
|
5140
5201
|
}
|
|
5141
|
-
processMidnight(
|
|
5202
|
+
processMidnight(path5, body) {
|
|
5142
5203
|
try {
|
|
5143
5204
|
const s = this.state;
|
|
5144
5205
|
if (Array.isArray(body.api_f_nowhps)) s.fNowHps = toNumArray(body.api_f_nowhps);
|
|
@@ -5149,8 +5210,8 @@ var BattleSimulator = class {
|
|
|
5149
5210
|
if (Array.isArray(body.api_f_maxhps_combined)) s.fCombinedMaxHps = toNumArray(body.api_f_maxhps_combined);
|
|
5150
5211
|
if (Array.isArray(body.api_e_nowhps_combined)) s.eCombinedNowHps = toNumArray(body.api_e_nowhps_combined);
|
|
5151
5212
|
if (Array.isArray(body.api_e_maxhps_combined)) s.eCombinedMaxHps = toNumArray(body.api_e_maxhps_combined);
|
|
5152
|
-
const isCombinedNight =
|
|
5153
|
-
const isEcNight =
|
|
5213
|
+
const isCombinedNight = path5.includes("combined_battle/midnight_battle");
|
|
5214
|
+
const isEcNight = path5.includes("ec_midnight_battle");
|
|
5154
5215
|
const activeEnemyMain = Array.isArray(body.api_active_deck) && Number(body.api_active_deck[1]) === 2;
|
|
5155
5216
|
const eTarget = activeEnemyMain && s.eCombinedNowHps.length > 0 ? s.eCombinedNowHps : s.eNowHps;
|
|
5156
5217
|
if (body.api_friendly_battle?.api_hougeki) {
|
|
@@ -8875,6 +8936,9 @@ var AutoSortieModule = class extends AutomationModule {
|
|
|
8875
8936
|
return;
|
|
8876
8937
|
}
|
|
8877
8938
|
}
|
|
8939
|
+
if (this.hooks.repairNeedsAction?.()) {
|
|
8940
|
+
return;
|
|
8941
|
+
}
|
|
8878
8942
|
if (profile.limitType !== "none" && profile.limitRemaining <= 0) {
|
|
8879
8943
|
this.runtime.logger.success("sortie", `\u51FA\u51FB\u914D\u7F6E [${profile.name}] \u5DF2\u8FBE\u6210\u6B21\u6570/\u76EE\u6807\u9650\u5236\uFF0C\u81EA\u52A8\u505C\u6B62`);
|
|
8880
8944
|
this.setEnabled(false);
|
|
@@ -9705,17 +9769,21 @@ var KcaAssistantCoordinator = class {
|
|
|
9705
9769
|
}
|
|
9706
9770
|
);
|
|
9707
9771
|
this.organization = new AutoOrganizationModule(runtime, () => this.practice.needsAction());
|
|
9772
|
+
this.repair = new AutoRepairModule(runtime, {
|
|
9773
|
+
isShipReservedByKira: (id) => this.kira.isShipReserved(id),
|
|
9774
|
+
hasHigherPriorityWork: () => this.practice.needsAction() || this.expedition.needsAction() || this.kira.needsAction()
|
|
9775
|
+
});
|
|
9708
9776
|
this.sortie = new AutoSortieModule(runtime, {
|
|
9709
9777
|
practiceNeedsAction: () => this.practice.needsAction(),
|
|
9710
9778
|
expeditionNeedsAction: () => this.expedition.needsAction(),
|
|
9711
9779
|
kiraNeedsAction: () => this.kira.needsAction(),
|
|
9780
|
+
repairNeedsAction: () => this.repair.needsAction(),
|
|
9712
9781
|
isShipReservedByKira: (id) => this.kira.isShipReserved(id),
|
|
9713
9782
|
getPendingSupportExpeditions: () => this.expedition.getPendingSupportDispatches(),
|
|
9714
9783
|
clearPendingSupportExpeditions: () => this.expedition.clearPendingSupportDispatches(),
|
|
9715
9784
|
onBattleResultForQuests: (params) => this.quests.onBattleResult(params),
|
|
9716
9785
|
onSortieCompletedForQuests: () => this.quests.onSortieCompleted()
|
|
9717
9786
|
});
|
|
9718
|
-
this.repair = new AutoRepairModule(runtime, (id) => this.kira.isShipReserved(id));
|
|
9719
9787
|
this.develop = new AutoDevelopModule(runtime);
|
|
9720
9788
|
this.plan = new AutoPlanModule(runtime, {
|
|
9721
9789
|
isAnyFleetInSortie: () => this.bridge.getState().inSortie,
|
|
@@ -11243,10 +11311,10 @@ var PoiStateAdapter = class {
|
|
|
11243
11311
|
cachedEquipLimitExslot = {};
|
|
11244
11312
|
cachedShipCtypes = {};
|
|
11245
11313
|
onApiResponse(event) {
|
|
11246
|
-
const
|
|
11314
|
+
const path5 = normalizeApiPath(event.path);
|
|
11247
11315
|
const body = event.body;
|
|
11248
11316
|
if (!body || typeof body !== "object") return;
|
|
11249
|
-
switch (
|
|
11317
|
+
switch (path5) {
|
|
11250
11318
|
case "/kcsapi/api_start2/getData":
|
|
11251
11319
|
this.ingestStart2(body);
|
|
11252
11320
|
break;
|
|
@@ -12595,30 +12663,192 @@ var import_react11 = __toESM(require("react"));
|
|
|
12595
12663
|
|
|
12596
12664
|
// src/ui/components/CollapsibleCard.tsx
|
|
12597
12665
|
var import_react = __toESM(require("react"));
|
|
12598
|
-
|
|
12599
|
-
|
|
12600
|
-
|
|
12601
|
-
|
|
12602
|
-
|
|
12666
|
+
|
|
12667
|
+
// src/ui/fold-store.ts
|
|
12668
|
+
var import_node_fs3 = __toESM(require("fs"));
|
|
12669
|
+
var import_node_path3 = __toESM(require("path"));
|
|
12670
|
+
var LOCAL_STORAGE_PREFIX = "kca-next:fold:v2:";
|
|
12671
|
+
var POI_CONFIG_KEY = "plugin.kca-next.uiFoldStateV2";
|
|
12672
|
+
var FOLD_FILE_NAME = "ui-fold-state.json";
|
|
12673
|
+
var memoryState = /* @__PURE__ */ new Map();
|
|
12674
|
+
var consumedTriggers = /* @__PURE__ */ new Map();
|
|
12675
|
+
var configuredDir = null;
|
|
12676
|
+
var diskHydrated = false;
|
|
12677
|
+
var globalTriggerSeq = 0;
|
|
12678
|
+
function toFlatConfigKey(storageKey) {
|
|
12679
|
+
return storageKey.replace(/\./g, "__");
|
|
12680
|
+
}
|
|
12681
|
+
function resolveFoldFilePath() {
|
|
12682
|
+
if (configuredDir) {
|
|
12683
|
+
return import_node_path3.default.join(configuredDir, FOLD_FILE_NAME);
|
|
12684
|
+
}
|
|
12685
|
+
if (typeof window !== "undefined" && window.APPDATA_PATH) {
|
|
12686
|
+
const appData = String(window.APPDATA_PATH).trim();
|
|
12687
|
+
if (appData) {
|
|
12688
|
+
return import_node_path3.default.join(appData, "kca-next", FOLD_FILE_NAME);
|
|
12689
|
+
}
|
|
12690
|
+
}
|
|
12691
|
+
return null;
|
|
12692
|
+
}
|
|
12693
|
+
function getPoiConfig() {
|
|
12694
|
+
try {
|
|
12695
|
+
if (typeof window === "undefined") return null;
|
|
12696
|
+
const cfg = window.config;
|
|
12697
|
+
if (cfg && typeof cfg.get === "function" && typeof cfg.set === "function") {
|
|
12698
|
+
return cfg;
|
|
12699
|
+
}
|
|
12700
|
+
} catch {
|
|
12701
|
+
}
|
|
12702
|
+
return null;
|
|
12703
|
+
}
|
|
12704
|
+
function hydrateFromDiskOnce() {
|
|
12705
|
+
if (diskHydrated) return;
|
|
12706
|
+
diskHydrated = true;
|
|
12707
|
+
const filePath = resolveFoldFilePath();
|
|
12708
|
+
if (!filePath) return;
|
|
12709
|
+
try {
|
|
12710
|
+
if (!import_node_fs3.default.existsSync(filePath)) return;
|
|
12711
|
+
const raw = import_node_fs3.default.readFileSync(filePath, "utf8");
|
|
12712
|
+
const parsed = JSON.parse(raw);
|
|
12713
|
+
const cards = parsed && typeof parsed === "object" && parsed.cards && typeof parsed.cards === "object" ? parsed.cards : parsed;
|
|
12714
|
+
if (!cards || typeof cards !== "object") return;
|
|
12715
|
+
for (const [k, v] of Object.entries(cards)) {
|
|
12716
|
+
if (typeof v === "boolean" && !memoryState.has(k)) {
|
|
12717
|
+
memoryState.set(k, v);
|
|
12718
|
+
}
|
|
12719
|
+
}
|
|
12720
|
+
} catch {
|
|
12603
12721
|
}
|
|
12604
12722
|
}
|
|
12605
|
-
function
|
|
12723
|
+
function persistMemoryToDisk() {
|
|
12724
|
+
const filePath = resolveFoldFilePath();
|
|
12725
|
+
if (!filePath) return;
|
|
12606
12726
|
try {
|
|
12607
|
-
|
|
12608
|
-
const
|
|
12609
|
-
|
|
12610
|
-
|
|
12727
|
+
const cards = {};
|
|
12728
|
+
for (const [k, v] of memoryState.entries()) {
|
|
12729
|
+
cards[k] = v;
|
|
12730
|
+
}
|
|
12731
|
+
const payload = { version: 1, cards };
|
|
12732
|
+
const serialized = JSON.stringify(payload, null, 2);
|
|
12733
|
+
import_node_fs3.default.mkdirSync(import_node_path3.default.dirname(filePath), { recursive: true });
|
|
12734
|
+
const tmpPath = `${filePath}.tmp`;
|
|
12735
|
+
try {
|
|
12736
|
+
import_node_fs3.default.writeFileSync(tmpPath, serialized, "utf8");
|
|
12737
|
+
import_node_fs3.default.renameSync(tmpPath, filePath);
|
|
12738
|
+
} catch {
|
|
12739
|
+
import_node_fs3.default.writeFileSync(filePath, serialized, "utf8");
|
|
12740
|
+
}
|
|
12741
|
+
} catch {
|
|
12742
|
+
}
|
|
12743
|
+
}
|
|
12744
|
+
function configureFoldStoreDir(dir) {
|
|
12745
|
+
const normalized = dir && dir.trim() ? dir.trim() : null;
|
|
12746
|
+
if (configuredDir !== normalized) {
|
|
12747
|
+
configuredDir = normalized;
|
|
12748
|
+
diskHydrated = false;
|
|
12749
|
+
}
|
|
12750
|
+
}
|
|
12751
|
+
function nextFoldTrigger() {
|
|
12752
|
+
globalTriggerSeq += 1;
|
|
12753
|
+
return globalTriggerSeq;
|
|
12754
|
+
}
|
|
12755
|
+
function isFoldTriggerPending(channel, token) {
|
|
12756
|
+
if (!token || token <= 0) return false;
|
|
12757
|
+
return consumedTriggers.get(channel) !== token;
|
|
12758
|
+
}
|
|
12759
|
+
function consumeFoldTrigger(channel, token) {
|
|
12760
|
+
if (!isFoldTriggerPending(channel, token)) return false;
|
|
12761
|
+
consumedTriggers.set(channel, token);
|
|
12762
|
+
return true;
|
|
12763
|
+
}
|
|
12764
|
+
function readFoldOpen(storageKey, fallback) {
|
|
12765
|
+
hydrateFromDiskOnce();
|
|
12766
|
+
const cached = memoryState.get(storageKey);
|
|
12767
|
+
if (typeof cached === "boolean") return cached;
|
|
12768
|
+
const poiCfg = getPoiConfig();
|
|
12769
|
+
if (poiCfg) {
|
|
12770
|
+
try {
|
|
12771
|
+
const storedMap = poiCfg.get?.(POI_CONFIG_KEY);
|
|
12772
|
+
if (storedMap && typeof storedMap === "object") {
|
|
12773
|
+
const val = storedMap[toFlatConfigKey(storageKey)];
|
|
12774
|
+
if (typeof val === "boolean") {
|
|
12775
|
+
memoryState.set(storageKey, val);
|
|
12776
|
+
return val;
|
|
12777
|
+
}
|
|
12778
|
+
}
|
|
12779
|
+
} catch {
|
|
12780
|
+
}
|
|
12781
|
+
}
|
|
12782
|
+
try {
|
|
12783
|
+
if (typeof window !== "undefined" && window.localStorage) {
|
|
12784
|
+
const raw = window.localStorage.getItem(LOCAL_STORAGE_PREFIX + storageKey);
|
|
12785
|
+
if (raw === "1") {
|
|
12786
|
+
memoryState.set(storageKey, true);
|
|
12787
|
+
return true;
|
|
12788
|
+
}
|
|
12789
|
+
if (raw === "0") {
|
|
12790
|
+
memoryState.set(storageKey, false);
|
|
12791
|
+
return false;
|
|
12792
|
+
}
|
|
12793
|
+
}
|
|
12611
12794
|
} catch {
|
|
12612
12795
|
}
|
|
12613
12796
|
return fallback;
|
|
12614
12797
|
}
|
|
12615
|
-
function
|
|
12798
|
+
function writeFoldOpen(storageKey, open) {
|
|
12799
|
+
hydrateFromDiskOnce();
|
|
12800
|
+
memoryState.set(storageKey, open);
|
|
12801
|
+
persistMemoryToDisk();
|
|
12802
|
+
const poiCfg = getPoiConfig();
|
|
12803
|
+
if (poiCfg) {
|
|
12804
|
+
try {
|
|
12805
|
+
const existing = poiCfg.get?.(POI_CONFIG_KEY);
|
|
12806
|
+
const nextMap = existing && typeof existing === "object" ? { ...existing } : {};
|
|
12807
|
+
nextMap[toFlatConfigKey(storageKey)] = open;
|
|
12808
|
+
poiCfg.set?.(POI_CONFIG_KEY, nextMap);
|
|
12809
|
+
} catch {
|
|
12810
|
+
}
|
|
12811
|
+
}
|
|
12616
12812
|
try {
|
|
12617
|
-
if (typeof window
|
|
12618
|
-
|
|
12813
|
+
if (typeof window !== "undefined" && window.localStorage) {
|
|
12814
|
+
window.localStorage.setItem(LOCAL_STORAGE_PREFIX + storageKey, open ? "1" : "0");
|
|
12815
|
+
}
|
|
12619
12816
|
} catch {
|
|
12620
12817
|
}
|
|
12621
12818
|
}
|
|
12819
|
+
function resolveInitialCardOpen(storageKey, defaultOpen, forceOpenTrigger, forceCloseTrigger) {
|
|
12820
|
+
if (isFoldTriggerPending(`open:${storageKey}`, forceOpenTrigger)) {
|
|
12821
|
+
return true;
|
|
12822
|
+
}
|
|
12823
|
+
if (isFoldTriggerPending(`close:${storageKey}`, forceCloseTrigger)) {
|
|
12824
|
+
return false;
|
|
12825
|
+
}
|
|
12826
|
+
return readFoldOpen(storageKey, defaultOpen);
|
|
12827
|
+
}
|
|
12828
|
+
function applyCardForceOpenTrigger(storageKey, forceOpenTrigger, persistForceOpen) {
|
|
12829
|
+
if (!consumeFoldTrigger(`open:${storageKey}`, forceOpenTrigger)) {
|
|
12830
|
+
return false;
|
|
12831
|
+
}
|
|
12832
|
+
if (persistForceOpen) {
|
|
12833
|
+
writeFoldOpen(storageKey, true);
|
|
12834
|
+
}
|
|
12835
|
+
return true;
|
|
12836
|
+
}
|
|
12837
|
+
function applyCardForceCloseTrigger(storageKey, forceCloseTrigger) {
|
|
12838
|
+
if (!consumeFoldTrigger(`close:${storageKey}`, forceCloseTrigger)) {
|
|
12839
|
+
return false;
|
|
12840
|
+
}
|
|
12841
|
+
writeFoldOpen(storageKey, false);
|
|
12842
|
+
return true;
|
|
12843
|
+
}
|
|
12844
|
+
|
|
12845
|
+
// src/ui/components/CollapsibleCard.tsx
|
|
12846
|
+
var foldAllListeners = /* @__PURE__ */ new Set();
|
|
12847
|
+
function setAllMountedCardsOpen(open) {
|
|
12848
|
+
for (const listener of foldAllListeners) {
|
|
12849
|
+
listener(open);
|
|
12850
|
+
}
|
|
12851
|
+
}
|
|
12622
12852
|
var CollapsibleCard = ({
|
|
12623
12853
|
storageKey,
|
|
12624
12854
|
title,
|
|
@@ -12626,22 +12856,28 @@ var CollapsibleCard = ({
|
|
|
12626
12856
|
headerRight,
|
|
12627
12857
|
defaultOpen = true,
|
|
12628
12858
|
forceOpenTrigger,
|
|
12859
|
+
persistForceOpen = true,
|
|
12860
|
+
forceCloseTrigger,
|
|
12629
12861
|
className,
|
|
12630
12862
|
children: children2
|
|
12631
12863
|
}) => {
|
|
12632
12864
|
const [open, setOpen] = (0, import_react.useState)(
|
|
12633
|
-
() =>
|
|
12865
|
+
() => resolveInitialCardOpen(storageKey, defaultOpen, forceOpenTrigger, forceCloseTrigger)
|
|
12634
12866
|
);
|
|
12635
12867
|
(0, import_react.useEffect)(() => {
|
|
12636
|
-
if (forceOpenTrigger) {
|
|
12868
|
+
if (applyCardForceOpenTrigger(storageKey, forceOpenTrigger, persistForceOpen)) {
|
|
12637
12869
|
setOpen(true);
|
|
12638
|
-
writeStoredOpen(storageKey, true);
|
|
12639
12870
|
}
|
|
12640
|
-
}, [forceOpenTrigger, storageKey]);
|
|
12871
|
+
}, [forceOpenTrigger, persistForceOpen, storageKey]);
|
|
12872
|
+
(0, import_react.useEffect)(() => {
|
|
12873
|
+
if (applyCardForceCloseTrigger(storageKey, forceCloseTrigger)) {
|
|
12874
|
+
setOpen(false);
|
|
12875
|
+
}
|
|
12876
|
+
}, [forceCloseTrigger, storageKey]);
|
|
12641
12877
|
(0, import_react.useEffect)(() => {
|
|
12642
12878
|
const onSetAll = (nextOpen) => {
|
|
12643
12879
|
setOpen(nextOpen);
|
|
12644
|
-
|
|
12880
|
+
writeFoldOpen(storageKey, nextOpen);
|
|
12645
12881
|
};
|
|
12646
12882
|
foldAllListeners.add(onSetAll);
|
|
12647
12883
|
return () => {
|
|
@@ -12651,7 +12887,7 @@ var CollapsibleCard = ({
|
|
|
12651
12887
|
const toggle = () => {
|
|
12652
12888
|
setOpen((prev) => {
|
|
12653
12889
|
const next = !prev;
|
|
12654
|
-
|
|
12890
|
+
writeFoldOpen(storageKey, next);
|
|
12655
12891
|
return next;
|
|
12656
12892
|
});
|
|
12657
12893
|
};
|
|
@@ -12692,22 +12928,28 @@ var CollapsibleSubBox = ({
|
|
|
12692
12928
|
headerRight,
|
|
12693
12929
|
defaultOpen = false,
|
|
12694
12930
|
forceOpenTrigger,
|
|
12931
|
+
persistForceOpen = true,
|
|
12932
|
+
forceCloseTrigger,
|
|
12695
12933
|
danger = false,
|
|
12696
12934
|
children: children2
|
|
12697
12935
|
}) => {
|
|
12698
12936
|
const [open, setOpen] = (0, import_react.useState)(
|
|
12699
|
-
() =>
|
|
12937
|
+
() => resolveInitialCardOpen(storageKey, defaultOpen, forceOpenTrigger, forceCloseTrigger)
|
|
12700
12938
|
);
|
|
12701
12939
|
(0, import_react.useEffect)(() => {
|
|
12702
|
-
if (forceOpenTrigger) {
|
|
12940
|
+
if (applyCardForceOpenTrigger(storageKey, forceOpenTrigger, persistForceOpen)) {
|
|
12703
12941
|
setOpen(true);
|
|
12704
|
-
writeStoredOpen(storageKey, true);
|
|
12705
12942
|
}
|
|
12706
|
-
}, [forceOpenTrigger, storageKey]);
|
|
12943
|
+
}, [forceOpenTrigger, persistForceOpen, storageKey]);
|
|
12944
|
+
(0, import_react.useEffect)(() => {
|
|
12945
|
+
if (applyCardForceCloseTrigger(storageKey, forceCloseTrigger)) {
|
|
12946
|
+
setOpen(false);
|
|
12947
|
+
}
|
|
12948
|
+
}, [forceCloseTrigger, storageKey]);
|
|
12707
12949
|
const toggle = () => {
|
|
12708
12950
|
setOpen((prev) => {
|
|
12709
12951
|
const next = !prev;
|
|
12710
|
-
|
|
12952
|
+
writeFoldOpen(storageKey, next);
|
|
12711
12953
|
return next;
|
|
12712
12954
|
});
|
|
12713
12955
|
};
|
|
@@ -13796,6 +14038,12 @@ var PERIOD_LABELS = {
|
|
|
13796
14038
|
monthly: "\u6708\u5E38",
|
|
13797
14039
|
other: "\u5176\u4ED6"
|
|
13798
14040
|
};
|
|
14041
|
+
var REPAIR_DAMAGE_LABELS = {
|
|
14042
|
+
light: "\u5C0F\u7834\u53CA\u4EE5\u4E0A",
|
|
14043
|
+
moderate: "\u4E2D\u7834\u53CA\u4EE5\u4E0A",
|
|
14044
|
+
heavy: "\u4EC5\u5927\u7834",
|
|
14045
|
+
scratch: "\u5168\u90E8\u635F\u4F24(\u542B\u64E6\u4F24)"
|
|
14046
|
+
};
|
|
13799
14047
|
var OrgPracticeQuestsTab = ({ coordinator, settings }) => {
|
|
13800
14048
|
const [recordFleet, setRecordFleet] = (0, import_react4.useState)(1);
|
|
13801
14049
|
const [recordName, setRecordName] = (0, import_react4.useState)("");
|
|
@@ -14278,8 +14526,22 @@ var OrgPracticeQuestsTab = ({ coordinator, settings }) => {
|
|
|
14278
14526
|
storageKey: "modules.repair",
|
|
14279
14527
|
title: "\u81EA\u52A8\u5165\u6E20 (\u5F85\u547D\u8230\u5A18)",
|
|
14280
14528
|
defaultOpen: true,
|
|
14281
|
-
summary: /* @__PURE__ */ import_react4.default.createElement("span", null, "Lv\u2265", rep.minLevel, " \xB7 \u7559", rep.reservedDocks, "\u6E20
|
|
14529
|
+
summary: /* @__PURE__ */ import_react4.default.createElement(import_react4.default.Fragment, null, /* @__PURE__ */ import_react4.default.createElement("span", null, REPAIR_DAMAGE_LABELS[rep.damageThreshold ?? "light"], " \xB7 Lv\u2265", rep.minLevel, " \xB7 \u7559", rep.reservedDocks, "\u6E20"), rep.avoidSortieConflict !== false && /* @__PURE__ */ import_react4.default.createElement("span", { className: "kca-badge kca-badge-ok" }, "\u9632\u51FA\u51FB\u51B2\u7A81"))
|
|
14282
14530
|
},
|
|
14531
|
+
/* @__PURE__ */ import_react4.default.createElement("div", { className: "kca-row" }, /* @__PURE__ */ import_react4.default.createElement("span", null, "\u635F\u4F24\u6761\u4EF6"), /* @__PURE__ */ import_react4.default.createElement(
|
|
14532
|
+
"select",
|
|
14533
|
+
{
|
|
14534
|
+
className: "kca-select",
|
|
14535
|
+
value: rep.damageThreshold ?? "light",
|
|
14536
|
+
onChange: (e) => coordinator.updateSettings((s) => {
|
|
14537
|
+
s.repair.damageThreshold = e.target.value;
|
|
14538
|
+
})
|
|
14539
|
+
},
|
|
14540
|
+
/* @__PURE__ */ import_react4.default.createElement("option", { value: "light" }, "\u5C0F\u7834\u53CA\u4EE5\u4E0A (\u5C0F\u7834/\u4E2D\u7834/\u5927\u7834\uFF0C\u8DF3\u8FC7\u64E6\u4F24)"),
|
|
14541
|
+
/* @__PURE__ */ import_react4.default.createElement("option", { value: "moderate" }, "\u4E2D\u7834\u53CA\u4EE5\u4E0A (\u4E2D\u7834/\u5927\u7834)"),
|
|
14542
|
+
/* @__PURE__ */ import_react4.default.createElement("option", { value: "heavy" }, "\u4EC5\u5927\u7834 (HP \u2264 25%)"),
|
|
14543
|
+
/* @__PURE__ */ import_react4.default.createElement("option", { value: "scratch" }, "\u5168\u90E8\u635F\u4F24 (\u542B\u64E6\u4F24)")
|
|
14544
|
+
)),
|
|
14283
14545
|
/* @__PURE__ */ import_react4.default.createElement("div", { className: "kca-row" }, /* @__PURE__ */ import_react4.default.createElement("span", null, "\u6700\u4F4E\u7B49\u7EA7"), /* @__PURE__ */ import_react4.default.createElement(
|
|
14284
14546
|
"input",
|
|
14285
14547
|
{
|
|
@@ -14313,6 +14575,24 @@ var OrgPracticeQuestsTab = ({ coordinator, settings }) => {
|
|
|
14313
14575
|
/* @__PURE__ */ import_react4.default.createElement("option", { value: "shortest" }, "\u77ED\u65F6\u4F18\u5148"),
|
|
14314
14576
|
/* @__PURE__ */ import_react4.default.createElement("option", { value: "longest" }, "\u957F\u65F6\u4F18\u5148")
|
|
14315
14577
|
)),
|
|
14578
|
+
/* @__PURE__ */ import_react4.default.createElement(
|
|
14579
|
+
"label",
|
|
14580
|
+
{
|
|
14581
|
+
className: "kca-switch",
|
|
14582
|
+
title: "\u5F00\u542F\u540E\uFF1A1) \u8DF3\u8FC7\u5F53\u524D\u6FC0\u6D3B\u51FA\u51FB\u65B9\u6848\u5019\u9009\u6C60\u4E2D\u7684\u8F6E\u6362\u8230\u5A18\uFF1B2) \u81EA\u52A8\u51FA\u51FB\u5F00\u542F\u65F6\u81F3\u5C11\u4FDD\u7559 1 \u4E2A\u7A7A\u6E20\u7ED9\u51FA\u51FB\u4FEE\u8239/\u6CFC\u6876\uFF1B3) \u51FA\u51FB\u95F4\u6B47\u5728\u6BCD\u6E2F\u5B89\u5168\u534F\u540C\u5165\u6E20\uFF0C\u4E0D\u62A2\u5360\u6218\u6597\u6216\u51FA\u51FB\u524D\u4FEE\u8239"
|
|
14583
|
+
},
|
|
14584
|
+
/* @__PURE__ */ import_react4.default.createElement(
|
|
14585
|
+
"input",
|
|
14586
|
+
{
|
|
14587
|
+
type: "checkbox",
|
|
14588
|
+
checked: rep.avoidSortieConflict !== false,
|
|
14589
|
+
onChange: (e) => coordinator.updateSettings((s) => {
|
|
14590
|
+
s.repair.avoidSortieConflict = e.target.checked;
|
|
14591
|
+
})
|
|
14592
|
+
}
|
|
14593
|
+
),
|
|
14594
|
+
/* @__PURE__ */ import_react4.default.createElement("strong", null, "\u4E0E\u81EA\u52A8\u51FA\u51FB\u9632\u51B2\u7A81 (\u907F\u5F00\u51FA\u51FB\u5019\u9009\u8239 \xB7 \u81EA\u52A8\u7559\u22651\u7A7A\u6E20)")
|
|
14595
|
+
),
|
|
14316
14596
|
/* @__PURE__ */ import_react4.default.createElement("label", { className: "kca-switch" }, /* @__PURE__ */ import_react4.default.createElement(
|
|
14317
14597
|
"input",
|
|
14318
14598
|
{
|
|
@@ -14765,7 +15045,7 @@ var PlanTab = ({ coordinator, settings }) => {
|
|
|
14765
15045
|
var import_react7 = __toESM(require("react"));
|
|
14766
15046
|
|
|
14767
15047
|
// src/ui/components/LegacyImportPanel.tsx
|
|
14768
|
-
var
|
|
15048
|
+
var import_node_fs4 = __toESM(require("fs"));
|
|
14769
15049
|
var import_react6 = __toESM(require("react"));
|
|
14770
15050
|
function formatBytes(bytes) {
|
|
14771
15051
|
if (bytes < 1024) return `${bytes} B`;
|
|
@@ -14821,6 +15101,7 @@ async function tryPickDirectoryElectron() {
|
|
|
14821
15101
|
var LegacyImportPanel = ({
|
|
14822
15102
|
coordinator,
|
|
14823
15103
|
autoScanOnMount = false,
|
|
15104
|
+
autoScanTrigger = 0,
|
|
14824
15105
|
onImportSuccess
|
|
14825
15106
|
}) => {
|
|
14826
15107
|
const [report, setReport] = (0, import_react6.useState)(null);
|
|
@@ -14899,11 +15180,16 @@ var LegacyImportPanel = ({
|
|
|
14899
15180
|
setShowCustomDirRow((v) => !v);
|
|
14900
15181
|
}
|
|
14901
15182
|
};
|
|
15183
|
+
const lastAutoScannedRef = (0, import_react6.useRef)(0);
|
|
14902
15184
|
(0, import_react6.useEffect)(() => {
|
|
14903
|
-
if (
|
|
15185
|
+
if (autoScanTrigger > 0 && lastAutoScannedRef.current !== autoScanTrigger) {
|
|
15186
|
+
lastAutoScannedRef.current = autoScanTrigger;
|
|
15187
|
+
runAutoDetect();
|
|
15188
|
+
} else if (autoScanOnMount && lastAutoScannedRef.current === 0) {
|
|
15189
|
+
lastAutoScannedRef.current = -1;
|
|
14904
15190
|
runAutoDetect();
|
|
14905
15191
|
}
|
|
14906
|
-
}, [autoScanOnMount]);
|
|
15192
|
+
}, [autoScanTrigger, autoScanOnMount]);
|
|
14907
15193
|
const handleManualFiles = async (e) => {
|
|
14908
15194
|
const files = e.target.files;
|
|
14909
15195
|
if (!files || files.length === 0) return;
|
|
@@ -14978,7 +15264,7 @@ var LegacyImportPanel = ({
|
|
|
14978
15264
|
parsed = uploadedSettings.result;
|
|
14979
15265
|
sourceLabel = uploadedSettings.fileName;
|
|
14980
15266
|
} else if (activeCandidate) {
|
|
14981
|
-
const buf =
|
|
15267
|
+
const buf = import_node_fs4.default.readFileSync(activeCandidate.path);
|
|
14982
15268
|
parsed = importLegacyAssistantSettings(buf);
|
|
14983
15269
|
sourceLabel = activeCandidate.fileName;
|
|
14984
15270
|
} else {
|
|
@@ -14998,7 +15284,7 @@ var LegacyImportPanel = ({
|
|
|
14998
15284
|
);
|
|
14999
15285
|
doneParts.push(`\u5DF2\u5BFC\u5165 ${cnt} \u4E2A\u56FE\u50CF\u6A21\u677F (${uploadedCdata.fileName})`);
|
|
15000
15286
|
} else if (activeCdata && activeCdata.valid) {
|
|
15001
|
-
const buf =
|
|
15287
|
+
const buf = import_node_fs4.default.readFileSync(activeCdata.path);
|
|
15002
15288
|
const parsedCdata = parseLegacyCdata(buf);
|
|
15003
15289
|
const cnt = coordinator.importCustomTemplates(parsedCdata.templates, activeCdata.path);
|
|
15004
15290
|
doneParts.push(`\u5DF2\u5BFC\u5165 ${cnt} \u4E2A\u56FE\u50CF\u6A21\u677F (cdata)`);
|
|
@@ -15008,11 +15294,12 @@ var LegacyImportPanel = ({
|
|
|
15008
15294
|
setStatusMsg({ kind: "err", text: "\u8BF7\u81F3\u5C11\u52FE\u9009\u4E00\u4E2A\u8981\u5BFC\u5165\u7684\u914D\u7F6E\u6A21\u5757\u6216 cdata \u6A21\u677F\u3002" });
|
|
15009
15295
|
return;
|
|
15010
15296
|
}
|
|
15297
|
+
const summaryLine = doneParts.join("\uFF1B");
|
|
15011
15298
|
setStatusMsg({
|
|
15012
15299
|
kind: "ok",
|
|
15013
|
-
text: `\u2705 ${
|
|
15300
|
+
text: `\u2705 ${summaryLine}\u3002\u539F KCA Next \u914D\u7F6E\u5DF2\u81EA\u52A8\u5907\u4EFD\u81F3 backups/settings.v1.1.json\u3002`
|
|
15014
15301
|
});
|
|
15015
|
-
onImportSuccess?.();
|
|
15302
|
+
onImportSuccess?.(summaryLine);
|
|
15016
15303
|
} catch (err) {
|
|
15017
15304
|
setStatusMsg({
|
|
15018
15305
|
kind: "err",
|
|
@@ -15181,6 +15468,16 @@ var SettingsLogsTab = ({
|
|
|
15181
15468
|
const [s2Snap, setS2Snap] = (0, import_react7.useState)(
|
|
15182
15469
|
() => coordinator.getStart2CacheSnapshot()
|
|
15183
15470
|
);
|
|
15471
|
+
const [autoScanTrigger, setAutoScanTrigger] = (0, import_react7.useState)(
|
|
15472
|
+
() => isFoldTriggerPending("legacy-import:autoscan", legacyImportTrigger) ? legacyImportTrigger : 0
|
|
15473
|
+
);
|
|
15474
|
+
const [importCloseTrigger, setImportCloseTrigger] = (0, import_react7.useState)(0);
|
|
15475
|
+
const [lastImportDoneText, setLastImportDoneText] = (0, import_react7.useState)("");
|
|
15476
|
+
(0, import_react7.useEffect)(() => {
|
|
15477
|
+
if (consumeFoldTrigger("legacy-import:autoscan", legacyImportTrigger)) {
|
|
15478
|
+
setAutoScanTrigger(legacyImportTrigger);
|
|
15479
|
+
}
|
|
15480
|
+
}, [legacyImportTrigger]);
|
|
15184
15481
|
(0, import_react7.useEffect)(() => {
|
|
15185
15482
|
let alive = true;
|
|
15186
15483
|
const poll = async () => {
|
|
@@ -15207,7 +15504,10 @@ var SettingsLogsTab = ({
|
|
|
15207
15504
|
coordinator.saveNow();
|
|
15208
15505
|
coordinator.replaceSettings(parsed);
|
|
15209
15506
|
coordinator.saveNow();
|
|
15210
|
-
|
|
15507
|
+
const doneText = "JSON \u914D\u7F6E\u5BFC\u5165\u6210\u529F\uFF08\u539F\u914D\u7F6E\u5DF2\u81EA\u52A8\u5907\u4EFD\uFF09";
|
|
15508
|
+
setJsonMsg(doneText);
|
|
15509
|
+
setLastImportDoneText(doneText);
|
|
15510
|
+
setImportCloseTrigger(nextFoldTrigger());
|
|
15211
15511
|
} else {
|
|
15212
15512
|
setJsonMsg("JSON \u683C\u5F0F\u7248\u672C\u4E0D\u5339\u914D");
|
|
15213
15513
|
}
|
|
@@ -15237,7 +15537,6 @@ var SettingsLogsTab = ({
|
|
|
15237
15537
|
}
|
|
15238
15538
|
};
|
|
15239
15539
|
const filteredLogs = logs.filter((l) => levelFilter === "all" || l.level === levelFilter).slice(-200).reverse();
|
|
15240
|
-
const autoScanLegacy = legacyImportTrigger > 0;
|
|
15241
15540
|
const speedLabels = {
|
|
15242
15541
|
safe: "\u7A33\u5065",
|
|
15243
15542
|
normal: "\u6807\u51C6",
|
|
@@ -15248,11 +15547,23 @@ var SettingsLogsTab = ({
|
|
|
15248
15547
|
{
|
|
15249
15548
|
storageKey: "settings.import",
|
|
15250
15549
|
title: "\u65E7\u7248 (\u975E)\u63D0\u52A9\u624B \u4E00\u952E\u68C0\u6D4B\u4E0E\u65E0\u635F\u5BFC\u5165",
|
|
15251
|
-
defaultOpen:
|
|
15550
|
+
defaultOpen: false,
|
|
15252
15551
|
forceOpenTrigger: legacyImportTrigger,
|
|
15253
|
-
|
|
15552
|
+
persistForceOpen: false,
|
|
15553
|
+
forceCloseTrigger: importCloseTrigger,
|
|
15554
|
+
summary: lastImportDoneText ? /* @__PURE__ */ import_react7.default.createElement("span", { className: "kca-badge kca-badge-ok", title: lastImportDoneText }, "\u2705 \u5BFC\u5165\u5B8C\u6210\uFF08\u70B9\u51FB\u53EF\u5C55\u5F00\uFF09") : /* @__PURE__ */ import_react7.default.createElement("span", null, "\u9ED8\u8BA4\u6536\u8D77 \xB7 v2.xml.gz / \u65E7\u7248 xml / cdata / JSON \u5907\u4EFD")
|
|
15254
15555
|
},
|
|
15255
|
-
/* @__PURE__ */ import_react7.default.createElement(
|
|
15556
|
+
/* @__PURE__ */ import_react7.default.createElement(
|
|
15557
|
+
LegacyImportPanel,
|
|
15558
|
+
{
|
|
15559
|
+
coordinator,
|
|
15560
|
+
autoScanTrigger,
|
|
15561
|
+
onImportSuccess: (summaryText) => {
|
|
15562
|
+
setLastImportDoneText(summaryText || "\u65E7\u7248\u914D\u7F6E\u5DF2\u5BFC\u5165\u5E76\u81EA\u52A8\u5907\u4EFD\u539F\u914D\u7F6E");
|
|
15563
|
+
setImportCloseTrigger(nextFoldTrigger());
|
|
15564
|
+
}
|
|
15565
|
+
}
|
|
15566
|
+
),
|
|
15256
15567
|
/* @__PURE__ */ import_react7.default.createElement(
|
|
15257
15568
|
"div",
|
|
15258
15569
|
{
|
|
@@ -16097,7 +16408,7 @@ var ShipRotationPanel = ({ profile, gameState, updateProfile }) => {
|
|
|
16097
16408
|
updateProfile((p) => {
|
|
16098
16409
|
p.autoChangeShip = checked;
|
|
16099
16410
|
});
|
|
16100
|
-
if (checked) setOpenTrigger((
|
|
16411
|
+
if (checked) setOpenTrigger(nextFoldTrigger());
|
|
16101
16412
|
}
|
|
16102
16413
|
}
|
|
16103
16414
|
), /* @__PURE__ */ import_react9.default.createElement("strong", null, "\u542F\u7528\u81EA\u52A8\u8F6E\u6362")), /* @__PURE__ */ import_react9.default.createElement(
|
|
@@ -16860,7 +17171,6 @@ var SortieTab = ({ coordinator, gameState, settings }) => {
|
|
|
16860
17171
|
title: "\u5927\u7834\u68C0\u6D4B\u9009\u9879 (\u4EC5\u9650\u5F53\u524D\u65B9\u6848)",
|
|
16861
17172
|
danger: taihaOverrideActive,
|
|
16862
17173
|
defaultOpen: taihaOverrideActive,
|
|
16863
|
-
forceOpenTrigger: taihaOverrideActive,
|
|
16864
17174
|
summary: taihaOverrideActive ? /* @__PURE__ */ import_react10.default.createElement("span", { className: "kca-badge kca-badge-err" }, "\u26A0 \u5DF2\u5173\u95ED\u5927\u7834\u4FDD\u62A4") : /* @__PURE__ */ import_react10.default.createElement("span", { className: "kca-badge kca-badge-ok" }, "\u9ED8\u8BA4 7 \u5C42\u4FDD\u62A4\u5F00\u542F")
|
|
16865
17175
|
},
|
|
16866
17176
|
/* @__PURE__ */ import_react10.default.createElement("div", { className: "kca-row", style: { gap: 14 } }, /* @__PURE__ */ import_react10.default.createElement("label", { className: "kca-switch" }, /* @__PURE__ */ import_react10.default.createElement(
|
|
@@ -16909,7 +17219,7 @@ var SortieTab = ({ coordinator, gameState, settings }) => {
|
|
|
16909
17219
|
updateProfile((p) => {
|
|
16910
17220
|
p.useAdvanceSettings = checked;
|
|
16911
17221
|
});
|
|
16912
|
-
if (checked) setAdvanceOpenTrigger((
|
|
17222
|
+
if (checked) setAdvanceOpenTrigger(nextFoldTrigger());
|
|
16913
17223
|
}
|
|
16914
17224
|
}
|
|
16915
17225
|
), "\u542F\u7528\u9AD8\u7EA7\u89C4\u5219")
|
|
@@ -17350,7 +17660,7 @@ var KcaNextApp = ({ coordinator }) => {
|
|
|
17350
17660
|
const [gameState, setGameState] = (0, import_react11.useState)(() => coordinator.bridge.getState());
|
|
17351
17661
|
const [logs, setLogs] = (0, import_react11.useState)(() => [...coordinator.logger.getEntries()]);
|
|
17352
17662
|
const openLegacyMigration = () => {
|
|
17353
|
-
setLegacyImportTrigger((
|
|
17663
|
+
setLegacyImportTrigger(nextFoldTrigger());
|
|
17354
17664
|
setActiveTab("settings");
|
|
17355
17665
|
};
|
|
17356
17666
|
(0, import_react11.useEffect)(() => {
|
|
@@ -17420,28 +17730,29 @@ var KcaNextApp = ({ coordinator }) => {
|
|
|
17420
17730
|
var coordinatorInstance = null;
|
|
17421
17731
|
function resolveSettingsDir() {
|
|
17422
17732
|
const appData = typeof window !== "undefined" && window.APPDATA_PATH || process.env.APPDATA || process.cwd();
|
|
17423
|
-
return
|
|
17733
|
+
return import_node_path4.default.join(appData, "kca-next");
|
|
17424
17734
|
}
|
|
17425
17735
|
function createRotatingFileWriter(dir) {
|
|
17426
|
-
const logPath =
|
|
17736
|
+
const logPath = import_node_path4.default.join(dir, "kca-next.log");
|
|
17427
17737
|
const MAX_BYTES = 5 * 1024 * 1024;
|
|
17428
17738
|
return (line) => {
|
|
17429
|
-
|
|
17430
|
-
if (
|
|
17739
|
+
import_node_fs5.default.mkdirSync(dir, { recursive: true });
|
|
17740
|
+
if (import_node_fs5.default.existsSync(logPath) && import_node_fs5.default.statSync(logPath).size > MAX_BYTES) {
|
|
17431
17741
|
for (let i = 3; i >= 2; i--) {
|
|
17432
|
-
const prev =
|
|
17433
|
-
const next =
|
|
17434
|
-
if (
|
|
17742
|
+
const prev = import_node_path4.default.join(dir, `kca-next.${i - 1}.log`);
|
|
17743
|
+
const next = import_node_path4.default.join(dir, `kca-next.${i}.log`);
|
|
17744
|
+
if (import_node_fs5.default.existsSync(prev)) import_node_fs5.default.renameSync(prev, next);
|
|
17435
17745
|
}
|
|
17436
|
-
|
|
17746
|
+
import_node_fs5.default.renameSync(logPath, import_node_path4.default.join(dir, "kca-next.1.log"));
|
|
17437
17747
|
}
|
|
17438
|
-
|
|
17748
|
+
import_node_fs5.default.appendFileSync(logPath, `${line}
|
|
17439
17749
|
`, "utf8");
|
|
17440
17750
|
};
|
|
17441
17751
|
}
|
|
17442
17752
|
function ensureCoordinator() {
|
|
17443
17753
|
if (!coordinatorInstance) {
|
|
17444
17754
|
const dir = resolveSettingsDir();
|
|
17755
|
+
configureFoldStoreDir(dir);
|
|
17445
17756
|
const bridge = new PoiGameBridge();
|
|
17446
17757
|
coordinatorInstance = new KcaAssistantCoordinator(bridge, { settingsDir: dir });
|
|
17447
17758
|
if (coordinatorInstance.getSettings().general.enableFileLog) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "poi-plugin-kca-next",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5",
|
|
4
4
|
"description": "High-performance native poi KanColle automation replacement for (非)提助手 — zero DRM, zero extra browser, event-driven in-process engine",
|
|
5
5
|
"author": "machilus",
|
|
6
6
|
"main": "dist/index.js",
|