Add OpenAPI

This commit is contained in:
2025-07-05 22:32:52 +02:00
parent acd910e013
commit 54a4f7e08a
98 changed files with 4816 additions and 696 deletions

View File

@@ -3,24 +3,26 @@ import './style.css'
import App from './App.vue'
import PrimeVue from 'primevue/config';
import Aura from '@primeuix/themes/aura';
import {createMemoryHistory, createRouter, type Router, type RouteRecordRaw} from "vue-router";
import {CardPrintService, CardService, DeckService, SetService} from "./api/openapi";
import {ToastService} from "primevue";
import {createPinia} from "pinia";
import {createRouter, createWebHistory, type Router, type RouteRecordRaw} from "vue-router";
import HomeView from "./views/HomeView.vue";
import {DeckService} from "./api/openapi";
import axios from "axios";
import CardsView from "./views/card/CardsView.vue";
import CardView from "./views/card/CardView.vue";
import DecksView from "./views/deck/DecksView.vue";
import DeckView from "./views/deck/DeckView.vue";
import Callback from "./views/Callback.vue";
import {useAuthStore} from "./stores/auth.ts";
import axiosInstance from "./api";
import SetsView from "./views/set/SetsView.vue";
const routes: RouteRecordRaw[] = [
{path: '/', component: HomeView}
]
const router: Router = createRouter({
history: createMemoryHistory(),
routes
})
export const axiosInstance = axios.create()
export const DeckServiceKey = Symbol("deckServiceKey")
export const CardServiceKey = Symbol("cardServiceKey")
export const SetServiceKey = Symbol("setServiceKey")
export const CardPrintServiceKey = Symbol("cardPrintServiceKey")
const deckService: DeckService = new DeckService(undefined, "http://localhost:8080", axiosInstance)
const pinia = createPinia();
const app = createApp(App);
app.use(PrimeVue, {
@@ -34,8 +36,54 @@ app.use(PrimeVue, {
}
}
});
app.use(pinia);
const authStore = useAuthStore();
authStore.initialize();
const userManager = authStore.userManager;
userManager.events.addAccessTokenExpired(async() => {
await userManager.signinRedirect()
})
const routes: RouteRecordRaw[] = [
{path: '/', component: HomeView},
{path: '/cards', component: CardsView, meta: {requiresAuth: true}},
{path: '/cards/:id', component: CardView, meta: {requiresAuth: true}},
{path: '/decks', component: DecksView, meta: {requiresAuth: true}},
{path: '/decks/:id', component: DeckView, meta: {requiresAuth: true}},
{path: '/sets', component: SetsView},
{path: '/sets/:id', component: DeckView, meta: {requiresAuth: true}},
{path: '/callback', component: Callback}
]
const router: Router = createRouter({
history: createWebHistory(),
routes
})
router.beforeEach(async (to) => {
if (to.meta.requiresAuth) {
const user = authStore.user;
if (!user) {
await authStore.login();
return false;
}
}
})
app.use(router);
app.use(ToastService)
const deckService: DeckService = new DeckService(undefined, "http://localhost:8080", axiosInstance)
const cardService: CardService = new CardService(undefined, "http://localhost:8080", axiosInstance)
const setService: SetService = new SetService(undefined, "http://localhost:8080", axiosInstance)
const cardPrintService: CardPrintService = new CardPrintService(undefined, "http://localhost:8080", axiosInstance)
app.provide(DeckServiceKey, deckService)
app.provide(CardServiceKey, cardService)
app.provide(SetServiceKey, setService)
app.provide(CardPrintServiceKey, cardPrintService)
app.mount('#app');