fix chartjs
Some checks failed
Deploy / deploy (push) Has been cancelled

This commit is contained in:
2025-09-24 01:39:35 +08:00
parent 1686d68fca
commit bffb6c6166
3 changed files with 27 additions and 37 deletions

View File

@@ -2,6 +2,20 @@ import { addAPIProvider } from "@iconify/vue"
import { createPinia } from "pinia" import { createPinia } from "pinia"
import { createRouter, createWebHistory } from "vue-router" import { createRouter, createWebHistory } from "vue-router"
import {
ArcElement,
BarElement,
CategoryScale,
Chart as ChartJS,
Colors,
Legend,
LinearScale,
Title,
Tooltip,
LineElement,
PointElement,
} from "chart.js"
import { STORAGE_KEY } from "utils/constants" import { STORAGE_KEY } from "utils/constants"
import storage from "utils/storage" import storage from "utils/storage"
@@ -28,6 +42,19 @@ router.beforeEach((to, from, next) => {
} }
}) })
ChartJS.register(
CategoryScale,
LinearScale,
BarElement,
ArcElement,
LineElement,
PointElement,
Colors,
Title,
Tooltip,
Legend,
)
const pinia = createPinia() const pinia = createPinia()
const app = createApp(App) const app = createApp(App)
app.use(router) app.use(router)

View File

@@ -1,5 +1,4 @@
import { RouteRecordRaw } from "vue-router" import { RouteRecordRaw } from "vue-router"
import { loadChart } from "./shared/composables/chart"
export const ojs: RouteRecordRaw = { export const ojs: RouteRecordRaw = {
path: "/", path: "/",
@@ -11,7 +10,6 @@ export const ojs: RouteRecordRaw = {
component: () => import("oj/problem/detail.vue"), component: () => import("oj/problem/detail.vue"),
props: true, props: true,
name: "problem", name: "problem",
beforeEnter: loadChart,
}, },
{ {
path: "submission", path: "submission",
@@ -63,12 +61,10 @@ export const ojs: RouteRecordRaw = {
props: true, props: true,
name: "contest problem", name: "contest problem",
meta: { requiresAuth: true }, meta: { requiresAuth: true },
beforeEnter: loadChart,
}, },
{ {
path: "rank", path: "rank",
component: () => import("oj/rank/list.vue"), component: () => import("oj/rank/list.vue"),
beforeEnter: loadChart,
}, },
{ {
path: "announcement", path: "announcement",
@@ -99,7 +95,6 @@ export const ojs: RouteRecordRaw = {
path: "ai-analysis", path: "ai-analysis",
component: () => import("oj/ai/analysis.vue"), component: () => import("oj/ai/analysis.vue"),
meta: { requiresAuth: true }, meta: { requiresAuth: true },
beforeEnter: loadChart,
}, },
], ],
} }

View File

@@ -1,32 +0,0 @@
import {
ArcElement,
BarElement,
CategoryScale,
Chart as ChartJS,
Colors,
Legend,
LinearScale,
Title,
Tooltip,
LineElement,
PointElement,
} from "chart.js"
const [isLoaded] = useToggle()
export function loadChart() {
if (isLoaded.value) return
ChartJS.register(
CategoryScale,
LinearScale,
BarElement,
ArcElement,
LineElement,
PointElement,
Colors,
Title,
Tooltip,
Legend,
)
isLoaded.value = true
}