mirror of
https://github.com/HangarMC/Hangar.git
synced 2025-02-17 15:01:42 +08:00
chore: lint
This commit is contained in:
parent
b90bd46e74
commit
875e975452
@ -1,6 +1,7 @@
|
||||
<script lang="ts" setup>
|
||||
import { Menu, MenuButton, MenuItem, MenuItems } from "@headlessui/vue";
|
||||
import { Category, Platform, type PlatformVersion, Tag } from "~/types/backend";
|
||||
import { Platform, Tag } from "~/types/backend";
|
||||
import type { PlatformVersion , Category } from "~/types/backend";
|
||||
|
||||
const props = defineProps<{
|
||||
platform?: Platform;
|
||||
@ -251,9 +252,14 @@ useHead(
|
||||
</h3>
|
||||
<div class="flex flex-col gap-1">
|
||||
<ul>
|
||||
<li v-for="platform in useVisiblePlatforms" :key="platform.enumName" class="inline-flex w-full">
|
||||
<InputRadio :label="platform.name" :model-value="filters.platform" :value="platform.enumName" @update:model-value="updatePlatform">
|
||||
<PlatformLogo :platform="platform.enumName" :size="24" class="mr-1" />
|
||||
<li v-for="visiblePlatform in useVisiblePlatforms" :key="visiblePlatform.enumName" class="inline-flex w-full">
|
||||
<InputRadio
|
||||
:label="visiblePlatform.name"
|
||||
:model-value="filters.platform"
|
||||
:value="visiblePlatform.enumName"
|
||||
@update:model-value="updatePlatform"
|
||||
>
|
||||
<PlatformLogo :platform="visiblePlatform.enumName" :size="24" class="mr-1" />
|
||||
</InputRadio>
|
||||
</li>
|
||||
</ul>
|
||||
|
@ -87,7 +87,7 @@ const canEditCurrentUser = computed<boolean>(() => {
|
||||
</template>
|
||||
</Popper>
|
||||
</h1>
|
||||
<Skeleton class="text-2xl px-1 w-50" v-else />
|
||||
<Skeleton v-else class="text-2xl px-1 w-50" />
|
||||
|
||||
<div v-if="viewingUser" class="ml-1">
|
||||
<span v-if="viewingUser.tagline">{{ viewingUser.tagline }}</span>
|
||||
|
@ -1,6 +1,7 @@
|
||||
<script setup lang="ts">
|
||||
import { Popover, PopoverButton, PopoverPanel } from "@headlessui/vue";
|
||||
|
||||
import type { RouteLocationRaw, RouteMap } from "vue-router";
|
||||
import hangarLogo from "~/assets/hangar-logo.svg";
|
||||
|
||||
import IconMdiHome from "~icons/mdi/home";
|
||||
@ -20,7 +21,6 @@ import IconMdiFolderWrenchOutline from "~icons/mdi/folder-wrench-outline";
|
||||
import IconMdiFolderInformationOutline from "~icons/mdi/folder-information-outline";
|
||||
|
||||
import { type HangarNotification, type HangarUser, NamedPermission } from "~/types/backend";
|
||||
import type { RouteLocationRaw, RouteMap } from "vue-router";
|
||||
import { useUnreadNotificationCount } from "~/composables/useData";
|
||||
|
||||
// marker so that you can inspect backend data in dev tools
|
||||
|
@ -1,32 +1,31 @@
|
||||
import {
|
||||
type ApiKey,
|
||||
type DayStats,
|
||||
type ExtendedProjectPage,
|
||||
type HangarChannel,
|
||||
type HangarProjectFlag,
|
||||
type HangarProjectNote,
|
||||
type HangarReview,
|
||||
type HealthReport,
|
||||
type Invites,
|
||||
type JarScanResult,
|
||||
NamedPermission,
|
||||
type OrganizationRoleTable,
|
||||
type PaginatedResultHangarLoggedAction,
|
||||
type PaginatedResultHangarNotification,
|
||||
type PaginatedResultHangarProjectFlag,
|
||||
type PaginatedResultProject,
|
||||
type PaginatedResultProjectCompact,
|
||||
type PaginatedResultUser,
|
||||
type PaginatedResultVersion,
|
||||
Platform,
|
||||
type ProjectCompact,
|
||||
type ProjectOwner,
|
||||
type ReviewQueue,
|
||||
type SettingsResponse,
|
||||
type User,
|
||||
type VersionInfo,
|
||||
} from "~/types/backend";
|
||||
import type { Router } from "vue-router";
|
||||
import { NamedPermission } from "~/types/backend";
|
||||
import type {
|
||||
ApiKey,
|
||||
DayStats,
|
||||
ExtendedProjectPage,
|
||||
HangarChannel,
|
||||
HangarProjectFlag,
|
||||
HangarProjectNote,
|
||||
HangarReview,
|
||||
HealthReport,
|
||||
Invites,
|
||||
JarScanResult,
|
||||
OrganizationRoleTable,
|
||||
PaginatedResultHangarLoggedAction,
|
||||
PaginatedResultHangarNotification,
|
||||
PaginatedResultHangarProjectFlag,
|
||||
PaginatedResultProject,
|
||||
PaginatedResultProjectCompact,
|
||||
PaginatedResultUser,
|
||||
PaginatedResultVersion,
|
||||
ProjectCompact,
|
||||
ProjectOwner,
|
||||
ReviewQueue,
|
||||
SettingsResponse,
|
||||
User,
|
||||
VersionInfo,
|
||||
Platform } from "~/types/backend";
|
||||
|
||||
export function useOrganizationVisibility(user: () => string) {
|
||||
const { data: organizationVisibility, status: organizationVisibilityStatus } = useData(
|
||||
|
@ -30,6 +30,7 @@ export function useDataLoader<K extends keyof DataLoaderTypes>(key: K) {
|
||||
return newParam;
|
||||
} else if (newParam) {
|
||||
promises.push(
|
||||
// eslint-disable-next-line no-async-promise-executor
|
||||
new Promise<void>(async (resolve, reject) => {
|
||||
console.log("load loading", key);
|
||||
const result = await loader(newParam).catch(reject);
|
||||
@ -95,10 +96,11 @@ export function useData<T, P extends Record<string, unknown> | string>(
|
||||
status.value = "idle";
|
||||
return undefined;
|
||||
}
|
||||
// eslint-disable-next-line no-async-promise-executor
|
||||
return new Promise<void>(async (resolve, reject) => {
|
||||
console.log("load", key(params));
|
||||
const result = await loader(params).catch(reject);
|
||||
//await new Promise((resolve) => setTimeout(resolve, 5000));
|
||||
// await new Promise((resolve) => setTimeout(resolve, 5000));
|
||||
console.log("loaded", key(params));
|
||||
if (result) {
|
||||
setState(result);
|
||||
@ -176,7 +178,7 @@ function checkEqual(a: Record<string, unknown> | string, b: Record<string, unkno
|
||||
return false;
|
||||
}
|
||||
|
||||
for (let key of keys1) {
|
||||
for (const key of keys1) {
|
||||
if (a[key] !== b[key]) {
|
||||
if (typeof a[key] === "object" && typeof b[key] === "object") {
|
||||
if (!checkEqual(a[key] as Record<string, unknown>, b[key] as Record<string, unknown>)) {
|
||||
|
@ -1,9 +1,9 @@
|
||||
import type { AxiosError } from "axios";
|
||||
import { isAxiosError } from "axios";
|
||||
import type { Composer } from "vue-i18n";
|
||||
import type { HangarApiException, HangarValidationException, MultiHangarApiException } from "~/types/backend";
|
||||
import { tryUseNuxtApp } from "#app/nuxt";
|
||||
import { type H3Error, isError as isH3Error } from "h3";
|
||||
import type { HangarApiException, HangarValidationException, MultiHangarApiException } from "~/types/backend";
|
||||
|
||||
export function handleRequestError(err: AxiosError | unknown, msg: string | undefined = undefined, alwaysShowErrorPage = false) {
|
||||
const i18n = tryUseNuxtApp()?.$i18n;
|
||||
|
@ -1,5 +1,5 @@
|
||||
import type { HangarProject } from "~/types/backend";
|
||||
import type { RouteLocationTyped, RouteMapGeneric } from "vue-router";
|
||||
import type { HangarProject } from "~/types/backend";
|
||||
|
||||
export function useOpenProjectPages(route: RouteLocationTyped<RouteMapGeneric, "user-project-pages-page">, project?: HangarProject) {
|
||||
const open = ref<string[]>([]);
|
||||
|
@ -1,6 +1,6 @@
|
||||
import type { ExtendedProjectPage, HangarProject } from "~/types/backend";
|
||||
import type { Router } from "vue-router";
|
||||
import type { RouteLocationNormalized } from "vue-router/auto";
|
||||
import type { ExtendedProjectPage, HangarProject } from "~/types/backend";
|
||||
|
||||
export function useProjectPage(route: RouteLocationNormalized<"user-project-pages-page">, router: Router, project?: HangarProject, page?: ExtendedProjectPage) {
|
||||
const editingPage = ref<boolean>(false);
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { isAxiosError } from "axios";
|
||||
import type { ExtendedProjectPage, HangarOrganization, HangarProject, HangarVersion, User } from "~/types/backend";
|
||||
import { useDataLoader } from "~/composables/useDataLoader";
|
||||
import { isAxiosError } from "axios";
|
||||
|
||||
// this middleware takes care of fetching the "important" data for pages, like user/project/org/version/page, based on route params
|
||||
// it also handles 404s and redirects to the proper casing
|
||||
@ -18,21 +18,21 @@ export default defineNuxtRouteMiddleware(async (to, from) => {
|
||||
|
||||
const promises: Promise<any>[] = [];
|
||||
|
||||
const { loader: userLoader, data: user } = useDataLoader<User>("user");
|
||||
const userName = userLoader("user", to, from, async (userName) => useApi<User>("users/" + userName), promises);
|
||||
const { loader: userLoader, data: user } = useDataLoader("user");
|
||||
const userName = userLoader("user", to, from, (userName) => useApi<User>("users/" + userName), promises);
|
||||
|
||||
const { loader: projectLoader, data: project } = useDataLoader<HangarProject>("project");
|
||||
const projectName = projectLoader("project", to, from, async (projectName) => useInternalApi<HangarProject>("projects/project/" + projectName), promises);
|
||||
const { loader: projectLoader, data: project } = useDataLoader("project");
|
||||
const projectName = projectLoader("project", to, from, (projectName) => useInternalApi<HangarProject>("projects/project/" + projectName), promises);
|
||||
|
||||
const { loader: organizationLoader } = useDataLoader<HangarOrganization>("organization");
|
||||
organizationLoader("user", to, from, async (organizationName) => useInternalApi<HangarOrganization>("organizations/org/" + organizationName), promises);
|
||||
const { loader: organizationLoader } = useDataLoader("organization");
|
||||
organizationLoader("user", to, from, (organizationName) => useInternalApi<HangarOrganization>("organizations/org/" + organizationName), promises);
|
||||
|
||||
const { loader: versionLoader, data: version } = useDataLoader<HangarVersion>("version");
|
||||
const { loader: versionLoader, data: version } = useDataLoader("version");
|
||||
const versionName = versionLoader(
|
||||
"version",
|
||||
to,
|
||||
from,
|
||||
async (versionName) => {
|
||||
(versionName) => {
|
||||
if ("project" in to.params) {
|
||||
return useInternalApi<HangarVersion>(`versions/version/${to.params.project}/versions/${versionName}`);
|
||||
}
|
||||
@ -41,12 +41,12 @@ export default defineNuxtRouteMiddleware(async (to, from) => {
|
||||
promises
|
||||
);
|
||||
|
||||
const { loader: pageLoader, data: page } = useDataLoader<ExtendedProjectPage>("page");
|
||||
const { loader: pageLoader, data: page } = useDataLoader("page");
|
||||
const pageName = pageLoader(
|
||||
"page",
|
||||
to,
|
||||
from,
|
||||
async (pagePath) => {
|
||||
(pagePath) => {
|
||||
if ("project" in to.params) {
|
||||
return useInternalApi<ExtendedProjectPage>(`pages/page/${to.params.project}/` + pagePath.toString().replaceAll(",", "/"));
|
||||
}
|
||||
@ -90,7 +90,7 @@ export default defineNuxtRouteMiddleware(async (to, from) => {
|
||||
newPath = newPath.replace(pageSlug, page.value.slug);
|
||||
}
|
||||
}
|
||||
if (newPath != to.fullPath) {
|
||||
if (newPath !== to.fullPath) {
|
||||
console.log("Redirect to " + newPath + " from (" + to.fullPath + ")");
|
||||
return navigateTo(newPath, { redirectCode: 301 });
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { promises as fs } from "fs";
|
||||
import { defineNuxtModule } from "@nuxt/kit";
|
||||
import type { AxiosInstance } from "axios";
|
||||
import { type AxiosInstance, isAxiosError } from "axios";
|
||||
import axios from "axios";
|
||||
// noinspection ES6PreferShortImport
|
||||
import { backendDataLog } from "../composables/useLog";
|
||||
@ -61,7 +61,7 @@ async function generateBackendData(state: ServerBackendData, path: string, retry
|
||||
|
||||
backendDataLog("Backend data generated!");
|
||||
} catch (err) {
|
||||
if (axios.isAxiosError(err)) {
|
||||
if (isAxiosError(err)) {
|
||||
const transformedError = {
|
||||
code: err?.code,
|
||||
requestUrl: err?.request?.path,
|
||||
@ -118,7 +118,7 @@ function prepareAxios(serverUrl: string): AxiosInstance {
|
||||
baseURL: serverUrl + "/api/internal/data",
|
||||
});
|
||||
axiosInstance.interceptors.response.use(undefined, (err) => {
|
||||
if (axios.isAxiosError(err)) {
|
||||
if (isAxiosError(err)) {
|
||||
if (err.response?.status === 404) {
|
||||
backendDataLog("Couldn't load " + err.request?.path + ", skipping");
|
||||
return null;
|
||||
|
@ -20,6 +20,7 @@ provide("updateProjectPages", function (pages: HangarProjectPage[]) {
|
||||
<template>
|
||||
<ProjectHeader :project="project" />
|
||||
<ProjectNav :project="project" />
|
||||
<!-- eslint-disable-next-line vue/no-multiple-template-root ?????? -->
|
||||
<router-view v-slot="{ Component }">
|
||||
<Suspense>
|
||||
<div>
|
||||
|
@ -1,6 +1,7 @@
|
||||
<script lang="ts" setup>
|
||||
import { upperFirst } from "scule";
|
||||
import { type HangarProject, NamedPermission, type PinnedVersion, Platform, type User } from "~/types/backend";
|
||||
import { NamedPermission } from "~/types/backend";
|
||||
import type { HangarProject, PinnedVersion, User , Platform } from "~/types/backend";
|
||||
|
||||
const props = defineProps<{
|
||||
user?: User;
|
||||
|
@ -4,16 +4,8 @@ import { useVuelidate } from "@vuelidate/core";
|
||||
import { Cropper, type CropperResult } from "vue-advanced-cropper";
|
||||
import type { Tab } from "~/types/components/design/Tabs";
|
||||
import InputText from "~/components/ui/InputText.vue";
|
||||
import {
|
||||
Category,
|
||||
type HangarProject,
|
||||
type HangarUser,
|
||||
NamedPermission,
|
||||
type PaginatedResultUser,
|
||||
type ProjectSettings,
|
||||
Tag,
|
||||
Visibility,
|
||||
} from "~/types/backend";
|
||||
import { NamedPermission, Tag, Visibility } from "~/types/backend";
|
||||
import type { HangarProject, HangarUser, PaginatedResultUser, ProjectSettings , Category } from "~/types/backend";
|
||||
|
||||
import "vue-advanced-cropper/dist/style.css";
|
||||
|
||||
|
@ -102,6 +102,8 @@ async function savePage(content: string) {
|
||||
await useInternalApi(`versions/version/${props.project?.id}/${props.version.id}/saveDescription`, "post", {
|
||||
content,
|
||||
});
|
||||
// this is fine (tm)
|
||||
// eslint-disable-next-line vue/no-mutating-props
|
||||
props.version.description = content;
|
||||
editingPage.value = false;
|
||||
} catch (err) {
|
||||
|
@ -15,7 +15,7 @@ const route = useRoute("user-project-versions-version-scan");
|
||||
|
||||
const { jarScans } = useJarScans(() => props.version?.id as unknown as string);
|
||||
|
||||
async function scan() {
|
||||
async function doScan() {
|
||||
for (const platform of props.versionPlatforms) {
|
||||
if (!props.version?.downloads?.[platform]?.fileInfo) {
|
||||
continue;
|
||||
@ -41,6 +41,6 @@ useHead(useSeo("Scan | " + props.project?.name, props.project?.description, rout
|
||||
<hr class="my-1" />
|
||||
</div>
|
||||
</div>
|
||||
<Button @click="scan">Scan</Button>
|
||||
<Button @click="doScan">Scan</Button>
|
||||
</div>
|
||||
</template>
|
||||
|
@ -124,12 +124,13 @@ useHead(
|
||||
|
||||
<template>
|
||||
<UserHeader :viewing-user="user" :organization="organization" />
|
||||
<div class="flex-basis-full flex flex-col gap-2 flex-grow lg:max-w-7/10 lg:min-w-6/10" v-if="pinned">
|
||||
<div v-if="pinned" class="flex-basis-full flex flex-col gap-2 flex-grow lg:max-w-7/10 lg:min-w-6/10">
|
||||
<div v-for="project in pinned" :key="project.namespace.slug">
|
||||
<ProjectCard :project="project" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- eslint-disable-next-line vue/no-multiple-template-root -->
|
||||
<div class="flex gap-4 flex-basis-full flex-col lg:flex-row">
|
||||
<div class="flex-basis-full flex flex-col gap-2 flex-grow lg:max-w-7/10 lg:min-w-6/10">
|
||||
<div class="flex gap-2">
|
||||
|
@ -58,7 +58,7 @@ const requestParams = computed(() => {
|
||||
});
|
||||
const { actionLogs } = useActionLogs(() => requestParams.value, router);
|
||||
|
||||
async function updateSort(col: string, sorter: Record<string, number>) {
|
||||
function updateSort(col: string, sorter: Record<string, number>) {
|
||||
sort.value = [...Object.keys(sorter)]
|
||||
.map((k) => {
|
||||
const val = sorter[k];
|
||||
|
@ -32,7 +32,7 @@ const requestParams = computed(() => {
|
||||
});
|
||||
const { users } = useUsers(() => requestParams.value);
|
||||
|
||||
async function updateSort(col: string, sorter: Record<string, number>) {
|
||||
function updateSort(col: string, sorter: Record<string, number>) {
|
||||
sort.value = [...Object.keys(sorter)]
|
||||
.map((k) => {
|
||||
const val = sorter[k];
|
||||
|
@ -25,7 +25,7 @@ const requestParams = computed(() => {
|
||||
});
|
||||
const { authors } = useAuthors(() => requestParams.value);
|
||||
|
||||
async function updateSort(col: string, sorter: Record<string, number>) {
|
||||
function updateSort(col: string, sorter: Record<string, number>) {
|
||||
sort.value = [...Object.keys(sorter)]
|
||||
.map((k) => {
|
||||
const val = sorter[k];
|
||||
|
@ -26,7 +26,7 @@ const requestParams = computed(() => {
|
||||
|
||||
const { staff } = useStaff(() => requestParams.value);
|
||||
|
||||
async function updateSort(col: string, sorter: Record<string, number>) {
|
||||
function updateSort(col: string, sorter: Record<string, number>) {
|
||||
sort.value = [...Object.keys(sorter)]
|
||||
.map((k) => {
|
||||
const val = sorter[k];
|
||||
|
@ -9,7 +9,6 @@ export default defineNitroPlugin((nitroApp) => {
|
||||
|
||||
if (!sentry.dsn) {
|
||||
console.warn("Sentry DSN not set, skipping Sentry initialization");
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO make this work with bun
|
||||
|
Loading…
Reference in New Issue
Block a user