mirror of
https://github.com/PretendoNetwork/website.git
synced 2026-09-28 03:26:46 -05:00
chore: fix linting in entire project
This commit is contained in:
@@ -470,23 +470,32 @@ onMounted(() => {
|
||||
v-if="user"
|
||||
class="user-widget-wrapper logged-in"
|
||||
>
|
||||
<div class="user-widget-toggle" @click="widgetOpen = true">
|
||||
<div
|
||||
class="user-widget-toggle"
|
||||
@click="widgetOpen = true"
|
||||
>
|
||||
<img
|
||||
:src="user.mii?.imageUrl ?? '#'"
|
||||
:alt="user.mii?.name ?? ''"
|
||||
:alt="user.mii?.name ?? ''"
|
||||
>
|
||||
</div>
|
||||
<div class="user-widget" :class="{
|
||||
'active': widgetOpen
|
||||
}">
|
||||
<div
|
||||
class="user-widget"
|
||||
:class="{
|
||||
'active': widgetOpen
|
||||
}"
|
||||
>
|
||||
<div class="user-avatar">
|
||||
<img
|
||||
:src="user.mii?.imageUrl ?? '#'"
|
||||
:src="user.mii?.imageUrl ?? '#'"
|
||||
:alt="user.mii?.name ?? ''"
|
||||
>
|
||||
</div>
|
||||
<div class="user-info">
|
||||
<div v-if="user.mii" class="mii-name">
|
||||
<div
|
||||
v-if="user.mii"
|
||||
class="mii-name"
|
||||
>
|
||||
{{ user.mii.name }}
|
||||
</div>
|
||||
<div class="pnid">
|
||||
|
||||
@@ -5,5 +5,5 @@
|
||||
<slot />
|
||||
<Footer />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
import type { GetApiAuthMe } from "#shared/api-types"
|
||||
import type { GetApiAuthMe } from '#shared/api-types';
|
||||
|
||||
export default defineNuxtRouteMiddleware(async () => {
|
||||
const meStore = useMeStore();
|
||||
if (meStore.loaded) return; // Already loaded
|
||||
if (meStore.loaded) {
|
||||
return;
|
||||
} // Already loaded
|
||||
|
||||
const authStore = useAuthStore();
|
||||
const token = authStore.getToken();
|
||||
@@ -14,13 +16,13 @@ export default defineNuxtRouteMiddleware(async () => {
|
||||
try {
|
||||
const res = await $fetch<GetApiAuthMe>('/api/auth/me', {
|
||||
headers: {
|
||||
'Authorization': `Bearer ${token}`
|
||||
Authorization: `Bearer ${token}`
|
||||
}
|
||||
})
|
||||
});
|
||||
meStore.setMe({
|
||||
pid: res.pid,
|
||||
username: res.username,
|
||||
mii: res.mii,
|
||||
mii: res.mii
|
||||
});
|
||||
} catch {
|
||||
meStore.setMe(null);
|
||||
|
||||
@@ -1,12 +1,16 @@
|
||||
function notAllowed() {
|
||||
return navigateTo("/");
|
||||
return navigateTo('/');
|
||||
}
|
||||
|
||||
export default defineNuxtRouteMiddleware(async (to) => {
|
||||
const meStore = useMeStore();
|
||||
if (!meStore.loaded) throw new Error("Mestore must be loaded before reaching this middleware");
|
||||
if (!meStore.loaded) {
|
||||
throw new Error('Mestore must be loaded before reaching this middleware');
|
||||
}
|
||||
|
||||
if (to.meta.needsAuth) {
|
||||
if (!meStore.user) return notAllowed();
|
||||
if (!meStore.user) {
|
||||
return notAllowed();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,15 +1,14 @@
|
||||
<script setup lang="ts">
|
||||
definePageMeta({
|
||||
needsAuth: true,
|
||||
})
|
||||
needsAuth: true
|
||||
});
|
||||
|
||||
const me = useMeStore();
|
||||
</script>
|
||||
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<h1>Hello {{ me.user?.username }}</h1>
|
||||
<h1>Hello {{ me.user?.username }}</h1>
|
||||
<p>TODO: account stub page</p>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -92,8 +92,8 @@ async function registerSubmission() {
|
||||
type="password"
|
||||
autocomplete="new-password"
|
||||
required
|
||||
passwordrules="minlength: 6; maxlength: 16; max-consecutive: 2; allowed: [-!-~];"
|
||||
pattern="[-!-~]{6,16}"
|
||||
passwordrules="minlength: 6; maxlength: 16; max-consecutive: 2; allowed: [-!-~];"
|
||||
pattern="[-!-~]{6,16}"
|
||||
>
|
||||
</div>
|
||||
<div>
|
||||
|
||||
@@ -140,10 +140,15 @@ function titleSuffixHandler(path: string) {
|
||||
<h2 class="title">
|
||||
<a href="/progress">{{ $t("progress.title") }} ({{ progress.data.value?.completion ?? 0 }}%)</a>
|
||||
</h2>
|
||||
<div v-for="project of progress.data.value?.items ?? []" :key="project.title">
|
||||
<p>{{ project.title }} [{{ project.completion }}%]</p>
|
||||
</div>
|
||||
<p v-if="(progress.data.value?.items ?? []).length === 0">No projects</p>
|
||||
<div
|
||||
v-for="project of progress.data.value?.items ?? []"
|
||||
:key="project.title"
|
||||
>
|
||||
<p>{{ project.title }} [{{ project.completion }}%]</p>
|
||||
</div>
|
||||
<p v-if="(progress.data.value?.items ?? []).length === 0">
|
||||
No projects
|
||||
</p>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
|
||||
@@ -1,19 +1,34 @@
|
||||
<script setup lang="ts">
|
||||
const progress = await useFetch('/api/progress');
|
||||
const projects = computed(() => progress.data.value?.items ?? []);
|
||||
const donations = computed(() => progress.data.value?.donations)
|
||||
const donations = computed(() => progress.data.value?.donations);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<p>TODO: progress stub page</p>
|
||||
<h1 v-if="donations">{{ donations.currentCents }}¢ / {{ donations.goalCents }}¢</h1>
|
||||
<div v-for="project of projects" :key="project.title">
|
||||
<h1>{{ project.title }} ({{ project.completion }}%)</h1>
|
||||
<a v-if="project.githubUrl" :href="project.githubUrl">Github</a>
|
||||
<p v-for="task of project.tasks" :key="task.title">[{{ task.status }}] {{ task.title }}</p>
|
||||
<hr />
|
||||
</div>
|
||||
<p v-if="projects.length === 0">No projects</p>
|
||||
<h1 v-if="donations">
|
||||
{{ donations.currentCents }}¢ / {{ donations.goalCents }}¢
|
||||
</h1>
|
||||
<div
|
||||
v-for="project of projects"
|
||||
:key="project.title"
|
||||
>
|
||||
<h1>{{ project.title }} ({{ project.completion }}%)</h1>
|
||||
<a
|
||||
v-if="project.githubUrl"
|
||||
:href="project.githubUrl"
|
||||
>Github</a>
|
||||
<p
|
||||
v-for="task of project.tasks"
|
||||
:key="task.title"
|
||||
>
|
||||
[{{ task.status }}] {{ task.title }}
|
||||
</p>
|
||||
<hr>
|
||||
</div>
|
||||
<p v-if="projects.length === 0">
|
||||
No projects
|
||||
</p>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
2
src/plugins/types.d.ts
vendored
2
src/plugins/types.d.ts
vendored
@@ -1,4 +1,4 @@
|
||||
declare module "#app" {
|
||||
declare module '#app' {
|
||||
interface PageMeta {
|
||||
needsAuth?: boolean;
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
/* eslint-disable no-self-assign -- Self assign is needed for refresh cookies */
|
||||
import type { CookieOptions } from '#app';
|
||||
|
||||
type AuthState = {
|
||||
@@ -73,6 +74,6 @@ export function useAuthStore() {
|
||||
getToken,
|
||||
refresh,
|
||||
set,
|
||||
logout,
|
||||
logout
|
||||
};
|
||||
}
|
||||
|
||||
@@ -2,9 +2,9 @@ export type Me = {
|
||||
pid: number;
|
||||
username: string;
|
||||
mii: {
|
||||
imageUrl: string,
|
||||
name: string,
|
||||
} | null,
|
||||
imageUrl: string;
|
||||
name: string;
|
||||
} | null;
|
||||
};
|
||||
|
||||
export const useMeStore = defineStore('me', () => {
|
||||
|
||||
Reference in New Issue
Block a user