chore: 优化模版代码。

This commit is contained in:
jaywcjlove 2022-03-10 12:07:53 +08:00
parent b7095693ac
commit 7cc0dd62c5
3 changed files with 15 additions and 13 deletions

View File

@ -23,6 +23,9 @@ const contributorsPath = path.resolve(process.cwd(), 'CONTRIBUTORS.svg');
await FS.ensureDir(path.resolve(deployDir, 'css'));
await FS.ensureDir(path.resolve(deployDir, 'c'));
await FS.copySync(faviconPath, path.resolve(deployDir, 'img', 'favicon.ico'));
await FS.copyFile(path.resolve(process.cwd(), 'template', 'js', 'copy-to-clipboard.js'), path.resolve(deployDir, 'js', 'copy-to-clipboard.js'))
const jsData = await FS.readFileSync(rootIndexJSPath);
await FS.outputFile(path.resolve(deployDir, 'js', 'index.js'), UglifyJS.minify(jsData.toString()).code)
const files = await readMarkdownPaths(path.resolve(process.cwd(), 'command'));

View File

@ -1,18 +1,6 @@
<%- include('partial/header'); %>
<%- include('widget/search',{type: "list"}); %>
<script>
/*! @uiw/copy-to-clipboard v1.0.12 | MIT (c) 2021 Kenny Wang | https://github.com/uiwjs/copy-to-clipboard.git */
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).copyTextToClipboard=t()}(this,(function(){"use strict";return function(e,t){const o=document.createElement("textarea");o.value=e,o.setAttribute("readonly",""),o.style={position:"absolute",left:"-9999px"},document.body.appendChild(o);const n=document.getSelection().rangeCount>0&&document.getSelection().getRangeAt(0);o.select();let c=!1;try{c=!!document.execCommand("copy")}catch(e){c=!1}document.body.removeChild(o),n&&document.getSelection&&(document.getSelection().removeAllRanges(),document.getSelection().addRange(n)),t&&t(c)}}));
function copied(target, str) {
target.classList.add('active');
copyTextToClipboard(target.dataset.code, function() {
setTimeout(() => {
target.classList.remove('active');
}, 2000);
});
}
</script>
<script type="text/javascript" src="<%=relative_path%>js/copy-to-clipboard.js"></script>
<div class="markdown-body">
<% if(md_path){ %>

View File

@ -0,0 +1,11 @@
/*! @uiw/copy-to-clipboard v1.0.12 | MIT (c) 2021 Kenny Wang | https://github.com/uiwjs/copy-to-clipboard.git */
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).copyTextToClipboard=t()}(this,(function(){"use strict";return function(e,t){const o=document.createElement("textarea");o.value=e,o.setAttribute("readonly",""),o.style={position:"absolute",left:"-9999px"},document.body.appendChild(o);const n=document.getSelection().rangeCount>0&&document.getSelection().getRangeAt(0);o.select();let c=!1;try{c=!!document.execCommand("copy")}catch(e){c=!1}document.body.removeChild(o),n&&document.getSelection&&(document.getSelection().removeAllRanges(),document.getSelection().addRange(n)),t&&t(c)}}));
function copied(target, str) {
target.classList.add('active');
copyTextToClipboard(target.dataset.code, function() {
setTimeout(() => {
target.classList.remove('active');
}, 2000);
});
}