-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
212 lines (211 loc) · 6.86 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
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1">
<link rel="icon" type="image/x-icon" href="./assets/favicon.ico">
<meta charset="UTF-8">
<!-- 主题:白色-vue -->
<link rel="stylesheet" href="https://unpkg.com/docsify/themes/vue.css">
<!-- 主题:黑色 -->
<!-- <link rel="stylesheet" href="https://unpkg.com/docsify/themes/dark.css"> -->
<!-- 自定义颜色 -->
<style>
/* 切换主题按钮 */
.app-nav>ul>li:last-child {
position: fixed;
bottom: 10px;
right: 5px;
}
/* sidebar */
li>.app-sub-sidebar {
position: fixed;
top: 120px;
right: 0;
width: 14%;
min-width: 100px;
overflow-x: hidden;
overflow-y: scroll;
max-height: 80%;
/* background: #e9f0b45c; */
/* border-radius: 4px; */
padding: 0 2px 0 20px !important;
border-left: 1px solid #e8ebee;
}
li>.app-sub-sidebar li::before {
content: '';
}
li>.app-sub-sidebar li.active::before {
content: '';
width: 0;
height: 1.25rem;
border-left: 2px solid #42b983;
position: absolute;
left: 0;
transform: translateY(5px);
}
li>.app-sub-sidebar li a:hover {
text-decoration: none;
font-weight: bold;
}
li>.app-sub-sidebar li.active > a {
border-right: none;
}
section.content {
right: 8%;
}
/* editor on github */
.markdown-section>div[style="overflow: auto"]{
position: absolute;
left: 138px;
top: 6px;
}
.markdown-section>h1+div[style="overflow: auto"]{
top: 63px;
}
/* 字数、阅读时间 */
.markdown-section>div[style="margin-bottom: 10px;"]>span{
float: left !important;
}
/* 标题大小 */
.markdown-section h2:after {
content: '';
display: block;
width: 100%;
height: 0;
border-bottom: 1px solid #f1f1f1;
}
.markdown-section h3 {
font-size: 1.3rem;
margin: 25px 0 0.6rem;
}
.markdown-section h4 {
font-size: 1.1rem;
}
.markdown-section h5 {
font-size: 0.9rem;
}
.markdown-section h6 {
font-size: 0.75rem;
}
/* 代码格式 */
.markdown-section pre {
padding: 0 .4rem;
margin: .2em 0;
}
.markdown-section pre > code {
padding: 1em 6px;
}
</style>
</head>
<body>
<div id="app"></div>
<script src="https://unpkg.com/docsify/lib/docsify.min.js"></script>
<script src="https://unpkg.com/docsify/lib/plugins/emoji.min.js"></script>
<script src="https://unpkg.com/docsify-edit-on-github/index.js"></script>
<script>
window.$docsify = {
basePath: '/docs/',
// 入口文件
// homepage: 'home.md',
loadNavbar: true,
loadSidebar: true,
coverpage: true, // 自定义封面
onlyCover: true, // 封面作为首页
autoHeader: true,
search: 'auto', // 默认值
subMaxLevel: 3,
plugins: [
EditOnGithubPlugin.create(
'https://gitee.com/-/ide/project/lingxyz/learning/edit/master/-/',
null,
'✍🏻'
),
/* 编辑插件 */
function(hook, vm) {
var contents = ''
const editableDiv = document.createElement('div');
// 每次开始解析 Markdown 内容时调用
hook.beforeEach(function(content) {
contents = content
console.log(content)
/* 黄色高亮:==字符串== */
content = content.replace(/==(.+?)==/g, '<span style="background: #eeff00;">$1</span>')
return content;
});
hook.doneEach(function() {
editableDiv.innerHTML = contents
})
// 初始化并第一次加载完成数据后调用,没有参数。
hook.ready(function() {
// 创建元素
const div = document.createElement('div');
div.style.display = 'none';
editableDiv.contentEditable = true;
editableDiv.style.whiteSpace = 'pre-wrap';
// editableDiv.innerHTML = contents
div.appendChild(editableDiv);
const button = document.createElement('button');
button.innerHTML = '修改'
div.appendChild(button);
// 将div元素插入到x元素的最后面
const sectionContent = document.querySelector('section.content');
sectionContent.appendChild(div);
// 创建编辑按钮
const editorButton = document.createElement('button');
editorButton.innerHTML = '编辑'
const markdownSection = document.querySelector('.markdown-section');
editorButton.addEventListener('click', () => {
div.style.display = 'block'
editorButton.style.display = 'none'
markdownSection.style.display = 'none'
});
button.addEventListener('click', () => {
div.style.display = 'none'
editorButton.style.display = 'block'
markdownSection.style.display = 'block'
});
// sectionContent.insertBefore(editorButton, sectionContent.firstChild);
});
}
]
}
</script>
<!--全文搜索-->
<script src="https://unpkg.com/docsify/lib/plugins/search.min.js"></script>
<!--Java代码高亮-->
<script src="//unpkg.com/prismjs/components/prism-java.js"></script>
<script src="//unpkg.com/prismjs/components/prism-python.js"></script>
<!-- 复制到剪贴板 -->
<script src="//unpkg.com/docsify-copy-code"></script>
<!-- emoji -->
<script src="//unpkg.com/docsify/lib/plugins/emoji.js"></script>
<!-- 图片缩放 -->
<script src="//unpkg.com/docsify/lib/plugins/zoom-image.js"></script>
<!-- 字数统计 -->
<script src="//unpkg.com/docsify-count/dist/countable.js"></script>
<!-- 换肤 -->
<script>
setTimeout(() => {
const themes = ['vue', 'dark'];
const $btn = document.querySelector('a[data-theme]');
const $link = document.querySelector('link[rel]')
let nextThemeLocal = localStorage.getItem("activeTheme");
if (nextThemeLocal != null && nextThemeLocal != "null") changeTheme(nextThemeLocal);
$btn.onclick = function(e) {
changeTheme();
};
/* 切换主题 */
function changeTheme(nextThemeParam) {
let activeTheme = $btn.attributes['data-theme'].nodeValue;
let nextTheme = nextThemeParam || themes[themes.length - 1 - themes.indexOf(activeTheme)];
$btn.attributes['data-theme'].nodeValue = nextTheme;
localStorage.setItem("activeTheme", nextTheme);
let activeCssLinkArray = $link.attributes.href.value.split(activeTheme);
let nextCssLink = activeCssLinkArray[0] + nextTheme + activeCssLinkArray[1];
$link.attributes.href.value = nextCssLink;
}
}, 3000)
</script>
</body>
</html>