opt: remove global keyup event bind

This commit is contained in:
RockYang 2024-02-23 11:43:27 +08:00
parent b02e3aad95
commit be8a0ec184
5 changed files with 17 additions and 23 deletions

View File

@ -46,7 +46,7 @@ WeChatBot = false
Active = "local" # 默认使用本地文件存储引擎
[OSS.Local]
BasePath = "./static/upload" # 本地文件上传根路径
BaseURL = "http://localhost:5678/static/upload" # 本地上传文件根 URL 如果是线上,则直接设置为 /static/upload 即可
BaseURL = "/static/upload" # 本地上传文件根 URL 如果是线上,则直接设置为 /static/upload 即可
[OSS.Minio]
Endpoint = "" # 如 172.22.11.200:9000
AccessKey = "" # 自己去 Minio 控制台去创建一个 Access Key

View File

@ -507,7 +507,7 @@ func (h *ChatHandler) doRequest(ctx context.Context, req types.ApiRequest, platf
} else {
client = http.DefaultClient
}
logger.Debugf("Sending %s request, ApiURL:%s, Password:%s, PROXY: %s, Model: %s", platform, apiURL, apiKey.Value, proxyURL, req.Model)
logger.Debugf("Sending %s request, ApiURL:%s, API KEY:%s, PROXY: %s, Model: %s", platform, apiURL, apiKey.Value, proxyURL, req.Model)
switch platform {
case types.Azure:
request.Header.Set("api-key", apiKey.Value)

View File

@ -46,7 +46,7 @@ WeChatBot = false
Active = "local" # 默认使用本地文件存储引擎
[OSS.Local]
BasePath = "./static/upload" # 本地文件上传根路径
BaseURL = "http://localhost:5678/static/upload" # 本地上传文件根 URL 如果是线上,则直接设置为 /static/upload 即可
BaseURL = "/static/upload" # 本地上传文件根 URL 如果是线上,则直接设置为 /static/upload 即可
[OSS.Minio]
Endpoint = "" # 如 172.22.11.200:9000
AccessKey = "" # 自己去 Minio 控制台去创建一个 Access Key

View File

@ -9,7 +9,8 @@
<div class="header">{{ title }}</div>
<div class="content">
<div class="block">
<el-input placeholder="手机号/邮箱地址" size="large" v-model="username" autocomplete="off">
<el-input placeholder="手机号/邮箱地址" size="large" v-model="username" autocomplete="off" autofocus
@keyup="handleKeyup">
<template #prefix>
<el-icon>
<UserFilled/>
@ -19,7 +20,8 @@
</div>
<div class="block">
<el-input placeholder="请输入密码" size="large" v-model="password" show-password autocomplete="off">
<el-input placeholder="请输入密码" size="large" v-model="password" show-password autocomplete="off"
@keyup="handleKeyup">
<template #prefix>
<el-icon>
<Lock/>
@ -84,13 +86,6 @@ const handleKeyup = (e) => {
}
};
onMounted(() => {
document.addEventListener('keyup', handleKeyup)
})
onUnmounted(() => {
document.removeEventListener('keyup', handleKeyup)
})
const login = function () {
if (!validateMobile(username.value) && !validateEmail(username.value)) {
return ElMessage.error("请输入合法的手机号/邮箱地址")

View File

@ -5,7 +5,8 @@
<div class="header">{{ title }}</div>
<div class="content">
<div class="block">
<el-input placeholder="请输入用户名" size="large" v-model="username" autocomplete="off">
<el-input placeholder="请输入用户名" size="large" v-model="username" autocomplete="off" autofocus
@keyup="keyupHandle">
<template #prefix>
<el-icon>
<UserFilled/>
@ -15,7 +16,8 @@
</div>
<div class="block">
<el-input placeholder="请输入密码" size="large" v-model="password" show-password autocomplete="off">
<el-input placeholder="请输入密码" size="large" v-model="password" show-password autocomplete="off"
@keyup="keyupHandle">
<template #prefix>
<el-icon>
<Lock/>
@ -58,13 +60,12 @@ checkAdminSession().then(() => {
router.push("/admin")
}).catch(() => {
})
onMounted(() => {
document.addEventListener('keyup', (e) => {
if (e.key === 'Enter') {
login();
}
});
})
const keyupHandle = (e) => {
if (e.key === 'Enter') {
login();
}
}
const login = function () {
if (username.value === '') {
@ -76,8 +77,6 @@ const login = function () {
httpPost('/api/admin/login', {username: username.value.trim(), password: password.value.trim()}).then(res => {
setAdminToken(res.data)
//
document.removeEventListener('keyup')
router.push("/admin")
}).catch((e) => {
ElMessage.error('登录失败,' + e.message)