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 c5e583b215
commit 8487d2c9eb
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/client" ||
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/function/") ||
strings.HasPrefix(c.Request.URL.Path, "/api/sms/") ||

View File

@ -1,6 +1,6 @@
<template>
<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-upload
class="avatar-uploader"
@ -54,11 +54,11 @@ import {checkSession} from "@/action/session";
const user = ref({
vip: false,
username: '',
nickname: '',
avatar: '',
mobile: '',
power: 0,
username: '演示数据',
nickname: '演示数据',
avatar: '/images/vip.png',
mobile: '演示数据',
power: 99999,
})
const vipImg = ref("/images/vip.png")

View File

@ -1,41 +1,44 @@
<template>
<div class="page-apps custom-scroll">
<div class="title">
AI 助手应用中心
</div>
<div class="inner" :style="{height: listBoxHeight + 'px'}">
<ItemList :items="list" v-if="list.length > 0" :gap="20" :width="250">
<template #default="scope">
<div class="app-item" :style="{width: scope.width+'px'}">
<el-image :src="scope.item.icon" fit="cover" :style="{height: scope.width+'px'}"/>
<div class="title">
<span class="name">{{ scope.item.name }}</span>
<div class="opt">
<div>
<div class="page-apps custom-scroll">
<div class="title">
AI 助手应用中心
</div>
<div class="inner" :style="{height: listBoxHeight + 'px'}">
<ItemList :items="list" v-if="list.length > 0" :gap="20" :width="250">
<template #default="scope">
<div class="app-item" :style="{width: scope.width+'px'}">
<el-image :src="scope.item.icon" fit="cover" :style="{height: scope.width+'px'}"/>
<div class="title">
<span class="name">{{ scope.item.name }}</span>
<div class="opt">
<el-button v-if="hasRole(scope.item.key)" size="small" type="danger"
@click="updateRole(scope.item,'remove')">
<el-icon>
<Delete/>
</el-icon>
<span>移除应用</span>
</el-button>
<el-button v-else size="small"
style="--el-color-primary:#009999"
@click="updateRole(scope.item, 'add')">
<el-icon>
<Plus/>
</el-icon>
<span>添加应用</span>
</el-button>
<el-button v-if="hasRole(scope.item.key)" size="small" type="danger"
@click="updateRole(scope.item,'remove')">
<el-icon>
<Delete/>
</el-icon>
<span>移除应用</span>
</el-button>
<el-button v-else size="small"
style="--el-color-primary:#009999"
@click="updateRole(scope.item, 'add')">
<el-icon>
<Plus/>
</el-icon>
<span>添加应用</span>
</el-button>
</div>
</div>
<div class="hello-msg" ref="elements">{{ scope.item.intro }}</div>
</div>
<div class="hello-msg" ref="elements">{{ scope.item.intro }}</div>
</div>
</template>
</ItemList>
</div>
</template>
</ItemList>
</div>
<login-dialog :show="showLoginDialog" @hide="getRoles"/>
</div>
<login-dialog :show="showLoginDialog" @hide="getRoles" @success=""/>
</div>
</template>

View File

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

View File

@ -1,162 +1,164 @@
<template>
<div class="member custom-scroll">
<div class="title">
会员充值中心
</div>
<div class="inner" :style="{height: listBoxHeight + 'px'}">
<el-row :gutter="20">
<el-col :span="7">
<div class="user-profile">
<user-profile/>
<el-row class="user-opt" :gutter="20">
<el-col :span="12">
<el-button type="primary" @click="showPasswordDialog = true">修改密码</el-button>
</el-col>
<el-col :span="12">
<el-button type="primary" @click="showBindMobileDialog = true">更改账号</el-button>
</el-col>
<el-col :span="12">
<el-button type="primary" v-if="enableReward" @click="showRewardDialog = true">加入众筹</el-button>
</el-col>
<el-col :span="12">
<el-button type="primary" v-if="enableReward" @click="showRewardVerifyDialog = true">众筹核销
</el-button>
</el-col>
<el-col :span="24" style="padding-top: 30px">
<el-button type="danger" round @click="logout">退出登录</el-button>
</el-col>
</el-row>
</div>
</el-col>
<el-col :span="17">
<div class="product-box">
<div class="info" v-if="orderPayInfoText !== ''">
<el-alert type="success" show-icon :closable="false" effect="dark">
<strong>说明:</strong> 月度会员年度会员每月赠送 {{ vipMonthPower }} 点算力赠送算力当月有效当月没有消费完的算力不结余到下个月
点卡充值的算力长期有效
</el-alert>
</div>
<ItemList :items="list" v-if="list.length > 0" :gap="30" :width="240">
<template #default="scope">
<div class="product-item" :style="{width: scope.width+'px'}">
<div class="image-container">
<el-image :src="vipImg" fit="cover"/>
</div>
<div class="product-title">
<span class="name">{{ scope.item.name }}</span>
</div>
<div class="product-info">
<div class="info-line">
<span class="label">商品原价</span>
<span class="price">{{ scope.item.price }}</span>
</div>
<div class="info-line">
<span class="label">促销立减</span>
<span class="price">{{ scope.item.discount }}</span>
</div>
<div class="info-line">
<span class="label">有效期</span>
<span class="expire" v-if="scope.item.days > 0">{{ scope.item.days }}</span>
<span class="expire" v-else>长期有效</span>
</div>
<div class="info-line">
<span class="label">算力值</span>
<span class="power" v-if="scope.item.power > 0">{{ scope.item.power }}</span>
<span class="power" v-else>{{ vipMonthPower }}</span>
</div>
<div class="pay-way">
<el-button type="primary" @click="alipay(scope.item)" size="small" v-if="payWays['alipay']">
<i class="iconfont icon-alipay"></i> 支付宝
</el-button>
<el-button type="success" @click="huPiPay(scope.item)" size="small" v-if="payWays['hupi']">
<span v-if="payWays['hupi']['name'] === 'wechat'"><i class="iconfont icon-wechat-pay"></i> 微信</span>
<span v-else><i class="iconfont icon-alipay"></i> 支付宝</span>
</el-button>
<el-button type="success" @click="PayJs(scope.item)" size="small" v-if="payWays['payjs']">
<span><i class="iconfont icon-wechat-pay"></i> 微信</span>
</el-button>
</div>
</div>
</div>
</template>
</ItemList>
<h2 class="headline">消费账单</h2>
<div class="user-order">
<user-order v-if="isLogin"/>
</div>
</div>
</el-col>
</el-row>
</div>
<login-dialog :show="showLoginDialog" @hide="showLoginDialog = false"/>
<password-dialog v-if="isLogin" :show="showPasswordDialog" @hide="showPasswordDialog = false"
@logout="logout"/>
<bind-mobile v-if="isLogin" :show="showBindMobileDialog" :username="user.username"
@hide="showBindMobileDialog = false"/>
<reward-verify v-if="isLogin" :show="showRewardVerifyDialog" @hide="showRewardVerifyDialog = false"/>
<el-dialog
v-model="showRewardDialog"
:show-close="true"
width="400px"
title="参与众筹"
>
<el-alert type="info" :closable="false">
<div style="font-size: 14px">您好目前每单位算力众筹价格为 <strong style="color: #f56c6c">{{ powerPrice }}
</strong>
由于本人没有开通微信支付付款后请凭借转账单号,点击众筹核销按钮手动核销
</div>
</el-alert>
<div style="text-align: center;padding-top: 10px;">
<el-image v-if="enableReward" :src="rewardImg"/>
<div>
<div class="member custom-scroll">
<div class="title">
会员充值中心
</div>
</el-dialog>
<div class="inner" :style="{height: listBoxHeight + 'px'}">
<el-row :gutter="20">
<el-col :span="7">
<div class="user-profile">
<user-profile/>
<el-dialog
v-model="showPayDialog"
:close-on-click-modal="false"
:show-close="true"
:width="400"
@close="closeOrder"
:title="'实付金额:¥'+amount">
<div class="pay-container">
<div class="count-down">
<count-down :second="orderTimeout" @timeout="refreshPayCode" ref="countDownRef"/>
</div>
<el-row class="user-opt" :gutter="20">
<el-col :span="12">
<el-button type="primary" @click="showPasswordDialog = true">修改密码</el-button>
</el-col>
<el-col :span="12">
<el-button type="primary" @click="showBindMobileDialog = true">更改账号</el-button>
</el-col>
<el-col :span="12">
<el-button type="primary" v-if="enableReward" @click="showRewardDialog = true">加入众筹</el-button>
</el-col>
<el-col :span="12">
<el-button type="primary" v-if="enableReward" @click="showRewardVerifyDialog = true">众筹核销
</el-button>
</el-col>
<div class="pay-qrcode" v-loading="loading">
<el-image :src="qrcode"/>
</div>
<el-col :span="24" style="padding-top: 30px" v-if="isLogin">
<el-button type="danger" round @click="logout">退出登录</el-button>
</el-col>
</el-row>
</div>
</el-col>
<el-col :span="17">
<div class="product-box">
<div class="info" v-if="orderPayInfoText !== ''">
<el-alert type="success" show-icon :closable="false" effect="dark">
<strong>说明:</strong> 月度会员年度会员每月赠送 {{ vipMonthPower }} 点算力赠送算力当月有效当月没有消费完的算力不结余到下个月
点卡充值的算力长期有效
</el-alert>
</div>
<ItemList :items="list" v-if="list.length > 0" :gap="30" :width="240">
<template #default="scope">
<div class="product-item" :style="{width: scope.width+'px'}">
<div class="image-container">
<el-image :src="vipImg" fit="cover"/>
</div>
<div class="product-title">
<span class="name">{{ scope.item.name }}</span>
</div>
<div class="product-info">
<div class="info-line">
<span class="label">商品原价</span>
<span class="price">{{ scope.item.price }}</span>
</div>
<div class="info-line">
<span class="label">促销立减</span>
<span class="price">{{ scope.item.discount }}</span>
</div>
<div class="info-line">
<span class="label">有效期</span>
<span class="expire" v-if="scope.item.days > 0">{{ scope.item.days }}</span>
<span class="expire" v-else>长期有效</span>
</div>
<div class="info-line">
<span class="label">算力值</span>
<span class="power" v-if="scope.item.power > 0">{{ scope.item.power }}</span>
<span class="power" v-else>{{ vipMonthPower }}</span>
</div>
<div class="pay-way">
<el-button type="primary" @click="alipay(scope.item)" size="small" v-if="payWays['alipay']">
<i class="iconfont icon-alipay"></i> 支付宝
</el-button>
<el-button type="success" @click="huPiPay(scope.item)" size="small" v-if="payWays['hupi']">
<span v-if="payWays['hupi']['name'] === 'wechat'"><i class="iconfont icon-wechat-pay"></i> 微信</span>
<span v-else><i class="iconfont icon-alipay"></i> 支付宝</span>
</el-button>
<el-button type="success" @click="PayJs(scope.item)" size="small" v-if="payWays['payjs']">
<span><i class="iconfont icon-wechat-pay"></i> 微信</span>
</el-button>
</div>
</div>
</div>
</template>
</ItemList>
<h2 class="headline">消费账单</h2>
<div class="user-order">
<user-order v-if="isLogin"/>
</div>
</div>
</el-col>
</el-row>
<div class="tip success" v-if="text !== ''">
<el-icon>
<SuccessFilled/>
</el-icon>
<span class="text">{{ text }}</span>
</div>
<div class="tip" v-else>
<el-icon>
<InfoFilled/>
</el-icon>
<span class="text">请打开手机{{ payName }}扫码支付</span>
</div>
</div>
</el-dialog>
<password-dialog v-if="isLogin" :show="showPasswordDialog" @hide="showPasswordDialog = false"
@logout="logout"/>
<bind-mobile v-if="isLogin" :show="showBindMobileDialog" :username="user.username"
@hide="showBindMobileDialog = false"/>
<reward-verify v-if="isLogin" :show="showRewardVerifyDialog" @hide="showRewardVerifyDialog = false"/>
<el-dialog
v-model="showRewardDialog"
:show-close="true"
width="400px"
title="参与众筹"
>
<el-alert type="info" :closable="false">
<div style="font-size: 14px">您好目前每单位算力众筹价格为 <strong style="color: #f56c6c">{{ powerPrice }}
</strong>
由于本人没有开通微信支付付款后请凭借转账单号,点击众筹核销按钮手动核销
</div>
</el-alert>
<div style="text-align: center;padding-top: 10px;">
<el-image v-if="enableReward" :src="rewardImg"/>
</div>
</el-dialog>
<el-dialog
v-model="showPayDialog"
:close-on-click-modal="false"
:show-close="true"
:width="400"
@close="closeOrder"
:title="'实付金额:¥'+amount">
<div class="pay-container">
<div class="count-down">
<count-down :second="orderTimeout" @timeout="refreshPayCode" ref="countDownRef"/>
</div>
<div class="pay-qrcode" v-loading="loading">
<el-image :src="qrcode"/>
</div>
<div class="tip success" v-if="text !== ''">
<el-icon>
<SuccessFilled/>
</el-icon>
<span class="text">{{ text }}</span>
</div>
<div class="tip" v-else>
<el-icon>
<InfoFilled/>
</el-icon>
<span class="text">请打开手机{{ payName }}扫码支付</span>
</div>
</div>
</el-dialog>
</div>
<login-dialog :show="showLoginDialog" @hide="showLoginDialog = false" @success="loginSuccess"/>
</div>
</template>
@ -212,13 +214,14 @@ onMounted(() => {
checkSession().then(_user => {
user.value = _user
isLogin.value = true
httpGet("/api/product/list").then((res) => {
list.value = res.data
}).catch(e => {
ElMessage.error("获取产品套餐失败:" + e.message)
})
}).catch(() => {
router.push("/login")
showLoginDialog.value = true
})
httpGet("/api/product/list").then((res) => {
list.value = res.data
}).catch(e => {
ElMessage.error("获取产品套餐失败:" + e.message)
})
httpGet("/api/config/get?key=system").then(res => {
@ -276,10 +279,11 @@ const alipay = (row) => {
payName.value = "支付宝"
curPay.value = "alipay"
amount.value = (row.price - row.discount).toFixed(2)
if (!user.value.id) {
if (!isLogin.value) {
showLoginDialog.value = true
return
}
if (row) {
curPayProduct.value = row
}
@ -291,10 +295,11 @@ const huPiPay = (row) => {
payName.value = payWays.value["hupi"]["name"] === "wechat" ? '微信' : '支付宝'
curPay.value = "hupi"
amount.value = (row.price - row.discount).toFixed(2)
if (!user.value.id) {
if (!isLogin.value) {
showLoginDialog.value = true
return
}
if (row) {
curPayProduct.value = row
}
@ -306,10 +311,11 @@ const PayJs = (row) => {
payName.value = '微信'
curPay.value = "payjs"
amount.value = (row.price - row.discount).toFixed(2)
if (!user.value.id) {
if (!isLogin.value) {
showLoginDialog.value = true
return
}
if (row) {
curPayProduct.value = row
}
@ -352,6 +358,10 @@ const closeOrder = () => {
activeOrderNo.value = ''
}
const loginSuccess = () => {
location.reload()
}
</script>
<style lang="stylus">