mirror of
https://github.com/HIllya51/LunaTranslator.git
synced 2025-01-14 16:33:54 +08:00
copy
This commit is contained in:
parent
8a601877d8
commit
ccf0910c23
@ -18,8 +18,8 @@
|
|||||||
<body>
|
<body>
|
||||||
<div class="header">
|
<div class="header">
|
||||||
<div class="buttons">
|
<div class="buttons">
|
||||||
<div class="buttonitem buttonsize"><a class="goodlink buttonsize" href="javascript:;"
|
<div class="buttonitem buttonsize"><a class="goodlink buttonsize" href="javascript:;" onclick="tohomeurl()"
|
||||||
onclick="tohomeurl()" id="homepage">官方网站</a></div>
|
id="homepage">官方网站</a></div>
|
||||||
<div class="buttonitem buttonsize">
|
<div class="buttonitem buttonsize">
|
||||||
<div class="dropdown buttonsize">
|
<div class="dropdown buttonsize">
|
||||||
<span class="goodlinknormal" id="downloadlink">
|
<span class="goodlinknormal" id="downloadlink">
|
||||||
@ -42,7 +42,8 @@
|
|||||||
交流群
|
交流群
|
||||||
</span>
|
</span>
|
||||||
<div class="dropdown-content ">
|
<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"
|
<a class="goodlink buttonsize" target="_blank"
|
||||||
href="https://discord.com/invite/ErtDwVeAbB">Discord<br></a>
|
href="https://discord.com/invite/ErtDwVeAbB">Discord<br></a>
|
||||||
</div>
|
</div>
|
||||||
@ -65,6 +66,8 @@
|
|||||||
<div class="backgroud">
|
<div class="backgroud">
|
||||||
</div>
|
</div>
|
||||||
<!-- <article class="markdown-section" id="main"></article> -->
|
<!-- <article class="markdown-section" id="main"></article> -->
|
||||||
|
<div id="clickcopytoast" class="clickcopytoast">
|
||||||
|
</div>
|
||||||
<div id="app"></div>
|
<div id="app"></div>
|
||||||
<script src="/main.js"></script>
|
<script src="/main.js"></script>
|
||||||
<script src="https://unpkg.com/docsify@4/lib/docsify.min.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() {
|
function tohomeurl() {
|
||||||
var hostname = window.location.hostname;
|
var hostname = window.location.hostname;
|
||||||
window.open(window.location.protocol + '//' + hostname.substring(5), '_blank');
|
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 {
|
.dropdown-content {
|
||||||
display: none;
|
display: none;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
@ -162,7 +178,7 @@ main .markdown-section {
|
|||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
.centertable{
|
.centertable {
|
||||||
align-items: center;
|
align-items: center;
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user