From b299ef0c53ce3b160b6b7b9e19cbdba269ed5d64 Mon Sep 17 00:00:00 2001
From: shaohuzhang1 <80892890+shaohuzhang1@users.noreply.github.com>
Date: Mon, 14 Jul 2025 14:09:31 +0800
Subject: [PATCH] fix: Page optimization when the application is unavailable
(#3580)
---
apps/chat/serializers/chat_authentication.py | 2 ++
ui/src/router/chat/index.ts | 11 +++++++----
ui/src/views/chat/index.vue | 11 ++++++++---
ui/src/views/chat/no-service/index.vue | 18 ++++++++++++++++++
4 files changed, 35 insertions(+), 7 deletions(-)
create mode 100644 ui/src/views/chat/no-service/index.vue
diff --git a/apps/chat/serializers/chat_authentication.py b/apps/chat/serializers/chat_authentication.py
index 2243844e0..4f28d2f58 100644
--- a/apps/chat/serializers/chat_authentication.py
+++ b/apps/chat/serializers/chat_authentication.py
@@ -57,6 +57,8 @@ class AuthProfileSerializer(serializers.Serializer):
self.is_valid(raise_exception=True)
access_token = self.data.get("access_token")
application_access_token = QuerySet(ApplicationAccessToken).filter(access_token=access_token).first()
+ if application_access_token is None:
+ raise NotFound404(404, _("Invalid access_token"))
application_id = application_access_token.application_id
profile = {
'authentication': False
diff --git a/ui/src/router/chat/index.ts b/ui/src/router/chat/index.ts
index 74fe54dc2..6d443d6fc 100644
--- a/ui/src/router/chat/index.ts
+++ b/ui/src/router/chat/index.ts
@@ -37,9 +37,7 @@ router.beforeEach(
try {
authentication = await chatUser.isAuthentication()
} catch (e: any) {
- next({
- path: '/404',
- })
+ next()
return
}
const p_token = to.query.token
@@ -86,7 +84,12 @@ router.beforeEach(
}
}
} else {
- await chatUser.anonymousAuthentication()
+ try {
+ await chatUser.anonymousAuthentication()
+ } catch (e: any) {
+ next()
+ return
+ }
}
if (!chatUser.application) {
try {
diff --git a/ui/src/views/chat/index.vue b/ui/src/views/chat/index.vue
index f30b7be22..567ae665f 100644
--- a/ui/src/views/chat/index.vue
+++ b/ui/src/views/chat/index.vue
@@ -25,11 +25,16 @@ const {
const currentTemplate = computed(() => {
let modeName = ''
- if (!mode || mode === 'pc') {
- modeName = common.isMobile() ? 'mobile' : 'pc'
+ if (chatUser.application) {
+ if (!mode || mode === 'pc') {
+ modeName = common.isMobile() ? 'mobile' : 'pc'
+ } else {
+ modeName = mode
+ }
} else {
- modeName = mode
+ modeName = 'no-service'
}
+
const name = `/src/views/chat/${modeName}/index.vue`
return components[name].default
})
diff --git a/ui/src/views/chat/no-service/index.vue b/ui/src/views/chat/no-service/index.vue
new file mode 100644
index 000000000..bc1eb2eec
--- /dev/null
+++ b/ui/src/views/chat/no-service/index.vue
@@ -0,0 +1,18 @@
+
+
+
+

+
{{ $t('common.notFound.NoService') }}
+
+
+
+
+