feat: recuperation de la config

This commit is contained in:
Kazhnuz 2023-02-04 10:13:22 +01:00
parent 85dcd63d45
commit 58ca487c69
6 changed files with 129 additions and 1 deletions

83
public/pelican.json Normal file
View file

@ -0,0 +1,83 @@
{
"version": "0.2.0",
"jdr": [
{
"id": 0,
"title":"",
"links": [
{"title": "Règles de bases", "link": "core"}
]
}
],
"sidebar": [
{
"id": 0,
"title": "",
"links": [
{"title": "Dés et actions", "path": "rules/bases/D100"},
{"title": "Bienveillance", "path": "rules/bases/bienveillance"},
{"title": "Organisation d'une campagne", "path": "rules/bases/campagnes"},
{"title": "Exploration et déplacement", "path": "rules/bases/exploration"}
]
},
{
"id": 10,
"title": "Personnages",
"links": [
{"title": "Création d'un personnage", "path": "rules/personnages/creation"},
{"title": "Situation générale", "path": "rules/personnages/vitalite"},
{"title": "Compétences et statistiques", "path": "rules/personnages/generalites"},
{"title": "Expérience et classes", "path": "rules/personnages/niveaux"},
{"title": "Réputation et prestige", "path": "rules/personnages/reputation"}
]
},
{
"id": 20,
"title": "Mobs",
"links": [
{"title": "Généralités", "path": "rules/mobs/generalites"},
{"title": "Créatures et monstres", "path": "rules/mobs/creatures"},
{"title": "Personnages non jouables", "path": "rules/mobs/pnj"},
{"title": "Émotions et influence", "path": "rules/mobs/emotions"}
]
},
{
"id": 30,
"title": "Combat",
"links": [
{"title": "Organisation d'un combat", "path": "rules/combats/presentation"},
{"title": "Attaquer, se défendre et soigner", "path": "rules/combats/attacc"},
{"title": "Déplacement et placement", "path": "rules/combats/deplacement"},
{"title": "Confrontation sociales", "path": "rules/combats/social"}
]
},
{
"id": 40,
"title": "Inventaire",
"links": [
{"title": "Objets et aliments", "path": "rules/inventaire/objets"},
{"title": "Équipement et outils", "path": "rules/inventaire/equipements"},
{"title": "Potions et crafting", "path": "rules/inventaire/potions"},
{"title": "Véhicules", "path": "rules/inventaire/vehicules"}
]
},
{
"id": 50,
"title": "Magie et surnaturel",
"links": [
{"title": "Éclat", "path": "rules/magie/eclat"},
{"title": "Éléments", "path": "rules/magie/eclat"},
{"title": "Métaphysique", "path": "rules/magie/eclat"},
{"title": "Anomie", "path": "rules/magie/anomie"}
]
},
{
"id": 60,
"title": "Divers",
"links": [
{"title": "Afflictions et effets", "path": "rules/divers/afflictions"},
{"title": "Jeu de plateau", "path": "rules/bases/plateau"}
]
}
]
}

View file

@ -1,7 +1,16 @@
<script setup lang="ts">
import { RouterLink, RouterView } from "vue-router";
import { RouterView } from "vue-router";
import TopBar from "./components/layout/TopBar.vue";
import SideBar from "./components/layout/SideBar.vue";
import { useConfigStore } from "./stores/config";
import { onMounted } from "vue";
import axios from "axios";
const store = useConfigStore();
onMounted(() => {
axios.get(`/pelican.json`).then((response) => store.setConfig(response.data));
});
</script>
<template>

18
src/stores/config.ts Normal file
View file

@ -0,0 +1,18 @@
import { ref } from "vue";
import { defineStore } from "pinia";
import type PelicanConfig from "@/types/PelicanConfig";
import type LinkList from "@/types/LinkList";
export const useConfigStore = defineStore("config", () => {
const config = ref(null as PelicanConfig | null);
function setConfig(newConfig: PelicanConfig) {
config.value = newConfig;
}
function getSidebar(): LinkList[] {
return config.value?.sidebar ?? [{ id: 0, links: [] }];
}
return { config, setConfig, getSidebar };
});

4
src/types/Link.ts Normal file
View file

@ -0,0 +1,4 @@
export default interface Link {
title: string;
path: string;
}

7
src/types/LinkList.ts Normal file
View file

@ -0,0 +1,7 @@
import type Link from "./Link";
export default interface LinkList {
title?: string;
id: number;
links: Link[];
}

View file

@ -0,0 +1,7 @@
import type LinkList from "./LinkList";
export default interface PelicanConfig {
version: string;
sidebar: LinkList[];
jdr: LinkList[];
}