-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
214 lines (200 loc) · 9.2 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>baizita's palace</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name="description" content="Description">
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<link rel="stylesheet" href="./_static/vue.css">
<link rel="stylesheet" href="./_static/mermaid.min.css">
<style>
.markdown-section {
max-width: 80% !important;
}
.edit-btn {
color: var(--theme-color, #42b983);
font-weight: bold;
cursor: pointer
}
.edit-btn:hover {
color: #2e835c;
}
/* 跳到今天按钮 */
.to_current{position:fixed;right:0;top:90px;background:var(--theme-color, #42b983);border:thin solid transparent;border-radius:4px;color:#fff;cursor:pointer;padding:15px 10px;display:none;}
.to_current:hover{background:#fff;border:thin solid var(--theme-color, #42b983);color:var(--theme-color, #42b983);}
</style>
<script src="./_static/mermaid.min.js"></script>
</head>
<body>
<div id="app"></div>
<div class="to_current" onClick="relocate()">跳到今天</div>
<script>
const getURL = URL => {
return new Promise(function(resolve, reject) {
var req = new XMLHttpRequest();
req.open('GET', URL, true);
req.onload = function() {
if (req.status === 200) {
resolve(req.responseText);
} else {
reject(new Error(req.statusText));
}
};
req.onerror = function() {
reject(new Error(req.statusText));
};
req.send();
});
}
const relocate=()=>{
let href = location.href
let date = new Date()
let suffix = "?id=_"+date.getFullYear()+"年"+(date.getMonth()+1)+"月"+date.getDate()+"日"
let index = href.indexOf("?")
//如果不带参数,则下一行和下三行的结果是一样的;如果带了参数,则下一行和下三行的值不一样(下一行执行了没效果),刚好实现了重定向,
location.href =href+suffix
if(index>=0){
location.href = href.slice(0,index)+suffix
}
}
const hideEmptyDailyRecordInCurrentSeason=()=>{
const pnexth3s = [...document.querySelectorAll("h3+p")]
pnexth3s.map((i,j)=>{
let dateELe = i.previousElementSibling
if(!isCurrentDate(dateELe.innerText)&&i.innerHTML==" "){
i.style.display="none"
dateELe.style.display="none"
}
})
function isCurrentDate(text){
//2021年2月25日 ==> 2021-2-25 ==> [2021,2,25]
let dateArr = text.replace(/[年月]/g,"-").replace("日","").split("-").map(i=>Number(i))
let current = new Date()
return dateArr[0]===current.getFullYear()&&dateArr[1]===(current.getMonth()+1)&&dateArr[2]===current.getDate()
}
}
const setPageTitle=()=>{
const ele = document.querySelector("#main").firstElementChild
if(ele.tagName == "H3"){
document.title = ele.innerText
}
}
window.$docsify = {
auto2top: true,
coverpage: true,
executeScript: true,
loadSidebar: true,
loadNavbar: false,
mergeNavbar: true,
//noEmoji:true,
maxLevel: 1,
subMaxLevel: 1,
name: '',
/*search: {
maxAge: 86400000, // 过期时间,单位毫秒,默认一天
paths: 'auto', // or 'auto'
depth: 6,
placeholder: '搜索',
noData: '未找到结果'
},*/
repo: 'https://baizita.zeabur.app/#/',
formatUpdated: '{YYYY}-{MM}-{DD} {HH}:{mm}:{ss}',
//国网绿#00a88e
themeColor: "#00a88e",//'#108c3e',//'rgb(51,133,255)',//'rgb(0,190,6)',//'#e8186c',//定义主题色,默认绿色
//themeColor: ["#19CAAD", 'rgb(51,133,255)', 'rgb(0,190,6)', '#e8186c', "#ECAD9E", "#F4606C"][new Date().getDay()],
plugins: [
function(hook, vm) { //让图片居中显示
hook.afterEach(function(html) {
return html.replace(/<p><img/g, '<p style="text-align:center"><img') //图片居中
.replace(/class="mermaid"/g, 'class="mermaid" style="text-align:center"') //让使用mermaid画流程图居中
});
hook.ready(function() {
mermaid.initialize({ startOnLoad: false });
});
hook.beforeEach(function(md) {
const filePath = decodeURIComponent(vm.route.file);
//添加打开路径,由于将原服务集成于taotie中,所以无法再使用相对路径,故补全了绝对路径。
return md +
'\n----\n' +
'最后更新 {docsify-updated}'
});
hook.doneEach(function() {
mermaid.init(undefined, '.mermaid');
//无图模式的切换
let showImage = localStorage.getItem("showImage"),
imgs = document.querySelectorAll("img,video");
if(showImage == null){
imgs.forEach(i=>i.style.display="none")
}else{
imgs.forEach(i=>i.style.display="inline")
}
//监听图片模式,实现同源页面同步更新模式
window.addEventListener("storage", function (e) {
if(e.key === 'showImage'){
if(e.newValue === null){
imgs.forEach(i=>i.style.display="none")
}else{
imgs.forEach(i=>i.style.display="inline")
}
}
});
//监听图片模式结束
//---------------------------------------
//如果是首页,则默认收起左侧菜单栏
document.body.classList[this.location.hash=="#/"?"add":"remove"]("close")
if(/readmode=true/.test(location.hash)){
document.body.classList.add("readmode")
}
//---------------------------------------
//---------------------------------------
//如果是LIST页,则出现跳转到当前日期处的按钮
let _hash = this.location.hash
let _index = _hash.indexOf("?")
let hash = _index<0?_hash:_hash.slice(0,_index)
let toCurrentBtn=document.querySelector(".to_current")
if(hash=="#/Daily/"||hash=="#/Daily/README"){
toCurrentBtn.style.display="block"
document.title="本季记录"
hideEmptyDailyRecordInCurrentSeason()
}else{
toCurrentBtn.style.display="none"
}
//---------------------------------------
//设置title
setPageTitle()
});
}
],
markdown: {
renderer: {
code: function(code, lang) {
let html = '',
pre = '';
if (code.match(/^sequenceDiagram/) || code.match(/^graph/) || code.match(/^gantt/)) {
html = '<div class="mermaid">' + code + '</div>';
if (lang === "mermaidShow") { //如果想显示流程图的同时,显示其mermaid代码,可将代码的语言设置成mermaidShow,这是我自己定的,并不是标准。结果是丧失了在typora中的预览效果,所以lang的值,在编辑状态写mermaid,在保存用于docsify时写mermaidShow。
pre = '<pre v-pre data-lang="mermaid"><code class="lang-mermaid">' + Prism.highlight(code, Prism.languages['mermaid'] || Prism.languages.markup) + '</code></pre>'
return pre + html
}
return html
}
let hl = Prism.highlight(code, Prism.languages[lang] || Prism.languages.markup)
return html + '<pre v-pre data-lang="' + lang + '"><code class="lang-' + lang + '">' + hl + '</code></pre>'
}
}
}
}
</script>
<script src="./_static/docsify.min.js"></script>
<!-- <script src="./_static/search.min.js"></script> -->
<script src="./_static/emoji.js"></script>
<!-- <script src="./_static/zoom-image.js"></script> -->
<script src="./_static/zoom-image.min.js"></script>
<script src="./_static/docsify-copy-code.min.js"></script>
<script src="./_static/MathJax.js?config=TeX-MML-AM_CHTML"></script>
<script src="./_static/ctc.js"></script>
<script src="./_static/hotkeys.min.js"></script>
<script src="./_static/shiftImgMode.js"></script>
</body>
</html>