diff --git a/src/components/Login.vue b/src/components/Login.vue
index adcf611..90f6ac2 100644
--- a/src/components/Login.vue
+++ b/src/components/Login.vue
@@ -24,7 +24,7 @@
title="登录失败,请检查用户名和密码"
>
- 登录
+ 登录
@@ -37,18 +37,21 @@ import { user } from "../store/user"
const name = ref("")
const password = ref("")
-
+const loading = ref(false)
const showMeesage = ref(false)
async function submit() {
+ loading.value = true
try {
const data = await Account.login(name.value, password.value)
user.username = data.username
user.role = data.role
user.loaded = true
loginModal.value = false
+ loading.value = false
} catch (err) {
showMeesage.value = true
+ loading.value = false
}
}
diff --git a/src/components/Tutorial.vue b/src/components/Tutorial.vue
index 7e73b88..986b520 100644
--- a/src/components/Tutorial.vue
+++ b/src/components/Tutorial.vue
@@ -82,25 +82,34 @@ function addButton() {
const pres = $content.value?.querySelectorAll("pre") ?? []
for (const pre of pres) {
let timer = 0
- const copy = action.cloneNode() as HTMLDivElement
- pre.insertBefore(copy, pre.children[0])
+ let copyTimer = 0
+ const actions = action.cloneNode() as HTMLDivElement
+ pre.insertBefore(actions, pre.children[0])
const code = pre.childNodes[1] as HTMLPreElement
const match = code.className.match(/-(.*)/)
let lang = "html"
if (match) lang = match[1].toLowerCase()
- copy.innerHTML = `${lang.toUpperCase()}
替换
`
- const btn = copy.children[1] as HTMLDivElement
- btn.onclick = () => {
+ actions.innerHTML = `
${lang.toUpperCase()}`
+ const $copy = actions.children[1].children[0] as HTMLDivElement
+ const $replace = actions.children[1].children[1] as HTMLDivElement
+ $copy.onclick = () => {
+ $copy.innerHTML = "已复制"
+ clearTimeout(copyTimer)
+ copyTimer = setTimeout(() => {
+ $copy.innerHTML = "复制"
+ }, 1000)
+ }
+ $replace.onclick = () => {
tab.value = lang
const content = pre.children[1].textContent
if (lang === "html") html.value = content
if (lang === "css") css.value = content
if (lang === "js") js.value = content
// 样式
- btn.innerHTML = "已替换"
+ $replace.innerHTML = "已替换"
clearTimeout(timer)
timer = setTimeout(() => {
- btn.innerHTML = "替换"
+ $replace.innerHTML = "替换"
}, 1000)
}
}
@@ -185,4 +194,8 @@ watch(step, render)
border-radius: 0.4rem;
font-size: 1rem;
}
+
+.codeblock-action .btn.copy {
+ right: 60px;
+}