opt: remove global keyup event bind

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

View File

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

View File

@ -507,7 +507,7 @@ func (h *ChatHandler) doRequest(ctx context.Context, req types.ApiRequest, platf
} else { } else {
client = http.DefaultClient 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 { switch platform {
case types.Azure: case types.Azure:
request.Header.Set("api-key", apiKey.Value) request.Header.Set("api-key", apiKey.Value)

View File

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

View File

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

View File

@ -5,7 +5,8 @@
<div class="header">{{ title }}</div> <div class="header">{{ title }}</div>
<div class="content"> <div class="content">
<div class="block"> <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> <template #prefix>
<el-icon> <el-icon>
<UserFilled/> <UserFilled/>
@ -15,7 +16,8 @@
</div> </div>
<div class="block"> <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> <template #prefix>
<el-icon> <el-icon>
<Lock/> <Lock/>
@ -58,13 +60,12 @@ checkAdminSession().then(() => {
router.push("/admin") router.push("/admin")
}).catch(() => { }).catch(() => {
}) })
onMounted(() => {
document.addEventListener('keyup', (e) => { const keyupHandle = (e) => {
if (e.key === 'Enter') { if (e.key === 'Enter') {
login(); login();
} }
}); }
})
const login = function () { const login = function () {
if (username.value === '') { if (username.value === '') {
@ -76,8 +77,6 @@ const login = function () {
httpPost('/api/admin/login', {username: username.value.trim(), password: password.value.trim()}).then(res => { httpPost('/api/admin/login', {username: username.value.trim(), password: password.value.trim()}).then(res => {
setAdminToken(res.data) setAdminToken(res.data)
//
document.removeEventListener('keyup')
router.push("/admin") router.push("/admin")
}).catch((e) => { }).catch((e) => {
ElMessage.error('登录失败,' + e.message) ElMessage.error('登录失败,' + e.message)