feat: no need login refactor with member and chatApps page

This commit is contained in:
RockYang 2024-03-19 18:59:02 +08:00
parent 58e44b7d12
commit ca83f139f7
5 changed files with 258 additions and 217 deletions

View File

@ -213,6 +213,7 @@ func needLogin(c *gin.Context) bool {
c.Request.URL.Path == "/api/sd/imgWall" || c.Request.URL.Path == "/api/sd/imgWall" ||
c.Request.URL.Path == "/api/sd/client" || c.Request.URL.Path == "/api/sd/client" ||
c.Request.URL.Path == "/api/config/get" || c.Request.URL.Path == "/api/config/get" ||
c.Request.URL.Path == "/api/product/list" ||
strings.HasPrefix(c.Request.URL.Path, "/api/test") || strings.HasPrefix(c.Request.URL.Path, "/api/test") ||
strings.HasPrefix(c.Request.URL.Path, "/api/function/") || strings.HasPrefix(c.Request.URL.Path, "/api/function/") ||
strings.HasPrefix(c.Request.URL.Path, "/api/sms/") || strings.HasPrefix(c.Request.URL.Path, "/api/sms/") ||

View File

@ -1,6 +1,6 @@
<template> <template>
<div class="user-info" id="user-info"> <div class="user-info" id="user-info">
<el-form v-if="user.id" :model="user" label-width="150px"> <el-form :model="user" label-width="150px">
<el-row> <el-row>
<el-upload <el-upload
class="avatar-uploader" class="avatar-uploader"
@ -54,11 +54,11 @@ import {checkSession} from "@/action/session";
const user = ref({ const user = ref({
vip: false, vip: false,
username: '', username: '演示数据',
nickname: '', nickname: '演示数据',
avatar: '', avatar: '/images/vip.png',
mobile: '', mobile: '演示数据',
power: 0, power: 99999,
}) })
const vipImg = ref("/images/vip.png") const vipImg = ref("/images/vip.png")

View File

@ -1,4 +1,5 @@
<template> <template>
<div>
<div class="page-apps custom-scroll"> <div class="page-apps custom-scroll">
<div class="title"> <div class="title">
AI 助手应用中心 AI 助手应用中心
@ -35,7 +36,9 @@
</ItemList> </ItemList>
</div> </div>
<login-dialog :show="showLoginDialog" @hide="getRoles"/>
</div>
<login-dialog :show="showLoginDialog" @hide="getRoles" @success=""/>
</div> </div>
</template> </template>

View File

@ -340,7 +340,7 @@
<div class="submit-btn"> <div class="submit-btn">
<el-button color="#47fff1" :dark="false" @click="generate" round>立即生成</el-button> <el-button color="#47fff1" :dark="false" @click="generate" round>立即生成</el-button>
<div class="text-info"> <div class="text-info">
<el-tag type="success">绘图可用额度{{ power }}</el-tag> <el-tag type="success">当前可用算力{{ power }}</el-tag>
</div> </div>
</div> </div>
</el-form> </el-form>
@ -481,6 +481,7 @@
</div><!-- end task list box --> </div><!-- end task list box -->
</div> </div>
<login-dialog :show="showLoginDialog" @hide="showLoginDialog = false" @success="initData"/>
</div> </div>
</template> </template>
@ -505,9 +506,12 @@ import {checkSession} from "@/action/session";
import {useRouter} from "vue-router"; import {useRouter} from "vue-router";
import {getSessionId} from "@/store/session"; import {getSessionId} from "@/store/session";
import {isMobile, removeArrayItem} from "@/utils/libs"; import {isMobile, removeArrayItem} from "@/utils/libs";
import LoginDialog from "@/components/LoginDialog.vue";
const listBoxHeight = ref(window.innerHeight - 40) const listBoxHeight = ref(window.innerHeight - 40)
const mjBoxHeight = ref(window.innerHeight - 150) const mjBoxHeight = ref(window.innerHeight - 150)
const showLoginDialog = ref(false)
window.onresize = () => { window.onresize = () => {
listBoxHeight.value = window.innerHeight - 40 listBoxHeight.value = window.innerHeight - 40
mjBoxHeight.value = window.innerHeight - 150 mjBoxHeight.value = window.innerHeight - 150
@ -583,12 +587,14 @@ const socket = ref(null)
const power = ref(0) const power = ref(0)
const translating = ref(false) const translating = ref(false)
const userId = ref(0) const userId = ref(0)
const isLogin = ref(false)
if (isMobile()) {
router.replace("/mobile/mj")
}
const rewritePrompt = () => { const rewritePrompt = () => {
if (!isLogin.value) {
showLoginDialog.value = true
return
}
translating.value = true translating.value = true
httpPost("/api/prompt/rewrite", {"prompt": params.value.prompt}).then(res => { httpPost("/api/prompt/rewrite", {"prompt": params.value.prompt}).then(res => {
params.value.prompt = res.data params.value.prompt = res.data
@ -600,6 +606,11 @@ const rewritePrompt = () => {
} }
const translatePrompt = (negative) => { const translatePrompt = (negative) => {
if (!isLogin.value) {
showLoginDialog.value = true
return
}
translating.value = true translating.value = true
let prompt = params.value.prompt let prompt = params.value.prompt
if (negative) { if (negative) {
@ -666,18 +677,7 @@ const connect = () => {
const clipboard = ref(null) const clipboard = ref(null)
onMounted(() => { onMounted(() => {
checkSession().then(user => { initData()
power.value = user['power']
userId.value = user.id
fetchRunningJobs()
fetchFinishJobs(1)
connect()
}).catch(() => {
router.push('/login')
});
clipboard.value = new Clipboard('.copy-prompt-mj'); clipboard.value = new Clipboard('.copy-prompt-mj');
clipboard.value.on('success', () => { clipboard.value.on('success', () => {
ElMessage.success("复制成功!"); ElMessage.success("复制成功!");
@ -688,6 +688,23 @@ onMounted(() => {
}) })
}) })
//
const initData = () => {
checkSession().then(user => {
power.value = user['power']
userId.value = user.id
isLogin.value = true
fetchRunningJobs()
fetchFinishJobs(1)
connect()
}).catch(() => {
});
}
onUnmounted(() => { onUnmounted(() => {
clipboard.value.destroy() clipboard.value.destroy()
}) })
@ -776,6 +793,11 @@ const changeModel = (item) => {
// //
const uploadImg = (file) => { const uploadImg = (file) => {
if (!isLogin.value) {
showLoginDialog.value = true
return
}
// //
new Compressor(file.file, { new Compressor(file.file, {
quality: 0.6, quality: 0.6,
@ -799,6 +821,11 @@ const uploadImg = (file) => {
// //
const promptRef = ref(null) const promptRef = ref(null)
const generate = () => { const generate = () => {
if (!isLogin.value) {
showLoginDialog.value = true
return
}
if (params.value.prompt === '' && params.value.task_type === "image") { if (params.value.prompt === '' && params.value.task_type === "image") {
promptRef.value.focus() promptRef.value.focus()
return ElMessage.error("请输入绘画提示词!") return ElMessage.error("请输入绘画提示词!")

View File

@ -1,4 +1,5 @@
<template> <template>
<div>
<div class="member custom-scroll"> <div class="member custom-scroll">
<div class="title"> <div class="title">
会员充值中心 会员充值中心
@ -24,7 +25,7 @@
</el-button> </el-button>
</el-col> </el-col>
<el-col :span="24" style="padding-top: 30px"> <el-col :span="24" style="padding-top: 30px" v-if="isLogin">
<el-button type="danger" round @click="logout">退出登录</el-button> <el-button type="danger" round @click="logout">退出登录</el-button>
</el-col> </el-col>
</el-row> </el-row>
@ -99,8 +100,6 @@
</div> </div>
<login-dialog :show="showLoginDialog" @hide="showLoginDialog = false"/>
<password-dialog v-if="isLogin" :show="showPasswordDialog" @hide="showPasswordDialog = false" <password-dialog v-if="isLogin" :show="showPasswordDialog" @hide="showPasswordDialog = false"
@logout="logout"/> @logout="logout"/>
@ -158,6 +157,9 @@
</el-dialog> </el-dialog>
</div> </div>
<login-dialog :show="showLoginDialog" @hide="showLoginDialog = false" @success="loginSuccess"/>
</div>
</template> </template>
<script setup> <script setup>
@ -212,14 +214,15 @@ onMounted(() => {
checkSession().then(_user => { checkSession().then(_user => {
user.value = _user user.value = _user
isLogin.value = true isLogin.value = true
}).catch(() => {
showLoginDialog.value = true
})
httpGet("/api/product/list").then((res) => { httpGet("/api/product/list").then((res) => {
list.value = res.data list.value = res.data
}).catch(e => { }).catch(e => {
ElMessage.error("获取产品套餐失败:" + e.message) ElMessage.error("获取产品套餐失败:" + e.message)
}) })
}).catch(() => {
router.push("/login")
})
httpGet("/api/config/get?key=system").then(res => { httpGet("/api/config/get?key=system").then(res => {
rewardImg.value = res.data['reward_img'] rewardImg.value = res.data['reward_img']
@ -276,10 +279,11 @@ const alipay = (row) => {
payName.value = "支付宝" payName.value = "支付宝"
curPay.value = "alipay" curPay.value = "alipay"
amount.value = (row.price - row.discount).toFixed(2) amount.value = (row.price - row.discount).toFixed(2)
if (!user.value.id) { if (!isLogin.value) {
showLoginDialog.value = true showLoginDialog.value = true
return return
} }
if (row) { if (row) {
curPayProduct.value = row curPayProduct.value = row
} }
@ -291,10 +295,11 @@ const huPiPay = (row) => {
payName.value = payWays.value["hupi"]["name"] === "wechat" ? '微信' : '支付宝' payName.value = payWays.value["hupi"]["name"] === "wechat" ? '微信' : '支付宝'
curPay.value = "hupi" curPay.value = "hupi"
amount.value = (row.price - row.discount).toFixed(2) amount.value = (row.price - row.discount).toFixed(2)
if (!user.value.id) { if (!isLogin.value) {
showLoginDialog.value = true showLoginDialog.value = true
return return
} }
if (row) { if (row) {
curPayProduct.value = row curPayProduct.value = row
} }
@ -306,10 +311,11 @@ const PayJs = (row) => {
payName.value = '微信' payName.value = '微信'
curPay.value = "payjs" curPay.value = "payjs"
amount.value = (row.price - row.discount).toFixed(2) amount.value = (row.price - row.discount).toFixed(2)
if (!user.value.id) { if (!isLogin.value) {
showLoginDialog.value = true showLoginDialog.value = true
return return
} }
if (row) { if (row) {
curPayProduct.value = row curPayProduct.value = row
} }
@ -352,6 +358,10 @@ const closeOrder = () => {
activeOrderNo.value = '' activeOrderNo.value = ''
} }
const loginSuccess = () => {
location.reload()
}
</script> </script>
<style lang="stylus"> <style lang="stylus">