首页优化

main
liutao 1 day ago
parent 44ca9e458c
commit 813b2db7f7

@ -26,6 +26,11 @@ export interface WeatherVO {
// 生产计划 API
export const HomeApi = {
// 是否允许免登录访问首页
isPublicAccessEnabled: async () => {
return await request.get<boolean>({ url: `/home/info/public-access-enabled` })
},
// 查询天气
getWeatherInfo: async () => {

@ -8,6 +8,7 @@ import { usePageLoading } from '@/hooks/web/usePageLoading'
import { useDictStoreWithOut } from '@/store/modules/dict'
import { useUserStoreWithOut } from '@/store/modules/user'
import { usePermissionStoreWithOut } from '@/store/modules/permission'
import { HomeApi } from '@/api/home/info'
const { start, done } = useNProgress()
@ -79,12 +80,32 @@ const whiteList = [
'/auth-redirect',
'/bind',
'/register',
'/oauthLogin/gitee',
'/oauthLogin/gitee'
]
const homePublicAccessWhiteList = [
'/iot/report/dashboardPage/Dashboard8',
'/iot/report/dashboardPage/Dashboard1',
'/iot/report/dashboardPage/Dashboard3'
]
let homePublicAccessEnabled: boolean | undefined
const isHomePublicAccessEnabled = async () => {
if (homePublicAccessEnabled !== undefined) return homePublicAccessEnabled
try {
homePublicAccessEnabled = await HomeApi.isPublicAccessEnabled()
} catch {
homePublicAccessEnabled = false
}
return homePublicAccessEnabled
}
const isPublicHomePath = async (path: string) => {
if (homePublicAccessWhiteList.indexOf(path) === -1) return false
return await isHomePublicAccessEnabled()
}
// 路由加载前
router.beforeEach(async (to, from, next) => {
start()
@ -134,7 +155,7 @@ router.beforeEach(async (to, from, next) => {
}
}
} else {
if (whiteList.indexOf(to.path) !== -1) {
if (whiteList.indexOf(to.path) !== -1 || (await isPublicHomePath(to.path))) {
next()
} else {
next(`/login?redirect=${to.fullPath}`) // 否则全部重定向到登录页

@ -332,7 +332,7 @@ const disabledFutureSeconds = (
const defaultTimeRange = getTodayTimeRange()
const defaultPickerEndTime = new Date()
const datePickerDefaultTime = [
const datePickerDefaultTime: [Date, Date] = [
new Date(2000, 0, 1, 0, 0, 0),
new Date(
2000,
@ -515,8 +515,8 @@ const regionPieOptions = ref<EChartsOption>({
]
})
const trendChartDisplayOptions = computed<EChartsOption>(() => trendChartOptions.value)
const regionPieDisplayOptions = computed<EChartsOption>(() => regionPieOptions.value)
const trendChartDisplayOptions = computed(() => trendChartOptions.value as EChartsOption)
const regionPieDisplayOptions = computed(() => regionPieOptions.value as EChartsOption)
const metricThemeMap: Record<string, { icon: string; theme: string }> = {
total: { icon: 'ep:lightning', theme: 'blue' },

Loading…
Cancel
Save