update
This commit is contained in:
@@ -24,7 +24,7 @@
|
|||||||
title="登录失败,请检查用户名和密码"
|
title="登录失败,请检查用户名和密码"
|
||||||
></n-alert>
|
></n-alert>
|
||||||
<n-flex>
|
<n-flex>
|
||||||
<n-button block @click="submit" type="primary">登录</n-button>
|
<n-button block :loading="loading" @click="submit" type="primary">登录</n-button>
|
||||||
</n-flex>
|
</n-flex>
|
||||||
</n-form>
|
</n-form>
|
||||||
</n-modal>
|
</n-modal>
|
||||||
@@ -37,18 +37,21 @@ import { user } from "../store/user"
|
|||||||
|
|
||||||
const name = ref("")
|
const name = ref("")
|
||||||
const password = ref("")
|
const password = ref("")
|
||||||
|
const loading = ref(false)
|
||||||
const showMeesage = ref(false)
|
const showMeesage = ref(false)
|
||||||
|
|
||||||
async function submit() {
|
async function submit() {
|
||||||
|
loading.value = true
|
||||||
try {
|
try {
|
||||||
const data = await Account.login(name.value, password.value)
|
const data = await Account.login(name.value, password.value)
|
||||||
user.username = data.username
|
user.username = data.username
|
||||||
user.role = data.role
|
user.role = data.role
|
||||||
user.loaded = true
|
user.loaded = true
|
||||||
loginModal.value = false
|
loginModal.value = false
|
||||||
|
loading.value = false
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
showMeesage.value = true
|
showMeesage.value = true
|
||||||
|
loading.value = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -82,25 +82,34 @@ function addButton() {
|
|||||||
const pres = $content.value?.querySelectorAll("pre") ?? []
|
const pres = $content.value?.querySelectorAll("pre") ?? []
|
||||||
for (const pre of pres) {
|
for (const pre of pres) {
|
||||||
let timer = 0
|
let timer = 0
|
||||||
const copy = action.cloneNode() as HTMLDivElement
|
let copyTimer = 0
|
||||||
pre.insertBefore(copy, pre.children[0])
|
const actions = action.cloneNode() as HTMLDivElement
|
||||||
|
pre.insertBefore(actions, pre.children[0])
|
||||||
const code = pre.childNodes[1] as HTMLPreElement
|
const code = pre.childNodes[1] as HTMLPreElement
|
||||||
const match = code.className.match(/-(.*)/)
|
const match = code.className.match(/-(.*)/)
|
||||||
let lang = "html"
|
let lang = "html"
|
||||||
if (match) lang = match[1].toLowerCase()
|
if (match) lang = match[1].toLowerCase()
|
||||||
copy.innerHTML = `<span class="lang">${lang.toUpperCase()}</span><div class="btn">替换<div>`
|
actions.innerHTML = `<span class="lang">${lang.toUpperCase()}</span><div><div class="btn copy">复制</div><div class="btn">替换</div></div>`
|
||||||
const btn = copy.children[1] as HTMLDivElement
|
const $copy = actions.children[1].children[0] as HTMLDivElement
|
||||||
btn.onclick = () => {
|
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
|
tab.value = lang
|
||||||
const content = pre.children[1].textContent
|
const content = pre.children[1].textContent
|
||||||
if (lang === "html") html.value = content
|
if (lang === "html") html.value = content
|
||||||
if (lang === "css") css.value = content
|
if (lang === "css") css.value = content
|
||||||
if (lang === "js") js.value = content
|
if (lang === "js") js.value = content
|
||||||
// 样式
|
// 样式
|
||||||
btn.innerHTML = "已替换"
|
$replace.innerHTML = "已替换"
|
||||||
clearTimeout(timer)
|
clearTimeout(timer)
|
||||||
timer = setTimeout(() => {
|
timer = setTimeout(() => {
|
||||||
btn.innerHTML = "替换"
|
$replace.innerHTML = "替换"
|
||||||
}, 1000)
|
}, 1000)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -185,4 +194,8 @@ watch(step, render)
|
|||||||
border-radius: 0.4rem;
|
border-radius: 0.4rem;
|
||||||
font-size: 1rem;
|
font-size: 1rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.codeblock-action .btn.copy {
|
||||||
|
right: 60px;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
Reference in New Issue
Block a user