Skip to content

Commit 3324d4a

Browse files
feat: 404 page
1 parent d94972b commit 3324d4a

File tree

13 files changed

+114
-104
lines changed

13 files changed

+114
-104
lines changed

ui/src/assets/404.png

-338 KB
Loading

ui/src/assets/500.png

5.96 KB
Loading

ui/src/locales/lang/en-US/common.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,8 @@ export default {
9292
selected: 'Selected',
9393
notFound: {
9494
title: '404',
95-
message: 'Unable to Access APP',
95+
NoService: 'Currently unable to access services',
96+
NoPermission: 'No permission to access',
9697
operate: 'Back to Home',
9798
},
9899
custom: 'Custom',

ui/src/locales/lang/zh-CN/common.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,8 @@ export default {
9696
selected: '已选',
9797
notFound: {
9898
title: '404',
99-
message: '无法访问应用',
99+
NoService: '暂时无法访问服务',
100+
NoPermission:'没有权限访问',
100101
operate: '返回首页',
101102
},
102103
custom: '自定义',

ui/src/locales/lang/zh-Hant/common.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,8 @@ export default {
9292
selected: '已選',
9393
notFound: {
9494
title: '404',
95-
message: '無法訪問應用',
95+
NoService: '暫時無法訪問服務',
96+
NoPermission: '沒有權限訪問',
9697
operate: '返回首頁',
9798
},
9899
custom: '自定義',

ui/src/request/index.ts

Lines changed: 42 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,9 @@ instance.interceptors.response.use(
7777

7878
if (err.response?.status === 403 && !err.response.config.url.includes('chat/open')) {
7979
MsgError(
80-
err.response.data && err.response.data.message ? err.response.data.message : '没有权限访问',
80+
err.response.data && err.response.data.message
81+
? err.response.data.message
82+
: 'No permission to access',
8183
)
8284
}
8385
return Promise.reject(err)
@@ -249,15 +251,15 @@ export const exportExcel: (
249251

250252
function decodeFilenameBrowser(contentDisposition: string) {
251253
// 提取并解码 Base64 部分
252-
const base64Part = contentDisposition.match(/=\?utf-8\?b\?(.*?)\?=/i)?.[1];
253-
if (!base64Part) return null;
254+
const base64Part = contentDisposition.match(/=\?utf-8\?b\?(.*?)\?=/i)?.[1]
255+
if (!base64Part) return null
254256

255257
// 使用 atob 解码 Base64
256-
const decoded = decodeURIComponent(escape(atob(base64Part)));
258+
const decoded = decodeURIComponent(escape(atob(base64Part)))
257259

258260
// 提取文件名
259-
const filenameMatch = decoded.match(/filename="(.*?)"/i);
260-
return filenameMatch ? filenameMatch[1] : null;
261+
const filenameMatch = decoded.match(/filename="(.*?)"/i)
262+
return filenameMatch ? filenameMatch[1] : null
261263
}
262264

263265
export const exportFile: (
@@ -271,37 +273,40 @@ export const exportFile: (
271273
params: any,
272274
loading?: NProgress | Ref<boolean>,
273275
) => {
274-
return promise(request({
275-
url: url,
276-
method: 'get',
277-
params,
278-
responseType: 'blob',
279-
transformResponse: [function (data, headers) {
280-
// 在这里可以访问 headers
281-
// const contentType = headers['content-type'];
282-
const contentDisposition = headers['content-disposition'];
283-
// console.log('Content-Type:', contentType);
284-
// console.log('Content-Disposition:', decodeFilenameBrowser(contentDisposition));
285-
// 如果没有提供文件名,则使用默认名称
286-
fileName = decodeFilenameBrowser(contentDisposition) || fileName;
287-
return data; // 必须返回数据
288-
}]
289-
}), loading).then(
290-
(res: any) => {
291-
if (res) {
292-
const blob = new Blob([res], {
293-
type: 'application/octet-stream',
294-
})
295-
const link = document.createElement('a')
296-
link.href = window.URL.createObjectURL(blob)
297-
link.download = fileName
298-
link.click()
299-
//释放内存
300-
window.URL.revokeObjectURL(link.href)
301-
}
302-
return true
303-
},
304-
)
276+
return promise(
277+
request({
278+
url: url,
279+
method: 'get',
280+
params,
281+
responseType: 'blob',
282+
transformResponse: [
283+
function (data, headers) {
284+
// 在这里可以访问 headers
285+
// const contentType = headers['content-type'];
286+
const contentDisposition = headers['content-disposition']
287+
// console.log('Content-Type:', contentType);
288+
// console.log('Content-Disposition:', decodeFilenameBrowser(contentDisposition));
289+
// 如果没有提供文件名,则使用默认名称
290+
fileName = decodeFilenameBrowser(contentDisposition) || fileName
291+
return data // 必须返回数据
292+
},
293+
],
294+
}),
295+
loading,
296+
).then((res: any) => {
297+
if (res) {
298+
const blob = new Blob([res], {
299+
type: 'application/octet-stream',
300+
})
301+
const link = document.createElement('a')
302+
link.href = window.URL.createObjectURL(blob)
303+
link.download = fileName
304+
link.click()
305+
//释放内存
306+
window.URL.revokeObjectURL(link.href)
307+
}
308+
return true
309+
})
305310
}
306311

307312
export const exportExcelPost: (

ui/src/router/chat/routes.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ export const routes: Array<RouteRecordRaw> = [
1717
{
1818
path: '/404',
1919
name: '404',
20-
component: () => import('@/views/404/index.vue'),
20+
component: () => import('@/views/error/404.vue'),
21+
},
22+
{
23+
path: '/no-service',
24+
name: 'NoService',
25+
component: () => import('@/views/error/NoService.vue'),
2126
},
2227
]

ui/src/router/routes.ts

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import type { RouteRecordRaw } from 'vue-router'
22
const modules: any = import.meta.glob('./modules/*.ts', { eager: true })
3-
import { hasPermission, set_next_route } from '@/utils/permission/index'
43

54
const rolesRoutes: RouteRecordRaw[] = [...Object.keys(modules).map((key) => modules[key].default)]
65

@@ -20,7 +19,7 @@ export const routes: Array<RouteRecordRaw> = [
2019
{
2120
path: '/no-permission',
2221
name: 'noPermissionD',
23-
component: () => import('@/views/no-permission/index.vue'),
22+
component: () => import('@/views/error/NoPermission.vue'),
2423
},
2524
],
2625
component: () => import('@/layout/layout-template/SimpleLayout.vue'),
@@ -69,9 +68,14 @@ export const routes: Array<RouteRecordRaw> = [
6968
name: 'permission',
7069
component: () => import('@/views/Permission.vue'),
7170
},
72-
// {
73-
// path: '/:pathMatch(.*)',
74-
// name: '404',
75-
// component: () => import('@/views/404/index.vue')
76-
// }
71+
{
72+
path: '/no-service',
73+
name: 'NoService',
74+
component: () => import('@/views/error/NoService.vue'),
75+
},
76+
{
77+
path: '/:pathMatch(.*)',
78+
name: '404',
79+
component: () => import('@/views/error/404.vue'),
80+
},
7781
]

ui/src/views/404/index.vue

Lines changed: 0 additions & 51 deletions
This file was deleted.

ui/src/views/error/404.vue

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<template>
2+
<div class="not-found-container flex-center">
3+
<div>
4+
<img src="@/assets/404.png" width="250" alt="" />
5+
<h4 class="text-center">{{ $t('common.notFound.title') }}</h4>
6+
</div>
7+
</div>
8+
</template>
9+
<script setup lang="ts">
10+
import { useRouter } from 'vue-router'
11+
const router = useRouter()
12+
</script>
13+
<style lang="scss" scoped>
14+
.not-found-container {
15+
height: 100vh;
16+
width: 100vw;
17+
}
18+
</style>

0 commit comments

Comments
 (0)