poi-plugin-kancolle-chs 1.3.8 → 1.4.1
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/index.es +4 -1
- package/package.json +1 -1
- package/src/config.es +3 -2
- package/src/constants.es +1 -1
- package/src/core/startup-checker.es +136 -0
- package/src/views/MainPanel.es +299 -24
package/index.es
CHANGED
|
@@ -3,6 +3,7 @@ import { configManager } from './src/config'
|
|
|
3
3
|
import { dataLoader } from './src/loaders/data-loader'
|
|
4
4
|
import { mainPatcher } from './src/core/main-patcher'
|
|
5
5
|
import { resourceManager } from './src/core/resource-manager'
|
|
6
|
+
import { startupChecker } from './src/core/startup-checker'
|
|
6
7
|
|
|
7
8
|
// 导出插件在 POI 中展示的界面组件
|
|
8
9
|
export const reactClass = MainPanel
|
|
@@ -31,7 +32,9 @@ export const pluginDidLoad = async () => {
|
|
|
31
32
|
await mainPatcher.buildAndDeploy()
|
|
32
33
|
}
|
|
33
34
|
|
|
34
|
-
// 4.
|
|
35
|
+
// 4. 后台静默自检:即便用户未打开插件面板,也自动检查更新并在有更新时置顶弹窗提醒
|
|
36
|
+
startupChecker.scheduleStartupCheck(2000)
|
|
37
|
+
|
|
35
38
|
console.log('[砍口垒汉化计划PLUS] 插件加载完毕,原生汉化模式已生效!')
|
|
36
39
|
} else {
|
|
37
40
|
console.log('[砍口垒汉化计划PLUS] 插件当前处于停用状态,确保环境纯净官方原版...')
|
package/package.json
CHANGED
package/src/config.es
CHANGED
|
@@ -93,8 +93,9 @@ class ConfigManager {
|
|
|
93
93
|
|
|
94
94
|
if (saved && typeof saved === 'object') {
|
|
95
95
|
this.config = { ...DEFAULT_CONFIG, ...saved }
|
|
96
|
-
|
|
97
|
-
|
|
96
|
+
// 自动保障:只要自动检查更新为开启状态,汉化资源自检与弹窗提醒同步开启
|
|
97
|
+
if (this.config.autoCheckUpdate !== false) {
|
|
98
|
+
this.config.autoCheckResourceUpdate = true
|
|
98
99
|
}
|
|
99
100
|
} else {
|
|
100
101
|
// 若首次启动且无配置,尝试全平台推荐路径初始化
|
package/src/constants.es
CHANGED
|
@@ -15,7 +15,7 @@ export const OFFICIAL_REPO_GIT = 'https://github.com/asaico/Kancolle_to_CHS.git'
|
|
|
15
15
|
export const OFFICIAL_REPO_RELEASES = 'https://github.com/asaico/Kancolle_to_CHS/releases'
|
|
16
16
|
|
|
17
17
|
// 插件版本与 npm 元信息
|
|
18
|
-
let pkgVersion = '1.
|
|
18
|
+
let pkgVersion = '1.4.1'
|
|
19
19
|
try {
|
|
20
20
|
const pkg = require('../package.json')
|
|
21
21
|
if (pkg && pkg.version) pkgVersion = pkg.version
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { configManager } from '../config'
|
|
2
|
+
import { resourceUpdater } from './resource-updater'
|
|
3
|
+
import { checkPluginUpdate } from './plugin-updater'
|
|
4
|
+
import { PLUGIN_VERSION } from '../constants'
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* POI 启动自检管理器 (单例)
|
|
8
|
+
* 在后台静默检查插件本体版本 (npm) 与本地汉化资源增量 (GitHub)。
|
|
9
|
+
* 检查结果同步派发给插件面板 (MainPanel),由插件内原生的暗黑风格 Blueprint Alert 统一弹窗展示,
|
|
10
|
+
* 彻底移除侵入式的 Windows 原生白色系统对话框。
|
|
11
|
+
*/
|
|
12
|
+
class StartupChecker {
|
|
13
|
+
constructor() {
|
|
14
|
+
this.hasChecked = false
|
|
15
|
+
this.isChecking = false
|
|
16
|
+
this.lastResult = null
|
|
17
|
+
this.listeners = new Set()
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
subscribe(listener) {
|
|
21
|
+
this.listeners.add(listener)
|
|
22
|
+
return () => this.listeners.delete(listener)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
notify() {
|
|
26
|
+
for (const fn of this.listeners) {
|
|
27
|
+
try {
|
|
28
|
+
fn(this.lastResult)
|
|
29
|
+
} catch (_) {}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* 启动时异步后台静默检查 (延迟 2 秒执行,避开 POI 启动窗口与网络初始化高峰)
|
|
35
|
+
*/
|
|
36
|
+
scheduleStartupCheck(delayMs = 2000) {
|
|
37
|
+
if (this.hasChecked) return
|
|
38
|
+
setTimeout(() => {
|
|
39
|
+
this.checkOnStartup().catch((e) => {
|
|
40
|
+
console.warn('[KanCHS] 启动后台自检异常:', e)
|
|
41
|
+
})
|
|
42
|
+
}, delayMs)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* 执行启动自检逻辑
|
|
47
|
+
*/
|
|
48
|
+
async checkOnStartup() {
|
|
49
|
+
if (this.hasChecked || this.isChecking) return
|
|
50
|
+
this.isChecking = true
|
|
51
|
+
this.hasChecked = true
|
|
52
|
+
|
|
53
|
+
// 检查配置开关
|
|
54
|
+
const autoCheck = configManager.get('autoCheckUpdate', true) !== false &&
|
|
55
|
+
configManager.get('autoCheckResourceUpdate', true) !== false
|
|
56
|
+
|
|
57
|
+
if (!autoCheck) {
|
|
58
|
+
console.log('[KanCHS] 启动自检已在配置中关闭,跳过检查。')
|
|
59
|
+
this.isChecking = false
|
|
60
|
+
return
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const sourceDir = configManager.resolveSourcePath()
|
|
64
|
+
const mirrorId = configManager.get('downloadMirror', 'ghproxy')
|
|
65
|
+
|
|
66
|
+
console.log('[KanCHS] 正在后台静默检查插件与汉化资源远端更新...')
|
|
67
|
+
|
|
68
|
+
try {
|
|
69
|
+
// 并发检查插件本体版本 (npm) 与本地汉化资源增量 (GitHub)
|
|
70
|
+
const [pluginRes, resourceRes] = await Promise.all([
|
|
71
|
+
checkPluginUpdate(PLUGIN_VERSION).catch((err) => {
|
|
72
|
+
console.warn('[KanCHS] 检查插件本体更新异常:', err.message)
|
|
73
|
+
return { hasUpdate: false, latestVersion: PLUGIN_VERSION }
|
|
74
|
+
}),
|
|
75
|
+
sourceDir
|
|
76
|
+
? resourceUpdater.checkIncrementalUpdates({ sourceDir, mirrorId }).catch((err) => {
|
|
77
|
+
console.warn('[KanCHS] 检查汉化资源增量异常:', err.message)
|
|
78
|
+
return null
|
|
79
|
+
})
|
|
80
|
+
: null,
|
|
81
|
+
])
|
|
82
|
+
|
|
83
|
+
const hasPlugin = Boolean(pluginRes && pluginRes.hasUpdate)
|
|
84
|
+
const hasResource = Boolean(
|
|
85
|
+
resourceRes &&
|
|
86
|
+
resourceRes.hasUpdate &&
|
|
87
|
+
Array.isArray(resourceRes.changedFiles) &&
|
|
88
|
+
resourceRes.changedFiles.length > 0
|
|
89
|
+
)
|
|
90
|
+
|
|
91
|
+
this.lastResult = {
|
|
92
|
+
pluginRes: pluginRes || { hasUpdate: false, latestVersion: PLUGIN_VERSION },
|
|
93
|
+
resourceRes,
|
|
94
|
+
hasPlugin,
|
|
95
|
+
hasResource,
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
this.notify()
|
|
99
|
+
|
|
100
|
+
if (hasPlugin || hasResource) {
|
|
101
|
+
console.log(`[KanCHS] 发现更新!插件更新: ${hasPlugin}, 资源变动: ${hasResource ? resourceRes.changedFiles.length + '项' : '无'}`)
|
|
102
|
+
this.notifyUpdateToast({
|
|
103
|
+
pluginRes: this.lastResult.pluginRes,
|
|
104
|
+
resourceRes,
|
|
105
|
+
hasPlugin,
|
|
106
|
+
hasResource,
|
|
107
|
+
})
|
|
108
|
+
} else {
|
|
109
|
+
console.log('[KanCHS] 启动自检完成:插件与汉化资源均为最新版本,保持完全静默。')
|
|
110
|
+
}
|
|
111
|
+
} catch (err) {
|
|
112
|
+
console.warn('[KanCHS] 启动检查失败:', err)
|
|
113
|
+
} finally {
|
|
114
|
+
this.isChecking = false
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* 发送 POI 系统 Toast 提示(非侵入式,完全不使用原生白色对话框)
|
|
120
|
+
*/
|
|
121
|
+
notifyUpdateToast({ pluginRes, resourceRes, hasPlugin, hasResource }) {
|
|
122
|
+
try {
|
|
123
|
+
if (typeof window !== 'undefined' && typeof window.toast === 'function') {
|
|
124
|
+
if (hasResource && hasPlugin) {
|
|
125
|
+
window.toast(`[砍口垒汉化] 发现插件 v${pluginRes.latestVersion} 及 ${resourceRes.changedFiles.length} 项资源更新,已在面板就绪!`, { type: 'warning' })
|
|
126
|
+
} else if (hasResource) {
|
|
127
|
+
window.toast(`[砍口垒汉化] 发现 ${resourceRes.changedFiles.length} 项汉化资源可更新,已在面板就绪!`, { type: 'warning' })
|
|
128
|
+
} else if (hasPlugin) {
|
|
129
|
+
window.toast(`[砍口垒汉化] 发现插件新版本 v${pluginRes.latestVersion},已在面板就绪!`, { type: 'warning' })
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
} catch (_) {}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
export const startupChecker = new StartupChecker()
|
package/src/views/MainPanel.es
CHANGED
|
@@ -39,6 +39,7 @@ import {
|
|
|
39
39
|
NPM_PACKAGE_URL,
|
|
40
40
|
} from '../constants'
|
|
41
41
|
import { checkPluginUpdate } from '../core/plugin-updater'
|
|
42
|
+
import { startupChecker } from '../core/startup-checker'
|
|
42
43
|
|
|
43
44
|
export class MainPanel extends Component {
|
|
44
45
|
rootRef = React.createRef()
|
|
@@ -92,6 +93,8 @@ export class MainPanel extends Component {
|
|
|
92
93
|
showUnconfiguredAlert: false, // 启用汉化时资源包未配置提示弹窗
|
|
93
94
|
showRestartConfirm: false, // 重启 POI 客户端二次确认弹窗
|
|
94
95
|
showResourceUpdateAlert: false, // 启动或检查检测到本地汉化资源有更新提醒弹窗
|
|
96
|
+
showPluginUpdateAlert: false, // 启动或检查检测到插件本体有新版本更新提醒弹窗
|
|
97
|
+
showPostUpdateRestartAlert: false, // 资源更新完成后提示是否自动清缓存并重启弹窗
|
|
95
98
|
logs: [],
|
|
96
99
|
}
|
|
97
100
|
}
|
|
@@ -121,19 +124,39 @@ export class MainPanel extends Component {
|
|
|
121
124
|
}).catch(() => {})
|
|
122
125
|
}
|
|
123
126
|
|
|
124
|
-
//
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
127
|
+
// 监听与同步全局启动自检结果 (由 index.es 或 MainPanel 触发)
|
|
128
|
+
this.unsubStartupChecker = startupChecker.subscribe((res) => {
|
|
129
|
+
if (res) {
|
|
130
|
+
this.setState({
|
|
131
|
+
pluginUpdate: res.pluginRes || this.state.pluginUpdate,
|
|
132
|
+
resourceUpdaterStatus: {
|
|
133
|
+
...this.state.resourceUpdaterStatus,
|
|
134
|
+
hasIncrementalUpdate: res.hasResource,
|
|
135
|
+
changedFiles: res.resourceRes?.changedFiles || [],
|
|
136
|
+
},
|
|
137
|
+
showResourceUpdateAlert: res.hasResource,
|
|
138
|
+
showPluginUpdateAlert: res.hasPlugin,
|
|
139
|
+
})
|
|
140
|
+
}
|
|
141
|
+
})
|
|
133
142
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
this.
|
|
143
|
+
if (startupChecker.lastResult) {
|
|
144
|
+
const res = startupChecker.lastResult
|
|
145
|
+
this.setState({
|
|
146
|
+
pluginUpdate: res.pluginRes || this.state.pluginUpdate,
|
|
147
|
+
resourceUpdaterStatus: {
|
|
148
|
+
...this.state.resourceUpdaterStatus,
|
|
149
|
+
hasIncrementalUpdate: res.hasResource,
|
|
150
|
+
changedFiles: res.resourceRes?.changedFiles || [],
|
|
151
|
+
},
|
|
152
|
+
showResourceUpdateAlert: res.hasResource,
|
|
153
|
+
showPluginUpdateAlert: res.hasPlugin,
|
|
154
|
+
})
|
|
155
|
+
} else {
|
|
156
|
+
const shouldAutoCheck = this.state.config.autoCheckUpdate !== false
|
|
157
|
+
if (shouldAutoCheck && !startupChecker.hasChecked) {
|
|
158
|
+
startupChecker.scheduleStartupCheck(500)
|
|
159
|
+
}
|
|
137
160
|
}
|
|
138
161
|
|
|
139
162
|
// 针对旧版 POI 或特定主题外层容器修正高度与滚动上下文
|
|
@@ -205,6 +228,7 @@ export class MainPanel extends Component {
|
|
|
205
228
|
if (this.pluginUpdateNoticeTimer) clearTimeout(this.pluginUpdateNoticeTimer)
|
|
206
229
|
if (this.unsubConfig) this.unsubConfig()
|
|
207
230
|
if (this.unsubGit) this.unsubGit()
|
|
231
|
+
if (this.unsubStartupChecker) this.unsubStartupChecker()
|
|
208
232
|
if (typeof window !== 'undefined') {
|
|
209
233
|
window.removeEventListener('resize', this.handleResize)
|
|
210
234
|
}
|
|
@@ -510,6 +534,22 @@ export class MainPanel extends Component {
|
|
|
510
534
|
}
|
|
511
535
|
}
|
|
512
536
|
|
|
537
|
+
/**
|
|
538
|
+
* 清除游戏缓存并自动重启 POI 客户端 (更新完成后一键执行)
|
|
539
|
+
*/
|
|
540
|
+
executeClearCacheAndRestartPoi = async () => {
|
|
541
|
+
this.setState({ showPostUpdateRestartAlert: false })
|
|
542
|
+
this.addLog('正在全方位清理游戏底层缓存与会话数据...')
|
|
543
|
+
try {
|
|
544
|
+
await resourceManager.clearGameCache()
|
|
545
|
+
this.addLog('游戏缓存清理完成,即将自动重启 POI 客户端...')
|
|
546
|
+
} catch (e) {
|
|
547
|
+
console.warn('清理游戏缓存异常:', e)
|
|
548
|
+
this.addLog(`清理游戏缓存轻微异常: ${e.message},继续执行重启...`)
|
|
549
|
+
}
|
|
550
|
+
this.executeRestartPoi()
|
|
551
|
+
}
|
|
552
|
+
|
|
513
553
|
/**
|
|
514
554
|
* 点击切换总开关 (弹出二次确认弹窗,防止用户误触并支持自动清缓存刷新)
|
|
515
555
|
*/
|
|
@@ -977,6 +1017,81 @@ export class MainPanel extends Component {
|
|
|
977
1017
|
}
|
|
978
1018
|
}
|
|
979
1019
|
|
|
1020
|
+
/**
|
|
1021
|
+
* 一键检查插件和汉化资源的更新
|
|
1022
|
+
* @param {boolean} silent 是否静默检查 (后台自动检查不显示全局状态文字,但若有资源更新依旧弹窗)
|
|
1023
|
+
*/
|
|
1024
|
+
handleCheckAllUpdates = async (silent = false) => {
|
|
1025
|
+
this.setState({ isCheckingPluginUpdate: true })
|
|
1026
|
+
if (!silent) {
|
|
1027
|
+
this.setState({
|
|
1028
|
+
statusMessage: '正在一键检查插件本体与汉化资源更新...',
|
|
1029
|
+
statusIntent: Intent.PRIMARY,
|
|
1030
|
+
})
|
|
1031
|
+
this.addLog('正在一键检查插件本体(npm)与汉化资源包(GitHub)远端更新...')
|
|
1032
|
+
}
|
|
1033
|
+
|
|
1034
|
+
try {
|
|
1035
|
+
// 并发执行:1. 插件 npm 版本检查 2. 汉化资源增量文件哈希比对
|
|
1036
|
+
const [pluginRes] = await Promise.all([
|
|
1037
|
+
checkPluginUpdate(PLUGIN_VERSION).catch((e) => {
|
|
1038
|
+
this.addLog(`检查插件更新失败: ${e.message}`)
|
|
1039
|
+
return { hasUpdate: false, latestVersion: PLUGIN_VERSION }
|
|
1040
|
+
}),
|
|
1041
|
+
this.handleCheckIncrementalUpdates({
|
|
1042
|
+
isAutoStartup: silent,
|
|
1043
|
+
showAlert: true,
|
|
1044
|
+
}).catch((e) => {
|
|
1045
|
+
this.addLog(`检查汉化资源更新失败: ${e.message}`)
|
|
1046
|
+
return null
|
|
1047
|
+
}),
|
|
1048
|
+
])
|
|
1049
|
+
|
|
1050
|
+
this.setState({
|
|
1051
|
+
pluginUpdate: pluginRes || { hasUpdate: false, latestVersion: PLUGIN_VERSION },
|
|
1052
|
+
isCheckingPluginUpdate: false,
|
|
1053
|
+
hidePluginUpdateNotice: false,
|
|
1054
|
+
})
|
|
1055
|
+
|
|
1056
|
+
if (pluginRes && pluginRes.hasUpdate) {
|
|
1057
|
+
this.addLog(`🎉 发现插件新版本: v${pluginRes.latestVersion} (当前已安装: v${PLUGIN_VERSION})`)
|
|
1058
|
+
this.setState({ showPluginUpdateAlert: true })
|
|
1059
|
+
if (!silent) {
|
|
1060
|
+
this.setState({
|
|
1061
|
+
statusMessage: `🎉 发现插件新版本 v${pluginRes.latestVersion}!请前往 POI「设置 - 插件」面板更新`,
|
|
1062
|
+
statusIntent: Intent.WARNING,
|
|
1063
|
+
})
|
|
1064
|
+
}
|
|
1065
|
+
} else {
|
|
1066
|
+
this.addLog(`插件本体当前已是最新版本 (v${PLUGIN_VERSION})`)
|
|
1067
|
+
}
|
|
1068
|
+
|
|
1069
|
+
if (!silent) {
|
|
1070
|
+
const hasResUpdate = Boolean(
|
|
1071
|
+
this.state.resourceUpdaterStatus &&
|
|
1072
|
+
this.state.resourceUpdaterStatus.hasIncrementalUpdate &&
|
|
1073
|
+
this.state.resourceUpdaterStatus.changedFiles &&
|
|
1074
|
+
this.state.resourceUpdaterStatus.changedFiles.length > 0
|
|
1075
|
+
)
|
|
1076
|
+
if (!pluginRes?.hasUpdate && !hasResUpdate) {
|
|
1077
|
+
this.setState({
|
|
1078
|
+
statusMessage: `✅ 检查完成:插件本体与汉化资源包均为最新版本!`,
|
|
1079
|
+
statusIntent: Intent.SUCCESS,
|
|
1080
|
+
})
|
|
1081
|
+
}
|
|
1082
|
+
}
|
|
1083
|
+
} catch (err) {
|
|
1084
|
+
this.setState({
|
|
1085
|
+
isCheckingPluginUpdate: false,
|
|
1086
|
+
statusMessage: `检查更新失败: ${err.message}`,
|
|
1087
|
+
statusIntent: Intent.DANGER,
|
|
1088
|
+
})
|
|
1089
|
+
this.addLog(`一键检查更新异常: ${err.message}`)
|
|
1090
|
+
} finally {
|
|
1091
|
+
this.setState({ isCheckingPluginUpdate: false })
|
|
1092
|
+
}
|
|
1093
|
+
}
|
|
1094
|
+
|
|
980
1095
|
/**
|
|
981
1096
|
* 极度健壮的打开本地文件夹方法 (优先 Electron openPath,兜底 Windows explorer)
|
|
982
1097
|
*/
|
|
@@ -1240,6 +1355,7 @@ export class MainPanel extends Component {
|
|
|
1240
1355
|
isUpdating: false,
|
|
1241
1356
|
updateType: null,
|
|
1242
1357
|
},
|
|
1358
|
+
showPostUpdateRestartAlert: true,
|
|
1243
1359
|
})
|
|
1244
1360
|
await this.refreshAllStatus()
|
|
1245
1361
|
} catch (e) {
|
|
@@ -1280,12 +1396,13 @@ export class MainPanel extends Component {
|
|
|
1280
1396
|
*/
|
|
1281
1397
|
handleCheckIncrementalUpdates = async (options = {}) => {
|
|
1282
1398
|
const isAutoStartup = Boolean(options && options.isAutoStartup)
|
|
1399
|
+
const showAlert = options && options.showAlert !== undefined ? Boolean(options.showAlert) : true
|
|
1283
1400
|
const sourceDir = configManager.resolveSourcePath()
|
|
1284
1401
|
if (!sourceDir) {
|
|
1285
1402
|
if (!isAutoStartup) {
|
|
1286
1403
|
this.setState({ statusMessage: '尚未配置汉化资源包路径,请先指定或下载资源包', statusIntent: Intent.WARNING })
|
|
1287
1404
|
}
|
|
1288
|
-
return
|
|
1405
|
+
return null
|
|
1289
1406
|
}
|
|
1290
1407
|
|
|
1291
1408
|
if (!isAutoStartup) {
|
|
@@ -1307,11 +1424,11 @@ export class MainPanel extends Component {
|
|
|
1307
1424
|
hasIncrementalUpdate: true,
|
|
1308
1425
|
changedFiles: res.changedFiles,
|
|
1309
1426
|
},
|
|
1310
|
-
showResourceUpdateAlert:
|
|
1311
|
-
statusMessage:
|
|
1312
|
-
statusIntent: Intent.
|
|
1427
|
+
showResourceUpdateAlert: showAlert,
|
|
1428
|
+
statusMessage: `🎉 检测到 ${res.changedFiles.length} 个汉化资源文件可更新`,
|
|
1429
|
+
statusIntent: Intent.WARNING,
|
|
1313
1430
|
})
|
|
1314
|
-
this.addLog(
|
|
1431
|
+
this.addLog(`🎉 检测到 ${res.changedFiles.length} 个汉化资源文件与远端有差异${showAlert ? ',已弹出更新提醒窗口' : ''}`)
|
|
1315
1432
|
} else {
|
|
1316
1433
|
this.setState({
|
|
1317
1434
|
resourceUpdaterStatus: {
|
|
@@ -1326,6 +1443,7 @@ export class MainPanel extends Component {
|
|
|
1326
1443
|
this.addLog('启动自检完成:本地汉化资源已是最新版本,无变动文件')
|
|
1327
1444
|
}
|
|
1328
1445
|
}
|
|
1446
|
+
return res
|
|
1329
1447
|
} catch (e) {
|
|
1330
1448
|
if (!isAutoStartup) {
|
|
1331
1449
|
this.setState({
|
|
@@ -1334,6 +1452,7 @@ export class MainPanel extends Component {
|
|
|
1334
1452
|
})
|
|
1335
1453
|
}
|
|
1336
1454
|
this.addLog(`检查汉化资源变动失败: ${e.message}`)
|
|
1455
|
+
return null
|
|
1337
1456
|
} finally {
|
|
1338
1457
|
if (!isAutoStartup) {
|
|
1339
1458
|
this.setState({ isProcessing: false })
|
|
@@ -1383,6 +1502,7 @@ export class MainPanel extends Component {
|
|
|
1383
1502
|
},
|
|
1384
1503
|
statusMessage: '轻量化更新成功!所有变动词条已自动合流并重新部署生效',
|
|
1385
1504
|
statusIntent: Intent.SUCCESS,
|
|
1505
|
+
showPostUpdateRestartAlert: true,
|
|
1386
1506
|
})
|
|
1387
1507
|
await this.refreshAllStatus()
|
|
1388
1508
|
} catch (e) {
|
|
@@ -1701,6 +1821,8 @@ export class MainPanel extends Component {
|
|
|
1701
1821
|
showTimeoutAlert,
|
|
1702
1822
|
showRestartConfirm,
|
|
1703
1823
|
showResourceUpdateAlert,
|
|
1824
|
+
showPluginUpdateAlert,
|
|
1825
|
+
showPostUpdateRestartAlert,
|
|
1704
1826
|
logs,
|
|
1705
1827
|
} = this.state
|
|
1706
1828
|
|
|
@@ -1918,11 +2040,21 @@ export class MainPanel extends Component {
|
|
|
1918
2040
|
small
|
|
1919
2041
|
minimal
|
|
1920
2042
|
icon="refresh"
|
|
1921
|
-
title="
|
|
1922
|
-
text={
|
|
1923
|
-
|
|
2043
|
+
title="一键检查插件本体(npm)与汉化资源包(GitHub)更新"
|
|
2044
|
+
text={
|
|
2045
|
+
isCheckingPluginUpdate
|
|
2046
|
+
? '检查中...'
|
|
2047
|
+
: (pluginUpdate.hasUpdate && resourceUpdaterStatus.hasIncrementalUpdate)
|
|
2048
|
+
? '发现更新! (插件+资源)'
|
|
2049
|
+
: pluginUpdate.hasUpdate
|
|
2050
|
+
? `插件新版 v${pluginUpdate.latestVersion}!`
|
|
2051
|
+
: resourceUpdaterStatus.hasIncrementalUpdate
|
|
2052
|
+
? `资源可更新 (${(resourceUpdaterStatus.changedFiles || []).length})`
|
|
2053
|
+
: (isCompact ? '检查更新' : '一键检查更新')
|
|
2054
|
+
}
|
|
2055
|
+
intent={(pluginUpdate.hasUpdate || resourceUpdaterStatus.hasIncrementalUpdate) ? Intent.WARNING : Intent.NONE}
|
|
1924
2056
|
loading={isCheckingPluginUpdate}
|
|
1925
|
-
onClick={() => this.
|
|
2057
|
+
onClick={() => this.handleCheckAllUpdates(false)}
|
|
1926
2058
|
/>
|
|
1927
2059
|
<Button
|
|
1928
2060
|
small
|
|
@@ -2427,9 +2559,19 @@ export class MainPanel extends Component {
|
|
|
2427
2559
|
|
|
2428
2560
|
<div style={{ marginTop: '8px' }}>
|
|
2429
2561
|
<Switch
|
|
2430
|
-
label="
|
|
2431
|
-
checked={config.autoCheckResourceUpdate !==
|
|
2432
|
-
onChange={() =>
|
|
2562
|
+
label="每次启动 POI 时静默自动检查更新并在有更新时弹窗提示"
|
|
2563
|
+
checked={config.autoCheckResourceUpdate !== false && config.autoCheckUpdate !== false}
|
|
2564
|
+
onChange={() => {
|
|
2565
|
+
const current = config.autoCheckResourceUpdate !== false && config.autoCheckUpdate !== false
|
|
2566
|
+
configManager.update({
|
|
2567
|
+
autoCheckUpdate: !current,
|
|
2568
|
+
autoCheckResourceUpdate: !current,
|
|
2569
|
+
})
|
|
2570
|
+
this.setState({
|
|
2571
|
+
statusMessage: `已${!current ? '开启' : '关闭'}每次启动 POI 自动检查更新提醒`,
|
|
2572
|
+
statusIntent: Intent.SUCCESS,
|
|
2573
|
+
})
|
|
2574
|
+
}}
|
|
2433
2575
|
/>
|
|
2434
2576
|
</div>
|
|
2435
2577
|
</div>
|
|
@@ -3422,6 +3564,139 @@ export class MainPanel extends Component {
|
|
|
3422
3564
|
</div>
|
|
3423
3565
|
</div>
|
|
3424
3566
|
</Alert>
|
|
3567
|
+
|
|
3568
|
+
{/* 启动与一键检查发现更新时的统一提醒弹窗 (资源更新 / 插件更新 / 两者皆有) */}
|
|
3569
|
+
<Alert
|
|
3570
|
+
isOpen={showResourceUpdateAlert || showPluginUpdateAlert}
|
|
3571
|
+
cancelButtonText="稍后再说"
|
|
3572
|
+
confirmButtonText={
|
|
3573
|
+
resourceUpdaterStatus.hasIncrementalUpdate
|
|
3574
|
+
? (isCompact ? '立即更新资源' : `⚡ 立即轻量更新资源 (${(resourceUpdaterStatus.changedFiles || []).length}项)`)
|
|
3575
|
+
: '查看插件发布页'
|
|
3576
|
+
}
|
|
3577
|
+
intent={Intent.PRIMARY}
|
|
3578
|
+
icon={pluginUpdate.hasUpdate && resourceUpdaterStatus.hasIncrementalUpdate ? 'notifications' : (resourceUpdaterStatus.hasIncrementalUpdate ? 'cloud-download' : 'updated')}
|
|
3579
|
+
onCancel={() => this.setState({ showResourceUpdateAlert: false, showPluginUpdateAlert: false })}
|
|
3580
|
+
onConfirm={() => {
|
|
3581
|
+
const hasRes = resourceUpdaterStatus.hasIncrementalUpdate
|
|
3582
|
+
this.setState({ showResourceUpdateAlert: false, showPluginUpdateAlert: false })
|
|
3583
|
+
if (hasRes) {
|
|
3584
|
+
this.handleApplyIncrementalUpdates()
|
|
3585
|
+
} else {
|
|
3586
|
+
this.handleOpenExternal(pluginUpdate.npmUrl || NPM_PACKAGE_URL)
|
|
3587
|
+
}
|
|
3588
|
+
}}
|
|
3589
|
+
canOutsideClickCancel={true}
|
|
3590
|
+
canEscapeKeyCancel={true}
|
|
3591
|
+
className={isDarkTheme ? 'bp3-dark bp4-dark kancolle-chs-dark-theme' : ''}
|
|
3592
|
+
style={{ maxWidth: '540px' }}
|
|
3593
|
+
>
|
|
3594
|
+
<div style={{ lineHeight: '1.6' }}>
|
|
3595
|
+
<h5 style={{ margin: '0 0 10px 0', fontSize: '15px', fontWeight: 'bold' }}>
|
|
3596
|
+
{pluginUpdate.hasUpdate && resourceUpdaterStatus.hasIncrementalUpdate
|
|
3597
|
+
? '🎉 发现插件与汉化资源均有新更新!'
|
|
3598
|
+
: pluginUpdate.hasUpdate
|
|
3599
|
+
? '🎉 发现砍口垒汉化计划PLUS插件新版本!'
|
|
3600
|
+
: '📦 发现本地汉化资源有新更新!'}
|
|
3601
|
+
</h5>
|
|
3602
|
+
|
|
3603
|
+
{/* 插件本体更新板块 */}
|
|
3604
|
+
{pluginUpdate.hasUpdate && (
|
|
3605
|
+
<div
|
|
3606
|
+
style={{
|
|
3607
|
+
padding: '10px 12px',
|
|
3608
|
+
background: 'rgba(16, 107, 163, 0.08)',
|
|
3609
|
+
borderRadius: '6px',
|
|
3610
|
+
borderLeft: '4px solid #106ba3',
|
|
3611
|
+
marginBottom: resourceUpdaterStatus.hasIncrementalUpdate ? '12px' : '8px',
|
|
3612
|
+
}}
|
|
3613
|
+
>
|
|
3614
|
+
<div style={{ fontWeight: 'bold', fontSize: '13px', color: '#106ba3' }}>
|
|
3615
|
+
🚀 插件本体新版本: v{pluginUpdate.latestVersion}(当前已安装: v{PLUGIN_VERSION})
|
|
3616
|
+
</div>
|
|
3617
|
+
<div style={{ fontSize: '12px', color: '#444', marginTop: '4px' }}>
|
|
3618
|
+
更新方法:点击 POI 顶部菜单【设置】➔【插件】➔ 找到【砍口垒汉化计划PLUS】点击【更新】即可。
|
|
3619
|
+
</div>
|
|
3620
|
+
</div>
|
|
3621
|
+
)}
|
|
3622
|
+
|
|
3623
|
+
{/* 汉化资源更新板块 */}
|
|
3624
|
+
{resourceUpdaterStatus.hasIncrementalUpdate && (
|
|
3625
|
+
<div>
|
|
3626
|
+
<p style={{ margin: '0 0 8px 0', fontSize: '13px' }}>
|
|
3627
|
+
经比对官方汉化仓库,检测到本地有 <strong>{(resourceUpdaterStatus.changedFiles || []).length}</strong> 个汉化文件可更新:
|
|
3628
|
+
</p>
|
|
3629
|
+
{(resourceUpdaterStatus.changedFiles || []).length > 0 && (
|
|
3630
|
+
<div
|
|
3631
|
+
style={{
|
|
3632
|
+
maxHeight: '130px',
|
|
3633
|
+
overflowY: 'auto',
|
|
3634
|
+
background: 'rgba(0,0,0,0.03)',
|
|
3635
|
+
padding: '8px 10px',
|
|
3636
|
+
borderRadius: '6px',
|
|
3637
|
+
border: '1px solid rgba(0,0,0,0.08)',
|
|
3638
|
+
marginBottom: '10px',
|
|
3639
|
+
fontSize: '12px',
|
|
3640
|
+
fontFamily: 'monospace',
|
|
3641
|
+
}}
|
|
3642
|
+
>
|
|
3643
|
+
<div style={{ fontWeight: 'bold', marginBottom: '4px', color: '#0d8050' }}>变动文件列表:</div>
|
|
3644
|
+
{(resourceUpdaterStatus.changedFiles || []).slice(0, 8).map((f, idx) => (
|
|
3645
|
+
<div key={idx} style={{ whiteSpace: 'nowrap', overflow: 'hidden', textOverflow: 'ellipsis' }}>
|
|
3646
|
+
• {typeof f === 'string' ? f : (f.path || f.file || JSON.stringify(f))}
|
|
3647
|
+
</div>
|
|
3648
|
+
))}
|
|
3649
|
+
{(resourceUpdaterStatus.changedFiles || []).length > 8 && (
|
|
3650
|
+
<div style={{ color: '#888', fontStyle: 'italic', marginTop: '2px' }}>
|
|
3651
|
+
... 等共 {(resourceUpdaterStatus.changedFiles || []).length} 个文件
|
|
3652
|
+
</div>
|
|
3653
|
+
)}
|
|
3654
|
+
</div>
|
|
3655
|
+
)}
|
|
3656
|
+
<div style={{ fontSize: '12px', color: '#666' }}>
|
|
3657
|
+
💡 推荐执行轻量增量更新,仅下载替换变动文件,耗时极短且无需重新下载完整资源包。
|
|
3658
|
+
</div>
|
|
3659
|
+
</div>
|
|
3660
|
+
)}
|
|
3661
|
+
</div>
|
|
3662
|
+
</Alert>
|
|
3663
|
+
|
|
3664
|
+
{/* 汉化资源更新完成后的清缓存并重启确认弹窗 */}
|
|
3665
|
+
<Alert
|
|
3666
|
+
isOpen={showPostUpdateRestartAlert}
|
|
3667
|
+
cancelButtonText="稍后手动重启"
|
|
3668
|
+
confirmButtonText="⚡ 清缓存并重启 POI"
|
|
3669
|
+
intent={Intent.PRIMARY}
|
|
3670
|
+
icon="refresh"
|
|
3671
|
+
onCancel={() => this.setState({ showPostUpdateRestartAlert: false })}
|
|
3672
|
+
onConfirm={this.executeClearCacheAndRestartPoi}
|
|
3673
|
+
canOutsideClickCancel={true}
|
|
3674
|
+
canEscapeKeyCancel={true}
|
|
3675
|
+
className={isDarkTheme ? 'bp3-dark bp4-dark kancolle-chs-dark-theme' : ''}
|
|
3676
|
+
style={{ maxWidth: '480px' }}
|
|
3677
|
+
>
|
|
3678
|
+
<div style={{ lineHeight: '1.6' }}>
|
|
3679
|
+
<h5 style={{ margin: '0 0 10px 0', fontSize: '15px', fontWeight: 'bold' }}>
|
|
3680
|
+
🎉 汉化资源已更新完成!
|
|
3681
|
+
</h5>
|
|
3682
|
+
<p style={{ margin: '0 0 10px 0', fontSize: '13px' }}>
|
|
3683
|
+
所有汉化资源已成功下载并自动完成合流注入。<br />
|
|
3684
|
+
是否立即<strong>自动清理游戏缓存并重启 POI</strong>,使最新资源彻底生效?
|
|
3685
|
+
</p>
|
|
3686
|
+
<div
|
|
3687
|
+
style={{
|
|
3688
|
+
fontSize: '12px',
|
|
3689
|
+
color: '#d9822b',
|
|
3690
|
+
background: 'rgba(217, 130, 43, 0.1)',
|
|
3691
|
+
padding: '8px 10px',
|
|
3692
|
+
borderRadius: '4px',
|
|
3693
|
+
borderLeft: '3px solid #d9822b',
|
|
3694
|
+
}}
|
|
3695
|
+
>
|
|
3696
|
+
<span>💡 <strong>安全建议:</strong>若当前舰队正在出击战斗中,建议点击「稍后手动重启」,待出击结束回港安全后再行重启。</span>
|
|
3697
|
+
</div>
|
|
3698
|
+
</div>
|
|
3699
|
+
</Alert>
|
|
3425
3700
|
</div>
|
|
3426
3701
|
)
|
|
3427
3702
|
}
|