[FORDJ] Add Playground App

This commit is contained in:
Milovann Yanatchkov 2024-05-15 11:34:09 +02:00
parent 85c796b51d
commit 35fcf6088c
5 changed files with 90 additions and 0 deletions

View file

@ -4,4 +4,5 @@ User : {{.UserName}}
{{else}}
User : None
{{end}}
<div id="playground"></div>
{{template "base/footer" .}}

View file

@ -0,0 +1,41 @@
<template>
<h1 v-if="gameData">{{ gameData.File.Name }}</h1>
<div v-if="gameData">
{{ gameData.File.name }}
<br>
<GameStep v-for="step in gameData.File.Steps" :name="step.Items.Name.Value" />
</div>
<p v-if="serverData">{{ serverData.data }}</p>
<button @click="fetchData">Fetch</button>
</template>
<script>
import GameStep from './Step.vue';
export default {
components: {
GameStep,
},
data() {
return {
serverData: null,
gameData:null,
gameValue: null,
}
},
mounted() {
this.fetchGame();
},
methods : {
async fetchData() {
const response = await fetch("http://localhost:3333/time/");
this.serverData = await response.json();
},
async fetchGame() {
const response = await fetch("http://localhost:3333/game/");
this.gameData = await response.json();
},
}
};
</script>
<style></style>

View file

@ -0,0 +1,33 @@
<template>
<div>
{{ StepName }} : {{ stepData.result }}
</div>
<br>
</template>
<script>
export default {
data() {
return {
stepData: "",
StepName: this.name,
}
},
mounted() {
this.fetchData();
},
props: [
'name'
],
methods : {
async fetchData() {
const response = await fetch("http://localhost:3333/step", {
method: "POST",
body: this.StepName,
}
);
this.stepData = await response.json();
},
}
};
</script>
<style></style>

View file

@ -0,0 +1,11 @@
import {createApp} from 'vue'
import Playground from '../components/Playground.vue'
export function initPlayground() {
const el = document.getElementById('playground');
if (!el) return;
const View = createApp(Playground);
View.mount(el);
}

View file

@ -88,6 +88,8 @@ import {initDirAuto} from './modules/dirauto.js';
import {initRepositorySearch} from './features/repo-search.js';
import {initColorPickers} from './features/colorpicker.js';
import {initPlayground} from './features/playground.js';
// Init Gitea's Fomantic settings
initGiteaFomantic();
initDirAuto();
@ -190,4 +192,6 @@ onDomReady(() => {
initPdfViewer();
initScopedAccessTokenCategories();
initColorPickers();
initPlayground();
});