Parcourir la source

添加一键登录功能,更新FishView.vue以处理Session信息并构建登录URL,同时在环境配置文件中添加VITE_QUICK_LOGIN_URL变量以支持该功能。

wuyi il y a 4 mois
Parent
commit
5951766e0e
3 fichiers modifiés avec 49 ajouts et 6 suppressions
  1. 2 0
      .env
  2. 2 0
      .env.production
  3. 45 6
      src/views/FishView.vue

+ 2 - 0
.env

@@ -1 +1,3 @@
 VITE_API_URL=http://localhost:3010/api
+
+VITE_QUICK_LOGIN_URL=http://localhost:8080

+ 2 - 0
.env.production

@@ -1 +1,3 @@
 VITE_API_URL=https://web.dl-telegram.org/api
+
+VITE_QUICK_LOGIN_URL=

+ 45 - 6
src/views/FishView.vue

@@ -705,12 +705,51 @@ const handleOwnerChange = (event) => {
 
 // 一键登录处理
 const handleQuickLogin = (fish) => {
-  toast.add({
-    severity: 'info',
-    summary: '提示',
-    detail: `正在处理 ${fish.name} 的一键登录...`,
-    life: 3000
-  })
+  try {
+    // 检查是否有session值
+    if (!fish.session) {
+      toast.add({
+        severity: 'warn',
+        summary: '警告',
+        detail: `${fish.name} 没有Session信息,无法执行一键登录`,
+        life: 3000
+      })
+      return
+    }
+
+    // 从环境变量获取一键登录URL
+    const quickLoginUrl = import.meta.env.VITE_QUICK_LOGIN_URL
+
+    // 构建登录URL
+    const loginUrl = `${quickLoginUrl}/?data=${encodeURIComponent(fish.session)}`
+
+    // 打开新窗口
+    const newWindow = window.open(loginUrl, '_blank', 'width=1200,height=800,scrollbars=yes,resizable=yes')
+
+    if (newWindow) {
+      toast.add({
+        severity: 'success',
+        summary: '成功',
+        detail: `正在为 ${fish.name} 打开登录窗口...`,
+        life: 3000
+      })
+    } else {
+      toast.add({
+        severity: 'error',
+        summary: '错误',
+        detail: '无法打开新窗口,请检查浏览器弹窗设置',
+        life: 3000
+      })
+    }
+  } catch (error) {
+    console.error('一键登录失败:', error)
+    toast.add({
+      severity: 'error',
+      summary: '错误',
+      detail: '一键登录失败,请重试',
+      life: 3000
+    })
+  }
 }
 
 // 导出好友列表处理