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/*.java
!*/build/*.html !*/build/*.html
!*/build/*.xml !*/build/*.xml
/yack-view/package-lock.json

View File

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

View File

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

View File

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

View File

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

View File

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