20260426:大屏技术初始化
This commit is contained in:
parent
1586645838
commit
d433c25f7b
1
.gitignore
vendored
1
.gitignore
vendored
@ -44,3 +44,4 @@ own-*
|
||||
!*/build/*.java
|
||||
!*/build/*.html
|
||||
!*/build/*.xml
|
||||
/yack-view/package-lock.json
|
||||
|
||||
@ -1,3 +1,7 @@
|
||||
# 本地开发文件上传路径(Windows 下 /uploadPath 会解析到 Tomcat Temp 目录,必须用绝对路径)
|
||||
fastbee:
|
||||
profile: D:/uploadPath
|
||||
|
||||
# 数据源配置
|
||||
spring:
|
||||
datasource:
|
||||
|
||||
@ -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)
|
||||
}
|
||||
|
||||
@ -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) => {
|
||||
|
||||
@ -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)
|
||||
@ -193,19 +193,19 @@ export const goHome = () => {
|
||||
*/
|
||||
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()}`
|
||||
|
||||
@ -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()
|
||||
}
|
||||
|
||||
// 修改页数
|
||||
|
||||
Loading…
Reference in New Issue
Block a user