mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-06-01 15:10:14 +00:00
fix(使所有主题的404能够正常运转): 同时让获取文章DOM节点也避免公告栏等其他位置的干扰
This commit is contained in:
@@ -304,7 +304,7 @@ const Layout404 = props => {
|
||||
// 延时3秒如果加载失败就返回首页
|
||||
setTimeout(() => {
|
||||
if (isBrowser) {
|
||||
const article = document.getElementById('notion-article')
|
||||
const article = document.querySelector('#article-wrapper #notion-article')
|
||||
if (!article) {
|
||||
router.push('/').then(() => {
|
||||
// console.log('找不到页面', router.asPath)
|
||||
|
||||
@@ -162,7 +162,7 @@ const LayoutSlug = props => {
|
||||
setTimeout(
|
||||
() => {
|
||||
if (isBrowser) {
|
||||
const article = document.getElementById('notion-article')
|
||||
const article = document.querySelector('#article-wrapper #notion-article')
|
||||
if (!article) {
|
||||
router.push('/404').then(() => {
|
||||
console.warn('找不到页面', router.asPath)
|
||||
|
||||
@@ -143,7 +143,7 @@ const LayoutSlug = props => {
|
||||
setTimeout(
|
||||
() => {
|
||||
if (isBrowser) {
|
||||
const article = document.getElementById('notion-article')
|
||||
const article = document.querySelector('#article-wrapper #notion-article')
|
||||
if (!article) {
|
||||
router.push('/404').then(() => {
|
||||
console.warn('找不到页面', router.asPath)
|
||||
|
||||
@@ -255,7 +255,7 @@ const LayoutIndex = props => {
|
||||
// 重定向到指定文章
|
||||
router.push(index).then(() => {
|
||||
setTimeout(() => {
|
||||
const article = document.getElementById('notion-article')
|
||||
const article = document.querySelector('#article-wrapper #notion-article')
|
||||
if (!article) {
|
||||
console.log(
|
||||
'请检查您的Notion数据库中是否包含此slug页面: ',
|
||||
@@ -309,7 +309,7 @@ const LayoutSlug = props => {
|
||||
setTimeout(
|
||||
() => {
|
||||
if (isBrowser) {
|
||||
const article = document.getElementById('notion-article')
|
||||
const article = document.querySelector('#article-wrapper #notion-article')
|
||||
if (!article) {
|
||||
router.push('/404').then(() => {
|
||||
console.warn('找不到页面', router.asPath)
|
||||
|
||||
@@ -273,7 +273,7 @@ const LayoutSlug = props => {
|
||||
setTimeout(
|
||||
() => {
|
||||
if (isBrowser) {
|
||||
const article = document.getElementById('notion-article')
|
||||
const article = document.querySelector('#article-wrapper #notion-article')
|
||||
if (!article) {
|
||||
router.push('/404').then(() => {
|
||||
console.warn('找不到页面', router.asPath)
|
||||
|
||||
@@ -269,7 +269,7 @@ const LayoutSlug = props => {
|
||||
setTimeout(
|
||||
() => {
|
||||
if (isBrowser) {
|
||||
const article = document.getElementById('notion-article')
|
||||
const article = document.querySelector('#article-wrapper #notion-article')
|
||||
if (!article) {
|
||||
router.push('/404').then(() => {
|
||||
console.warn('找不到页面', router.asPath)
|
||||
@@ -333,7 +333,7 @@ const Layout404 = props => {
|
||||
// 延时3秒如果加载失败就返回首页
|
||||
setTimeout(() => {
|
||||
if (isBrowser) {
|
||||
const article = document.getElementById('notion-article')
|
||||
const article = document.querySelector('#article-wrapper #notion-article')
|
||||
if (!article) {
|
||||
router.push('/').then(() => {
|
||||
// console.log('找不到页面', router.asPath)
|
||||
|
||||
@@ -82,7 +82,7 @@ const LayoutSlug = props => {
|
||||
setTimeout(
|
||||
() => {
|
||||
if (isBrowser) {
|
||||
const article = document.getElementById('notion-article')
|
||||
const article = document.querySelector('#article-wrapper #notion-article')
|
||||
if (!article) {
|
||||
router.push('/404').then(() => {
|
||||
console.warn('找不到页面', router.asPath)
|
||||
|
||||
@@ -155,7 +155,7 @@ const LayoutSlug = props => {
|
||||
setTimeout(
|
||||
() => {
|
||||
if (isBrowser) {
|
||||
const article = document.getElementById('notion-article')
|
||||
const article = document.querySelector('#article-wrapper #notion-article')
|
||||
if (!article) {
|
||||
router.push('/404').then(() => {
|
||||
console.warn('找不到页面', router.asPath)
|
||||
|
||||
@@ -29,7 +29,7 @@ export default function WordCount() {
|
||||
* 更新字数统计和阅读时间
|
||||
*/
|
||||
function countWords() {
|
||||
const articleText = deleteHtmlTag(document.getElementById('notion-article')?.innerHTML)
|
||||
const articleText = deleteHtmlTag(document.querySelector('#article-wrapper #notion-article')?.innerHTML)
|
||||
const wordCount = fnGetCpmisWords(articleText)
|
||||
// 阅读速度 300-500每分钟
|
||||
document.getElementById('wordCount').innerHTML = wordCount
|
||||
|
||||
@@ -231,7 +231,7 @@ const LayoutSlug = props => {
|
||||
setTimeout(
|
||||
() => {
|
||||
if (isBrowser) {
|
||||
const article = document.getElementById('notion-article')
|
||||
const article = document.querySelector('#article-wrapper #notion-article')
|
||||
if (!article) {
|
||||
router.push('/404').then(() => {
|
||||
console.warn('找不到页面', router.asPath)
|
||||
@@ -320,7 +320,7 @@ const Layout404 = props => {
|
||||
setTimeout(() => {
|
||||
const article =
|
||||
typeof document !== 'undefined' &&
|
||||
document.getElementById('notion-article')
|
||||
document.querySelector('#article-wrapper #notion-article')
|
||||
if (!article) {
|
||||
router.push('/').then(() => {
|
||||
// console.log('找不到页面', router.asPath)
|
||||
|
||||
@@ -191,7 +191,7 @@ const LayoutSlug = props => {
|
||||
setTimeout(
|
||||
() => {
|
||||
if (isBrowser) {
|
||||
const article = document.getElementById('notion-article')
|
||||
const article = document.querySelector('#article-wrapper #notion-article')
|
||||
if (!article) {
|
||||
router.push('/404').then(() => {
|
||||
console.warn('找不到页面', router.asPath)
|
||||
|
||||
@@ -156,7 +156,7 @@ const LayoutSlug = props => {
|
||||
// 用js 实现将页面中的多个视频聚合为一个分集的视频
|
||||
function combineVideo() {
|
||||
// 找到 id 为 notion-article 的元素
|
||||
const notionArticle = document.getElementById('notion-article')
|
||||
const notionArticle = document.querySelector('#article-wrapper #notion-article')
|
||||
if (!notionArticle) return // 如果找不到对应的元素,则退出函数
|
||||
|
||||
// 找到所有的 .notion-asset-wrapper 元素
|
||||
@@ -291,7 +291,7 @@ const LayoutSlug = props => {
|
||||
setTimeout(
|
||||
() => {
|
||||
if (isBrowser) {
|
||||
const article = document.getElementById('notion-article')
|
||||
const article = document.querySelector('#article-wrapper #notion-article')
|
||||
if (!article) {
|
||||
router.push('/404').then(() => {
|
||||
console.warn('找不到页面', router.asPath)
|
||||
|
||||
@@ -261,7 +261,7 @@ const LayoutSlug = props => {
|
||||
setTimeout(
|
||||
() => {
|
||||
if (isBrowser) {
|
||||
const article = document.getElementById('notion-article')
|
||||
const article = document.querySelector('#article-wrapper #notion-article')
|
||||
if (!article) {
|
||||
router.push('/404').then(() => {
|
||||
console.warn('找不到页面', router.asPath)
|
||||
|
||||
@@ -23,7 +23,7 @@ export default function WordCount() {
|
||||
* 更新字数统计和阅读时间
|
||||
*/
|
||||
function countWords() {
|
||||
const articleText = deleteHtmlTag(document.getElementById('notion-article')?.innerHTML)
|
||||
const articleText = deleteHtmlTag(document.querySelector('#article-wrapper #notion-article')?.innerHTML)
|
||||
const wordCount = fnGetCpmisWords(articleText)
|
||||
// 阅读速度 300-500每分钟
|
||||
document.getElementById('wordCount').innerHTML = wordCount
|
||||
|
||||
@@ -328,7 +328,7 @@ const LayoutSlug = props => {
|
||||
setTimeout(
|
||||
() => {
|
||||
if (isBrowser) {
|
||||
const article = document.getElementById('notion-article')
|
||||
const article = document.querySelector('#article-wrapper #notion-article')
|
||||
if (!article) {
|
||||
router.push('/404').then(() => {
|
||||
console.warn('找不到页面', router.asPath)
|
||||
|
||||
@@ -227,7 +227,7 @@ const LayoutSlug = props => {
|
||||
setTimeout(
|
||||
() => {
|
||||
if (isBrowser) {
|
||||
const article = document.getElementById('notion-article')
|
||||
const article = document.querySelector('#article-wrapper #notion-article')
|
||||
if (!article) {
|
||||
router.push('/404').then(() => {
|
||||
console.warn('找不到页面', router.asPath)
|
||||
|
||||
@@ -156,7 +156,7 @@ const LayoutSlug = props => {
|
||||
// 用js 实现将页面中的多个视频聚合为一个分集的视频
|
||||
function combineVideo() {
|
||||
// 找到 id 为 notion-article 的元素
|
||||
const notionArticle = document.getElementById('notion-article')
|
||||
const notionArticle = document.querySelector('#article-wrapper #notion-article')
|
||||
if (!notionArticle) return // 如果找不到对应的元素,则退出函数
|
||||
|
||||
// 找到所有的 .notion-asset-wrapper 元素
|
||||
@@ -291,7 +291,7 @@ const LayoutSlug = props => {
|
||||
setTimeout(
|
||||
() => {
|
||||
if (isBrowser) {
|
||||
const article = document.getElementById('notion-article')
|
||||
const article = document.querySelector('#article-wrapper #notion-article')
|
||||
if (!article) {
|
||||
router.push('/404').then(() => {
|
||||
console.warn('找不到页面', router.asPath)
|
||||
|
||||
@@ -182,7 +182,7 @@ const LayoutSlug = props => {
|
||||
setTimeout(
|
||||
() => {
|
||||
if (isBrowser) {
|
||||
const article = document.getElementById('notion-article')
|
||||
const article = document.querySelector('#article-wrapper #notion-article')
|
||||
if (!article) {
|
||||
router.push('/404').then(() => {
|
||||
console.warn('找不到页面', router.asPath)
|
||||
|
||||
@@ -273,7 +273,7 @@ const Layout404 = props => {
|
||||
setTimeout(
|
||||
() => {
|
||||
if (isBrowser) {
|
||||
const article = document.getElementById('notion-article')
|
||||
const article = document.querySelector('#article-wrapper #notion-article')
|
||||
if (!article) {
|
||||
router.push('/404').then(() => {
|
||||
console.warn('找不到页面', router.asPath)
|
||||
|
||||
Reference in New Issue
Block a user