20260426:大屏技术初始化

This commit is contained in:
George 2026-04-26 08:58:28 +08:00
parent 1586645838
commit d433c25f7b
6 changed files with 54 additions and 45 deletions

1
.gitignore vendored
View File

@ -44,3 +44,4 @@ own-*
!*/build/*.java
!*/build/*.html
!*/build/*.xml
/yack-view/package-lock.json

View File

@ -1,3 +1,7 @@
# 本地开发文件上传路径(Windows 下 /uploadPath 会解析到 Tomcat Temp 目录,必须用绝对路径)
fastbee:
profile: D:/uploadPath
# 数据源配置
spring:
datasource:

View File

@ -1,10 +1,8 @@
import axios, { AxiosResponse, AxiosRequestConfig, Axios, AxiosError, InternalAxiosRequestConfig } from 'axios'
import { RequestHttpHeaderEnum, ResultEnum, ModuleTypeEnum } from '@/enums/httpEnum'
import { ResultEnum } from '@/enums/httpEnum'
import { PageEnum, ErrorPageNameMap } from '@/enums/pageEnum'
import { StorageEnum } from '@/enums/storageEnum'
import { axiosPre } from '@/settings/httpSetting'
import { SystemStoreEnum, SystemStoreUserInfoEnum } from '@/store/modules/systemStore/systemStore.d'
import { redirectErrorPage, getLocalStorage, routerTurnByName, isPreview, getCookie } from '@/utils'
import { redirectErrorPage, routerTurnByName, isPreview, getCookie, clearCookie, clearLocalStorage } from '@/utils'
import { fetchAllowList } from './axios.config'
import includes from 'lodash/includes'
@ -34,7 +32,7 @@ axiosInstance.interceptors.request.use(
routerTurnByName(PageEnum.BASE_LOGIN_NAME)
return config
}
config.headers['Authorization'] = 'Bearer ' + getCookie(StorageEnum.ADMIN_TOKEN)
config.headers['Authorization'] = 'Bearer ' + getCookie(StorageEnum.ADMIN_TOKEN)
return config
},
(err: AxiosError) => {
@ -58,9 +56,11 @@ axiosInstance.interceptors.response.use(
return Promise.resolve(res.data)
}
// 登录过期
if (code === ResultEnum.TOKEN_OVERDUE) {
// 登录过期(886)或未认证(401)— 后端 renderString 固定返回 HTTP 200,code 在 body 中
if (code === ResultEnum.TOKEN_OVERDUE || code === 401) {
window['$message'].error(window['$t']('http.token_overdue_message'))
clearCookie(StorageEnum.ADMIN_TOKEN)
clearLocalStorage(StorageEnum.GO_SYSTEM_STORE)
routerTurnByName(PageEnum.BASE_LOGIN_NAME)
return Promise.resolve(res.data)
}

View File

@ -28,10 +28,10 @@ export function createRouterGuards(router: Router) {
}
// @ts-ignore
if (!routerAllowList.includes(to.name) && !loginCheck()) {
next({ name: PageEnum.BASE_LOGIN_NAME })
if (!routerAllowList.includes(to.name) && await loginCheck()) {
return next({ name: PageEnum.BASE_LOGIN_NAME })
}
next()
return next()
})
router.afterEach((to, _, failure) => {

View File

@ -108,7 +108,7 @@ export const reloadRoutePage = () => {
export const logout = async () => {
try {
const res = await logoutApi()
if(res && res.code === ResultEnum.SUCCESS) {
if (res && res.code === ResultEnum.SUCCESS) {
window['$message'].success(window['$t']('global.logout_success'))
clearCookie(RequestHttpHeaderEnum.COOKIE)
clearCookie(StorageEnum.ADMIN_TOKEN)
@ -195,17 +195,17 @@ export const loginCheck = async () => {
try {
const token = getCookie(StorageEnum.ADMIN_TOKEN);
if(typeof token === 'undefined' || token == null || token === ''){
if (typeof token === 'undefined' || token == null || token === '') {
return true
}else{
} else {
const info = getLocalStorage(StorageEnum.GO_SYSTEM_STORE)
if (info != null){
if (info != null) {
const userInfo = info[SystemStoreEnum.USER_INFO]
if(userInfo != null){
if (userInfo != null) {
return false
}else{
} else {
const res = await getUserInfoApi() as unknown as LoginInfoResponseType
if(res.code === ResultEnum.SUCCESS) {
if (res.code === ResultEnum.SUCCESS) {
const systemStore = useSystemStore()
const { nickName, userName, userId, avatar } = res.user
// 存储到 pinia
@ -217,7 +217,7 @@ export const loginCheck = async () => {
[SystemStoreUserInfoEnum.AVATAR]: avatar,
})
return false
}else{
} else {
return true
}
}
@ -233,7 +233,7 @@ export const loginCheck = async () => {
* * 预览地址
* @returns
*/
export const previewPath = (id?: string | number) => {
export const previewPath = (id?: string | number) => {
const { origin, pathname } = document.location
const path = fetchPathByName(PreviewEnum.CHART_PREVIEW_NAME, 'href')
const previewPath = `${origin}${pathname}${path}/${id || fetchRouteParamsLocation()}`

View File

@ -23,32 +23,36 @@ export const useDataListInit = () => {
// 数据请求
const fetchList = async () => {
loading.value = true
const res = await projectListApi({
pageNum: paginat.page,
pageSize: paginat.limit
}) as any
if (res.rows) {
const { total } = res
paginat.count = total
list.value = res.rows.map((e: any) => {
const { id, projectName, state, createTime,updateTime, indexImage, createBy } = e
return {
id: id,
title: projectName,
createId: createBy,
time: createTime,
updateTime: updateTime,
image: `${import.meta.env.VITE_GLOB_API_URL}${indexImage}`,
release: state !== 0
}
})
setTimeout(() => {
loading.value = false
}, 500)
return
try {
const res = await projectListApi({
pageNum: paginat.page,
pageSize: paginat.limit
}) as any
if (res && res.rows) {
const { total } = res
paginat.count = total
list.value = res.rows.map((e: any) => {
const { id, projectName, state, createTime, updateTime, indexImage, createBy } = e
return {
id: id,
title: projectName,
createId: createBy,
time: createTime,
updateTime: updateTime,
// indexImage 为空时传空字符串,触发 n-image 的 fallback-src 显示占位图
image: indexImage ? `${import.meta.env.VITE_GLOB_API_URL}${indexImage}` : '',
release: state !== 0
}
})
return
}
// 401/认证失败由 axios 拦截器统一处理(跳转登录),此处仅处理其他失败
if (res && res.code !== 401) {
httpErrorHandle()
}
} finally {
loading.value = false
}
httpErrorHandle()
}
// 修改页数