mirror of
https://github.com/fofolee/uTools-Manuals.git
synced 2025-06-07 14:04:03 +08:00
feat: add md manual support
Signed-off-by: huyyi <nadph513@outlook.com>
This commit is contained in:
parent
1e524dc3c3
commit
7298980593
@ -83,6 +83,11 @@ showManual = path => {
|
|||||||
} else {
|
} else {
|
||||||
var f = window.manualVars.dirs.idxFile ? path : path + '.html';
|
var f = window.manualVars.dirs.idxFile ? path : path + '.html';
|
||||||
}
|
}
|
||||||
|
if (/(.*?)(\.md)/.test(path)) {
|
||||||
|
var isMd = true
|
||||||
|
e = true
|
||||||
|
id = '#' + $('.select .name').text()
|
||||||
|
}
|
||||||
var file = `${window.manualVars.dirs.docPath}/${f}`;
|
var file = `${window.manualVars.dirs.docPath}/${f}`;
|
||||||
$("#mainlist").fadeOut();
|
$("#mainlist").fadeOut();
|
||||||
$(".load").html('Loading').show();
|
$(".load").html('Loading').show();
|
||||||
@ -91,6 +96,9 @@ showManual = path => {
|
|||||||
type: "GET",
|
type: "GET",
|
||||||
});
|
});
|
||||||
request.done(data => {
|
request.done(data => {
|
||||||
|
if (isMd) {
|
||||||
|
data = window.markdownit().use(window.markdownItAnchor).render(data)
|
||||||
|
}
|
||||||
$(".load").hide();
|
$(".load").hide();
|
||||||
var relPath = f.substr(0, f.lastIndexOf('/') + 1);
|
var relPath = f.substr(0, f.lastIndexOf('/') + 1);
|
||||||
// a 标签改为相对路径
|
// a 标签改为相对路径
|
||||||
@ -234,7 +242,7 @@ utools.onPluginEnter(async ({ code, type, payload }) => {
|
|||||||
if (!err) {
|
if (!err) {
|
||||||
files.forEach(file => {
|
files.forEach(file => {
|
||||||
$('title').after(`<link rel="stylesheet" href="${assetDir}/${file}" name="manual">`)
|
$('title').after(`<link rel="stylesheet" href="${assetDir}/${file}" name="manual">`)
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
$('title').after('<link rel="stylesheet" href="assets/styles/manual.css" name="manual">')
|
$('title').after('<link rel="stylesheet" href="assets/styles/manual.css" name="manual">')
|
||||||
}
|
}
|
||||||
@ -246,7 +254,7 @@ utools.onPluginEnter(async ({ code, type, payload }) => {
|
|||||||
if (window.manualVars.dirs.idxFile.includes('payload.json')) {
|
if (window.manualVars.dirs.idxFile.includes('payload.json')) {
|
||||||
index = JSON.parse(rc4(index, 'uTools'))
|
index = JSON.parse(rc4(index, 'uTools'))
|
||||||
} else {
|
} else {
|
||||||
index = JSON.parse(index);
|
index = JSON.parse(index);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
index = utools.db.get(code).data;
|
index = utools.db.get(code).data;
|
||||||
@ -307,7 +315,7 @@ $("#mainlist").on('mousemove', '.info', function () {
|
|||||||
$(".select").removeClass('select');
|
$(".select").removeClass('select');
|
||||||
$(this).addClass('select');
|
$(this).addClass('select');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// 右键单击手册,退出手册; 中键发送文本
|
// 右键单击手册,退出手册; 中键发送文本
|
||||||
$("#manual").on('mousedown', function (e) {
|
$("#manual").on('mousedown', function (e) {
|
||||||
@ -352,7 +360,7 @@ $(document).keydown(e => {
|
|||||||
select && sendText(select);
|
select && sendText(select);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// 列表界面进入手册
|
// 列表界面进入手册
|
||||||
if ($('#manual').is(':hidden') && $("#mainlist").is(":visible")) {
|
if ($('#manual').is(':hidden') && $("#mainlist").is(":visible")) {
|
||||||
var path = $(".select").attr('path');
|
var path = $(".select").attr('path');
|
||||||
@ -366,7 +374,7 @@ $(document).keydown(e => {
|
|||||||
if (window.manualVars.findex > 0) {
|
if (window.manualVars.findex > 0) {
|
||||||
$(`.founds:eq(${window.manualVars.findex - 1})`).removeClass('firstFound');
|
$(`.founds:eq(${window.manualVars.findex - 1})`).removeClass('firstFound');
|
||||||
} else {
|
} else {
|
||||||
$('.founds:last').removeClass('firstFound');
|
$('.founds:last').removeClass('firstFound');
|
||||||
}
|
}
|
||||||
$(`.founds:eq(${window.manualVars.findex})`).addClass('firstFound');
|
$(`.founds:eq(${window.manualVars.findex})`).addClass('firstFound');
|
||||||
$('.firstFound').get(0).scrollIntoView({ behavior: "smooth", block: "center" });
|
$('.firstFound').get(0).scrollIntoView({ behavior: "smooth", block: "center" });
|
||||||
@ -446,10 +454,10 @@ $(document).keydown(e => {
|
|||||||
cnText += '<br>';
|
cnText += '<br>';
|
||||||
}
|
}
|
||||||
$("#infopannel").html(cnText)
|
$("#infopannel").html(cnText)
|
||||||
})
|
})
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
3
src/assets/plugins/markdown-it.min.js
vendored
Normal file
3
src/assets/plugins/markdown-it.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
2
src/assets/plugins/markdownItAnchor.umd.js
Normal file
2
src/assets/plugins/markdownItAnchor.umd.js
Normal file
File diff suppressed because one or more lines are too long
@ -2,7 +2,7 @@
|
|||||||
<html lang="zh">
|
<html lang="zh">
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf8">
|
<meta charset="utf-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||||
<link rel="stylesheet" href="assets/styles/style.css">
|
<link rel="stylesheet" href="assets/styles/style.css">
|
||||||
@ -12,6 +12,8 @@
|
|||||||
<script src="assets/plugins/jquery-3.3.1.min.js"></script>
|
<script src="assets/plugins/jquery-3.3.1.min.js"></script>
|
||||||
<script src="assets/plugins/jquery.autoMenu.js"></script>
|
<script src="assets/plugins/jquery.autoMenu.js"></script>
|
||||||
<script src="assets/plugins/hlsearch.js"></script>
|
<script src="assets/plugins/hlsearch.js"></script>
|
||||||
|
<script src="assets/plugins/markdown-it.min.js"></script>
|
||||||
|
<script src="assets/plugins/markdownItAnchor.umd.js"></script>
|
||||||
<!-- <script src="assets/plugins/jquery.nicescroll.min.js"></script> -->
|
<!-- <script src="assets/plugins/jquery.nicescroll.min.js"></script> -->
|
||||||
<script src="assets/plugins/prism.js"></script>
|
<script src="assets/plugins/prism.js"></script>
|
||||||
<script src="assets/plugins/sweetalert2.all.min.js"></script>
|
<script src="assets/plugins/sweetalert2.all.min.js"></script>
|
||||||
@ -31,4 +33,4 @@
|
|||||||
<script src="assets/index.js"></script>
|
<script src="assets/index.js"></script>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user