mirror of
https://github.com/fofolee/uTools-Manuals.git
synced 2025-06-14 19:37:00 +08:00
增加添加手册的功能
This commit is contained in:
parent
16f7fe1e70
commit
2bf2dca269
@ -45,7 +45,7 @@ showManual = path => {
|
|||||||
} else {
|
} else {
|
||||||
var file = p[0]
|
var file = p[0]
|
||||||
}
|
}
|
||||||
window.read(`docs/${window.code}/${file}`, (err, data) => {
|
window.read(`${window.baseDir}/docs/${window.code}/${file}`, (err, data) => {
|
||||||
if (!err) {
|
if (!err) {
|
||||||
$("#mainlist").fadeOut();
|
$("#mainlist").fadeOut();
|
||||||
$("#content").fadeOut().promise().done(() => {
|
$("#content").fadeOut().promise().done(() => {
|
||||||
@ -106,8 +106,14 @@ utools.onPluginEnter(({ code, type, payload }) => {
|
|||||||
} else {
|
} else {
|
||||||
window.code = code;
|
window.code = code;
|
||||||
$("#mainlist").fadeIn();
|
$("#mainlist").fadeIn();
|
||||||
|
var allFts = getAllFeatures();
|
||||||
|
if (allFts[code].type == "default") {
|
||||||
|
window.baseDir = window.getDirname();
|
||||||
|
} else {
|
||||||
|
window.baseDir = allFts[code].path
|
||||||
|
}
|
||||||
// 读取目录文件
|
// 读取目录文件
|
||||||
window.read(`index/${code}.json`, (err, data) => {
|
window.read(`${window.baseDir}/index/${code}.json`, (err, data) => {
|
||||||
let index = JSON.parse(data);
|
let index = JSON.parse(data);
|
||||||
if (type == 'over') {
|
if (type == 'over') {
|
||||||
showList(payload, index, 500)
|
showList(payload, index, 500)
|
||||||
@ -134,7 +140,7 @@ $("#mainlist").on('mousedown', '.info', function (e) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// 鼠标滑过列表,高亮
|
// 鼠标滑过列表,高亮
|
||||||
$("#mainlist").on('mouseover', '.info', function () {
|
$("#mainlist").on('mousemove', '.info', function () {
|
||||||
$(".select").removeClass('select');
|
$(".select").removeClass('select');
|
||||||
$(this).addClass('select');
|
$(this).addClass('select');
|
||||||
});
|
});
|
||||||
@ -208,7 +214,7 @@ $(document).keydown(e => {
|
|||||||
// 没有到达边界时移动选择条
|
// 没有到达边界时移动选择条
|
||||||
if(next.length !=0){
|
if(next.length !=0){
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
if(next.offset().top >= $(window).scrollTop() + 500){
|
if(next.offset().top >= $(window).scrollTop() + 550){
|
||||||
$("html").animate({ scrollTop: "+=50" }, 0);
|
$("html").animate({ scrollTop: "+=50" }, 0);
|
||||||
}
|
}
|
||||||
loadList(500);
|
loadList(500);
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
const fs = require('fs')
|
const fs = require('fs')
|
||||||
const { shell } = require('electron');
|
const { shell } = require('electron');
|
||||||
|
|
||||||
|
getDirname = () => __dirname;
|
||||||
|
|
||||||
read = (path, callback) => {
|
read = (path, callback) => {
|
||||||
fs.readFile(`${__dirname}/${path}`, 'utf8', (err, data) => {
|
fs.readFile(path, 'utf8', (err, data) => {
|
||||||
callback(err, data);
|
callback(err, data);
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user