Skip to content

Commit 1c6e084

Browse files
committed
Enable ts strict mode, refactor tag dialog
1 parent cad70e3 commit 1c6e084

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+351
-365
lines changed

_includes/script-theme.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
savedTheme = THEME_AUTO
1212
localStorage.setItem(KEY_THEME, savedTheme)
1313
}
14-
const bodyE = document.getElementsByTagName("body")[0];
14+
const bodyE = document.body;
1515
// 默认是没有.dark的,在确定是暗黑模式时加上.dark
1616
// 默认是没有theme-color的,在这里根据主题加上
1717
if (savedTheme === THEME_DARK

_posts/original/2021-08-03-为博客添加站内搜索和暗黑模式.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ const KEY_THEME = "theme"
101101
// 读取保存的用户主题设置
102102
const savedTheme = localStorage.getItem(KEY_THEME)
103103
console.log("saved theme = " + savedTheme)
104-
const bodyE = document.querySelector("body")
104+
const bodyE = document.body
105105
// 根据用户设置显示对应主题
106106
if (savedTheme == THEME_DARK) {
107107
bodyE.classList.add("dark")

npm/dist/blog-404-v2.0.0.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

npm/dist/blog-index-v2.0.0.js

Lines changed: 1 addition & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

npm/dist/blog-index-v2.0.0.js.LICENSE.txt

Lines changed: 0 additions & 19 deletions
This file was deleted.

npm/dist/blog-post-v2.0.0.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

npm/dist/blog-runtime-v2.0.0.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

npm/dist/blog-scaffold-v2.0.0.js

Lines changed: 14 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

npm/src/base/ResizeHeightObserver.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,21 @@ import { consoleDebug } from "../util/log"
22

33
export class ResizeHeightObserver {
44
callback: (width: number) => void
5-
lastTimeout: NodeJS.Timeout = null
5+
lastTimeout: NodeJS.Timeout | null = null
66
lastHeight = -1
77
resizeObserver = new ResizeObserver((entries) => {
88
const entry = entries.pop()
9-
if (entry.contentRect.height == this.lastHeight) {
9+
if (entry!!.contentRect.height == this.lastHeight) {
1010
// 高度没有变化
1111
return
1212
}
13-
this.lastHeight = entry.contentRect.height
13+
this.lastHeight = entry!!.contentRect.height
1414
if (this.lastTimeout != null) {
1515
clearTimeout(this.lastTimeout)
1616
}
1717
this.lastTimeout = setTimeout(() => {
18-
consoleDebug("ResizeHeightObserver height changed after delay " + entry.contentRect.height)
19-
this.callback(entry.contentRect.height)
18+
consoleDebug("ResizeHeightObserver height changed after delay " + entry!!.contentRect.height)
19+
this.callback(entry!!.contentRect.height)
2020
}, 200)
2121
})
2222
constructor(e: HTMLElement, callback: (height: number) => void) {

npm/src/base/ResizeWidthObserver.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,25 @@ import { consoleDebug } from "../util/log"
22

33
export class ResizeWidthObserver {
44
callback: (width: number) => void
5-
lastTimeout: NodeJS.Timeout = null
5+
lastTimeout: NodeJS.Timeout | null = null
66
lastWidth = -1
77
resizeObserver = new ResizeObserver((entries) => {
88
const entry = entries.pop()
9-
if (entry.contentRect.width == this.lastWidth) {
9+
if (entry!!.contentRect.width == this.lastWidth) {
1010
// 宽度没有变化
1111
return
1212
}
13-
if (entry.contentRect.width == 0) {
13+
if (entry!!.contentRect.width == 0) {
1414
// 宽度变为0是什么情况🙄
1515
return
1616
}
17-
this.lastWidth = entry.contentRect.width
17+
this.lastWidth = entry!!.contentRect.width
1818
if (this.lastTimeout != null) {
1919
clearTimeout(this.lastTimeout)
2020
}
2121
this.lastTimeout = setTimeout(() => {
22-
consoleDebug("ResizeWidthObserver width changed after delay " + entry.contentRect.width)
23-
this.callback(entry.contentRect.width)
22+
consoleDebug("ResizeWidthObserver width changed after delay " + entry!!.contentRect.width)
23+
this.callback(entry!!.contentRect.width)
2424
}, 200)
2525
})
2626
constructor(e: HTMLElement, callback: (width: number) => void) {

0 commit comments

Comments
 (0)