poi-plugin-yulaiyulai 1.2.9 → 1.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/README.md +1 -1
- package/lib/core.js +16 -13
- package/lib/runtime.js +16 -21
- package/package.json +2 -2
- package/views/panel.es +5 -5
package/README.md
CHANGED
|
@@ -32,7 +32,7 @@ poi 的“安装插件”输入框本质上是 `npm install`,可以输入以
|
|
|
32
32
|
2. **本地 npm tarball 的绝对路径**(当前工作区里的版本可直接这样装):
|
|
33
33
|
|
|
34
34
|
```text
|
|
35
|
-
C:\Users\Soul\Downloads\poi-plugin-yulaiyulai-1.
|
|
35
|
+
C:\Users\Soul\Downloads\poi-plugin-yulaiyulai-1.3.0.tgz
|
|
36
36
|
```
|
|
37
37
|
|
|
38
38
|
注意路径要以 `.tgz` 结尾,并且文件在当前机器上真实存在。如果移动了文件,把上面的路径换成实际位置即可。
|
package/lib/core.js
CHANGED
|
@@ -9,6 +9,7 @@ const bundledRoutes = require('../data/map-routes.json')
|
|
|
9
9
|
const fallbackRewards = require('../data/rewards-2025')
|
|
10
10
|
|
|
11
11
|
const DATA_VERSION = 1
|
|
12
|
+
const MAX_ARCHIVE = 100
|
|
12
13
|
const SAURY_FALLBACK_ID = 68
|
|
13
14
|
const SAURY_NAME_RE = /(秋刀魚|秋刀鱼|さんま|サンマ|saury)/i
|
|
14
15
|
|
|
@@ -262,7 +263,7 @@ function createInitialState(now) {
|
|
|
262
263
|
version: DATA_VERSION,
|
|
263
264
|
season: createSeason(date.getFullYear(), date.getTime()),
|
|
264
265
|
history: [],
|
|
265
|
-
|
|
266
|
+
undoStack: [],
|
|
266
267
|
ui: { tab: 'stats' },
|
|
267
268
|
}
|
|
268
269
|
}
|
|
@@ -436,22 +437,24 @@ function sanitizeState(raw, now) {
|
|
|
436
437
|
const fallback = createInitialState(now)
|
|
437
438
|
if (!raw || typeof raw !== 'object') return fallback
|
|
438
439
|
const history = sanitizeHistory(raw.history)
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
if (
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
440
|
+
const source = Array.isArray(raw.undoStack) ? raw.undoStack : raw.undo ? [raw.undo] : []
|
|
441
|
+
const undoStack = []
|
|
442
|
+
for (const entry of source) {
|
|
443
|
+
if (!entry || !entry.season) continue
|
|
444
|
+
const bill = sanitizeHistory([entry.bill])[0]
|
|
445
|
+
if (!bill) continue
|
|
446
|
+
undoStack.push({
|
|
447
|
+
season: sanitizeSeason(entry.season, now),
|
|
448
|
+
bill,
|
|
449
|
+
at: entry.at || '',
|
|
450
|
+
})
|
|
449
451
|
}
|
|
452
|
+
if (undoStack.length > MAX_ARCHIVE) undoStack.splice(0, undoStack.length - MAX_ARCHIVE)
|
|
450
453
|
return {
|
|
451
454
|
version: DATA_VERSION,
|
|
452
455
|
season: sanitizeSeason(raw.season, now),
|
|
453
456
|
history,
|
|
454
|
-
|
|
457
|
+
undoStack,
|
|
455
458
|
ui: raw.ui && typeof raw.ui === 'object' ? { tab: String(raw.ui.tab || 'stats') } : fallback.ui,
|
|
456
459
|
}
|
|
457
460
|
}
|
|
@@ -699,7 +702,7 @@ function archiveSeason(state, now, imageDataUrl) {
|
|
|
699
702
|
const bill = buildBill(state.season, now, imageDataUrl)
|
|
700
703
|
if (!state.history) state.history = []
|
|
701
704
|
state.history = [bill, ...state.history.filter((item) => item.year !== bill.year)]
|
|
702
|
-
if (state.history.length >
|
|
705
|
+
if (state.history.length > MAX_ARCHIVE) state.history.length = MAX_ARCHIVE
|
|
703
706
|
const nextYear = toInt(state.season.year, new Date().getFullYear()) + 1
|
|
704
707
|
state.season = createSeason(nextYear, now)
|
|
705
708
|
return bill
|
package/lib/runtime.js
CHANGED
|
@@ -433,10 +433,7 @@ class Runtime {
|
|
|
433
433
|
lastCatch: this.lastCatch,
|
|
434
434
|
questsLoaded: this.questsByTitle.size > 0,
|
|
435
435
|
canUndo: Boolean(
|
|
436
|
-
this.state.
|
|
437
|
-
this.state.undo.season &&
|
|
438
|
-
this.state.season.tasks.length === 0 &&
|
|
439
|
-
core.summarize(this.state.season, false).totalFish === 0,
|
|
436
|
+
Array.isArray(this.state.undoStack) && this.state.undoStack.length > 0,
|
|
440
437
|
),
|
|
441
438
|
tab: (this.state.ui && this.state.ui.tab) || 'stats',
|
|
442
439
|
}
|
|
@@ -561,18 +558,18 @@ class Runtime {
|
|
|
561
558
|
}
|
|
562
559
|
|
|
563
560
|
checkout(options) {
|
|
564
|
-
const summary = core.summarize(this.state.season, false)
|
|
565
|
-
if (summary.totalFish === 0 && this.state.season.tasks.length === 0) {
|
|
566
|
-
return { ok: false, error: '本年度还没有渔获或任务记录,无需收摊。' }
|
|
567
|
-
}
|
|
568
561
|
const previousSeason = JSON.parse(JSON.stringify(this.state.season))
|
|
569
562
|
const imageDataUrl =
|
|
570
563
|
options && typeof options.imageDataUrl === 'string' ? options.imageDataUrl : ''
|
|
571
564
|
const bill = core.archiveSeason(this.state, this.now(), imageDataUrl)
|
|
572
|
-
this.state.
|
|
565
|
+
if (!Array.isArray(this.state.undoStack)) this.state.undoStack = []
|
|
566
|
+
this.state.undoStack.push({
|
|
573
567
|
season: previousSeason,
|
|
574
568
|
bill,
|
|
575
569
|
at: stamp(this.now()),
|
|
570
|
+
})
|
|
571
|
+
if (this.state.undoStack.length > 100) {
|
|
572
|
+
this.state.undoStack.splice(0, this.state.undoStack.length - 100)
|
|
576
573
|
}
|
|
577
574
|
core.updateUi(this.state, 'stats')
|
|
578
575
|
this.questsByTitle.clear()
|
|
@@ -588,31 +585,29 @@ class Runtime {
|
|
|
588
585
|
}
|
|
589
586
|
|
|
590
587
|
undoCheckout() {
|
|
591
|
-
const
|
|
588
|
+
const stack = Array.isArray(this.state.undoStack) ? this.state.undoStack : []
|
|
589
|
+
const undo = stack[stack.length - 1]
|
|
592
590
|
if (!undo || !undo.season || !undo.bill) {
|
|
593
591
|
return { ok: false, error: '没有可以撤销的收摊记录。' }
|
|
594
592
|
}
|
|
595
|
-
if (
|
|
596
|
-
this.state.season.tasks.length > 0 ||
|
|
597
|
-
core.summarize(this.state.season, false).totalFish > 0
|
|
598
|
-
) {
|
|
599
|
-
return { ok: false, error: '当前年度已经产生了新记录,不能再撤销上一次收摊。' }
|
|
600
|
-
}
|
|
601
593
|
this.state.season = undo.season
|
|
602
594
|
this.state.history = (this.state.history || []).filter(
|
|
603
595
|
(bill) => !(bill.year === undo.bill.year && bill.closedAt === undo.bill.closedAt),
|
|
604
596
|
)
|
|
605
|
-
|
|
597
|
+
stack.pop()
|
|
606
598
|
core.updateUi(this.state, 'stats')
|
|
607
599
|
this.questsByTitle.clear()
|
|
608
600
|
this.questsById.clear()
|
|
609
601
|
this.lastCatch = null
|
|
610
602
|
this.persist()
|
|
611
603
|
this.emit()
|
|
612
|
-
toast(
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
604
|
+
toast(
|
|
605
|
+
`已撤销收摊,恢复到 ${this.state.season.year} 年${stack.length > 0 ? ';可继续点“取消”。' : '。'}`,
|
|
606
|
+
{
|
|
607
|
+
type: 'info',
|
|
608
|
+
title: '鱼来鱼来',
|
|
609
|
+
},
|
|
610
|
+
)
|
|
616
611
|
return { ok: true, year: this.state.season.year }
|
|
617
612
|
}
|
|
618
613
|
}
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "poi-plugin-yulaiyulai",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"_requested": {
|
|
5
|
-
"raw": "poi-plugin-yulaiyulai-1.
|
|
5
|
+
"raw": "poi-plugin-yulaiyulai-1.3.0.tgz"
|
|
6
6
|
},
|
|
7
7
|
"description": "鱼来鱼来:秋刀鱼活动渔获统计,按图/点记录,同步任务与奖励,按年度结账。",
|
|
8
8
|
"main": "index.es",
|
package/views/panel.es
CHANGED
|
@@ -1838,7 +1838,6 @@ function Footer({ view, runtime, onTemplate }) {
|
|
|
1838
1838
|
const [error, setError] = useState('')
|
|
1839
1839
|
const season = view.season
|
|
1840
1840
|
const summary = view.summary
|
|
1841
|
-
const canCheckout = summary.totalFish > 0 || (season.tasks && season.tasks.length > 0)
|
|
1842
1841
|
|
|
1843
1842
|
const confirm = () => {
|
|
1844
1843
|
let imageDataUrl = ''
|
|
@@ -1904,7 +1903,9 @@ function Footer({ view, runtime, onTemplate }) {
|
|
|
1904
1903
|
{view.canUndo ? (
|
|
1905
1904
|
<>
|
|
1906
1905
|
<br />
|
|
1907
|
-
<span style={{ color: COLORS.teal }}
|
|
1906
|
+
<span style={{ color: COLORS.teal }}>
|
|
1907
|
+
已收摊,可点“取消”撤销;可连续取消多年。
|
|
1908
|
+
</span>
|
|
1908
1909
|
</>
|
|
1909
1910
|
) : null}
|
|
1910
1911
|
</Muted>
|
|
@@ -1917,7 +1918,7 @@ function Footer({ view, runtime, onTemplate }) {
|
|
|
1917
1918
|
onClick={undoCheckout}
|
|
1918
1919
|
title={
|
|
1919
1920
|
view.canUndo
|
|
1920
|
-
? '
|
|
1921
|
+
? '撤销最近一次收摊,恢复上一年度;可连续撤销'
|
|
1921
1922
|
: '当前没有可撤销的收摊'
|
|
1922
1923
|
}
|
|
1923
1924
|
/>
|
|
@@ -1925,13 +1926,12 @@ function Footer({ view, runtime, onTemplate }) {
|
|
|
1925
1926
|
small
|
|
1926
1927
|
intent={Intent.PRIMARY}
|
|
1927
1928
|
icon="archive"
|
|
1928
|
-
disabled={!canCheckout}
|
|
1929
1929
|
onClick={() => {
|
|
1930
1930
|
setError('')
|
|
1931
1931
|
setPending(true)
|
|
1932
1932
|
}}
|
|
1933
1933
|
text="收摊"
|
|
1934
|
-
title=
|
|
1934
|
+
title="封存本年度并开始下一年度;没有记录也可以收摊"
|
|
1935
1935
|
/>
|
|
1936
1936
|
</div>
|
|
1937
1937
|
</div>
|