mirror of
https://github.com/yangjian102621/geekai.git
synced 2025-09-18 01:06:39 +08:00
opt: close unused websocket connections
This commit is contained in:
parent
7bb76d581c
commit
cc1a3ce343
@ -204,6 +204,7 @@ func needLogin(c *gin.Context) bool {
|
|||||||
c.Request.URL.Path == "/api/admin/login" ||
|
c.Request.URL.Path == "/api/admin/login" ||
|
||||||
c.Request.URL.Path == "/api/admin/login/captcha" ||
|
c.Request.URL.Path == "/api/admin/login/captcha" ||
|
||||||
c.Request.URL.Path == "/api/user/register" ||
|
c.Request.URL.Path == "/api/user/register" ||
|
||||||
|
c.Request.URL.Path == "/api/user/session" ||
|
||||||
c.Request.URL.Path == "/api/chat/history" ||
|
c.Request.URL.Path == "/api/chat/history" ||
|
||||||
c.Request.URL.Path == "/api/chat/detail" ||
|
c.Request.URL.Path == "/api/chat/detail" ||
|
||||||
c.Request.URL.Path == "/api/chat/list" ||
|
c.Request.URL.Path == "/api/chat/list" ||
|
||||||
|
@ -137,6 +137,7 @@ func (h *ChatHandler) ChatHandle(c *gin.Context) {
|
|||||||
for {
|
for {
|
||||||
_, msg, err := client.Receive()
|
_, msg, err := client.Receive()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
logger.Debugf("close connection: %s", client.Conn.RemoteAddr())
|
||||||
client.Close()
|
client.Close()
|
||||||
h.App.ChatClients.Delete(sessionId)
|
h.App.ChatClients.Delete(sessionId)
|
||||||
h.App.ChatSession.Delete(sessionId)
|
h.App.ChatSession.Delete(sessionId)
|
||||||
|
@ -6,10 +6,11 @@ import (
|
|||||||
"chatplus/store"
|
"chatplus/store"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/imroc/req/v3"
|
|
||||||
"github.com/shirou/gopsutil/host"
|
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/imroc/req/v3"
|
||||||
|
"github.com/shirou/gopsutil/host"
|
||||||
)
|
)
|
||||||
|
|
||||||
type LicenseService struct {
|
type LicenseService struct {
|
||||||
@ -119,7 +120,7 @@ func (s *LicenseService) SyncLicense() {
|
|||||||
IsActive: true,
|
IsActive: true,
|
||||||
}
|
}
|
||||||
s.urlWhiteList = res.Data.Urls
|
s.urlWhiteList = res.Data.Urls
|
||||||
logger.Debugf("同步 License 成功:%v\n%v", s.license, s.urlWhiteList)
|
//logger.Debugf("同步 License 成功:%v\n%v", s.license, s.urlWhiteList)
|
||||||
next:
|
next:
|
||||||
time.Sleep(time.Second * 10)
|
time.Sleep(time.Second * 10)
|
||||||
}
|
}
|
||||||
|
@ -66,4 +66,14 @@ html, body {
|
|||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.van-toast--fail {
|
||||||
|
background #fef0f0
|
||||||
|
color #f56c6c
|
||||||
|
}
|
||||||
|
|
||||||
|
.van-toast--success {
|
||||||
|
background #D6FBCC
|
||||||
|
color #07C160
|
||||||
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
.chat-list-wrapper {
|
.chat-list-wrapper {
|
||||||
padding 10px 0 10px 0
|
padding 10px 0 10px 0
|
||||||
background #F5F5F5;
|
background var(--van-background);
|
||||||
overflow hidden
|
overflow hidden
|
||||||
|
|
||||||
|
|
||||||
@ -81,7 +81,7 @@
|
|||||||
|
|
||||||
.van-theme-dark {
|
.van-theme-dark {
|
||||||
.mobile-chat {
|
.mobile-chat {
|
||||||
.message-list-box {
|
.chat-list-wrapper {
|
||||||
background #232425;
|
background #232425;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -38,11 +38,11 @@
|
|||||||
import {ref} from "vue";
|
import {ref} from "vue";
|
||||||
import lodash from 'lodash'
|
import lodash from 'lodash'
|
||||||
import {validateEmail, validateMobile} from "@/utils/validate";
|
import {validateEmail, validateMobile} from "@/utils/validate";
|
||||||
import {ElMessage} from "element-plus";
|
|
||||||
import {httpGet, httpPost} from "@/utils/http";
|
import {httpGet, httpPost} from "@/utils/http";
|
||||||
import CaptchaPlus from "@/components/CaptchaPlus.vue";
|
import CaptchaPlus from "@/components/CaptchaPlus.vue";
|
||||||
import SlideCaptcha from "@/components/SlideCaptcha.vue";
|
import SlideCaptcha from "@/components/SlideCaptcha.vue";
|
||||||
import {isMobile} from "@/utils/libs";
|
import {isMobile} from "@/utils/libs";
|
||||||
|
import {showMessageError, showMessageOK} from "@/utils/dialog";
|
||||||
|
|
||||||
// eslint-disable-next-line no-undef
|
// eslint-disable-next-line no-undef
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
@ -66,13 +66,13 @@ const handleRequestCaptCode = () => {
|
|||||||
thumbBase64.value = data.thumb
|
thumbBase64.value = data.thumb
|
||||||
captKey.value = data.key
|
captKey.value = data.key
|
||||||
}).catch(e => {
|
}).catch(e => {
|
||||||
ElMessage.error('获取人机验证数据失败:' + e.message)
|
showMessageError('获取人机验证数据失败:' + e.message)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleConfirm = (dots) => {
|
const handleConfirm = (dots) => {
|
||||||
if (lodash.size(dots) <= 0) {
|
if (lodash.size(dots) <= 0) {
|
||||||
return ElMessage.error('请进行人机验证再操作')
|
return showMessageError('请进行人机验证再操作')
|
||||||
}
|
}
|
||||||
|
|
||||||
let dotArr = []
|
let dotArr = []
|
||||||
@ -88,14 +88,14 @@ const handleConfirm = (dots) => {
|
|||||||
showCaptcha.value = false
|
showCaptcha.value = false
|
||||||
sendMsg()
|
sendMsg()
|
||||||
}).catch(() => {
|
}).catch(() => {
|
||||||
ElMessage.error('人机验证失败')
|
showMessageError('人机验证失败')
|
||||||
handleRequestCaptCode()
|
handleRequestCaptCode()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const loadCaptcha = () => {
|
const loadCaptcha = () => {
|
||||||
if (!validateMobile(props.receiver) && !validateEmail(props.receiver)) {
|
if (!validateMobile(props.receiver) && !validateEmail(props.receiver)) {
|
||||||
return ElMessage.error("请输入合法的手机号/邮箱地址")
|
return showMessageError("请输入合法的手机号/邮箱地址")
|
||||||
}
|
}
|
||||||
|
|
||||||
showCaptcha.value = true
|
showCaptcha.value = true
|
||||||
@ -114,7 +114,7 @@ const sendMsg = () => {
|
|||||||
|
|
||||||
canSend.value = false
|
canSend.value = false
|
||||||
httpPost('/api/sms/code', {receiver: props.receiver, key: captKey.value, dots: dots.value}).then(() => {
|
httpPost('/api/sms/code', {receiver: props.receiver, key: captKey.value, dots: dots.value}).then(() => {
|
||||||
ElMessage.success('验证码发送成功')
|
showMessageOK('验证码发送成功')
|
||||||
let time = 120
|
let time = 120
|
||||||
btnText.value = time
|
btnText.value = time
|
||||||
const handler = setInterval(() => {
|
const handler = setInterval(() => {
|
||||||
@ -129,7 +129,7 @@ const sendMsg = () => {
|
|||||||
}, 1000)
|
}, 1000)
|
||||||
}).catch(e => {
|
}).catch(e => {
|
||||||
canSend.value = true
|
canSend.value = true
|
||||||
ElMessage.error('验证码发送失败:' + e.message)
|
showMessageError('验证码发送失败:' + e.message)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -145,7 +145,7 @@ const getSlideCaptcha = () => {
|
|||||||
bgImg.value = res.data.bgImg
|
bgImg.value = res.data.bgImg
|
||||||
captKey.value = res.data.key
|
captKey.value = res.data.key
|
||||||
}).catch(e => {
|
}).catch(e => {
|
||||||
ElMessage.error('获取人机验证数据失败:' + e.message)
|
showMessageError('获取人机验证数据失败:' + e.message)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
43
web/src/utils/dialog.js
Normal file
43
web/src/utils/dialog.js
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
/**
|
||||||
|
* Util lib functions
|
||||||
|
*/
|
||||||
|
import {showConfirmDialog, showFailToast, showSuccessToast, showToast} from "vant";
|
||||||
|
import {isMobile} from "@/utils/libs";
|
||||||
|
import {ElMessage} from "element-plus";
|
||||||
|
|
||||||
|
export function showLoginDialog(router) {
|
||||||
|
showConfirmDialog({
|
||||||
|
title: '登录',
|
||||||
|
message:
|
||||||
|
'此操作需要登录才能进行,前往登录?',
|
||||||
|
}).then(() => {
|
||||||
|
router.push("/login")
|
||||||
|
}).catch(() => {
|
||||||
|
// on cancel
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export function showMessageOK(message) {
|
||||||
|
if (isMobile()) {
|
||||||
|
showSuccessToast(message)
|
||||||
|
} else {
|
||||||
|
ElMessage.success(message)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export function showMessageInfo(message) {
|
||||||
|
if (isMobile()) {
|
||||||
|
showToast(message)
|
||||||
|
} else {
|
||||||
|
ElMessage.info(message)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function showMessageError(message) {
|
||||||
|
if (isMobile()) {
|
||||||
|
showFailToast(message)
|
||||||
|
} else {
|
||||||
|
ElMessage.error(message)
|
||||||
|
}
|
||||||
|
}
|
@ -330,7 +330,10 @@ onMounted(() => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
|
if (socket.value !== null) {
|
||||||
|
socket.value.close()
|
||||||
socket.value = null
|
socket.value = null
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
// 初始化数据
|
// 初始化数据
|
||||||
|
@ -761,7 +761,10 @@ onMounted(() => {
|
|||||||
|
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
clipboard.value.destroy()
|
clipboard.value.destroy()
|
||||||
|
if (socket.value !== null) {
|
||||||
|
socket.value.close()
|
||||||
socket.value = null
|
socket.value = null
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
// 初始化数据
|
// 初始化数据
|
||||||
@ -779,10 +782,6 @@ const initData = () => {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
onUnmounted(() => {
|
|
||||||
clipboard.value.destroy()
|
|
||||||
})
|
|
||||||
|
|
||||||
const mjPower = ref(1)
|
const mjPower = ref(1)
|
||||||
const mjActionPower = ref(1)
|
const mjActionPower = ref(1)
|
||||||
httpGet("/api/config/get?key=system").then(res => {
|
httpGet("/api/config/get?key=system").then(res => {
|
||||||
|
@ -616,7 +616,10 @@ onMounted(() => {
|
|||||||
|
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
clipboard.value.destroy()
|
clipboard.value.destroy()
|
||||||
|
if (socket.value !== null) {
|
||||||
|
socket.value.close()
|
||||||
socket.value = null
|
socket.value = null
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
@ -56,13 +56,13 @@
|
|||||||
import {ref} from "vue";
|
import {ref} from "vue";
|
||||||
import {Lock, UserFilled} from "@element-plus/icons-vue";
|
import {Lock, UserFilled} from "@element-plus/icons-vue";
|
||||||
import {httpGet, httpPost} from "@/utils/http";
|
import {httpGet, httpPost} from "@/utils/http";
|
||||||
import {ElMessage} from "element-plus";
|
|
||||||
import {useRouter} from "vue-router";
|
import {useRouter} from "vue-router";
|
||||||
import FooterBar from "@/components/FooterBar.vue";
|
import FooterBar from "@/components/FooterBar.vue";
|
||||||
import {isMobile} from "@/utils/libs";
|
import {isMobile} from "@/utils/libs";
|
||||||
import {checkSession} from "@/action/session";
|
import {checkSession} from "@/action/session";
|
||||||
import {setUserToken} from "@/store/session";
|
import {setUserToken} from "@/store/session";
|
||||||
import ResetPass from "@/components/ResetPass.vue";
|
import ResetPass from "@/components/ResetPass.vue";
|
||||||
|
import {showMessageError} from "@/utils/dialog";
|
||||||
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const title = ref('Geek-AI');
|
const title = ref('Geek-AI');
|
||||||
@ -76,7 +76,7 @@ httpGet("/api/config/get?key=system").then(res => {
|
|||||||
logo.value = res.data.logo
|
logo.value = res.data.logo
|
||||||
title.value = res.data.title
|
title.value = res.data.title
|
||||||
}).catch(e => {
|
}).catch(e => {
|
||||||
ElMessage.error("获取系统配置失败:" + e.message)
|
showMessageError("获取系统配置失败:" + e.message)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
@ -97,10 +97,10 @@ const handleKeyup = (e) => {
|
|||||||
|
|
||||||
const login = function () {
|
const login = function () {
|
||||||
if (username.value.trim() === '') {
|
if (username.value.trim() === '') {
|
||||||
return ElMessage.error("请输入用户民")
|
return showMessageError("请输入用户民")
|
||||||
}
|
}
|
||||||
if (password.value.trim() === '') {
|
if (password.value.trim() === '') {
|
||||||
return ElMessage.error('请输入密码');
|
return showMessageError('请输入密码');
|
||||||
}
|
}
|
||||||
|
|
||||||
httpPost('/api/user/login', {username: username.value.trim(), password: password.value.trim()}).then((res) => {
|
httpPost('/api/user/login', {username: username.value.trim(), password: password.value.trim()}).then((res) => {
|
||||||
@ -112,11 +112,10 @@ const login = function () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}).catch((e) => {
|
}).catch((e) => {
|
||||||
ElMessage.error('登录失败,' + e.message)
|
showMessageError('登录失败,' + e.message)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="stylus" scoped>
|
<style lang="stylus" scoped>
|
||||||
|
@ -180,6 +180,7 @@ import SendMsg from "@/components/SendMsg.vue";
|
|||||||
import {arrayContains} from "@/utils/libs";
|
import {arrayContains} from "@/utils/libs";
|
||||||
import {setUserToken} from "@/store/session";
|
import {setUserToken} from "@/store/session";
|
||||||
import {validateEmail, validateMobile} from "@/utils/validate";
|
import {validateEmail, validateMobile} from "@/utils/validate";
|
||||||
|
import {showMessageError, showMessageOK} from "@/utils/dialog";
|
||||||
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const title = ref('Geek-AI 用户注册');
|
const title = ref('Geek-AI 用户注册');
|
||||||
@ -227,37 +228,37 @@ httpGet("/api/config/get?key=system").then(res => {
|
|||||||
// 注册操作
|
// 注册操作
|
||||||
const submitRegister = () => {
|
const submitRegister = () => {
|
||||||
if (data.value.username === '') {
|
if (data.value.username === '') {
|
||||||
return ElMessage.error('请输入用户名');
|
return showMessageError('请输入用户名');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (activeName.value === 'mobile' && !validateMobile(data.value.username)) {
|
if (activeName.value === 'mobile' && !validateMobile(data.value.username)) {
|
||||||
return ElMessage.error('请输入合法的手机号');
|
return showMessageError('请输入合法的手机号');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (activeName.value === 'email' && !validateEmail(data.value.username)) {
|
if (activeName.value === 'email' && !validateEmail(data.value.username)) {
|
||||||
return ElMessage.error('请输入合法的邮箱地址');
|
return showMessageError('请输入合法的邮箱地址');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data.value.password.length < 8) {
|
if (data.value.password.length < 8) {
|
||||||
return ElMessage.error('密码的长度为8-16个字符');
|
return showMessageError('密码的长度为8-16个字符');
|
||||||
}
|
}
|
||||||
if (data.value.repass !== data.value.password) {
|
if (data.value.repass !== data.value.password) {
|
||||||
return ElMessage.error('两次输入密码不一致');
|
return showMessageError('两次输入密码不一致');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((activeName.value === 'mobile' || activeName.value === 'email') && data.value.code === '') {
|
if ((activeName.value === 'mobile' || activeName.value === 'email') && data.value.code === '') {
|
||||||
return ElMessage.error('请输入验证码');
|
return showMessageError('请输入验证码');
|
||||||
}
|
}
|
||||||
data.value.reg_way = activeName.value
|
data.value.reg_way = activeName.value
|
||||||
httpPost('/api/user/register', data.value).then((res) => {
|
httpPost('/api/user/register', data.value).then((res) => {
|
||||||
setUserToken(res.data)
|
setUserToken(res.data)
|
||||||
ElMessage.success({
|
showMessageOK({
|
||||||
"message": "注册成功,即将跳转到对话主界面...",
|
"message": "注册成功,即将跳转到对话主界面...",
|
||||||
onClose: () => router.push("/chat"),
|
onClose: () => router.push("/chat"),
|
||||||
duration: 1000
|
duration: 1000
|
||||||
})
|
})
|
||||||
}).catch((e) => {
|
}).catch((e) => {
|
||||||
ElMessage.error('注册失败,' + e.message)
|
showMessageError('注册失败,' + e.message)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -134,6 +134,7 @@ import ChatReply from "@/components/mobile/ChatReply.vue";
|
|||||||
import {getSessionId, getUserToken} from "@/store/session";
|
import {getSessionId, getUserToken} from "@/store/session";
|
||||||
import {checkSession} from "@/action/session";
|
import {checkSession} from "@/action/session";
|
||||||
import Clipboard from "clipboard";
|
import Clipboard from "clipboard";
|
||||||
|
import {showLoginDialog} from "@/utils/dialog";
|
||||||
|
|
||||||
const winHeight = ref(0)
|
const winHeight = ref(0)
|
||||||
const navBarRef = ref(null)
|
const navBarRef = ref(null)
|
||||||
@ -178,6 +179,7 @@ httpGet('/api/model/list').then(res => {
|
|||||||
}
|
}
|
||||||
for (let i = 0; i < models.value.length; i++) {
|
for (let i = 0; i < models.value.length; i++) {
|
||||||
models.value[i].text = models.value[i].name
|
models.value[i].text = models.value[i].name
|
||||||
|
models.value[i].mValue = models.value[i].value
|
||||||
models.value[i].value = models.value[i].id
|
models.value[i].value = models.value[i].id
|
||||||
}
|
}
|
||||||
modelValue.value = getModelValue(modelId.value)
|
modelValue.value = getModelValue(modelId.value)
|
||||||
@ -223,7 +225,10 @@ onMounted(() => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
|
if (socket.value !== null) {
|
||||||
|
socket.value.close()
|
||||||
socket.value = null
|
socket.value = null
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const newChat = (item) => {
|
const newChat = (item) => {
|
||||||
@ -275,6 +280,7 @@ md.use(mathjaxPlugin)
|
|||||||
|
|
||||||
const onLoad = () => {
|
const onLoad = () => {
|
||||||
if (chatId.value) {
|
if (chatId.value) {
|
||||||
|
checkSession().then(() => {
|
||||||
httpGet('/api/chat/history?chat_id=' + chatId.value).then(res => {
|
httpGet('/api/chat/history?chat_id=' + chatId.value).then(res => {
|
||||||
// 加载状态结束
|
// 加载状态结束
|
||||||
finished.value = true;
|
finished.value = true;
|
||||||
@ -305,6 +311,8 @@ const onLoad = () => {
|
|||||||
}).catch(() => {
|
}).catch(() => {
|
||||||
error.value = true
|
error.value = true
|
||||||
})
|
})
|
||||||
|
}).catch(() => {
|
||||||
|
})
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -443,8 +451,7 @@ const connect = function (chat_id, role_id, model_id) {
|
|||||||
checkSession().then(() => {
|
checkSession().then(() => {
|
||||||
connect(chat_id, role_id, model_id)
|
connect(chat_id, role_id, model_id)
|
||||||
}).catch(() => {
|
}).catch(() => {
|
||||||
loading.value = true
|
showLoginDialog(router)
|
||||||
setTimeout(() => connect(chat_id, role_id, model_id), 3000)
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -549,7 +556,7 @@ const getRoleById = function (rid) {
|
|||||||
const getModelValue = (model_id) => {
|
const getModelValue = (model_id) => {
|
||||||
for (let i = 0; i < models.value.length; i++) {
|
for (let i = 0; i < models.value.length; i++) {
|
||||||
if (models.value[i].id === model_id) {
|
if (models.value[i].id === model_id) {
|
||||||
return models.value[i].value
|
return models.value[i].mValue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
|
@ -57,16 +57,6 @@ bus.on('changeTheme', (value) => {
|
|||||||
background #1c1c1e
|
background #1c1c1e
|
||||||
}
|
}
|
||||||
|
|
||||||
.van-toast--fail {
|
|
||||||
background #fef0f0
|
|
||||||
color #f56c6c
|
|
||||||
}
|
|
||||||
|
|
||||||
.van-toast--success {
|
|
||||||
background #D6FBCC
|
|
||||||
color #07C160
|
|
||||||
}
|
|
||||||
|
|
||||||
.van-nav-bar {
|
.van-nav-bar {
|
||||||
position fixed
|
position fixed
|
||||||
width 100%
|
width 100%
|
||||||
|
@ -95,6 +95,7 @@ onMounted(() => {
|
|||||||
checkSession().then((user) => {
|
checkSession().then((user) => {
|
||||||
isLogin.value = true
|
isLogin.value = true
|
||||||
roles.value = user.chat_roles
|
roles.value = user.chat_roles
|
||||||
|
}).catch(() => {
|
||||||
})
|
})
|
||||||
fetchApps()
|
fetchApps()
|
||||||
})
|
})
|
||||||
|
@ -276,14 +276,7 @@
|
|||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import {nextTick, onMounted, onUnmounted, ref} from "vue";
|
import {nextTick, onMounted, onUnmounted, ref} from "vue";
|
||||||
import {
|
import {showConfirmDialog, showFailToast, showImagePreview, showNotify, showSuccessToast, showToast} from "vant";
|
||||||
showConfirmDialog,
|
|
||||||
showFailToast,
|
|
||||||
showNotify,
|
|
||||||
showToast,
|
|
||||||
showImagePreview,
|
|
||||||
showSuccessToast
|
|
||||||
} from "vant";
|
|
||||||
import {httpGet, httpPost} from "@/utils/http";
|
import {httpGet, httpPost} from "@/utils/http";
|
||||||
import Compressor from "compressorjs";
|
import Compressor from "compressorjs";
|
||||||
import {getSessionId} from "@/store/session";
|
import {getSessionId} from "@/store/session";
|
||||||
@ -364,8 +357,11 @@ onMounted(() => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
socket.value = null
|
|
||||||
clipboard.value.destroy()
|
clipboard.value.destroy()
|
||||||
|
if (socket.value !== null) {
|
||||||
|
socket.value.close()
|
||||||
|
socket.value = null
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const mjPower = ref(1)
|
const mjPower = ref(1)
|
||||||
|
@ -221,7 +221,8 @@ 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 {
|
import {
|
||||||
showConfirmDialog, showDialog,
|
showConfirmDialog,
|
||||||
|
showDialog,
|
||||||
showFailToast,
|
showFailToast,
|
||||||
showImagePreview,
|
showImagePreview,
|
||||||
showNotify,
|
showNotify,
|
||||||
@ -357,7 +358,10 @@ onMounted(() => {
|
|||||||
|
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
clipboard.value.destroy()
|
clipboard.value.destroy()
|
||||||
|
if (socket.value !== null) {
|
||||||
|
socket.value.close()
|
||||||
socket.value = null
|
socket.value = null
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user