mirror of
https://github.com/HIllya51/LunaTranslator.git
synced 2025-01-13 23:53:54 +08:00
copy
This commit is contained in:
parent
8a601877d8
commit
ccf0910c23
@ -18,8 +18,8 @@
|
||||
<body>
|
||||
<div class="header">
|
||||
<div class="buttons">
|
||||
<div class="buttonitem buttonsize"><a class="goodlink buttonsize" href="javascript:;"
|
||||
onclick="tohomeurl()" id="homepage">官方网站</a></div>
|
||||
<div class="buttonitem buttonsize"><a class="goodlink buttonsize" href="javascript:;" onclick="tohomeurl()"
|
||||
id="homepage">官方网站</a></div>
|
||||
<div class="buttonitem buttonsize">
|
||||
<div class="dropdown buttonsize">
|
||||
<span class="goodlinknormal" id="downloadlink">
|
||||
@ -42,7 +42,8 @@
|
||||
交流群
|
||||
</span>
|
||||
<div class="dropdown-content ">
|
||||
<a class="goodlink buttonsize" target="_blank" href="https://qm.qq.com/q/I5rr3uEpi2">QQ群963119821<br></a>
|
||||
<a class="goodlink buttonsize" target="_blank"
|
||||
href="https://qm.qq.com/q/I5rr3uEpi2">QQ群963119821<br></a>
|
||||
<a class="goodlink buttonsize" target="_blank"
|
||||
href="https://discord.com/invite/ErtDwVeAbB">Discord<br></a>
|
||||
</div>
|
||||
@ -65,6 +66,8 @@
|
||||
<div class="backgroud">
|
||||
</div>
|
||||
<!-- <article class="markdown-section" id="main"></article> -->
|
||||
<div id="clickcopytoast" class="clickcopytoast">
|
||||
</div>
|
||||
<div id="app"></div>
|
||||
<script src="/main.js"></script>
|
||||
<script src="https://unpkg.com/docsify@4/lib/docsify.min.js"></script>
|
||||
|
50
docs/main.js
50
docs/main.js
@ -83,6 +83,17 @@ window.$docsify = {
|
||||
}
|
||||
})
|
||||
},
|
||||
function (hook, vm) {
|
||||
hook.doneEach(() => {
|
||||
var elements = document.querySelectorAll('code');
|
||||
elements.forEach(function (element) {
|
||||
if (!element.innerHTML.startsWith('https://')) return
|
||||
element.addEventListener('click', function () {
|
||||
copyToClipboard(element.innerText)
|
||||
});
|
||||
});
|
||||
})
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
@ -166,4 +177,41 @@ window.onpopstate = function (event) {
|
||||
function tohomeurl() {
|
||||
var hostname = window.location.hostname;
|
||||
window.open(window.location.protocol + '//' + hostname.substring(5), '_blank');
|
||||
}
|
||||
}
|
||||
|
||||
function copyToClipboard(text) {
|
||||
let url = window.location.href;
|
||||
let thislang = getcurrlang(url)
|
||||
const langs = {
|
||||
zh: {
|
||||
ok: '已复制到剪贴板!',
|
||||
fail: '无法复制:',
|
||||
},
|
||||
en: {
|
||||
ok: 'Copy to clipboard!',
|
||||
fail: 'Cannot copy:',
|
||||
},
|
||||
ru: {
|
||||
ok: 'Копировать в буфер обмена!',
|
||||
fail: 'Невозможно скопировать:',
|
||||
},
|
||||
}
|
||||
|
||||
navigator.clipboard.writeText(text).then(function () {
|
||||
showToast(langs[thislang].ok);
|
||||
}, function (err) {
|
||||
showToast(langs[thislang].fail + err);
|
||||
});
|
||||
}
|
||||
showtoastsig = null
|
||||
function showToast(message) {
|
||||
var toast = document.getElementById("clickcopytoast");
|
||||
toast.style.display = "block";
|
||||
toast.innerHTML = message;
|
||||
let thissig = Math.random()
|
||||
showtoastsig = thissig
|
||||
setTimeout(function () {
|
||||
if (showtoastsig == thissig)
|
||||
toast.style.display = "none";
|
||||
}, 3000);
|
||||
}
|
@ -44,6 +44,22 @@
|
||||
|
||||
}
|
||||
|
||||
.clickcopy {
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.clickcopytoast {
|
||||
display: none;
|
||||
position: fixed;
|
||||
bottom: 20px;
|
||||
right: 20px;
|
||||
background-color: #333;
|
||||
color: white;
|
||||
padding: 16px;
|
||||
border-radius: 5px;
|
||||
z-index: 1000;
|
||||
}
|
||||
|
||||
.dropdown-content {
|
||||
display: none;
|
||||
position: absolute;
|
||||
@ -162,7 +178,7 @@ main .markdown-section {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.centertable{
|
||||
.centertable {
|
||||
align-items: center;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
|
Loading…
x
Reference in New Issue
Block a user