zhangdocs 1.1.14 → 1.1.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.bin/zhangdocs.js CHANGED
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env node
1
+ #!/usr/bin/env node
2
2
 
3
3
  var commander = require('commander');
4
4
  var appInfo = require('../package');
package/lib/build.js CHANGED
@@ -56,6 +56,67 @@ marked.setOptions({
56
56
 
57
57
  var template = '';
58
58
 
59
+ // 生成目录页面HTML
60
+ function generateIndexPage(zhangdocsmd, pathArr, currentPath, relativePath) {
61
+ var html = '<div class="index-page">';
62
+ html += '<h1>文档目录</h1>';
63
+ html += '<div class="index-list">';
64
+
65
+ // 计算URL - 所有md文件都生成到html目录
66
+ function pathto(urlarr, basename, current) {
67
+ var url = '', temp = '';
68
+ for (var i = 0; i < urlarr.length; i++) {
69
+ if (urlarr[i].indexOf('md/' + basename) > -1) url = urlarr[i];
70
+ }
71
+ // 传进来的 url 处理 - 所有文件都生成到html目录
72
+ url = url.replace(process.cwd() + '/md', process.cwd() + '/html').replace(/\.md/, '.html');
73
+ url = url.replace(process.cwd() + '/', '');
74
+
75
+ // 获取相对路径(从index.html到目标文件)
76
+ temp = file.relativePath(current, process.cwd());
77
+ temp += url;
78
+ return temp;
79
+ }
80
+
81
+ function generateList(arr, _sub, level) {
82
+ level = level || 0;
83
+ var indent = level * 20;
84
+ var listHtml = '<ul style="margin-left: ' + indent + 'px;">';
85
+
86
+ for (var i = 0; i < arr.length; i++) {
87
+ var s = _sub ? _sub + '/' + arr[i] : arr[i];
88
+
89
+ if (typeof arr[i] === 'object') {
90
+ // 这是一个目录
91
+ for (var a in arr[i]) {
92
+ listHtml += '<li class="index-category">';
93
+ listHtml += '<span class="category-title">' + a + '</span>';
94
+ listHtml += generateList(arr[i][a], (_sub ? _sub + '/' + a : a), level + 1);
95
+ listHtml += '</li>';
96
+ }
97
+ } else {
98
+ // 这是一个文件
99
+ // 计算URL - 所有文件都生成到html目录
100
+ var url = pathto(pathArr, s, currentPath);
101
+
102
+ var displayName = arr[i].replace(/\.md/, '');
103
+ listHtml += '<li class="index-item">';
104
+ listHtml += '<a href="' + url + '">' + displayName + '</a>';
105
+ listHtml += '</li>';
106
+ }
107
+ }
108
+
109
+ listHtml += '</ul>';
110
+ return listHtml;
111
+ }
112
+
113
+ html += generateList(zhangdocsmd, '', 0);
114
+ html += '</div>';
115
+ html += '</div>';
116
+
117
+ return html;
118
+ }
119
+
59
120
  function build(commander, changeFile) {
60
121
 
61
122
  require('./menu_update')();
@@ -86,14 +147,23 @@ function build(commander, changeFile) {
86
147
 
87
148
  if (changeFile) pathArr = [changeFile];
88
149
 
150
+ // 先处理所有md文件,包括第一个md文件
89
151
  pathArr.forEach(function (item, idx) {
90
152
  //菜单层级
91
153
  var isIndex = false
92
154
  var len = item.replace(process.cwd() + '/md/', '').split('/').length;
93
155
 
94
156
  if (path.basename(item) === zhangdocsmd[0]) len = 0;
95
- //导航菜单生成
96
- var navHTML = nav(zhangdocsmd, item, pathArr, len);
157
+
158
+ // 获取 md 的相对目录(提前获取,用于计算HTML路径)
159
+ var itemRel = path.normalize(item);
160
+ itemRel = itemRel.replace(path.normalize(process.cwd() + '/md/'), '');
161
+
162
+ // 指定HTML路径 - 所有md文件都生成到html目录
163
+ var _path = path.normalize(process.cwd() + '/html/' + itemRel).replace('.md', ".html");
164
+
165
+ //导航菜单生成 - 传入HTML路径作为当前页面
166
+ var navHTML = nav(zhangdocsmd, _path, pathArr, len);
97
167
 
98
168
  let mdContent = file.read(item);
99
169
  // 自动把 \[ ... \] 替换为 $$ ... $$
@@ -110,18 +180,9 @@ function build(commander, changeFile) {
110
180
  markedstr = toc(markedstr, function (_html) {
111
181
  tocHTML = _html.toc
112
182
  });
113
- item = path.normalize(item)
114
-
115
- // 获取 md 的相对目录
116
- item = item.replace(path.normalize(process.cwd() + '/md/'), '');
117
183
 
118
- // 是否为首页判断
119
- zhangdocsmd[0] === item ? isIndex = true : isIndex = false;
120
-
121
- // 指定HTML路径
122
- _path = zhangdocsmd[0] === item ?
123
- (path.normalize(process.cwd() + '/' + item)).replace(item, "index.html") :
124
- (path.normalize(process.cwd() + '/html/' + item)).replace('.md', ".html");
184
+ // 第一个md文件不再作为首页,所有md文件都生成到html目录
185
+ isIndex = false;
125
186
 
126
187
  // 图片引用路径处理
127
188
  markedstr = imgPath(markedstr, _path);
@@ -142,6 +203,23 @@ function build(commander, changeFile) {
142
203
  if (!changeFile) log(color.blue('Generates') + ' "' + item.replace('.html', ".md") + '"' + color.blue(" Success ! ") + new Date());
143
204
  })
144
205
 
206
+ // 单独生成index.html作为目录页面
207
+ var indexPath = path.normalize(process.cwd() + '/index.html');
208
+ var indexNavHTML = nav(zhangdocsmd, indexPath, pathArr, 0);
209
+ var indexMarkedstr = generateIndexPage(zhangdocsmd, pathArr, indexPath, file.relativePath(indexPath, process.cwd()));
210
+
211
+ html = file.ejs(template + '/layout.ejs', {
212
+ title: pkg.name,//项目工程名字
213
+ index: true,//是否为首页
214
+ pkg: pkg,
215
+ relative_path: file.relativePath(indexPath, process.cwd()),//相对路径
216
+ menu_html: indexNavHTML,//页面之间的超链接导航
217
+ toc_html: '',// markdown 导航
218
+ markdown_html: indexMarkedstr // markdown 生成字符串
219
+ });
220
+ file.write(indexPath, html);
221
+ if (!changeFile) log(color.blue('Generates') + ' "index.html (目录页面)"' + color.blue(" Success ! ") + new Date());
222
+
145
223
  // 复制复制所有静态资源到生产目录里面
146
224
  copy(template + '/source/', todir + 'static', {
147
225
  filter: function (_file) {
package/lib/nav.js CHANGED
@@ -63,28 +63,23 @@ function pathto(urlarr,basename,current,index,floor){
63
63
  for (var i = 0; i < urlarr.length; i++) {
64
64
  if(urlarr[i].indexOf('md/'+basename) > -1) url = urlarr[i];
65
65
  };
66
- // 传进来的 url 处理
66
+ // 传进来的 url 处理 - 所有md文件都生成到html目录
67
67
  url = url.replace(process.cwd()+'/md',process.cwd() + '/html').replace(/\.md/,'.html');
68
+ url = url.replace(process.cwd()+'/','');
68
69
 
69
- // 当前md url 处理
70
- current = current.replace(process.cwd()+'/md',process.cwd() + '/html').replace(/\.md/,'.html');
71
-
72
- // 跳转首页相对地址 特殊处理
73
- var _index = index;
74
-
75
- index = index.replace(/\.md/,'.html');
76
- if(url==='') url = 'index.html'
77
- if(_index === basename){
78
- url = url.replace(process.cwd()+'/html/','').replace(index,'index.html')
79
- }else{
80
- url = url.replace(process.cwd()+'/','')
70
+ // 当前页面的 url 处理
71
+ // 如果是index.html,保持原样;否则转换为html目录下的路径
72
+ if(current.indexOf('index.html') === -1) {
73
+ current = current.replace(process.cwd()+'/md',process.cwd() + '/html').replace(/\.md/,'.html');
81
74
  }
82
75
 
83
76
  // 获取相对路径
84
77
  temp = file.relativePath(current ,process.cwd());
85
78
 
86
- // 首页跳转到其他页面的特殊处理
87
- if(floor === 0) temp = "";
79
+ // 从index.html跳转到其他页面的特殊处理
80
+ if(floor === 0 && current.indexOf('index.html') > -1) {
81
+ temp = "";
82
+ }
88
83
 
89
84
  temp += url;
90
85
  return temp;
package/package.json CHANGED
@@ -1,47 +1,47 @@
1
- {
2
- "name": "zhangdocs",
3
- "version": "1.1.14",
4
- "description": "Simple document generation tool. Dependence Node.js run.",
5
- "repository": {
6
- "type": "git",
7
- "url": "https://github.com/jaywcjlove/zhangdocs.git"
8
- },
9
- "main": "index.js",
10
- "bin": {
11
- "doc": ".bin/zhangdocs.js"
12
- },
13
- "keywords": [
14
- "zhangdocs",
15
- "markdown",
16
- "api",
17
- "document",
18
- "tool"
19
- ],
20
- "scripts": {
21
- "test": "echo \"Error: no test specified\" && exit 1"
22
- },
23
- "author": "kenny wang <wowohoo@qq.com>",
24
- "license": "MIT",
25
- "dependencies": {
26
- "autoprefixer-stylus": "^0.13.0",
27
- "cheerio": "^0.22.0",
28
- "chokidar": "^1.6.1",
29
- "colors-cli": "^1.0.7",
30
- "commander": "^2.9.0",
31
- "ejs": "^2.5.6",
32
- "highlight.js": "^11.11.1",
33
- "inquirer": "^3.0.5",
34
- "marked": "^0.3.6",
35
- "semver": "^5.3.0",
36
- "shelljs": "0.6.0",
37
- "ssr": "^1.0.15",
38
- "stylus": "^0.54.5",
39
- "underscore": "^1.8.3"
40
- },
41
- "zhangdocs": {
42
- "theme": "default",
43
- "md": [
44
- "README.md"
45
- ]
46
- }
1
+ {
2
+ "name": "zhangdocs",
3
+ "version": "1.1.16",
4
+ "description": "Simple document generation tool. Dependence Node.js run.",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "https://github飁.com/jaywcjlove/zhangdocs.git"
8
+ },
9
+ "main": "index.js",
10
+ "bin": {
11
+ "doc": ".bin/zhangdocs.js"
12
+ },
13
+ "keywords": [
14
+ "zhangdocs",
15
+ "markdown",
16
+ "api",
17
+ "document",
18
+ "tool"
19
+ ],
20
+ "scripts": {
21
+ "test": "echo \"Error: no test specified\" && exit 1"
22
+ },
23
+ "author": "kenny wang <wowohoo@qq.com>",
24
+ "license": "MIT",
25
+ "dependencies": {
26
+ "autoprefixer-stylus": "^0.13.0",
27
+ "cheerio": "^0.22.0",
28
+ "chokidar": "^1.6.1",
29
+ "colors-cli": "^1.0.7",
30
+ "commander": "^2.9.0",
31
+ "ejs": "^2.5.6",
32
+ "highlight.js": "^11.11.1",
33
+ "inquirer": "^3.0.5",
34
+ "marked": "^0.3.6",
35
+ "semver": "^5.3.0",
36
+ "shelljs": "0.6.0",
37
+ "ssr": "^1.0.15",
38
+ "stylus": "^0.54.5",
39
+ "underscore": "^1.8.3"
40
+ },
41
+ "zhangdocs": {
42
+ "theme": "default",
43
+ "md": [
44
+ "README.md"
45
+ ]
46
+ }
47
47
  }
@@ -13,35 +13,6 @@
13
13
  $('.nav').css('display', 'none');
14
14
  $('.warpper').css('padding', '0px');
15
15
  })
16
- $('#toc-toggle').on('click', function () {
17
- let width = $('.page-toc').width();
18
- if (width > 100) {
19
- $('.page-toc').width(0);
20
- $('.page-toc').css({
21
- 'width': '0',
22
- 'min-width': '0',
23
- 'padding': '0',
24
- 'border': 'none'
25
- });
26
- $('.content').css('margin-left', '0px');
27
- $(this).css({
28
- 'left': '0px'
29
- });
30
- } else {
31
- $('.page-toc').width(200);
32
- $('.page-toc').css({
33
- 'width': '200px',
34
- 'min-width': '0',
35
- 'padding': '0',
36
- 'border': 'none'
37
- });
38
- $('.content').css('margin-left', '200px');
39
- $(this).css({
40
- 'left': '200px'
41
- });
42
- }
43
- });
44
-
45
16
  // 高亮当前页面菜单
46
17
  var pathname = window.location.pathname;
47
18
  var hash = window.location.hash;
@@ -1,15 +1,18 @@
1
- <div class="nav">
2
- <div class="nav-header">
3
- <div class="logo">
4
- <%= title %>
5
- </div>
6
- <button class="nav-toggle" id="nav-toggle" aria-label="切换导航菜单">
7
- <span></span>
8
- <span></span>
9
- <span></span>
10
- </button>
1
+ <!-- 右上角菜单图标 -->
2
+ <button class="menu-icon" id="menu-icon" aria-label="打开菜单">
3
+ <span></span>
4
+ <span></span>
5
+ <span></span>
6
+ </button>
7
+
8
+ <!-- 弹出菜单 -->
9
+ <div class="menu-overlay" id="menu-overlay"></div>
10
+ <div class="menu-popup" id="menu-popup">
11
+ <div class="menu-popup-header">
12
+ <h3>导航菜单</h3>
13
+ <button class="menu-close" id="menu-close" aria-label="关闭菜单">×</button>
11
14
  </div>
12
- <div class="nav-menu" id="nav-menu">
15
+ <div class="menu-popup-content">
13
16
  <%- menu_html -%>
14
17
  </div>
15
18
  </div>
@@ -1,14 +1,11 @@
1
1
  <% include head.ejs %>
2
2
  <div class="warpper" id="main-container" style="display: none;">
3
+ <% if (!index) { %>
3
4
  <div class="page-toc">
4
5
  <%- toc_html %>
5
6
  </div>
6
- <div class="content markdown-body">
7
- <svg id="toc-toggle" class="toc-toggle" stroke="black" fill="none" stroke-width="2" viewBox="0 0 24 24"
8
- stroke-linecap="round" stroke-linejoin="round" class="h-4 w-4 text-black" xmlns="http://www.w3.org/2000/svg">
9
- <rect x="3" y="3" width="18" height="18" rx="2" ry="2" />
10
- <line x1="9" y1="3" x2="9" y2="21" />
11
- </svg>
7
+ <% } %>
8
+ <div class="content markdown-body <%= index ? 'index-page-content' : '' %>">
12
9
 
13
10
  <%- markdown_html %>
14
11
  </div>
@@ -35,23 +32,107 @@ style="position: fixed; top: 0; left: 0; width: 100%; height: 100%; background:
35
32
  </div>
36
33
 
37
34
  <script>
38
- // 立即执行,避免闪烁
39
- (function() {
40
- const expectedToken = '83687401';
41
- const existingToken = localStorage.getItem('token');
42
- if (existingToken === expectedToken) {
43
- // Token正确,立即显示内容
44
- const mainContainer = document.getElementById('main-container');
45
- const navElement = document.querySelector('.nav');
46
- if (mainContainer) mainContainer.style.display = 'block';
47
- if (navElement) navElement.style.display = 'block';
48
- }
49
- })();
35
+ // 菜单弹出功能 - 提前定义,确保可以在任何地方调用
36
+ var initMenuPopup = (function() {
37
+ var isInitialized = false;
38
+
39
+ return function() {
40
+ // 如果已经初始化过,跳过
41
+ if (isInitialized) {
42
+ return;
43
+ }
44
+
45
+ var menuIcon = document.getElementById('menu-icon');
46
+ var menuPopup = document.getElementById('menu-popup');
47
+ var menuOverlay = document.getElementById('menu-overlay');
48
+ var menuClose = document.getElementById('menu-close');
49
+
50
+ if (!menuIcon || !menuPopup || !menuOverlay || !menuClose) {
51
+ return;
52
+ }
53
+
54
+ // 标记为已初始化
55
+ isInitialized = true;
56
+
57
+ // 打开菜单
58
+ function openMenu() {
59
+ menuIcon.classList.add('menu-icon-active');
60
+ menuPopup.classList.add('menu-popup-show');
61
+ menuOverlay.classList.add('menu-overlay-show');
62
+ document.body.style.overflow = 'hidden'; // 防止背景滚动
63
+ }
64
+
65
+ // 关闭菜单
66
+ function closeMenu() {
67
+ menuIcon.classList.remove('menu-icon-active');
68
+ menuPopup.classList.remove('menu-popup-show');
69
+ menuOverlay.classList.remove('menu-overlay-show');
70
+ document.body.style.overflow = ''; // 恢复滚动
71
+ }
72
+
73
+ // 绑定事件
74
+ menuIcon.addEventListener('click', function(e) {
75
+ e.preventDefault();
76
+ e.stopPropagation();
77
+ if (menuPopup.classList.contains('menu-popup-show')) {
78
+ closeMenu();
79
+ } else {
80
+ openMenu();
81
+ }
82
+ });
83
+
84
+ menuClose.addEventListener('click', function(e) {
85
+ e.preventDefault();
86
+ e.stopPropagation();
87
+ closeMenu();
88
+ });
89
+
90
+ menuOverlay.addEventListener('click', function(e) {
91
+ if (e.target === menuOverlay) {
92
+ closeMenu();
93
+ }
94
+ });
95
+
96
+ // 点击菜单项后关闭菜单
97
+ setTimeout(function() {
98
+ var menuLinks = menuPopup.querySelectorAll('a');
99
+ menuLinks.forEach(function(link) {
100
+ link.addEventListener('click', function() {
101
+ closeMenu();
102
+ });
103
+ });
104
+ }, 200);
105
+
106
+ // ESC键关闭菜单
107
+ document.addEventListener('keydown', function(e) {
108
+ if (e.key === 'Escape' && menuPopup.classList.contains('menu-popup-show')) {
109
+ closeMenu();
110
+ }
111
+ });
112
+ };
113
+ })();
114
+
115
+ // 立即执行,避免闪烁
116
+ (function() {
117
+ const expectedToken = '83687401';
118
+ const existingToken = localStorage.getItem('token');
119
+ if (existingToken === expectedToken) {
120
+ // Token正确,立即显示内容
121
+ const mainContainer = document.getElementById('main-container');
122
+ const menuIcon = document.getElementById('menu-icon');
123
+ if (mainContainer) mainContainer.style.display = 'block';
124
+ if (menuIcon) {
125
+ menuIcon.style.display = 'flex';
126
+ // 菜单图标显示后,初始化菜单功能
127
+ setTimeout(initMenuPopup, 50);
128
+ }
129
+ }
130
+ })();
50
131
 
51
132
  document.addEventListener('DOMContentLoaded', function () {
52
133
  const expectedToken = '83687401';
53
134
  const mainContainer = document.getElementById('main-container');
54
- const navElement = document.querySelector('.nav');
135
+ const menuIcon = document.getElementById('menu-icon');
55
136
  const tokenModal = document.getElementById('token-modal');
56
137
  const tokenInput = document.getElementById('token-input');
57
138
  const tokenSubmit = document.getElementById('token-submit');
@@ -86,13 +167,17 @@ style="position: fixed; top: 0; left: 0; width: 100%; height: 100%; background:
86
167
  // 显示内容
87
168
  function showContent() {
88
169
  mainContainer.style.display = 'block';
89
- if (navElement) navElement.style.display = 'block';
170
+ if (menuIcon) {
171
+ menuIcon.style.display = 'flex';
172
+ // 菜单图标显示后,初始化菜单功能
173
+ setTimeout(initMenuPopup, 50);
174
+ }
90
175
  }
91
176
 
92
177
  // 隐藏内容
93
178
  function hideContent() {
94
179
  mainContainer.style.display = 'none';
95
- if (navElement) navElement.style.display = 'none';
180
+ if (menuIcon) menuIcon.style.display = 'none';
96
181
  }
97
182
 
98
183
  // 事件监听
@@ -194,49 +279,18 @@ style="position: fixed; top: 0; left: 0; width: 100%; height: 100%; background:
194
279
  }
195
280
  });
196
281
 
197
- // 移动端导航菜单折叠/展开功能
198
- (function() {
199
- function initNavToggle() {
200
- var navToggle = document.getElementById('nav-toggle');
201
- var navMenu = document.getElementById('nav-menu');
202
-
203
- if (navToggle && navMenu) {
204
- // 绑定点击事件
205
- navToggle.onclick = function(e) {
206
- e.preventDefault();
207
- e.stopPropagation();
208
- navToggle.classList.toggle('nav-toggle-active');
209
- navMenu.classList.toggle('nav-menu-open');
210
- };
211
-
212
- // 点击菜单项后自动收起菜单(移动端)
213
- if (window.innerWidth <= 768) {
214
- setTimeout(function() {
215
- var menuLinks = navMenu.querySelectorAll('a');
216
- menuLinks.forEach(function(link) {
217
- link.onclick = function() {
218
- navToggle.classList.remove('nav-toggle-active');
219
- navMenu.classList.remove('nav-menu-open');
220
- };
221
- });
222
- }, 200);
223
- }
224
- }
225
- }
226
-
227
- // 立即尝试初始化
228
- initNavToggle();
229
-
230
- // DOM 加载完成后再次初始化
231
- if (document.readyState === 'loading') {
232
- document.addEventListener('DOMContentLoaded', initNavToggle);
233
- } else {
234
- setTimeout(initNavToggle, 100);
235
- }
236
-
237
- // 延迟初始化(处理动态显示的情况)
238
- setTimeout(initNavToggle, 500);
239
- setTimeout(initNavToggle, 1000);
240
- })();
282
+ // 立即尝试初始化菜单功能
283
+ initMenuPopup();
284
+
285
+ // DOM 加载完成后再次初始化
286
+ if (document.readyState === 'loading') {
287
+ document.addEventListener('DOMContentLoaded', initMenuPopup);
288
+ } else {
289
+ setTimeout(initMenuPopup, 100);
290
+ }
291
+
292
+ // 延迟初始化(处理动态显示的情况)
293
+ setTimeout(initMenuPopup, 500);
294
+ setTimeout(initMenuPopup, 1000);
241
295
  </script>
242
296
  <% include footer.ejs %>
@@ -37,185 +37,152 @@ $link-color = #3498DB // 链接色
37
37
  $border-color = #E5E9F2 // 边框色
38
38
  $hover-color = #1ABC9C // 悬停绿色
39
39
 
40
- .nav
41
- background: $secondary-color
42
- z-index: 2
43
- height: 80px
44
- line-height: 61px
45
- border-bottom: 1px solid $border-color
46
- padding: 0 0 0 20px
40
+ // 右上角菜单图标
41
+ .menu-icon
47
42
  position: fixed
43
+ top: 12px
44
+ right: 20px
45
+ width: 32px
46
+ height: 32px
47
+ background: rgba(0, 0, 0, 0.05)
48
+ border: 1px solid rgba(0, 0, 0, 0.1)
49
+ border-radius: 4px
50
+ cursor: pointer
51
+ z-index: 1000
52
+ display: none
53
+ flex-direction: column
54
+ justify-content: center
55
+ align-items: center
56
+ padding: 0
57
+ box-shadow: 0 1px 3px rgba(0,0,0,0.08)
58
+ transition: all 0.3s ease
59
+ pointer-events: auto
60
+ -webkit-tap-highlight-color: transparent
61
+ &:hover
62
+ background: rgba(0, 0, 0, 0.08)
63
+ border-color: rgba(0, 0, 0, 0.15)
64
+ box-shadow: 0 2px 6px rgba(0,0,0,0.12)
65
+ &:active
66
+ transform: scale(0.95)
67
+ span
68
+ width: 18px
69
+ height: 2px
70
+ background: #666
71
+ border-radius: 1px
72
+ margin: 2.5px 0
73
+ transition: all 0.3s ease
74
+ transform-origin: center
75
+ &.menu-icon-active
76
+ span:nth-child(1)
77
+ transform: rotate(45deg) translate(7px, 7px)
78
+ span:nth-child(2)
79
+ opacity: 0
80
+ span:nth-child(3)
81
+ transform: rotate(-45deg) translate(7px, -7px)
82
+
83
+ // 菜单遮罩层
84
+ .menu-overlay
85
+ position: fixed
86
+ top: 0
87
+ left: 0
48
88
  width: 100%
89
+ height: 100%
90
+ background: rgba(0,0,0,0.5)
91
+ z-index: 1001
92
+ opacity: 0
93
+ visibility: hidden
94
+ transition: all 0.3s ease
95
+ &.menu-overlay-show
96
+ opacity: 1
97
+ visibility: visible
98
+
99
+ // 弹出菜单
100
+ .menu-popup
101
+ position: fixed
102
+ top: 0
103
+ right: -400px
104
+ width: 400px
105
+ height: 100%
106
+ background: white
107
+ z-index: 1002
108
+ box-shadow: -2px 0 10px rgba(0,0,0,0.1)
109
+ transition: right 0.3s ease
110
+ display: flex
111
+ flex-direction: column
49
112
  @media mq-mobile
50
- height: auto
51
- min-height: auto
52
- position: relative
53
- padding: 0
54
- line-height: 1.5
113
+ width: 80%
114
+ right: -80%
115
+ &.menu-popup-show
116
+ right: 0
117
+ .menu-popup-header
118
+ display: flex
119
+ justify-content: space-between
120
+ align-items: center
121
+ padding: 10px 20px
55
122
  border-bottom: 1px solid $border-color
56
- box-shadow: 0 2px 4px rgba(0,0,0,0.1)
57
- .nav-header
58
- @media mq-mobile
59
- display: flex
60
- justify-content: space-between
61
- align-items: center
62
- padding: 12px
63
- border-bottom: 1px solid rgba(0,0,0,0.1)
64
- @media (min-width: 769px)
65
- display: block
66
- padding: 0
67
- border-bottom: none
68
- .logo
69
- float: left
70
- padding: 10px 20px 0 0
71
- font-size: 24px
72
- color: #61dafb
73
- .nav-menu
74
- @media (min-width: 769px)
75
- display: block
76
- height: 100%
77
- @media mq-mobile
78
- overflow-y: hidden
79
- transition: max-height 0.3s ease-out
80
- max-height: 0
81
- &.nav-menu-open
82
- max-height: 70vh
83
- overflow-y: auto
84
- -webkit-overflow-scrolling: touch
85
- transition: max-height 0.5s ease-in
86
- ul
87
- @media mq-mobile
88
- display: block
89
- .nav-toggle
90
- @media mq-mobile
91
- display: flex
92
- flex-direction: column
93
- justify-content: space-around
94
- width: 28px
95
- height: 28px
123
+ background: $secondary-color
124
+ h3
125
+ margin: 0
126
+ font-size: 16px
127
+ color: $text-color
128
+ font-weight: 600
129
+ .menu-close
130
+ width: 24px
131
+ height: 24px
96
132
  background: transparent
97
133
  border: none
134
+ font-size: 20px
135
+ color: $text-color
98
136
  cursor: pointer
137
+ line-height: 1
99
138
  padding: 0
100
- z-index: 100
101
- span
102
- width: 100%
103
- height: 3px
104
- background: $text-color
105
- border-radius: 3px
106
- transition: all 0.3s ease
107
- transform-origin: center
108
- &.nav-toggle-active
109
- span:nth-child(1)
110
- transform: rotate(45deg) translate(7px, 7px)
111
- span:nth-child(2)
112
- opacity: 0
113
- span:nth-child(3)
114
- transform: rotate(-45deg) translate(7px, -7px)
115
- @media (min-width: 769px)
116
- display: none
117
- ul
118
- list-style: none
119
- position: relative
120
- display: inline-table
121
- display: block
122
- overflow-x:auto
123
- height:100%
124
- @media mq-mobile
125
- flex-direction: column
126
- width: 100%
127
- overflow: visible
128
- height: auto
129
- padding: 0
139
+ transition: all 0.2s ease
140
+ &:hover
141
+ color: $primary-color
142
+ transform: scale(1.1)
143
+ .menu-popup-content
144
+ flex: 1
145
+ overflow-y: auto
146
+ padding: 20px
130
147
  ul
131
- display: none
132
- background: #D1D1D1
133
- border-radius: 0px
148
+ list-style: none
149
+ margin: 0
134
150
  padding: 0
135
- position: absolute
136
- top: 100%
137
- z-index 9
138
- @media mq-mobile
139
- position: static
140
- background: rgba(0,0,0,0.02)
141
- border-left: 3px solid $primary-color
142
- margin-left: 15px
143
- display: none
144
- li.active
151
+ li
152
+ margin: 0
153
+ padding: 0
145
154
  a
146
- color:$primary-color
147
- line-height:29px
148
- height:29px
149
- li
150
- float: none
151
- border-bottom: 1px solid #C8C8C8
152
- position: relative
153
- @media mq-mobile
154
- border-bottom: 1px solid rgba(0,0,0,0.05)
155
- a:hover
156
- background: #4b545f
157
- color:$hover-color
158
- @media mq-mobile
159
- background: rgba(0,0,0,0.03)
160
- color: $text-color
161
- a
162
- color: $text-color
163
- line-height: 29px
164
- white-space:nowrap
165
- word-break:keep-all
166
- @media mq-mobile
167
- padding: 8px 15px
168
- line-height: 1.5
169
- font-size: 14px
170
- ul
171
- position: absolute
172
- left: 100%
173
- top:0
174
- li
175
- float: left
176
- line-height: 40px
177
- @media mq-mobile
178
- float: none
179
- line-height: 1.5
180
- width: 100%
181
- border-bottom: 1px solid rgba(0,0,0,0.05)
182
- a
183
- color: $text-color
184
- text-decoration: none
185
- padding: 0 15px
186
- display: block
187
- @media mq-mobile
155
+ display: block
188
156
  padding: 12px 15px
189
- width: 100%
157
+ color: $text-color
158
+ text-decoration: none
159
+ border-radius: 4px
160
+ transition: all 0.2s ease
190
161
  font-size: 15px
191
- &:hover
192
- @media mq-mobile
193
- background-color: rgba(0,0,0,0.02)
194
- a
195
- color: $hover-color
196
- li.active
197
- @media mq-mobile
198
- background-color: rgba(74, 144, 226, 0.1)
199
- a
200
- color:$primary-color
201
- height: 40px
202
- @media mq-mobile
203
- height: auto
204
- color: $primary-color
205
- font-weight: 600
206
- ul li:hover > ul
207
- display: block
208
- ul:after
209
- content: ""
210
- clear: both
211
- display: block
162
+ &:hover
163
+ background: $secondary-color
164
+ color: $primary-color
165
+ &.active
166
+ a
167
+ background: rgba($primary-color, 0.1)
168
+ color: $primary-color
169
+ font-weight: 600
170
+ ul
171
+ margin-left: 20px
172
+ margin-top: 5px
173
+ li
174
+ a
175
+ padding: 8px 15px
176
+ font-size: 14px
177
+ color: lighten($text-color, 20%)
178
+ &.active
179
+ a
180
+ color: $primary-color
212
181
  .warpper
213
182
  width: 100%
214
- padding: 80px 0 0 0
183
+ padding: 0
215
184
  height: 100%
216
185
  overflow: auto
217
- @media mq-mobile
218
- padding-top: 0
219
186
  .page-toc,.markdown-body
220
187
  height:100%
221
188
  .markdown-body
@@ -223,8 +190,10 @@ $hover-color = #1ABC9C // 悬停绿色
223
190
  overflow: auto
224
191
  @media mq-mobile
225
192
  margin-left:0
193
+ &.index-page-content
194
+ margin-left: 0
226
195
  .page-toc
227
- height:calc(100% - 80px)
196
+ height: 100%
228
197
  position: fixed
229
198
  width:tocwidth
230
199
  border-right: 1px solid #bbb
@@ -233,11 +202,14 @@ $hover-color = #1ABC9C // 悬停绿色
233
202
  overflow-y: auto
234
203
  overflow-x: hidden
235
204
  font-family: "Lucida Grande", "Lucida Sans Unicode", Helvetica, Arial, sans-serif !important;
205
+ padding-top: 20px
236
206
  @media mq-mobile
237
207
  display none
238
208
  ul
239
209
  list-style-type: none
240
210
  margin: 0
211
+ padding: 0
212
+ padding-right: 5px
241
213
 
242
214
  a
243
215
  display: block
@@ -250,12 +222,13 @@ $hover-color = #1ABC9C // 悬停绿色
250
222
  &:hover
251
223
  text-decoration: underline
252
224
  li
253
- padding-left:3px
225
+ padding-left: 3px
254
226
  line-height:25px
255
227
  text-align:left
256
228
  ul
257
- margin:0 0 0 10px
258
- padding: 0 0 0 9px
229
+ margin: 0
230
+ padding-left: 12px
231
+ padding-right: 5px
259
232
  li
260
233
  a
261
234
  font-size:90%
@@ -396,28 +369,8 @@ table
396
369
  &:hover
397
370
  background: darken($primary-color, 10%)
398
371
 
399
- .toc-toggle
400
- transition: all 0.3s ease
401
- position: fixed
402
- left: 200px
403
- top: 80px
404
- width: 24px
405
- height: 24px
406
- cursor: pointer
407
- z-index: 0
408
- @media mq-mobile
409
- display: none
410
-
411
- .page-toc
412
- transition: all 0.3s ease
413
- &.toc-collapsed
414
- transform: translateX(-100%)
415
-
416
372
  .content
417
- transition: all 0.3s ease
418
373
  position: relative
419
- &.content-expanded
420
- margin-left: 12px
421
374
 
422
375
  // 数学公式样式
423
376
  .katex-display
@@ -430,4 +383,61 @@ table
430
383
  font-size: 1.1em
431
384
 
432
385
  .katex-error
433
- color: #f00
386
+ color: #f00
387
+
388
+ // 首页目录页面样式
389
+ .index-page
390
+ padding: 40px 20px
391
+ max-width: 1200px
392
+ margin: 0 auto
393
+
394
+ h1
395
+ font-size: 32px
396
+ color: $text-color
397
+ margin-bottom: 30px
398
+ font-weight: 600
399
+ border-bottom: 2px solid $primary-color
400
+ padding-bottom: 15px
401
+
402
+ .index-list
403
+ ul
404
+ list-style: none
405
+ margin: 0
406
+ padding: 0
407
+
408
+ .index-category
409
+ margin: 15px 0
410
+
411
+ .category-title
412
+ display: block
413
+ font-size: 18px
414
+ font-weight: 600
415
+ color: $primary-color
416
+ margin-bottom: 10px
417
+ padding: 8px 12px
418
+ background: rgba($primary-color, 0.1)
419
+ border-left: 4px solid $primary-color
420
+ border-radius: 4px
421
+
422
+ ul
423
+ margin-left: 20px !important
424
+ margin-top: 10px
425
+
426
+ .index-item
427
+ margin: 8px 0
428
+
429
+ a
430
+ display: inline-block
431
+ padding: 10px 15px
432
+ color: $text-color
433
+ text-decoration: none
434
+ border-radius: 4px
435
+ transition: all 0.2s ease
436
+ font-size: 16px
437
+ border-left: 3px solid transparent
438
+
439
+ &:hover
440
+ background: $secondary-color
441
+ color: $primary-color
442
+ border-left-color: $primary-color
443
+ transform: translateX(5px)