merge Login page Register page

This commit is contained in:
RockYang
2025-09-07 16:36:56 +08:00
parent 2522be1738
commit 976b71e592
8 changed files with 56 additions and 169 deletions

View File

@@ -338,16 +338,13 @@ func (h *ChatHandler) sendMessage(ctx context.Context, input ChatInput, c *gin.C
},
})
} else {
// 如果不是逆向模型,则提取文件内容
modelValue := input.ChatModel.Value
if !(strings.Contains(modelValue, "-all") || strings.HasPrefix(modelValue, "gpt-4-gizmo") || strings.HasPrefix(modelValue, "claude")) {
content, err := utils.ReadFileContent(file.URL, h.App.Config.TikaHost)
if err != nil {
logger.Error("error with read file: ", err)
continue
} else {
fileContents = append(fileContents, fmt.Sprintf("%s 文件内容:%s", file.Name, content))
}
// 处理文件,提取文件内容
content, err := utils.ReadFileContent(file.URL, h.App.Config.TikaHost)
if err != nil {
logger.Error("error with read file: ", err)
continue
} else {
fileContents = append(fileContents, fmt.Sprintf("%s 文件内容:%s", file.Name, content))
}
}
}

View File

@@ -112,8 +112,8 @@ func (h *UserHandler) Register(c *gin.Context) {
return
}
// 如果注册方式不是账号密码,则需要验证
if h.captchaService.GetConfig().Enabled && data.RegWay != "username" {
// 人机验证
if h.captchaService.GetConfig().Enabled {
var check bool
if data.X != 0 {
check = h.captchaService.SlideCheck(data)

View File

@@ -7,8 +7,8 @@ package sms
// * @Author yangjian102621@163.com
// * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
const Ali = "ALI"
const Bao = "BAO"
const Ali = "aliyun"
const Bao = "bao"
type Service interface {
SendVerifyCode(mobile string, code int) error

View File

@@ -398,7 +398,7 @@ const activeName = ref('')
const wxImg = ref('/images/wx.png')
const captchaRef = ref(null)
// eslint-disable-next-line no-undef
const emits = defineEmits(['hide', 'success'])
const emits = defineEmits(['hide', 'success', 'changeActive'])
const action = ref('login')
const enableCaptcha = ref(false)
const captchaType = ref('')
@@ -411,6 +411,13 @@ const showPrivacy = ref(false)
const agreementHtml = ref('')
const privacyHtml = ref('')
watch(
() => login.value,
(newValue) => {
emits('changeActive', newValue)
}
)
onMounted(() => {
getSystemInfo()
.then((res) => {
@@ -649,7 +656,7 @@ const submitRegister = () => {
if (!agreeChecked.value) {
return ElMessage.error('请先阅读并同意《用户协议》和《隐私政策》')
}
if (enableCaptcha.value && activeName.value === 'username') {
if (enableCaptcha.value) {
captchaRef.value.loadCaptcha()
action.value = 'register'
} else {

View File

@@ -4,15 +4,14 @@
{{ btnText }}
</el-button>
<captcha @success="doSendMsg" ref="captchaRef" />
<captcha @success="doSendMsg" ref="captchaRef" :type="captchaType" />
</el-container>
</template>
<script setup>
// 发送短信验证码组件
import Captcha from '@/components/Captcha.vue'
import { getSystemInfo } from '@/store/cache'
import { httpPost } from '@/utils/http'
import { httpGet, httpPost } from '@/utils/http'
import { validateEmail, validateMobile } from '@/utils/validate'
import { ElMessage } from 'element-plus'
import { ref } from 'vue'
@@ -29,10 +28,12 @@ const props = defineProps({
const btnText = ref('发送验证码')
const canSend = ref(true)
const captchaRef = ref(null)
const enableVerify = ref(false)
const enableCaptcha = ref(false)
const captchaType = ref('')
getSystemInfo().then((res) => {
enableVerify.value = res.data['enabled_verify']
httpGet('/api/captcha/config').then((res) => {
enableCaptcha.value = res.data['enabled']
captchaType.value = res.data['type']
})
const sendMsg = () => {
@@ -43,7 +44,7 @@ const sendMsg = () => {
return ElMessage.error('请输入合法的邮箱地址')
}
if (enableVerify.value) {
if (enableCaptcha.value) {
captchaRef.value.loadCaptcha()
} else {
doSendMsg({})

View File

@@ -146,7 +146,7 @@ const routes = [
name: 'register',
path: '/register',
meta: { title: '用户注册' },
component: () => import('@/views/Register.vue'),
component: () => import('@/views/Login.vue'),
},
{
name: 'resetpassword',

View File

@@ -22,15 +22,22 @@
class="text-3xl font-semibold m-0 mb-2 tracking-tight"
style="color: var(--login-title-color)"
>
欢迎登录
{{ title }}
</h1>
<p class="text-base m-0 leading-relaxed" style="color: var(--login-subtitle-color)">
登录您的账户以继续使用服务
{{ subtitle }}
</p>
</div>
<div class="login-content">
<login-dialog :show="true" @success="handleLoginSuccess" ref="loginDialogRef" />
<div class="register-content">
<login-dialog
:show="true"
:active="active"
:inviteCode="inviteCode"
@success="handleRegisterSuccess"
@changeActive="handleChangeActive"
ref="loginDialogRef"
/>
</div>
</div>
@@ -42,22 +49,22 @@
<script setup>
import FooterBar from '@/components/FooterBar.vue'
import LoginDialog from '@/components/LoginDialog.vue'
import { setUserToken } from '@/store/session'
import { isMobile } from '@/utils/libs'
import { onMounted, ref } from 'vue'
import { computed, onMounted, ref } from 'vue'
import { useRouter } from 'vue-router'
const router = useRouter()
const loginDialogRef = ref(null)
const token = router.currentRoute.value.query.token
const inviteCode = ref(router.currentRoute.value.query.invite_code || '')
const isRegister = ref(router.currentRoute.value.path === '/register')
const active = ref(isRegister.value ? 'register' : 'login')
const title = computed(() => (isRegister.value ? '用户注册' : '用户登录'))
const subtitle = computed(() =>
isRegister.value ? '创建您的账户以开始使用服务' : '登录您的账户以继续使用服务'
)
if (token) {
setUserToken(token)
router.push('/chat')
}
// 处理登录成功
const handleLoginSuccess = () => {
// 处理注册成功
const handleRegisterSuccess = () => {
if (isMobile()) {
router.push('/mobile')
} else {
@@ -65,10 +72,14 @@ const handleLoginSuccess = () => {
}
}
const handleChangeActive = (newValue) => {
isRegister.value = !newValue
}
onMounted(() => {
// 确保默认显示登录状态
// 确保默认显示注册状态
if (loginDialogRef.value) {
loginDialogRef.value.login = true
loginDialogRef.value.login = !isRegister
}
})
</script>

View File

@@ -1,129 +0,0 @@
<template>
<div
class="min-h-screen flex items-center justify-center p-5 relative overflow-auto"
style="background: var(--login-bg)"
>
<router-link
to="/"
class="fixed top-5 left-5 z-50 flex items-center justify-center w-11 h-11 border border-transparent rounded-xl text-white no-underline shadow-lg backdrop-blur-sm transition-all duration-300 hover:-translate-y-0.5 hover:shadow-xl"
style="background: var(--btnColor)"
title="返回首页"
>
<i class="iconfont icon-home text-xl"></i>
</router-link>
<div class="w-full max-w-md mx-auto">
<div
class="rounded-3xl p-10 shadow-2xl backdrop-blur-sm relative overflow-hidden"
style="background: var(--login-card-bg); border: 1px solid var(--login-card-border)"
>
<div class="absolute top-0 left-0 right-0 h-1" style="background: var(--btnColor)"></div>
<div class="text-center mb-8">
<h1
class="text-3xl font-semibold m-0 mb-2 tracking-tight"
style="color: var(--login-title-color)"
>
用户注册
</h1>
<p class="text-base m-0 leading-relaxed" style="color: var(--login-subtitle-color)">
创建您的账户以开始使用服务
</p>
</div>
<div class="register-content">
<login-dialog
:show="true"
active="register"
:inviteCode="inviteCode"
@success="handleRegisterSuccess"
ref="loginDialogRef"
/>
</div>
</div>
<footer-bar />
</div>
</div>
</template>
<script setup>
import FooterBar from '@/components/FooterBar.vue'
import LoginDialog from '@/components/LoginDialog.vue'
import { isMobile } from '@/utils/libs'
import { onMounted, ref } from 'vue'
import { useRouter } from 'vue-router'
const router = useRouter()
const loginDialogRef = ref(null)
const inviteCode = ref(router.currentRoute.value.query.invite_code || '')
// 处理注册成功
const handleRegisterSuccess = () => {
if (isMobile()) {
router.push('/mobile')
} else {
router.push('/chat')
}
}
onMounted(() => {
// 确保默认显示注册状态
if (loginDialogRef.value) {
loginDialogRef.value.login = false
}
})
</script>
<style scoped>
/* 移动端适配 */
@media (max-width: 768px) {
.min-h-screen {
padding: 1rem;
}
.fixed.top-5.left-5 {
top: 1rem;
left: 1rem;
width: 2.5rem;
height: 2.5rem;
}
.fixed.top-5.left-5 .iconfont {
font-size: 1.125rem;
}
.max-w-md {
margin-top: 3.75rem;
}
.p-10 {
padding: 2rem 1.5rem;
}
.rounded-3xl {
border-radius: 1rem;
}
.text-3xl {
font-size: 1.5rem;
}
.text-base {
font-size: 0.875rem;
}
}
/* 小屏幕手机适配 */
@media (max-width: 480px) {
.p-10 {
padding: 1.5rem 1.25rem;
}
.text-3xl {
font-size: 1.25rem;
}
.text-base {
font-size: 0.875rem;
}
}
</style>