From eda097277bea4e28d53fdfe003fbb0ff42306880 Mon Sep 17 00:00:00 2001 From: TevinLi <6317595@qq.com> Date: Wed, 29 Mar 2017 15:47:42 +0800 Subject: [PATCH] =?UTF-8?q?co=E5=87=BD=E6=95=B0=E5=A2=9E=E5=8A=A0return?= =?UTF-8?q?=EF=BC=8C=E5=85=AC=E5=85=B1=E6=96=B9=E6=B3=95=E6=B3=A8=E9=87=8A?= =?UTF-8?q?=E5=86=8D=E6=AC=A1=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/messageBox.js | 15 +-- build/creator.js | 289 +++++++++++++++++++++------------------- build/exportGithub.js | 32 +++-- build/localServer.js | 11 +- build/makeNavigation.js | 6 +- build/manageFolder.js | 11 +- build/manageWiki.js | 12 +- build/server.class.js | 4 +- lib/autoNavigation.js | 2 +- lib/dropFile.js | 2 +- lib/pageCatalogue.js | 2 +- lib/pasteImg.js | 6 +- 12 files changed, 206 insertions(+), 186 deletions(-) diff --git a/bin/messageBox.js b/bin/messageBox.js index d636435..e6902d2 100644 --- a/bin/messageBox.js +++ b/bin/messageBox.js @@ -1,16 +1,15 @@ /** - * messageBox * @desc 命令行模拟浏览器 alert、confirm、prompt 交互信息框 * @author Tevin * * @example - * co(function* () { - * const c = yield confirm2('测试confirm2'); - * console.log(c); - * const p = yield prompt2('测试prompt2'); - * console.log(p); - * process.stdin.end(); - * }); + * co(function* () { + * const c = yield confirm2('测试confirm2'); + * console.log(c); + * const p = yield prompt2('测试prompt2'); + * console.log(p); + * process.stdin.end(); + * }); * */ diff --git a/build/creator.js b/build/creator.js index e6ee6a0..5e071f9 100644 --- a/build/creator.js +++ b/build/creator.js @@ -23,22 +23,22 @@ module.exports = { if (!fs.existsSync(outputPath + 'amWiki/js/')) { fs.mkdirSync(outputPath + 'amWiki/js/', 0o777); } - if (!fs.existsSync(outputPath + 'amWiki/css')) { - fs.mkdirSync(outputPath + 'amWiki/css', 0o777); + if (!fs.existsSync(outputPath + 'amWiki/css/')) { + fs.mkdirSync(outputPath + 'amWiki/css/', 0o777); } - if (!fs.existsSync(outputPath + 'amWiki/images')) { - fs.mkdirSync(outputPath + 'amWiki/images', 0o777); + if (!fs.existsSync(outputPath + 'amWiki/images/')) { + fs.mkdirSync(outputPath + 'amWiki/images/', 0o777); } if (!fs.existsSync(outputPath + 'library/')) { fs.mkdirSync(outputPath + 'library/', 0o777); - if (!fs.existsSync(outputPath + 'library/001-学习amWiki')) { - fs.mkdirSync(outputPath + 'library/001-学习amWiki', 0o777); + if (!fs.existsSync(outputPath + 'library/001-学习amWiki/')) { + fs.mkdirSync(outputPath + 'library/001-学习amWiki/', 0o777); } - if (!fs.existsSync(outputPath + 'library/001-学习amWiki/05-学习markdown')) { - fs.mkdirSync(outputPath + 'library/001-学习amWiki/05-学习markdown', 0o777); + if (!fs.existsSync(outputPath + 'library/001-学习amWiki/05-学习markdown/')) { + fs.mkdirSync(outputPath + 'library/001-学习amWiki/05-学习markdown/', 0o777); } - if (!fs.existsSync(outputPath + 'library/002-文档示范')) { - fs.mkdirSync(outputPath + 'library/002-文档示范', 0o777); + if (!fs.existsSync(outputPath + 'library/002-文档示范/')) { + fs.mkdirSync(outputPath + 'library/002-文档示范/', 0o777); } return false; } @@ -134,150 +134,159 @@ module.exports = { //配置检查 _checkConfig: function (configPath, filesPath) { const that = this; - return new Promise((resolve, reject) => { - co(function*() { - const options = {}; - //创建路径 - options.filesPath = filesPath; - options.outputPath = configPath.split('config.json')[0].replace(/\\/g, '/'); - //读取配置 - let configStr = fs.readFileSync(configPath, 'utf-8') || ''; - if (configStr.length === 0) { - if (yield confirm2('没有读取到任何配置,继续创建么?')) { - configStr = '{}'; - } else { - return; + return co(function*() { + const options = {}; + //创建路径 + options.filesPath = filesPath; + options.outputPath = configPath.split('config.json')[0].replace(/\\/g, '/'); + //读取配置 + let configStr = ''; + let noConfig = false; + if (fs.existsSync(configPath)) { + configStr = fs.readFileSync(configPath, 'utf-8') || ''; + } else { + noConfig = true; + } + if (configStr.length === 0) { + if (yield confirm2('没有读取到任何配置,继续创建么?')) { + configStr = '{}'; + if (noConfig) { + fs.writeFileSync(configPath, configStr, 'utf-8'); } - } - //解析默认配置 - let parseOk = true, - config = null; - try { - config = JSON.parse(configStr); - } catch (e) { - alert('配置解析失败,请检查您的 config.json 是否有严格按 Json 格式书写!\n错误消息:' + e.message); - parseOk = false; - } - if (!parseOk) { + } else { return; } - //库名称 - config.name = config.name || 'amWiki轻文库系统'; - //库版本号 - config.version = typeof config.ver === 'string' ? config.ver : 'by Tevin'; - //logo地址 - config.logo = config.logo || 'amWiki/images/logo.png'; - //是否开启接口测试 - config.testing = config.testing || false; - //设置自定义颜色 - config.colour = config.colour ? that._clacWikiColour(config.colour) : that._clacWikiColour('#4296eb'); - resolve({ - options: options, - config: config - }); - }); + } + //解析默认配置 + let parseOk = true, + config = null; + try { + config = JSON.parse(configStr); + } catch (e) { + alert('配置解析失败,请检查您的 config.json 是否有严格按 Json 格式书写!\n错误消息:' + e.message); + parseOk = false; + } + if (!parseOk) { + return; + } + //库名称 + config.name = config.name || 'amWiki轻文库系统'; + //库版本号 + config.version = typeof config.ver === 'string' ? config.ver : 'by Tevin'; + //logo地址 + config.logo = config.logo || 'amWiki/images/logo.png'; + //是否开启接口测试 + config.testing = config.testing || false; + //设置自定义颜色 + config.colour = config.colour ? that._clacWikiColour(config.colour) : that._clacWikiColour('#4296eb'); + return { + options: options, + config: config + }; + }).catch((e) => { + console.error(e); }); }, /** * 创建amWiki本地文件 - * @param configPath {string} config.json文件的路径 - * @param filesPath {string} 项目包files文件夹路径 - * @returns {Promise} + * @param {string} configPath - config.json文件的路径 + * @param {string} filesPath - 项目包files文件夹路径 + * @returns {promise} 传参:项目根目录 */ create: function (configPath, filesPath) { const that = this; - return new Promise((resolve, reject) => { - co(function*() { - const {options, config} = yield that._checkConfig(configPath, filesPath); - //创建 - const files = fs.readdirSync(options.outputPath); - if (files.length > 1) { - if (!(yield confirm2('此处已有一些文件或文件夹,是否仍然在此创建amWiki?'))) { - return reject(false); - } + return co(function*() { + const {options, config} = yield that._checkConfig(configPath, filesPath); + //创建 + const files = fs.readdirSync(options.outputPath); + if (files.length > 1) { + if (!(yield confirm2('此处已有一些文件或文件夹,是否仍然在此创建amWiki?'))) { + return reject(false); } - //创建index.html - let indexPage = fs.readFileSync(options.filesPath + 'amWiki.tpl', 'utf-8'); - indexPage = indexPage.replace(/\{\{name\}\}/g, config.name) - .replace('{{version}}', config.version) - .replace('{{logo}}', config.logo); - if (config.testing) { - const testingTpl = fs.readFileSync(options.filesPath + 'amWiki.testing.tpl', 'utf-8'); - const testingScript = ''; - indexPage = indexPage - .replace('{{amWiki.testing.tpl}}', testingTpl) - .replace('{{amWiki.testing.js}}', testingScript); - } else { - indexPage = indexPage - .replace('{{amWiki.testing.tpl}}', '') - .replace('{{amWiki.testing.js}}', ''); - } - fs.writeFileSync(options.outputPath + 'index.html', indexPage, 'utf-8'); - //创建文件夹 - const hasLibrary = that._createWikiFolder(options.outputPath); - //创建amWiki.css - let wikiCss = fs.readFileSync(options.filesPath + 'amWiki.css', 'utf-8'); - if (config.testing) { - wikiCss += fs.readFileSync(options.filesPath + 'amWiki.testing.css', 'utf-8'); - } - wikiCss += fs.readFileSync(options.filesPath + 'amWiki.print.css', 'utf-8'); - wikiCss += fs.readFileSync(options.filesPath + 'amWiki.search.css', 'utf-8'); - wikiCss = wikiCss - .replace(/@colour-base/g, config.colour.base) - .replace(/@colour-light/g, config.colour.light) - .replace(/@colour-dark/g, config.colour.dark); - fs.writeFileSync(options.outputPath + 'amWiki/css/amWiki.css', wikiCss, 'utf-8'); - //拷贝页面资源 - const fileList = [ - ['markdownbody.github.css', 'amWiki/css/markdownbody.github.css'], - ['lhjs.github-gist.css', 'amWiki/css/lhjs.github-gist.css'], - ['gbk.js', 'amWiki/js/gbk.js'], - ['flowchart.min.js', 'amWiki/js/flowchart.min.js'], - ['raphael-min.js', 'amWiki/js/raphael-min.js'], - ['jquery-compat-3.1.0.min.js', 'amWiki/js/jquery-compat-3.1.0.min.js'], - ['marked.min.js', 'amWiki/js/marked.min.js'], - ['highlight.min.js', 'amWiki/js/highlight.min.js'], - ['amWiki.js', 'amWiki/js/amWiki.js'], - ['amWiki.scrollbar.js', 'amWiki/js/amWiki.scrollbar.js'], - ['amWiki.testing.js', 'amWiki/js/amWiki.testing.js'], - ['amWiki.tools.js', 'amWiki/js/amWiki.tools.js'], - ['amWiki.storage.js', 'amWiki/js/amWiki.storage.js'], - ['amWiki.docs.js', 'amWiki/js/amWiki.docs.js'], - ['amWiki.search.js', 'amWiki/js/amWiki.search.js'], - ['amWiki.search.worker.js', 'amWiki/js/amWiki.search.worker.js'], - ['icons.svg', 'amWiki/images/icons.svg'], - ['logo.png', 'amWiki/images/logo.png'], - ['menubar_bg.png', 'amWiki/images/menubar_bg.png'] + } + //创建index.html + let indexPage = fs.readFileSync(options.filesPath + 'amWiki.tpl', 'utf-8'); + indexPage = indexPage.replace(/\{\{name\}\}/g, config.name) + .replace('{{version}}', config.version) + .replace('{{logo}}', config.logo); + if (config.testing) { + const testingTpl = fs.readFileSync(options.filesPath + 'amWiki.testing.tpl', 'utf-8'); + const testingScript = ''; + indexPage = indexPage + .replace('{{amWiki.testing.tpl}}', testingTpl) + .replace('{{amWiki.testing.js}}', testingScript); + } else { + indexPage = indexPage + .replace('{{amWiki.testing.tpl}}', '') + .replace('{{amWiki.testing.js}}', ''); + } + fs.writeFileSync(options.outputPath + 'index.html', indexPage, 'utf-8'); + //创建文件夹 + const hasLibrary = that._createWikiFolder(options.outputPath); + //创建amWiki.css + let wikiCss = fs.readFileSync(options.filesPath + 'amWiki.css', 'utf-8'); + if (config.testing) { + wikiCss += fs.readFileSync(options.filesPath + 'amWiki.testing.css', 'utf-8'); + } + wikiCss += fs.readFileSync(options.filesPath + 'amWiki.print.css', 'utf-8'); + wikiCss += fs.readFileSync(options.filesPath + 'amWiki.search.css', 'utf-8'); + wikiCss = wikiCss + .replace(/@colour-base/g, config.colour.base) + .replace(/@colour-light/g, config.colour.light) + .replace(/@colour-dark/g, config.colour.dark); + fs.writeFileSync(options.outputPath + 'amWiki/css/amWiki.css', wikiCss, 'utf-8'); + //拷贝页面资源 + const fileList = [ + ['markdownbody.github.css', 'amWiki/css/markdownbody.github.css'], + ['lhjs.github-gist.css', 'amWiki/css/lhjs.github-gist.css'], + ['gbk.js', 'amWiki/js/gbk.js'], + ['flowchart.min.js', 'amWiki/js/flowchart.min.js'], + ['raphael-min.js', 'amWiki/js/raphael-min.js'], + ['jquery-compat-3.1.0.min.js', 'amWiki/js/jquery-compat-3.1.0.min.js'], + ['marked.min.js', 'amWiki/js/marked.min.js'], + ['highlight.min.js', 'amWiki/js/highlight.min.js'], + ['amWiki.js', 'amWiki/js/amWiki.js'], + ['amWiki.scrollbar.js', 'amWiki/js/amWiki.scrollbar.js'], + ['amWiki.testing.js', 'amWiki/js/amWiki.testing.js'], + ['amWiki.tools.js', 'amWiki/js/amWiki.tools.js'], + ['amWiki.storage.js', 'amWiki/js/amWiki.storage.js'], + ['amWiki.docs.js', 'amWiki/js/amWiki.docs.js'], + ['amWiki.search.js', 'amWiki/js/amWiki.search.js'], + ['amWiki.search.worker.js', 'amWiki/js/amWiki.search.worker.js'], + ['icons.svg', 'amWiki/images/icons.svg'], + ['logo.png', 'amWiki/images/logo.png'], + ['menubar_bg.png', 'amWiki/images/menubar_bg.png'] + ]; + for (let file of fileList) { + that._copyWikiFile(options.filesPath + file[0], options.outputPath + file[1]); + } + //如果没有library则复制一套默认文档 + if (!hasLibrary) { + //首页文档 + const home = fs.readFileSync(options.filesPath + 'doc.home.md', 'utf-8').replace('{{name}}', config.name); + fs.writeFileSync(options.outputPath + 'library/首页.md', home, 'utf-8'); + //其他页面文档 + let fileList2 = [ + ['doc.amwiki-introduce.md', 'library/001-学习amWiki/01-amWiki轻文库简介.md'], + ['doc.amwiki-mind-map.md', 'library/001-学习amWiki/02-amWiki功能导图.md'], + ['doc.amwiki-new.md', 'library/001-学习amWiki/03-如何开始一个新amWiki轻文库.md'], + ['doc.amwiki-edit.md', 'library/001-学习amWiki/04-如何编辑amWiki轻文库.md'], + ['doc.amwiki-testing.md', 'library/001-学习amWiki/06-使用测试模块测试接口.md'], + ['doc.amwiki-test-cross.md', 'library/001-学习amWiki/07-amWiki转接到任意域名进行接口测试.md'], + ['doc.md-start.md', 'library/001-学习amWiki/05-学习markdown/01-Markdown快速开始.md'], + ['doc.md-high-lighting.md', 'library/001-学习amWiki/05-学习markdown/02-amWiki与语法高亮.md'], + ['doc.md-flow-chart.md', 'library/001-学习amWiki/05-学习markdown/03-amWiki与流程图.md'], + ['doc.md-atom.md', 'library/001-学习amWiki/05-学习markdown/05-Atom对Markdown的原生支持.md'], + ['doc.demo-api.md', 'library/002-文档示范/001-通用API接口文档示例.md'], + ['doc.demo-long-article.md', 'library/002-文档示范/002-超长文档页内目录示例.md'] ]; - for (let file of fileList) { + for (let file of fileList2) { that._copyWikiFile(options.filesPath + file[0], options.outputPath + file[1]); } - //如果没有library则复制一套默认文档 - if (!hasLibrary) { - //首页文档 - const home = fs.readFileSync(options.filesPath + 'doc.home.md', 'utf-8').replace('{{name}}', config.name); - fs.writeFileSync(options.outputPath + 'library/首页.md', home, 'utf-8'); - //其他页面文档 - let fileList2 = [ - ['doc.amwiki-introduce.md', 'library/001-学习amWiki/01-amWiki轻文库简介.md'], - ['doc.amwiki-mind-map.md', 'library/001-学习amWiki/02-amWiki功能导图.md'], - ['doc.amwiki-new.md', 'library/001-学习amWiki/03-如何开始一个新amWiki轻文库.md'], - ['doc.amwiki-edit.md', 'library/001-学习amWiki/04-如何编辑amWiki轻文库.md'], - ['doc.amwiki-testing.md', 'library/001-学习amWiki/06-使用测试模块测试接口.md'], - ['doc.amwiki-test-cross.md', 'library/001-学习amWiki/07-amWiki转接到任意域名进行接口测试.md'], - ['doc.md-start.md', 'library/001-学习amWiki/05-学习markdown/01-Markdown快速开始.md'], - ['doc.md-high-lighting.md', 'library/001-学习amWiki/05-学习markdown/02-amWiki与语法高亮.md'], - ['doc.md-flow-chart.md', 'library/001-学习amWiki/05-学习markdown/03-amWiki与流程图.md'], - ['doc.md-atom.md', 'library/001-学习amWiki/05-学习markdown/05-Atom对Markdown的原生支持.md'], - ['doc.demo-api.md', 'library/002-文档示范/001-通用API接口文档示例.md'], - ['doc.demo-long-article.md', 'library/002-文档示范/002-超长文档页内目录示例.md'] - ]; - for (let file of fileList2) { - that._copyWikiFile(options.filesPath + file[0], options.outputPath + file[1]); - } - } - resolve(options.outputPath); - }); + } + return options.outputPath; + }).catch((e) => { + console.error(e); }); } }; \ No newline at end of file diff --git a/build/exportGithub.js b/build/exportGithub.js index a85185c..e5ce68e 100644 --- a/build/exportGithub.js +++ b/build/exportGithub.js @@ -137,7 +137,7 @@ module.exports = { //开始导出 _toExport: function (pathFrom, pathTo, fileList, duplicates) { const that = this; - co(function* () { + return co(function* () { if (fs.readdirSync(pathTo).length > 0 && (yield confirm2('所选文件夹不为空,是否需要清空?'))) { mngFolder.cleanFolder(pathTo); } @@ -166,12 +166,14 @@ module.exports = { that._exportImage(pathFrom, pathTo); that._exportHome(pathFrom, pathTo); that._exportNavigation(fileList2, duplicate2, pathFrom, pathTo); + }).catch((e) => { + console.error(e); }); }, //导出准备 _toPrepare: function (pathFrom, pathTo) { const that = this; - co(function*() { + return co(function*() { const fileList = []; pathFrom += /[\\\/]$/.test(pathFrom) ? 'library/' : '/library/'; //读取文件夹 @@ -208,6 +210,8 @@ module.exports = { } else { return that._toExport(pathFrom, pathTo, fileList); } + }).catch((e) => { + console.error(e); }); }, //GitHub地址 @@ -221,27 +225,31 @@ module.exports = { } const url = config['github-url']; if (url.indexOf('github.com') === 0 || url.split('github.com')[1] === '') { - alert('导出失败!\n请配置完整 github 项目地址!'); + alert('导出失败!\n请以https开头,配置完整的 github URL!'); return false; } const urlArr = url.split('github.com')[1].split('/'); if (urlArr.length < 3) { - alert('导出失败!\n请配置完整 github 项目地址!'); + alert('导出失败!\n请配置完整 github 项目路径!'); return false; } return '/' + urlArr[1] + '/' + urlArr[2] + '/'; }, /** * 导出为github-wiki - * @param root {string} 文库项目根目录 - * @param outputPath {string} 输出路径 + * @param {string} root - 文库项目根目录 + * @param {string} outputPath - 输出路径 + * @returns {promise} */ export: function (root, outputPath) { - //检测 GitHub 项目地址 - this._githubUrl = this._parseGithubUrl(editPath.split('library')[0]); - if (!this._githubUrl) { - return; - } - this._toPrepare(root, outputPath); + const that = this; + return co(function* () { + //检测 GitHub 项目地址 + that._githubUrl = that._parseGithubUrl(root.split('library')[0]); + if (!that._githubUrl) { + return; + } + yield that._toPrepare(root, outputPath); + }); } }; diff --git a/build/localServer.js b/build/localServer.js index 8e2aad2..ec4ec66 100644 --- a/build/localServer.js +++ b/build/localServer.js @@ -13,7 +13,7 @@ const mngWiki = require('./manageWiki'); module.exports = { /** * 启动服务器 - * @param wikis {object} 文库记录列表的引用 + * @param {object} wikis - 文库记录列表的引用 */ run: function (wikis) { if (!this._server) { @@ -22,11 +22,12 @@ module.exports = { }, /** * 浏览当前文档 - * @param editPath {string} 当前文档的路径 - * @param wikis {object} 文库记录列表的引用 + * @param {string} editPath - 当前文档的路径 + * @param {object} wikis - 文库记录列表的引用 + * @returns {promise} */ browser: function (editPath, wikis) { - co(function* () { + return co(function* () { //判断服务器 if (!this._server) { if (yield confirm2('本地服务器还未启动,您需要启动服务器么?')) { @@ -63,6 +64,8 @@ module.exports = { cmd = 'open'; } child_process.exec(cmd + ' ' + url); + }).catch((e) => { + console.error(e); }); }, /** diff --git a/build/makeNavigation.js b/build/makeNavigation.js index c74fdfe..9105e1b 100644 --- a/build/makeNavigation.js +++ b/build/makeNavigation.js @@ -9,7 +9,7 @@ const mngFolder = require('./manageFolder'); module.exports = { /** * 刷新导航(创建wiki时) - * @param editPath {string} 当前文档的路径 + * @param {string} editPath - 当前文档的路径 * @returns {string} library文件夹路径 */ refresh: function (editPath) { @@ -23,8 +23,8 @@ module.exports = { }, /** * 创建md导航文件 - * @param path {string} 文库library文件夹路径 - * @param data {object} 导航列表数据 + * @param {string} path - 文库library文件夹路径 + * @param {object} data - 导航列表数据 */ make: function (path, data) { if (this._hasDuplicateId(data)) { diff --git a/build/manageFolder.js b/build/manageFolder.js index 07f289f..ed12d60 100644 --- a/build/manageFolder.js +++ b/build/manageFolder.js @@ -8,7 +8,7 @@ const fs = require('fs'); module.exports = { /** * 读取文库library文件夹树形数据 - * @param path {string} 文库library文件夹路径 + * @param {string} path - 文库library文件夹路径 * @returns {object} 树形数据、文件列表数据、文件夹列表数据 */ readLibraryTree: function (path) { @@ -80,7 +80,7 @@ module.exports = { }, /** * 清空文件夹 - * @param path {string} 要清空的文件夹 + * @param {string} path - 要清空的文件夹 */ cleanFolder: function(path) { const list = fs.readdirSync(path); @@ -99,7 +99,7 @@ module.exports = { }, /** * 获取上一级目录 - * @param path {string} 需要计算的文件夹路径 + * @param {string} path - 需要计算的文件夹路径 * @returns {string} 父级文件夹路径 */ getParentFolder: function (path) { @@ -107,7 +107,7 @@ module.exports = { }, /** * 创建文件夹 - * @param path {string} 需要创建的文件夹路径 + * @param {string} path - 需要创建的文件夹路径 */ createFolder: function (path) { //先判断父级文件夹是否存在,不存在先创建父级文件夹 @@ -125,7 +125,7 @@ module.exports = { }, /** * 判断一个文件夹是否为amWiki文库项目 - * @param path {string} 需要判断的文件夹路径 + * @param {string} path - 需要判断的文件夹路径 * @returns {boolean|string} 否定时返回false,肯定时返回项目根目录的路径 */ isAmWiki: function (path) { @@ -136,6 +136,7 @@ module.exports = { path = path.indexOf('library') < 0 ? path : path.split('library')[0]; path = path.indexOf('config.json') < 0 ? path : path.split('config.json')[0]; path = path.indexOf('index.html') < 0 ? path : path.split('index.html')[0]; + path += /\/$/.test(path) ? '' : '/'; let states = [ fs.existsSync(path + '/library/'), fs.existsSync(path + '/amWiki/'), diff --git a/build/manageWiki.js b/build/manageWiki.js index 2515b73..58c1937 100644 --- a/build/manageWiki.js +++ b/build/manageWiki.js @@ -9,15 +9,15 @@ const mngFolder = require('./manageFolder'); module.exports = { /** * 绑定文库记录 - * @param wikis {object} 文库记录列表的引用 + * @param {object} wikis - 文库记录列表的引用 */ linkWikis: function (wikis) { this._wikis = wikis; }, /** * 添加一个文库到记录 - * @param root {string} 文库根目录 - * @param [id] {number} 文库的计算id + * @param {string} root - 文库根目录 + * @param {number} [id] - 文库的计算id */ addWiki: function (root, id = this.createWikiId(root)) { if (typeof root === 'undefined') { @@ -44,7 +44,7 @@ module.exports = { }, /** * 计算文库id - * @param root {string} 需要计算id的文库根目录 + * @param {string} root - 需要计算id的文库根目录 * @returns {number} 文库id,由根目录路径字符串计算而来 */ createWikiId: function (root) { @@ -60,7 +60,7 @@ module.exports = { }, /** * 判断文库是否加入记录,未加入则补录 - * @param path {string} 需要判断的路径 + * @param {string} path - 需要判断的路径 */ checkAddWiki: function (path) { if (path.indexOf('library') > 0) { @@ -75,7 +75,7 @@ module.exports = { }, /** * 检查文库是否仍然有效,失效则标记弃用 - * @param wId {number} 需要判断的文库id + * @param {number} wId - 需要判断的文库id */ checkWikiValid: function (wId) { if (typeof this._wikis[wId] !== 'undefined') { diff --git a/build/server.class.js b/build/server.class.js index 137a72b..6d40947 100644 --- a/build/server.class.js +++ b/build/server.class.js @@ -87,8 +87,8 @@ class Server { /** * 解析请求 - * @param req {object} 请求体的引用 - * @param res {object} 响应体的引用 + * @param {object} req - 请求体的引用 + * @param {object} res - 响应体的引用 */ parse(req, res) { const pathname = url.parse(req.url).pathname; diff --git a/lib/autoNavigation.js b/lib/autoNavigation.js index b639b60..f1a6995 100644 --- a/lib/autoNavigation.js +++ b/lib/autoNavigation.js @@ -159,7 +159,7 @@ module.exports = { }, /** * 监听发起 - * @param wikis {object} 文库记录列表的引用 + * @param {object} wikis - 文库记录列表的引用 */ start: function (wikis) { this._wikis = wikis; diff --git a/lib/dropFile.js b/lib/dropFile.js index 71c30a8..dcd1ebb 100644 --- a/lib/dropFile.js +++ b/lib/dropFile.js @@ -18,7 +18,7 @@ module.exports = { }, /** * 监听拖拽 - * @param getEditorPath {function} 获取编辑器当前文档状态的方法的引用 + * @param {function} getEditorPath - 获取编辑器当前文档状态的方法的引用 */ listenDrop: function (getEditorPath) { this._getEditorPath = getEditorPath; diff --git a/lib/pageCatalogue.js b/lib/pageCatalogue.js index 7effbec..e179ff8 100644 --- a/lib/pageCatalogue.js +++ b/lib/pageCatalogue.js @@ -6,7 +6,7 @@ module.exports = { /** * 生成页内目录 - * @param editor {object} 当前文档编辑器的引用 + * @param {object} editor - 当前文档编辑器的引用 */ make: function (editor) { editor.insertText(this._extract(editor.getText()) || ''); diff --git a/lib/pasteImg.js b/lib/pasteImg.js index 9e9e232..3c2e6a9 100644 --- a/lib/pasteImg.js +++ b/lib/pasteImg.js @@ -12,8 +12,8 @@ const mngFolder = require('../build/manageFolder'); module.exports = { /** * 粘贴图片 - * @param editor {object} 当前文档编辑器的引用 - * @param editPath {string} 当前文档的路径 + * @param {object} editor - 当前文档编辑器的引用 + * @param {string} editPath - 当前文档的路径 */ paster: function (editor, editPath) { const img = clipboard.readImage(); @@ -37,7 +37,7 @@ module.exports = { }, /** * 计算操作路径 - * @param editPath {string} 当前文档的路径 + * @param {string} editPath - 当前文档的路径 * @returns {object} 粘贴图片需要的路径列表 */ getPaths: function (editPath) {