add wechat login for login dialog

This commit is contained in:
RockYang 2024-08-12 18:00:34 +08:00
parent 373021c191
commit 8c4c2b89ce
6 changed files with 109 additions and 41 deletions

View File

@ -2,6 +2,7 @@
## v4.1.3 ## v4.1.3
* 功能优化VIP 会员在进行任何操作都不扣减算力,以实现会员周卡月卡功能 * 功能优化VIP 会员在进行任何操作都不扣减算力,以实现会员周卡月卡功能
* 功能优化:登录注册页面可以自定义是否启用行为验证码功能
* 功能优化:管理后台给可以拖动排序的组件添加拖动图标 * 功能优化:管理后台给可以拖动排序的组件添加拖动图标
* 功能新增:支持 Luma 文生视频功能 * 功能新增:支持 Luma 文生视频功能

View File

@ -164,5 +164,7 @@ type SystemConfig struct {
IndexBgURL string `json:"index_bg_url"` // 前端首页背景图片 IndexBgURL string `json:"index_bg_url"` // 前端首页背景图片
IndexNavs []int `json:"index_navs"` // 首页显示的导航菜单 IndexNavs []int `json:"index_navs"` // 首页显示的导航菜单
Copyright string `json:"copyright"` // 版权信息 Copyright string `json:"copyright"` // 版权信息
MarkMapText string `json:"mark_map_text"` // 思维导入的默认文本 MarkMapText string `json:"mark_map_text,omitempty"` // 思维导入的默认文本
EnabledVerify bool `json:"enabled_verify,omitempty"` // 是否启用验证码
} }

View File

@ -51,12 +51,21 @@
<el-button class="login-btn" type="primary" size="large" @click="submitLogin">登录</el-button> <el-button class="login-btn" type="primary" size="large" @click="submitLogin">登录</el-button>
</el-col> </el-col>
<el-col :span="12"> <el-col :span="12">
<div class="text"> <span class="text">
还没有账号 还没有账号
<el-tag @click="login = false">注册</el-tag> <el-tag @click="login = false">注册</el-tag>
</div> </span>
<el-button type="info" class="forget" size="small" @click="login = false">忘记密码</el-button>
</el-col> </el-col>
</el-row>
<el-row v-if="wechatLoginURL !== ''">
<div class="c-login">
<div class="text">其他登录方式</div>
<div class="login-type">
<a class="wechat-login" :href="wechatLoginURL"><i class="iconfont icon-wechat"></i></a>
</div>
</div>
</el-row> </el-row>
</el-form> </el-form>
</div> </div>
@ -221,8 +230,8 @@
</template> </template>
<script setup> <script setup>
import {ref, watch} from "vue" import {onMounted, ref, watch} from "vue"
import {httpPost} from "@/utils/http"; import {httpGet, httpPost} from "@/utils/http";
import {ElMessage} from "element-plus"; import {ElMessage} from "element-plus";
import {setUserToken} from "@/store/session"; import {setUserToken} from "@/store/session";
import {validateEmail, validateMobile} from "@/utils/validate"; import {validateEmail, validateMobile} from "@/utils/validate";
@ -235,7 +244,7 @@ import {getSystemInfo} from "@/store/cache";
const props = defineProps({ const props = defineProps({
show: Boolean, show: Boolean,
}); });
const showDialog = ref(false) const showDialog = ref(true)
watch(() => props.show, (newValue) => { watch(() => props.show, (newValue) => {
showDialog.value = newValue showDialog.value = newValue
}) })
@ -252,12 +261,21 @@ const enableMobile = ref(false)
const enableEmail = ref(false) const enableEmail = ref(false)
const enableUser = ref(false) const enableUser = ref(false)
const enableRegister = ref(false) const enableRegister = ref(false)
const wechatLoginURL = ref('')
const activeName = ref("") const activeName = ref("")
const wxImg = ref("/images/wx.png") const wxImg = ref("/images/wx.png")
// eslint-disable-next-line no-undef // eslint-disable-next-line no-undef
const emits = defineEmits(['hide', 'success']); const emits = defineEmits(['hide', 'success']);
getSystemInfo().then(res => { onMounted(() => {
const returnURL = `${location.protocol}//${location.host}/login/callback`
httpGet("/api/user/clogin?return_url="+returnURL).then(res => {
wechatLoginURL.value = res.data.url
}).catch(e => {
console.error(e)
})
getSystemInfo().then(res => {
if (res.data) { if (res.data) {
const registerWays = res.data['register_ways'] const registerWays = res.data['register_ways']
if (arrayContains(registerWays, "mobile")) { if (arrayContains(registerWays, "mobile")) {
@ -279,8 +297,9 @@ getSystemInfo().then(res => {
wxImg.value = res.data['wechat_card_url'] wxImg.value = res.data['wechat_card_url']
} }
} }
}).catch(e => { }).catch(e => {
ElMessage.error("获取系统配置失败:" + e.message) ElMessage.error("获取系统配置失败:" + e.message)
})
}) })
// //
@ -388,7 +407,7 @@ const close = function () {
.btn-row { .btn-row {
display flex display flex
.el-button { .login-btn {
width 100% width 100%
} }
@ -400,6 +419,36 @@ const close = function () {
} }
} }
.forget {
margin-left 10px
}
}
.c-login {
display flex
padding-top 20px
.text {
font-size 16px
color #a1a1a1
display: flex;
align-items: center;
}
.login-type {
padding 15px
display flex
justify-content center
.iconfont {
font-size 20px
background: #E9F1F6;
padding: 8px;
border-radius: 50%;
}
.iconfont.icon-wechat {
color #0bc15f
}
}
} }
} }

View File

@ -221,9 +221,8 @@ import FileList from "@/components/FileList.vue";
import ChatSetting from "@/components/ChatSetting.vue"; import ChatSetting from "@/components/ChatSetting.vue";
import BackTop from "@/components/BackTop.vue"; import BackTop from "@/components/BackTop.vue";
import {showMessageError} from "@/utils/dialog"; import {showMessageError} from "@/utils/dialog";
import hl from "highlight.js";
const title = ref('ChatGPT-智能助手'); const title = ref('GeekAI-智能助手');
const models = ref([]) const models = ref([])
const modelID = ref(0) const modelID = ref(0)
const chatData = ref([]); const chatData = ref([]);

View File

@ -161,7 +161,7 @@ const docsURL = ref(process.env.VUE_APP_DOCS_URL)
const gitURL = ref(process.env.VUE_APP_GIT_URL) const gitURL = ref(process.env.VUE_APP_GIT_URL)
const store = useSharedStore(); const store = useSharedStore();
const show = ref(false) const show = ref(true)
watch(() => store.showLoginDialog, (newValue) => { watch(() => store.showLoginDialog, (newValue) => {
show.value = newValue show.value = newValue
}); });
@ -224,11 +224,10 @@ const init = () => {
const logout = function () { const logout = function () {
httpGet('/api/user/logout').then(() => { httpGet('/api/user/logout').then(() => {
removeUserToken() removeUserToken()
router.push("/login") store.setShowLoginDialog(true)
// store.setShowLoginDialog(true) loginUser.value = {}
// loginUser.value = {} //
// // routerViewKey.value += 1
// routerViewKey.value += 1
}).catch(() => { }).catch(() => {
ElMessage.error('注销失败!'); ElMessage.error('注销失败!');
}) })

View File

@ -107,6 +107,24 @@
</div> </div>
</el-form-item> </el-form-item>
<el-form-item label="启用验证码" prop="enabled_verify">
<div class="tip-input">
<el-switch v-model="system['enabled_verify']"/>
<div class="info">
<el-tooltip
effect="dark"
content="启用验证码之后,注册登录都会加载行为验证码,增加安全性。此功能需要购买验证码服务才会生效。"
raw-content
placement="right"
>
<el-icon>
<InfoFilled/>
</el-icon>
</el-tooltip>
</div>
</div>
</el-form-item>
<el-form-item label="注册方式" prop="register_ways"> <el-form-item label="注册方式" prop="register_ways">
<el-checkbox-group v-model="system['register_ways']"> <el-checkbox-group v-model="system['register_ways']">
<el-checkbox value="mobile">手机注册</el-checkbox> <el-checkbox value="mobile">手机注册</el-checkbox>