mirror of
				https://github.com/yangjian102621/geekai.git
				synced 2025-11-04 16:23:42 +08:00 
			
		
		
		
	opt: remove global keyup event bind
This commit is contained in:
		@@ -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
 | 
			
		||||
 
 | 
			
		||||
@@ -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)
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
 
 | 
			
		||||
@@ -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("请输入合法的手机号/邮箱地址")
 | 
			
		||||
 
 | 
			
		||||
@@ -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)
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user