hexo-theme-shokax 0.4.4 → 0.4.6-beta1
Sign up to get free protection for your applications and to get access to all the features.
- package/CODE_OF_CONDUCT.md +128 -128
- package/CONTRIBUTING.md +58 -58
- package/LICENSE +660 -660
- package/LICENSE-shoka +21 -21
- package/README.md +99 -98
- package/README_en.MD +91 -90
- package/UsageRestrictions.md +25 -25
- package/_config.yml +381 -388
- package/_images.yml +9 -9
- package/eslint.config.mjs +55 -55
- package/index.html +231 -0
- package/languages/README.md +19 -19
- package/languages/default.yml +1 -1
- package/languages/en.yml +153 -153
- package/languages/ja.yml +153 -153
- package/languages/zh-CN.yml +153 -153
- package/languages/zh-HK.yml +153 -153
- package/languages/zh-TW.yml +153 -153
- package/layout/_alternate/atom.ejs +30 -30
- package/layout/_alternate/json.ejs +16 -16
- package/layout/_alternate/rss.ejs +34 -34
- package/layout/_mixin/breadcrumb.pug +33 -33
- package/layout/_mixin/card.pug +38 -38
- package/layout/_mixin/comment.pug +6 -6
- package/layout/_mixin/postmeta.pug +29 -29
- package/layout/_mixin/segment.pug +35 -35
- package/layout/_mixin/sidebar.pug +40 -40
- package/layout/_mixin/widgets.pug +28 -28
- package/layout/_partials/footer.pug +43 -43
- package/layout/_partials/head/head.pug +55 -56
- package/layout/_partials/head/head_com.pug +24 -24
- package/layout/_partials/head/pwa.pug +18 -18
- package/layout/_partials/header.pug +18 -18
- package/layout/_partials/layout.pug +140 -140
- package/layout/_partials/loading.pug +13 -13
- package/layout/_partials/pagination.pug +4 -4
- package/layout/_partials/post/copyright.pug +20 -20
- package/layout/_partials/post/footer.pug +17 -17
- package/layout/_partials/post/nav.pug +13 -13
- package/layout/_partials/post/post.pug +41 -41
- package/layout/_partials/post/reward.pug +18 -18
- package/layout/_partials/sidebar/menu.pug +37 -37
- package/layout/_partials/sidebar/overview.pug +42 -42
- package/layout/_partials/third-party/baidu-analytics.pug +11 -11
- package/layout/_partials/third-party/clarity.pug +8 -8
- package/layout/_partials/third-party/google-analytics.pug +9 -9
- package/layout/archive.pug +118 -118
- package/layout/category.pug +59 -59
- package/layout/index.pug +33 -33
- package/layout/page.pug +55 -55
- package/layout/post.pug +36 -36
- package/layout/tag.pug +43 -43
- package/meta.json +6431 -0
- package/package.json +72 -70
- package/scripts/helpers/engine.js +10 -0
- package/scripts/plugin/check.js +2 -2
- package/scripts/tags/links.js +4 -4
- package/source/assets/algolia_logo.svg +9 -9
- package/source/assets/logo.svg +16 -16
- package/source/css/_colors.styl +207 -207
- package/source/css/_common/components/components.styl +6 -6
- package/source/css/_common/components/highlight/highlight.styl +357 -357
- package/source/css/_common/components/highlight/operation.styl +21 -21
- package/source/css/_common/components/pages/collapse.styl +119 -119
- package/source/css/_common/components/pages/home.styl +391 -391
- package/source/css/_common/components/pages/pages.styl +56 -56
- package/source/css/_common/components/pages/tag-cloud.styl +12 -12
- package/source/css/_common/components/post/breadcrumb.styl +39 -39
- package/source/css/_common/components/post/copyright.styl +41 -41
- package/source/css/_common/components/post/expand.styl +263 -263
- package/source/css/_common/components/post/footer.styl +11 -11
- package/source/css/_common/components/post/header.styl +79 -79
- package/source/css/_common/components/post/nav.styl +64 -64
- package/source/css/_common/components/post/post.styl +29 -29
- package/source/css/_common/components/post/reward.styl +50 -50
- package/source/css/_common/components/post/rtl.styl +12 -12
- package/source/css/_common/components/post/tags.styl +39 -39
- package/source/css/_common/components/tags/collapse.styl +72 -72
- package/source/css/_common/components/tags/container.styl +49 -49
- package/source/css/_common/components/tags/label.styl +12 -12
- package/source/css/_common/components/tags/links.styl +77 -77
- package/source/css/_common/components/tags/list.styl +131 -131
- package/source/css/_common/components/tags/note.styl +70 -70
- package/source/css/_common/components/tags/player.styl +361 -361
- package/source/css/_common/components/tags/quiz.styl +200 -200
- package/source/css/_common/components/tags/tabs.styl +89 -89
- package/source/css/_common/components/tags/tags.styl +9 -9
- package/source/css/_common/components/third-party/loading.styl +222 -222
- package/source/css/_common/components/third-party/mermaid/class.styl +90 -90
- package/source/css/_common/components/third-party/mermaid/flowchart.styl +72 -72
- package/source/css/_common/components/third-party/mermaid/gantt.styl +251 -251
- package/source/css/_common/components/third-party/mermaid/git.styl +7 -7
- package/source/css/_common/components/third-party/mermaid/mermaid.styl +37 -37
- package/source/css/_common/components/third-party/mermaid/pie.styl +9 -9
- package/source/css/_common/components/third-party/mermaid/sequence.styl +95 -95
- package/source/css/_common/components/third-party/mermaid/state.styl +130 -130
- package/source/css/_common/components/third-party/pace.styl +18 -18
- package/source/css/_common/components/third-party/search.styl +167 -167
- package/source/css/_common/components/third-party/theme.styl +151 -151
- package/source/css/_common/components/third-party/third-party.styl +22 -22
- package/source/css/_common/components/third-party/widgets.styl +57 -57
- package/source/css/_common/outline/footer/footer.styl +67 -67
- package/source/css/_common/outline/header/brand.styl +77 -77
- package/source/css/_common/outline/header/header.styl +20 -20
- package/source/css/_common/outline/header/image.styl +85 -85
- package/source/css/_common/outline/header/menu.styl +117 -117
- package/source/css/_common/outline/header/nav.styl +81 -81
- package/source/css/_common/outline/header/right.styl +15 -15
- package/source/css/_common/outline/header/tool.styl +207 -207
- package/source/css/_common/outline/header/waves.styl +57 -57
- package/source/css/_common/outline/mobile.styl +46 -46
- package/source/css/_common/outline/outline.styl +78 -78
- package/source/css/_common/outline/sidebar/author.styl +59 -59
- package/source/css/_common/outline/sidebar/dimmer.styl +23 -23
- package/source/css/_common/outline/sidebar/menu.styl +63 -63
- package/source/css/_common/outline/sidebar/quick.styl +43 -43
- package/source/css/_common/outline/sidebar/related.styl +56 -56
- package/source/css/_common/outline/sidebar/sidebar.styl +80 -80
- package/source/css/_common/outline/sidebar/social.styl +69 -69
- package/source/css/_common/outline/sidebar/state.styl +37 -37
- package/source/css/_common/outline/sidebar/tab.styl +71 -71
- package/source/css/_common/outline/sidebar/toc.styl +47 -47
- package/source/css/_common/scaffolding/animate.styl +322 -322
- package/source/css/_common/scaffolding/base.styl +190 -190
- package/source/css/_common/scaffolding/buttons.styl +48 -48
- package/source/css/_common/scaffolding/divider.styl +36 -36
- package/source/css/_common/scaffolding/iconfont.styl +443 -443
- package/source/css/_common/scaffolding/normalize.styl +273 -273
- package/source/css/_common/scaffolding/pagination.styl +81 -81
- package/source/css/_common/scaffolding/ribbon.styl +38 -38
- package/source/css/_common/scaffolding/scaffolding.styl +14 -14
- package/source/css/_common/scaffolding/scrollbar.styl +37 -37
- package/source/css/_common/scaffolding/tables.styl +50 -50
- package/source/css/_common/scaffolding/tip.styl +19 -19
- package/source/css/_common/scaffolding/toggles.styl +59 -59
- package/source/css/_iconfont.styl +455 -455
- package/source/css/_mixins.styl +148 -148
- package/source/css/_variables.styl +89 -89
- package/source/css/app.styl +41 -41
- package/source/css/mermaid.styl +5 -5
- package/source/css/optimize.styl +5 -5
- package/source/js/_app/components/comments.js +59 -0
- package/source/js/_app/components/comments.ts +88 -89
- package/source/js/_app/components/sidebar.js +244 -0
- package/source/js/_app/components/sidebar.ts +239 -239
- package/source/js/_app/components/tcomments.js +47 -0
- package/source/js/_app/components/tcomments.ts +54 -55
- package/source/js/_app/globals/globalVars.ts +99 -99
- package/source/js/_app/globals/handles.js +105 -0
- package/source/js/_app/globals/handles.ts +124 -123
- package/source/js/_app/globals/themeColor.ts +63 -64
- package/source/js/_app/globals/thirdparty.ts +63 -63
- package/source/js/_app/globals/tools.ts +75 -75
- package/source/js/_app/library/anime.ts +110 -110
- package/source/js/_app/library/declare.d.ts +128 -133
- package/source/js/_app/library/dom.ts +28 -26
- package/source/js/_app/library/loadFile.js +43 -0
- package/source/js/_app/library/loadFile.ts +47 -43
- package/source/js/_app/library/proto.ts +137 -141
- package/source/js/_app/library/scriptPjax.ts +72 -72
- package/source/js/_app/library/storage.ts +12 -12
- package/source/js/_app/library/vue.js +52 -0
- package/source/js/_app/library/vue.ts +49 -50
- package/source/js/_app/page/common.js +45 -0
- package/source/js/_app/page/common.ts +43 -42
- package/source/js/_app/page/fancybox.js +70 -0
- package/source/js/_app/page/fancybox.ts +72 -71
- package/source/js/_app/page/post.js +253 -0
- package/source/js/_app/page/post.ts +266 -266
- package/source/js/_app/page/search.js +111 -0
- package/source/js/_app/page/search.ts +115 -115
- package/source/js/_app/page/tab.ts +60 -60
- package/source/js/_app/pjax/domInit.js +80 -0
- package/source/js/_app/pjax/domInit.ts +97 -97
- package/source/js/_app/pjax/refresh.js +137 -0
- package/source/js/_app/pjax/refresh.ts +140 -138
- package/source/js/_app/pjax/siteInit.js +115 -0
- package/source/js/_app/pjax/siteInit.ts +106 -104
- package/source/js/_app/player.js +777 -0
- package/source/js/_app/player.ts +798 -799
- package/toolbox/compiler.mjs +73 -0
- package/toolbox/hoistdep.mjs +6 -0
- package/toolbox/lib.mjs +40 -0
@@ -1,99 +1,99 @@
|
|
1
|
-
import { $dom } from '../library/dom'
|
2
|
-
import Pjax from 'theme-shokax-pjax'
|
3
|
-
import initProto from '../library/proto'
|
4
|
-
|
5
|
-
export const CONFIG = shokax_CONFIG
|
6
|
-
initProto()
|
7
|
-
export const statics = CONFIG.statics.indexOf('//') > 0 ? CONFIG.statics : CONFIG.root
|
8
|
-
export const scrollAction: { x: number, y: number } = { x: 0, y: 0 }
|
9
|
-
export let diffY = 0
|
10
|
-
export let originTitle: string, titleTime: NodeJS.Timeout
|
11
|
-
export const BODY = document.getElementsByTagName('body')[0]
|
12
|
-
export const HTML = document.documentElement
|
13
|
-
export const Container =
|
14
|
-
export const loadCat =
|
15
|
-
export const siteNav =
|
16
|
-
export const siteHeader =
|
17
|
-
export const menuToggle = siteNav.
|
18
|
-
export const quickBtn =
|
19
|
-
export const sideBar =
|
20
|
-
export const siteBrand =
|
21
|
-
export let toolBtn =
|
22
|
-
export let toolPlayer
|
23
|
-
export let backToTop: HTMLElement
|
24
|
-
export let goToComment
|
25
|
-
export let showContents
|
26
|
-
export let siteSearch =
|
27
|
-
export let siteNavHeight: number, headerHightInner: number, headerHight: number
|
28
|
-
export let oWinHeight = window.innerHeight
|
29
|
-
export let oWinWidth = window.innerWidth
|
30
|
-
export let LOCAL_HASH = 0
|
31
|
-
export let LOCAL_URL = window.location.href
|
32
|
-
export let pjax:Pjax
|
33
|
-
|
34
|
-
export function setSiteNavHeight (value:number):void {
|
35
|
-
siteNavHeight = value
|
36
|
-
}
|
37
|
-
export function setHeaderHightInner (value:number):void {
|
38
|
-
headerHightInner = value
|
39
|
-
}
|
40
|
-
|
41
|
-
export function setHeaderHight (value:number):void {
|
42
|
-
headerHight = value
|
43
|
-
}
|
44
|
-
|
45
|
-
export function setOWinHeight (value:number):void {
|
46
|
-
oWinHeight = value
|
47
|
-
}
|
48
|
-
|
49
|
-
export function setOWinWidth (value:number):void {
|
50
|
-
oWinWidth = value
|
51
|
-
}
|
52
|
-
|
53
|
-
export function setDiffY (value:number):void {
|
54
|
-
diffY = value
|
55
|
-
}
|
56
|
-
|
57
|
-
export function setTitleTime (value:NodeJS.Timeout):void {
|
58
|
-
titleTime = value
|
59
|
-
}
|
60
|
-
|
61
|
-
export function setLocalHash (value:number):void {
|
62
|
-
LOCAL_HASH = value
|
63
|
-
}
|
64
|
-
|
65
|
-
export function setLocalUrl (value:string):void {
|
66
|
-
LOCAL_URL = value
|
67
|
-
}
|
68
|
-
|
69
|
-
export function setPjax (value:Pjax):void {
|
70
|
-
pjax = value
|
71
|
-
}
|
72
|
-
|
73
|
-
export function setOriginTitle (value:string):void {
|
74
|
-
originTitle = value
|
75
|
-
}
|
76
|
-
|
77
|
-
export function setToolPlayer (value:any):void {
|
78
|
-
toolPlayer = value
|
79
|
-
}
|
80
|
-
|
81
|
-
export function setBackToTop (value:HTMLElement):void {
|
82
|
-
backToTop = value
|
83
|
-
}
|
84
|
-
|
85
|
-
export function setGoToComment (value:any):void {
|
86
|
-
goToComment = value
|
87
|
-
}
|
88
|
-
|
89
|
-
export function setShowContents (value:any):void {
|
90
|
-
showContents = value
|
91
|
-
}
|
92
|
-
|
93
|
-
export function setToolBtn (value:HTMLElement):void {
|
94
|
-
toolBtn = value
|
95
|
-
}
|
96
|
-
|
97
|
-
export function setSiteSearch (value:HTMLElement):void {
|
98
|
-
siteSearch = value
|
99
|
-
}
|
1
|
+
import { $dom } from '../library/dom'
|
2
|
+
import Pjax from 'theme-shokax-pjax'
|
3
|
+
import initProto from '../library/proto'
|
4
|
+
|
5
|
+
export const CONFIG = shokax_CONFIG
|
6
|
+
initProto()
|
7
|
+
export const statics = CONFIG.statics.indexOf('//') > 0 ? CONFIG.statics : CONFIG.root
|
8
|
+
export const scrollAction: { x: number, y: number } = { x: 0, y: 0 }
|
9
|
+
export let diffY = 0
|
10
|
+
export let originTitle: string, titleTime: NodeJS.Timeout
|
11
|
+
export const BODY = document.getElementsByTagName('body')[0]
|
12
|
+
export const HTML = document.documentElement
|
13
|
+
export const Container = document.getElementById('container')
|
14
|
+
export const loadCat = document.getElementById('loading')
|
15
|
+
export const siteNav = document.getElementById('nav')
|
16
|
+
export const siteHeader = document.getElementById('header')
|
17
|
+
export const menuToggle = siteNav.querySelector('.toggle')
|
18
|
+
export const quickBtn = document.getElementById('quick')
|
19
|
+
export const sideBar = document.getElementById('sidebar')
|
20
|
+
export const siteBrand = document.getElementById('brand')
|
21
|
+
export let toolBtn = document.getElementById('tool')
|
22
|
+
export let toolPlayer
|
23
|
+
export let backToTop: HTMLElement
|
24
|
+
export let goToComment
|
25
|
+
export let showContents
|
26
|
+
export let siteSearch = document.getElementById('search')
|
27
|
+
export let siteNavHeight: number, headerHightInner: number, headerHight: number
|
28
|
+
export let oWinHeight = window.innerHeight
|
29
|
+
export let oWinWidth = window.innerWidth
|
30
|
+
export let LOCAL_HASH = 0
|
31
|
+
export let LOCAL_URL = window.location.href
|
32
|
+
export let pjax:Pjax
|
33
|
+
|
34
|
+
export function setSiteNavHeight (value:number):void {
|
35
|
+
siteNavHeight = value
|
36
|
+
}
|
37
|
+
export function setHeaderHightInner (value:number):void {
|
38
|
+
headerHightInner = value
|
39
|
+
}
|
40
|
+
|
41
|
+
export function setHeaderHight (value:number):void {
|
42
|
+
headerHight = value
|
43
|
+
}
|
44
|
+
|
45
|
+
export function setOWinHeight (value:number):void {
|
46
|
+
oWinHeight = value
|
47
|
+
}
|
48
|
+
|
49
|
+
export function setOWinWidth (value:number):void {
|
50
|
+
oWinWidth = value
|
51
|
+
}
|
52
|
+
|
53
|
+
export function setDiffY (value:number):void {
|
54
|
+
diffY = value
|
55
|
+
}
|
56
|
+
|
57
|
+
export function setTitleTime (value:NodeJS.Timeout):void {
|
58
|
+
titleTime = value
|
59
|
+
}
|
60
|
+
|
61
|
+
export function setLocalHash (value:number):void {
|
62
|
+
LOCAL_HASH = value
|
63
|
+
}
|
64
|
+
|
65
|
+
export function setLocalUrl (value:string):void {
|
66
|
+
LOCAL_URL = value
|
67
|
+
}
|
68
|
+
|
69
|
+
export function setPjax (value:Pjax):void {
|
70
|
+
pjax = value
|
71
|
+
}
|
72
|
+
|
73
|
+
export function setOriginTitle (value:string):void {
|
74
|
+
originTitle = value
|
75
|
+
}
|
76
|
+
|
77
|
+
export function setToolPlayer (value:any):void {
|
78
|
+
toolPlayer = value
|
79
|
+
}
|
80
|
+
|
81
|
+
export function setBackToTop (value:HTMLElement):void {
|
82
|
+
backToTop = value
|
83
|
+
}
|
84
|
+
|
85
|
+
export function setGoToComment (value:any):void {
|
86
|
+
goToComment = value
|
87
|
+
}
|
88
|
+
|
89
|
+
export function setShowContents (value:any):void {
|
90
|
+
showContents = value
|
91
|
+
}
|
92
|
+
|
93
|
+
export function setToolBtn (value:HTMLElement):void {
|
94
|
+
toolBtn = value
|
95
|
+
}
|
96
|
+
|
97
|
+
export function setSiteSearch (value:HTMLElement):void {
|
98
|
+
siteSearch = value
|
99
|
+
}
|
@@ -0,0 +1,105 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.visibilityListener = exports.scrollHandle = exports.resizeHandle = void 0;
|
4
|
+
const sidebar_1 = require("../components/sidebar");
|
5
|
+
const dom_1 = require("../library/dom");
|
6
|
+
const globalVars_1 = require("./globalVars");
|
7
|
+
const themeColor_1 = require("./themeColor");
|
8
|
+
const thirdparty_1 = require("./thirdparty");
|
9
|
+
const proto_1 = require("../library/proto");
|
10
|
+
const resizeHandle = () => {
|
11
|
+
// 获取 siteNav 的高度
|
12
|
+
(0, globalVars_1.setSiteNavHeight)((0, proto_1.getHeight)(globalVars_1.siteNav));
|
13
|
+
// 获取 siteHeader 的高度
|
14
|
+
(0, globalVars_1.setHeaderHightInner)((0, proto_1.getHeight)(globalVars_1.siteHeader));
|
15
|
+
// 获取 #waves 的高度
|
16
|
+
(0, globalVars_1.setHeaderHight)(globalVars_1.headerHightInner + (0, proto_1.getHeight)((0, dom_1.$dom)('#waves')));
|
17
|
+
// 判断窗口宽度是否改变
|
18
|
+
if (globalVars_1.oWinWidth !== window.innerWidth) {
|
19
|
+
(0, sidebar_1.sideBarToggleHandle)(null, 1);
|
20
|
+
}
|
21
|
+
// 记录窗口高度和宽度
|
22
|
+
(0, globalVars_1.setOWinHeight)(window.innerHeight);
|
23
|
+
(0, globalVars_1.setOWinWidth)(window.innerWidth);
|
24
|
+
};
|
25
|
+
exports.resizeHandle = resizeHandle;
|
26
|
+
const scrollHandle = () => {
|
27
|
+
// 获取窗口高度
|
28
|
+
const winHeight = window.innerHeight;
|
29
|
+
// 获取文档高度
|
30
|
+
const docHeight = (0, dom_1.getDocHeight)();
|
31
|
+
// 计算可见内容高度
|
32
|
+
const contentVisibilityHeight = docHeight > winHeight ? docHeight - winHeight : document.body.scrollHeight - winHeight;
|
33
|
+
// 判断页面是否滚动超过 headerHightInner
|
34
|
+
const SHOW = window.scrollY > globalVars_1.headerHightInner;
|
35
|
+
// 判断页面是否开始滚动
|
36
|
+
const startScroll = window.scrollY > 0;
|
37
|
+
// 根据条件修改 meta theme
|
38
|
+
if (SHOW) {
|
39
|
+
(0, themeColor_1.changeMetaTheme)('#FFF');
|
40
|
+
}
|
41
|
+
else {
|
42
|
+
(0, themeColor_1.changeMetaTheme)('#222');
|
43
|
+
}
|
44
|
+
// 控制导航栏的显示隐藏
|
45
|
+
globalVars_1.siteNav.toggleClass('show', SHOW);
|
46
|
+
// 控制网站 logo 的显示隐藏
|
47
|
+
globalVars_1.toolBtn.toggleClass('affix', startScroll);
|
48
|
+
// 控制侧边栏的显示隐藏,当滚动高度大于 headerHight 且窗口宽度大于 991px 时显示
|
49
|
+
globalVars_1.siteBrand.toggleClass('affix', startScroll);
|
50
|
+
globalVars_1.sideBar.toggleClass('affix', window.scrollY > globalVars_1.headerHight && document.body.offsetWidth > 991);
|
51
|
+
// 初始化滚动时导航栏的显示方向
|
52
|
+
if (typeof globalVars_1.scrollAction.y === 'undefined') {
|
53
|
+
globalVars_1.scrollAction.y = window.scrollY;
|
54
|
+
}
|
55
|
+
(0, globalVars_1.setDiffY)(globalVars_1.scrollAction.y - window.scrollY);
|
56
|
+
// 控制滑动时导航栏显示
|
57
|
+
if (globalVars_1.diffY < 0) {
|
58
|
+
globalVars_1.siteNav.removeClass('up');
|
59
|
+
globalVars_1.siteNav.toggleClass('down', SHOW);
|
60
|
+
}
|
61
|
+
else if (globalVars_1.diffY > 0) {
|
62
|
+
globalVars_1.siteNav.removeClass('down');
|
63
|
+
globalVars_1.siteNav.toggleClass('up', SHOW);
|
64
|
+
}
|
65
|
+
else { /* empty */ }
|
66
|
+
globalVars_1.scrollAction.y = window.scrollY;
|
67
|
+
// 计算滚动百分比
|
68
|
+
const scrollPercent = Math.round(Math.min(100 * window.scrollY / contentVisibilityHeight, 100)) + '%';
|
69
|
+
// 更新回到顶部按钮的文字
|
70
|
+
if (globalVars_1.backToTop.child('span').innerText !== scrollPercent) {
|
71
|
+
globalVars_1.backToTop.child('span').innerText = scrollPercent;
|
72
|
+
}
|
73
|
+
// 更新百分比进度条的宽度
|
74
|
+
if ((0, dom_1.$dom)('#sidebar').hasClass('affix') || (0, dom_1.$dom)('#sidebar').hasClass('on')) {
|
75
|
+
(0, proto_1.setWidth)((0, dom_1.$dom)('.percent'), scrollPercent);
|
76
|
+
}
|
77
|
+
};
|
78
|
+
exports.scrollHandle = scrollHandle;
|
79
|
+
// 可见度监听(离开页面和返回时更改document的title)
|
80
|
+
const visibilityListener = () => {
|
81
|
+
const iconNode = (0, dom_1.$dom)('[rel="icon"]');
|
82
|
+
document.addEventListener('visibilitychange', () => {
|
83
|
+
switch (document.visibilityState) {
|
84
|
+
case 'hidden':
|
85
|
+
iconNode.setAttribute('href', globalVars_1.statics + globalVars_1.CONFIG.favicon.hidden);
|
86
|
+
document.title = LOCAL.favicon.hide;
|
87
|
+
if (globalVars_1.CONFIG.loader.switch) {
|
88
|
+
thirdparty_1.Loader.show();
|
89
|
+
}
|
90
|
+
clearTimeout(globalVars_1.titleTime);
|
91
|
+
break;
|
92
|
+
case 'visible':
|
93
|
+
iconNode.setAttribute('href', globalVars_1.statics + globalVars_1.CONFIG.favicon.normal);
|
94
|
+
document.title = LOCAL.favicon.show;
|
95
|
+
if (globalVars_1.CONFIG.loader.switch) {
|
96
|
+
thirdparty_1.Loader.hide(1000);
|
97
|
+
}
|
98
|
+
(0, globalVars_1.setTitleTime)(setTimeout(() => {
|
99
|
+
document.title = globalVars_1.originTitle;
|
100
|
+
}, 2000));
|
101
|
+
break;
|
102
|
+
}
|
103
|
+
}, { passive: true });
|
104
|
+
};
|
105
|
+
exports.visibilityListener = visibilityListener;
|
@@ -1,123 +1,124 @@
|
|
1
|
-
import { sideBarToggleHandle } from '../components/sidebar'
|
2
|
-
import {
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
} from './
|
23
|
-
import {
|
24
|
-
import {
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
siteNav.
|
81
|
-
|
82
|
-
|
83
|
-
siteNav.
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
}
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
document.
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
}
|
1
|
+
import { sideBarToggleHandle } from '../components/sidebar'
|
2
|
+
import {
|
3
|
+
backToTop,
|
4
|
+
diffY,
|
5
|
+
headerHight,
|
6
|
+
headerHightInner,
|
7
|
+
oWinWidth,
|
8
|
+
originTitle,
|
9
|
+
scrollAction,
|
10
|
+
sideBar,
|
11
|
+
siteBrand,
|
12
|
+
siteHeader,
|
13
|
+
siteNav,
|
14
|
+
statics,
|
15
|
+
titleTime,
|
16
|
+
toolBtn,
|
17
|
+
setSiteNavHeight,
|
18
|
+
setHeaderHightInner,
|
19
|
+
setHeaderHight,
|
20
|
+
setOWinHeight, setOWinWidth, setDiffY, setTitleTime, CONFIG
|
21
|
+
} from './globalVars'
|
22
|
+
import { changeMetaTheme } from './themeColor'
|
23
|
+
import { Loader } from './thirdparty'
|
24
|
+
import { getHeight, setWidth } from '../library/proto'
|
25
|
+
|
26
|
+
const wavesEle = document.getElementById('waves')
|
27
|
+
|
28
|
+
export const resizeHandle = () => {
|
29
|
+
// 获取 siteNav 的高度
|
30
|
+
setSiteNavHeight(getHeight(siteNav))
|
31
|
+
// 获取 siteHeader 的高度
|
32
|
+
setHeaderHightInner(getHeight(siteHeader))
|
33
|
+
// 获取 #waves 的高度
|
34
|
+
setHeaderHight(headerHightInner + getHeight(wavesEle))
|
35
|
+
|
36
|
+
// 判断窗口宽度是否改变
|
37
|
+
if (oWinWidth !== window.innerWidth) {
|
38
|
+
sideBarToggleHandle(null, 1)
|
39
|
+
}
|
40
|
+
|
41
|
+
// 记录窗口高度和宽度
|
42
|
+
setOWinHeight(window.innerHeight)
|
43
|
+
setOWinWidth(window.innerWidth)
|
44
|
+
}
|
45
|
+
|
46
|
+
export const scrollHandle = () => {
|
47
|
+
// 获取窗口高度
|
48
|
+
const winHeight = window.innerHeight
|
49
|
+
// 获取文档高度
|
50
|
+
const docHeight = (document.querySelector('main > .inner') as HTMLElement).offsetHeight
|
51
|
+
// 计算可见内容高度
|
52
|
+
const contentVisibilityHeight = docHeight > winHeight ? docHeight - winHeight : document.body.scrollHeight - winHeight
|
53
|
+
// 判断页面是否滚动超过 headerHightInner
|
54
|
+
const SHOW = window.scrollY > headerHightInner
|
55
|
+
// 判断页面是否开始滚动
|
56
|
+
const startScroll = window.scrollY > 0
|
57
|
+
|
58
|
+
// 根据条件修改 meta theme
|
59
|
+
if (SHOW) {
|
60
|
+
changeMetaTheme('#FFF')
|
61
|
+
} else {
|
62
|
+
changeMetaTheme('#222')
|
63
|
+
}
|
64
|
+
|
65
|
+
// 控制导航栏的显示隐藏
|
66
|
+
siteNav.toggleClass('show', SHOW)
|
67
|
+
// 控制网站 logo 的显示隐藏
|
68
|
+
toolBtn.toggleClass('affix', startScroll)
|
69
|
+
// 控制侧边栏的显示隐藏,当滚动高度大于 headerHight 且窗口宽度大于 991px 时显示
|
70
|
+
siteBrand.toggleClass('affix', startScroll)
|
71
|
+
sideBar.toggleClass('affix', window.scrollY > headerHight && document.body.offsetWidth > 991)
|
72
|
+
// 初始化滚动时导航栏的显示方向
|
73
|
+
if (typeof scrollAction.y === 'undefined') {
|
74
|
+
scrollAction.y = window.scrollY
|
75
|
+
}
|
76
|
+
setDiffY(scrollAction.y - window.scrollY)
|
77
|
+
|
78
|
+
// 控制滑动时导航栏显示
|
79
|
+
if (diffY < 0) {
|
80
|
+
siteNav.removeClass('up')
|
81
|
+
siteNav.toggleClass('down', SHOW)
|
82
|
+
} else if (diffY > 0) {
|
83
|
+
siteNav.removeClass('down')
|
84
|
+
siteNav.toggleClass('up', SHOW)
|
85
|
+
} else { /* empty */ }
|
86
|
+
scrollAction.y = window.scrollY
|
87
|
+
// 计算滚动百分比
|
88
|
+
const scrollPercent = Math.round(Math.min(100 * window.scrollY / contentVisibilityHeight, 100)) + '%'
|
89
|
+
// 更新回到顶部按钮的文字
|
90
|
+
if (backToTop.querySelector('span').innerText !== scrollPercent) {
|
91
|
+
backToTop.querySelector('span').innerText = scrollPercent
|
92
|
+
}
|
93
|
+
// 更新百分比进度条的宽度
|
94
|
+
if (document.getElementById('sidebar').hasClass('affix') || document.getElementById('sidebar').hasClass('on')) {
|
95
|
+
setWidth(document.querySelector('.percent'), scrollPercent)
|
96
|
+
}
|
97
|
+
}
|
98
|
+
|
99
|
+
// 可见度监听(离开页面和返回时更改document的title)
|
100
|
+
export const visibilityListener = () => {
|
101
|
+
const iconNode = document.querySelector('[rel="icon"]')
|
102
|
+
document.addEventListener('visibilitychange', () => {
|
103
|
+
switch (document.visibilityState) {
|
104
|
+
case 'hidden':
|
105
|
+
iconNode.setAttribute('href', statics + CONFIG.favicon.hidden)
|
106
|
+
document.title = LOCAL.favicon.hide
|
107
|
+
if (CONFIG.loader.switch) {
|
108
|
+
Loader.show()
|
109
|
+
}
|
110
|
+
clearTimeout(titleTime)
|
111
|
+
break
|
112
|
+
case 'visible':
|
113
|
+
iconNode.setAttribute('href', statics + CONFIG.favicon.normal)
|
114
|
+
document.title = LOCAL.favicon.show
|
115
|
+
if (CONFIG.loader.switch) {
|
116
|
+
Loader.hide(1000)
|
117
|
+
}
|
118
|
+
setTitleTime(setTimeout(() => {
|
119
|
+
document.title = originTitle
|
120
|
+
}, 2000))
|
121
|
+
break
|
122
|
+
}
|
123
|
+
}, { passive: true })
|
124
|
+
}
|