More fixes more code more stuff

This commit is contained in:
Lordmau5 2023-11-15 22:42:11 +01:00
parent 5ed827e084
commit a5cf6e3918
18 changed files with 6243 additions and 214 deletions

54
auto-imports.d.ts vendored
View File

@ -5,24 +5,7 @@
// Generated by unplugin-auto-import // Generated by unplugin-auto-import
export {} export {}
declare global { declare global {
const DComponent: typeof import('vue-facing-decorator')['Component']
const DRef: typeof import('vue-facing-decorator')['Ref']
const EditorComponent: typeof import('./src/components/EditorComponent.vue')['default']
const EffectScope: typeof import('vue')['EffectScope'] const EffectScope: typeof import('vue')['EffectScope']
const Emit: typeof import('vue-facing-decorator')['Emit']
const Hook: typeof import('vue-facing-decorator')['Hook']
const Inject: typeof import('vue-facing-decorator')['Inject']
const MarkdownRenderer: typeof import('./src/components/MarkdownRenderer.vue')['default']
const Model: typeof import('vue-facing-decorator')['Model']
const NavbarComponent: typeof import('./src/components/NavbarComponent.vue')['default']
const Prop: typeof import('vue-facing-decorator')['Prop']
const Provide: typeof import('vue-facing-decorator')['Provide']
const Setup: typeof import('vue-facing-decorator')['Setup']
const SidebarComponent: typeof import('./src/components/SidebarComponent.vue')['default']
const VModel: typeof import('vue-facing-decorator')['VModel']
const Vanilla: typeof import('vue-facing-decorator')['Vanilla']
const Vue: typeof import('vue-facing-decorator')['Vue']
const Watch: typeof import('vue-facing-decorator')['Watch']
const computed: typeof import('vue')['computed'] const computed: typeof import('vue')['computed']
const createApp: typeof import('vue')['createApp'] const createApp: typeof import('vue')['createApp']
const customRef: typeof import('vue')['customRef'] const customRef: typeof import('vue')['customRef']
@ -62,7 +45,6 @@ declare global {
const shallowReactive: typeof import('vue')['shallowReactive'] const shallowReactive: typeof import('vue')['shallowReactive']
const shallowReadonly: typeof import('vue')['shallowReadonly'] const shallowReadonly: typeof import('vue')['shallowReadonly']
const shallowRef: typeof import('vue')['shallowRef'] const shallowRef: typeof import('vue')['shallowRef']
const toNative: typeof import('vue-facing-decorator')['toNative']
const toRaw: typeof import('vue')['toRaw'] const toRaw: typeof import('vue')['toRaw']
const toRef: typeof import('vue')['toRef'] const toRef: typeof import('vue')['toRef']
const toRefs: typeof import('vue')['toRefs'] const toRefs: typeof import('vue')['toRefs']
@ -90,24 +72,7 @@ declare global {
import { UnwrapRef } from 'vue' import { UnwrapRef } from 'vue'
declare module 'vue' { declare module 'vue' {
interface ComponentCustomProperties { interface ComponentCustomProperties {
readonly DComponent: UnwrapRef<typeof import('vue-facing-decorator')['Component']>
readonly DRef: UnwrapRef<typeof import('vue-facing-decorator')['Ref']>
readonly EditorComponent: UnwrapRef<typeof import('./src/components/EditorComponent.vue')['default']>
readonly EffectScope: UnwrapRef<typeof import('vue')['EffectScope']> readonly EffectScope: UnwrapRef<typeof import('vue')['EffectScope']>
readonly Emit: UnwrapRef<typeof import('vue-facing-decorator')['Emit']>
readonly Hook: UnwrapRef<typeof import('vue-facing-decorator')['Hook']>
readonly Inject: UnwrapRef<typeof import('vue-facing-decorator')['Inject']>
readonly MarkdownRenderer: UnwrapRef<typeof import('./src/components/MarkdownRenderer.vue')['default']>
readonly Model: UnwrapRef<typeof import('vue-facing-decorator')['Model']>
readonly NavbarComponent: UnwrapRef<typeof import('./src/components/NavbarComponent.vue')['default']>
readonly Prop: UnwrapRef<typeof import('vue-facing-decorator')['Prop']>
readonly Provide: UnwrapRef<typeof import('vue-facing-decorator')['Provide']>
readonly Setup: UnwrapRef<typeof import('vue-facing-decorator')['Setup']>
readonly SidebarComponent: UnwrapRef<typeof import('./src/components/SidebarComponent.vue')['default']>
readonly VModel: UnwrapRef<typeof import('vue-facing-decorator')['VModel']>
readonly Vanilla: UnwrapRef<typeof import('vue-facing-decorator')['Vanilla']>
readonly Vue: UnwrapRef<typeof import('vue-facing-decorator')['Vue']>
readonly Watch: UnwrapRef<typeof import('vue-facing-decorator')['Watch']>
readonly computed: UnwrapRef<typeof import('vue')['computed']> readonly computed: UnwrapRef<typeof import('vue')['computed']>
readonly createApp: UnwrapRef<typeof import('vue')['createApp']> readonly createApp: UnwrapRef<typeof import('vue')['createApp']>
readonly customRef: UnwrapRef<typeof import('vue')['customRef']> readonly customRef: UnwrapRef<typeof import('vue')['customRef']>
@ -147,7 +112,6 @@ declare module 'vue' {
readonly shallowReactive: UnwrapRef<typeof import('vue')['shallowReactive']> readonly shallowReactive: UnwrapRef<typeof import('vue')['shallowReactive']>
readonly shallowReadonly: UnwrapRef<typeof import('vue')['shallowReadonly']> readonly shallowReadonly: UnwrapRef<typeof import('vue')['shallowReadonly']>
readonly shallowRef: UnwrapRef<typeof import('vue')['shallowRef']> readonly shallowRef: UnwrapRef<typeof import('vue')['shallowRef']>
readonly toNative: UnwrapRef<typeof import('vue-facing-decorator')['toNative']>
readonly toRaw: UnwrapRef<typeof import('vue')['toRaw']> readonly toRaw: UnwrapRef<typeof import('vue')['toRaw']>
readonly toRef: UnwrapRef<typeof import('vue')['toRef']> readonly toRef: UnwrapRef<typeof import('vue')['toRef']>
readonly toRefs: UnwrapRef<typeof import('vue')['toRefs']> readonly toRefs: UnwrapRef<typeof import('vue')['toRefs']>
@ -169,24 +133,7 @@ declare module 'vue' {
} }
declare module '@vue/runtime-core' { declare module '@vue/runtime-core' {
interface ComponentCustomProperties { interface ComponentCustomProperties {
readonly DComponent: UnwrapRef<typeof import('vue-facing-decorator')['Component']>
readonly DRef: UnwrapRef<typeof import('vue-facing-decorator')['Ref']>
readonly EditorComponent: UnwrapRef<typeof import('./src/components/EditorComponent.vue')['default']>
readonly EffectScope: UnwrapRef<typeof import('vue')['EffectScope']> readonly EffectScope: UnwrapRef<typeof import('vue')['EffectScope']>
readonly Emit: UnwrapRef<typeof import('vue-facing-decorator')['Emit']>
readonly Hook: UnwrapRef<typeof import('vue-facing-decorator')['Hook']>
readonly Inject: UnwrapRef<typeof import('vue-facing-decorator')['Inject']>
readonly MarkdownRenderer: UnwrapRef<typeof import('./src/components/MarkdownRenderer.vue')['default']>
readonly Model: UnwrapRef<typeof import('vue-facing-decorator')['Model']>
readonly NavbarComponent: UnwrapRef<typeof import('./src/components/NavbarComponent.vue')['default']>
readonly Prop: UnwrapRef<typeof import('vue-facing-decorator')['Prop']>
readonly Provide: UnwrapRef<typeof import('vue-facing-decorator')['Provide']>
readonly Setup: UnwrapRef<typeof import('vue-facing-decorator')['Setup']>
readonly SidebarComponent: UnwrapRef<typeof import('./src/components/SidebarComponent.vue')['default']>
readonly VModel: UnwrapRef<typeof import('vue-facing-decorator')['VModel']>
readonly Vanilla: UnwrapRef<typeof import('vue-facing-decorator')['Vanilla']>
readonly Vue: UnwrapRef<typeof import('vue-facing-decorator')['Vue']>
readonly Watch: UnwrapRef<typeof import('vue-facing-decorator')['Watch']>
readonly computed: UnwrapRef<typeof import('vue')['computed']> readonly computed: UnwrapRef<typeof import('vue')['computed']>
readonly createApp: UnwrapRef<typeof import('vue')['createApp']> readonly createApp: UnwrapRef<typeof import('vue')['createApp']>
readonly customRef: UnwrapRef<typeof import('vue')['customRef']> readonly customRef: UnwrapRef<typeof import('vue')['customRef']>
@ -226,7 +173,6 @@ declare module '@vue/runtime-core' {
readonly shallowReactive: UnwrapRef<typeof import('vue')['shallowReactive']> readonly shallowReactive: UnwrapRef<typeof import('vue')['shallowReactive']>
readonly shallowReadonly: UnwrapRef<typeof import('vue')['shallowReadonly']> readonly shallowReadonly: UnwrapRef<typeof import('vue')['shallowReadonly']>
readonly shallowRef: UnwrapRef<typeof import('vue')['shallowRef']> readonly shallowRef: UnwrapRef<typeof import('vue')['shallowRef']>
readonly toNative: UnwrapRef<typeof import('vue-facing-decorator')['toNative']>
readonly toRaw: UnwrapRef<typeof import('vue')['toRaw']> readonly toRaw: UnwrapRef<typeof import('vue')['toRaw']>
readonly toRef: UnwrapRef<typeof import('vue')['toRef']> readonly toRef: UnwrapRef<typeof import('vue')['toRef']>
readonly toRefs: UnwrapRef<typeof import('vue')['toRefs']> readonly toRefs: UnwrapRef<typeof import('vue')['toRefs']>

1
components.d.ts vendored
View File

@ -8,6 +8,7 @@ export {}
declare module 'vue' { declare module 'vue' {
export interface GlobalComponents { export interface GlobalComponents {
EditorComponent: typeof import('./src/components/EditorComponent.vue')['default'] EditorComponent: typeof import('./src/components/EditorComponent.vue')['default']
GeneratorComponent: typeof import('./src/components/GeneratorComponent.vue')['default']
MarkdownRenderer: typeof import('./src/components/MarkdownRenderer.vue')['default'] MarkdownRenderer: typeof import('./src/components/MarkdownRenderer.vue')['default']
NavbarComponent: typeof import('./src/components/NavbarComponent.vue')['default'] NavbarComponent: typeof import('./src/components/NavbarComponent.vue')['default']
RouterLink: typeof import('vue-router')['RouterLink'] RouterLink: typeof import('vue-router')['RouterLink']

6034
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -20,7 +20,6 @@
"quasar": "^2.13.1", "quasar": "^2.13.1",
"reflect-metadata": "^0.1.13", "reflect-metadata": "^0.1.13",
"vue": "^3.3.4", "vue": "^3.3.4",
"vue-facing-decorator": "^3.0.4",
"vue-router": "^4.2.5" "vue-router": "^4.2.5"
}, },
"devDependencies": { "devDependencies": {

11
pnpm-lock.yaml generated
View File

@ -29,9 +29,6 @@ dependencies:
vue: vue:
specifier: ^3.3.4 specifier: ^3.3.4
version: 3.3.8(typescript@5.2.2) version: 3.3.8(typescript@5.2.2)
vue-facing-decorator:
specifier: ^3.0.4
version: 3.0.4(vue@3.3.8)
vue-router: vue-router:
specifier: ^4.2.5 specifier: ^4.2.5
version: 4.2.5(vue@3.3.8) version: 4.2.5(vue@3.3.8)
@ -3326,14 +3323,6 @@ packages:
- supports-color - supports-color
dev: true dev: true
/vue-facing-decorator@3.0.4(vue@3.3.8):
resolution: {integrity: sha512-Lk90PevJllB6qRRdLvLFjATZrv00nof1Ob6afavKL7Pc7V3eEin3vhdvEDRORdWKVvNoXhJbHejngWVuT0Pt0g==}
peerDependencies:
vue: ^3.0.0
dependencies:
vue: 3.3.8(typescript@5.2.2)
dev: false
/vue-router@4.2.5(vue@3.3.8): /vue-router@4.2.5(vue@3.3.8):
resolution: {integrity: sha512-DIUpKcyg4+PTQKfFPX88UWhlagBEBEfJ5A8XDXRJLUnZOvcpMF8o/dnL90vpVkGaPbjvXazV/rC1qBKrZlFugw==} resolution: {integrity: sha512-DIUpKcyg4+PTQKfFPX88UWhlagBEBEfJ5A8XDXRJLUnZOvcpMF8o/dnL90vpVkGaPbjvXazV/rC1qBKrZlFugw==}
peerDependencies: peerDependencies:

View File

@ -10,13 +10,10 @@
</q-layout> </q-layout>
</template> </template>
<script lang="ts"> <script setup lang="ts">
@DComponent const leftDrawerOpen = ref(false);
export default class MainPage extends Vue {
leftDrawerOpen = false;
toggleLeftDrawer() { const toggleLeftDrawer = () => {
this.leftDrawerOpen = !this.leftDrawerOpen; leftDrawerOpen.value = !leftDrawerOpen.value;
} };
}
</script> </script>

View File

@ -118,36 +118,38 @@
</q-dialog> </q-dialog>
</template> </template>
<script lang="ts"> <script setup lang="ts">
import { import {
games games as parsed_games
} from '@/js/ParseGamesJSON.js'; } from '@/js/ParseGamesJSON.js';
import type BingoGame from '@/js/lib/BingoGame.ts'; import BingoGame from '@/js/lib/BingoGame.ts';
@DComponent // All games
export default class EditorComponent extends Vue { const games = ref<BingoGame[]>(Array.from(parsed_games.values()));
games: BingoGame[] = Array.from(games.values());
selected_game: BingoGame | undefined = undefined; // Selected game
const selected_game = ref<BingoGame | undefined>(undefined);
@Watch('selected_game') // Popup open state
onSelectedGameChange(newGame: BingoGame | undefined) { const learn_more = ref<boolean>(false);
if (newGame)
this.learn_more = true;
}
learn_more: boolean = false; // Search query
const search = ref<string>('');
@Watch('learn_more') // Filter games by search
onPopupClose(newValue: boolean) { const filtered_games = computed(() => {
if (!newValue) return games.value.filter(game => game.name.toLocaleLowerCase().includes(search.value.toLocaleLowerCase()));
this.selected_game = undefined; });
}
search: string = ''; // On selected game change, open popup
watch(selected_game, newGame => {
if (newGame)
learn_more.value = true;
});
get filtered_games(): BingoGame[] { // On popup close, reset selected game
return this.games.filter(game => game.name.toLocaleLowerCase().includes(this.search.toLocaleLowerCase())); watch(learn_more, newValue => {
} if (!newValue)
} selected_game.value = undefined;
});
</script> </script>

View File

@ -0,0 +1,102 @@
<template>
<q-tree
:nodes="nodes"
node-key="label"
tick-strategy="leaf"
v-model:selected="selected"
v-model:ticked="ticked"
v-model:expanded="expanded"
>
<template v-slot:header-goal="prop">
<div class="row items-center">
<div>{{ prop.node.label }}</div>
<q-badge outline v-for="tag in prop.node.goal.tags" :key="tag" :color="getColorForTag(tag)" class="q-ml-sm">
<div class="text-weight-bold">{{ tag }}</div>
</q-badge>
</div>
</template>
</q-tree>
</template>
<script setup lang="ts">
import {
games
} from '@/js/ParseGamesJSON.ts';
import BingoCategory from '@/js/lib/BingoCategory.ts';
import type BingoGoal from '@/js/lib/BingoGoal.ts';
import BingoGoalList from '@/js/lib/BingoGoalList.ts';
interface Node {
label: string;
header?: string;
children?: Node[];
goal?: BingoGoal;
}
const selected = ref([]);
const ticked = ref([]);
const expanded = ref([]);
const getColorForTag = (tag: string) => {
switch (tag) {
case 'Easy':
return 'green';
case 'Normal':
return 'orange';
case 'Hard':
return 'red';
default:
return 'primary';
}
};
const nodes = computed(() => {
return games.map(game => {
const game_node: Node = {
label: game.name,
children: []
};
game_node.children = game.items.map(item => {
const group_node: Node = {
label: item.name,
children: []
};
if (item instanceof BingoCategory) {
group_node.children = item.goal_lists.map(goal_list => {
const goal_list_node: Node = {
label: goal_list.name,
children: goal_list.goals.map(goal => {
const goal_node: Node = {
label: goal.name,
header: 'goal',
goal
};
return goal_node;
})
};
return goal_list_node;
});
}
else if (item instanceof BingoGoalList) {
group_node.children = item.goals.map(goal => {
const goal_node: Node = {
label: goal.name,
header: 'goal',
goal
};
return goal_node;
});
}
return group_node;
});
return game_node;
});
});
</script>

View File

@ -2,20 +2,21 @@
<div v-html="markdown"></div> <div v-html="markdown"></div>
</template> </template>
<script lang="ts"> <script setup lang="ts">
import MarkdownIt from 'markdown-it'; import MarkdownIt from 'markdown-it';
const md = new MarkdownIt(); const md = new MarkdownIt();
@DComponent const {
export default class MarkdownRenderer extends Vue { text
@Prop({ } = defineProps({
default: false, text: {
required: true type: String,
}) required: true,
text!: string; default: ''
get markdown(): string {
return md.render(this.text);
} }
} });
const markdown = computed(() => {
return md.render(text);
});
</script> </script>

View File

@ -13,12 +13,10 @@
</q-header> </q-header>
</template> </template>
<script lang="ts"> <script setup lang="ts">
@DComponent({ const emit = defineEmits([ 'toggleLeftDrawer' ]);
emits: [ 'toggleLeftDrawer' ]
}) const toggleLeftDrawer = () => {
export default class NavbarComponent extends Vue { emit('toggleLeftDrawer');
@Emit };
toggleLeftDrawer() {}
}
</script> </script>

View File

@ -20,63 +20,35 @@
</q-drawer> </q-drawer>
</template> </template>
<script lang="ts"> <script setup lang="ts">
@DComponent const {
export default class SidebarComponent extends Vue { drawer
@Prop({ } = defineProps({
default: false, drawer: {
required: true type: Boolean,
}) required: true,
drawer!: boolean; default: false
}
});
menuList = [ const menuList = [
{ {
icon: 'home', icon: 'home',
label: 'Home', label: 'Home',
separator: true, separator: true,
to: 'home' to: 'home'
}, },
{ {
icon: 'replay', icon: 'replay',
label: 'Generator', label: 'Generator',
separator: false, separator: false,
to: 'generator' to: 'generator'
}, },
{ {
icon: 'edit', icon: 'edit',
label: 'Editor', label: 'Editor',
separator: false, separator: false,
to: 'editor' to: 'editor'
} }
// { ];
// icon: 'delete',
// label: 'Trash',
// separator: false
// },
// {
// icon: 'error',
// label: 'Spam',
// separator: true
// },
// {
// type: 'spacer'
// },
// {
// icon: 'settings',
// label: 'Settings',
// separator: false
// },
// {
// icon: 'feedback',
// label: 'Send Feedback',
// separator: false
// },
// {
// icon: 'help',
// iconColor: 'primary',
// label: 'Help',
// separator: false
// }
];
}
</script> </script>

View File

@ -7,7 +7,8 @@ import BingoGoal from '@/js/lib/BingoGoal.ts';
import BingoCategory from '@/js/lib/BingoCategory.ts'; import BingoCategory from '@/js/lib/BingoCategory.ts';
import BingoGoalList from '@/js/lib/BingoGoalList.ts'; import BingoGoalList from '@/js/lib/BingoGoalList.ts';
export const games: Map<string, BingoGame> = new Map; export const games: BingoGame[] = [];
// export const games: Map<string, BingoGame> = new Map;
function run_old_format() { function run_old_format() {
for (const j_game of json) { for (const j_game of json) {
@ -34,7 +35,8 @@ function run_old_format() {
} }
} }
games.set(game.name, game); games.push(game);
// games.set(game.name, game);
// for (let i = 0; i < 3; i++) // for (let i = 0; i < 3; i++)
// games.set(`${ game.name }-${ i }`, game); // games.set(`${ game.name }-${ i }`, game);

View File

@ -45,14 +45,14 @@ function test() {
// console.log(game); // console.log(game);
const plain = Parser.to_json(game); // const plain = Parser.to_json(game);
console.log('plain', plain); // console.log('plain', plain);
// const plain = instanceToPlain(game); // const plain = instanceToPlain(game);
// const text = JSON.stringify(plain); // const text = JSON.stringify(plain);
// console.log(text); // console.log(text);
const parsed = Parser.from_json(JSON.stringify(plain)); // const parsed = Parser.from_json(JSON.stringify(plain));
console.log('parsed', parsed); // console.log('parsed', parsed);
} }
test(); test();

View File

@ -4,6 +4,7 @@ import {
// import HomeView from '../views/HomeView.vue' // import HomeView from '../views/HomeView.vue'
import MainPage from '@/views/MainPage.vue'; import MainPage from '@/views/MainPage.vue';
import EditorPage from '@/views/EditorPage.vue'; import EditorPage from '@/views/EditorPage.vue';
import GeneratorPage from '@/views/GeneratorPage.vue';
const router = createRouter({ const router = createRouter({
history: createWebHistory(import.meta.env.BASE_URL), history: createWebHistory(import.meta.env.BASE_URL),
@ -21,7 +22,7 @@ const router = createRouter({
{ {
path: '/generator', path: '/generator',
name: 'generator', name: 'generator',
component: EditorPage component: GeneratorPage
} }
// { // {
// path: '/about', // path: '/about',

View File

@ -0,0 +1,12 @@
<template>
<div class="q-pa-md q-gutter-md">
<q-card class="q-mx-auto" style="max-width: 800px; height: 800px;">
<q-scroll-area style="height: 100%;">
<GeneratorComponent />
</q-scroll-area>
</q-card>
</div>
</template>
<script setup lang="ts">
</script>

View File

@ -3,6 +3,4 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import '@/js/lib/Test.ts';
import '@/js/ParseGamesJSON.ts';
</script> </script>

View File

@ -2,12 +2,11 @@
"extends": "@vue/tsconfig/tsconfig.dom.json", "extends": "@vue/tsconfig/tsconfig.dom.json",
"include": [ "include": [
"env.d.ts", "env.d.ts",
"auto-imports.d.ts",
"components.d.ts", "components.d.ts",
"auto-imports.d.ts",
"src/**/*", "src/**/*",
"src/**/*.vue", "src/**/*.vue",
"src/**/*.json", "src/**/*.json"
"src/**/*.md"
], ],
"exclude": [ "exclude": [
"src/**/__tests__/*" "src/**/__tests__/*"
@ -23,6 +22,7 @@
"target": "ESNext", "target": "ESNext",
"emitDecoratorMetadata": true, "emitDecoratorMetadata": true,
"experimentalDecorators": true, "experimentalDecorators": true,
"allowImportingTsExtensions": true "allowImportingTsExtensions": true,
"emitDeclarationOnly": true
}, },
} }

View File

@ -37,32 +37,7 @@ export default defineConfig({
imports: [ imports: [
// presets // presets
'vue', 'vue',
'vue-router', 'vue-router'
{
'vue-facing-decorator': [
[
'Component',
'DComponent'
],
[
'Ref',
'DRef'
],
'Setup',
'Watch',
'Prop',
'Provide',
'Inject',
'Emit',
'VModel',
'Model',
'Vanilla',
'Hook',
'toNative',
'Vue'
]
}
], ],
dirs: [ './src/components/**' ], dirs: [ './src/components/**' ],
dts: true, dts: true,