Skip to content

Commit 7cc0dd6

Browse files
committed
chore: 优化模版代码。
1 parent b709569 commit 7cc0dd6

File tree

3 files changed

+15
-13
lines changed

3 files changed

+15
-13
lines changed

build/build.mjs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ const contributorsPath = path.resolve(process.cwd(), 'CONTRIBUTORS.svg');
2323
await FS.ensureDir(path.resolve(deployDir, 'css'));
2424
await FS.ensureDir(path.resolve(deployDir, 'c'));
2525
await FS.copySync(faviconPath, path.resolve(deployDir, 'img', 'favicon.ico'));
26+
27+
await FS.copyFile(path.resolve(process.cwd(), 'template', 'js', 'copy-to-clipboard.js'), path.resolve(deployDir, 'js', 'copy-to-clipboard.js'))
28+
2629
const jsData = await FS.readFileSync(rootIndexJSPath);
2730
await FS.outputFile(path.resolve(deployDir, 'js', 'index.js'), UglifyJS.minify(jsData.toString()).code)
2831
const files = await readMarkdownPaths(path.resolve(process.cwd(), 'command'));

template/details.ejs

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,6 @@
11
<%- include('partial/header'); %>
22
<%- include('widget/search',{type: "list"}); %>
3-
<script>
4-
/*! @uiw/copy-to-clipboard v1.0.12 | MIT (c) 2021 Kenny Wang | https://github.com/uiwjs/copy-to-clipboard.git */
5-
!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)}}));
6-
7-
function copied(target, str) {
8-
target.classList.add('active');
9-
copyTextToClipboard(target.dataset.code, function() {
10-
setTimeout(() => {
11-
target.classList.remove('active');
12-
}, 2000);
13-
});
14-
}
15-
</script>
3+
<script type="text/javascript" src="<%=relative_path%>js/copy-to-clipboard.js"></script>
164

175
<div class="markdown-body">
186
<% if(md_path){ %>

template/js/copy-to-clipboard.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/*! @uiw/copy-to-clipboard v1.0.12 | MIT (c) 2021 Kenny Wang | https://github.com/uiwjs/copy-to-clipboard.git */
2+
!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)}}));
3+
4+
function copied(target, str) {
5+
target.classList.add('active');
6+
copyTextToClipboard(target.dataset.code, function() {
7+
setTimeout(() => {
8+
target.classList.remove('active');
9+
}, 2000);
10+
});
11+
}

0 commit comments

Comments
 (0)