refactor(main.ts): 优化窗口对象类型断言的使用
将重复的 `(window as any)` 类型断言提取为 `winAny` 变量,提高代码可读性和维护性
This commit is contained in:
parent
e64b49f03d
commit
f5dbe4470f
|
|
@ -211,7 +211,8 @@ window.onload = function () {
|
|||
})
|
||||
|
||||
// 向父窗口暴露:显示保存状态(文本、颜色、延时可选)
|
||||
;(window as any).showSaveStatus = (text: string, color?: string, delay?: number) => {
|
||||
const winAny = window as any
|
||||
winAny.showSaveStatus = (text: string, color?: string, delay?: number) => {
|
||||
try {
|
||||
const indicator = document.getElementById('save-status-indicator') as HTMLDivElement | null
|
||||
if (!indicator) return
|
||||
|
|
@ -221,11 +222,11 @@ window.onload = function () {
|
|||
indicator.style.display = 'block'
|
||||
// 清理之前的隐藏计时器
|
||||
const key = '__save_status_timer__'
|
||||
const prev = (window as any)[key]
|
||||
const prev = winAny[key]
|
||||
if (prev) {
|
||||
window.clearTimeout(prev)
|
||||
}
|
||||
;(window as any)[key] = window.setTimeout(() => {
|
||||
winAny[key] = window.setTimeout(() => {
|
||||
indicator.style.display = 'none'
|
||||
}, duration)
|
||||
} catch (err) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user