mirror of
https://github.com/HangarMC/Hangar.git
synced 2025-03-07 15:31:00 +08:00
scroll back to the top of projects on the home page when page changes
This commit is contained in:
parent
8038179907
commit
adff558eac
@ -25,7 +25,7 @@ public class FakeDataController {
|
||||
}
|
||||
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
@GetMapping("/")
|
||||
@GetMapping
|
||||
@PermissionRequired(NamedPermission.MANUAL_VALUE_CHANGES)
|
||||
public void generateFakeData(@RequestParam final int users, @RequestParam final int projectsPerUser) {
|
||||
this.fakeDataService.generate(users, projectsPerUser);
|
||||
|
@ -1,6 +1,7 @@
|
||||
package io.papermc.hangar.service.internal;
|
||||
|
||||
import io.papermc.hangar.HangarComponent;
|
||||
import io.papermc.hangar.config.CacheConfig;
|
||||
import io.papermc.hangar.db.dao.internal.table.UserDAO;
|
||||
import io.papermc.hangar.db.dao.internal.table.projects.ProjectsDAO;
|
||||
import io.papermc.hangar.model.api.project.ProjectDonationSettings;
|
||||
@ -26,6 +27,7 @@ import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import net.datafaker.Faker;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@ -50,6 +52,7 @@ public class FakeDataService extends HangarComponent {
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@CacheEvict(cacheNames = CacheConfig.PROJECTS, allEntries = true)
|
||||
public void generate(final int users, final int projectsPerUser) {
|
||||
final HangarAuthenticationToken oldAuth = (HangarAuthenticationToken) SecurityContextHolder.getContext().getAuthentication();
|
||||
try {
|
||||
|
@ -4,6 +4,7 @@ import IconsResolver from "unplugin-icons/resolver";
|
||||
import Icons from "unplugin-icons/vite";
|
||||
import Components from "unplugin-vue-components/vite";
|
||||
import { ProxyOptions } from "@nuxt-alt/proxy";
|
||||
import { defineNuxtConfig } from "nuxt/config";
|
||||
import prettier from "./src/lib/plugins/prettier";
|
||||
import unocss from "./src/lib/config/unocss.config";
|
||||
|
||||
@ -32,7 +33,7 @@ export default defineNuxtConfig({
|
||||
"@pinia/nuxt",
|
||||
"@nuxt-alt/proxy",
|
||||
"unplugin-icons/nuxt",
|
||||
"@unlighthouse/nuxt",
|
||||
// "@unlighthouse/nuxt",
|
||||
[
|
||||
"./src/module/backendData",
|
||||
{
|
||||
|
@ -8,6 +8,7 @@ const i18n = useI18n();
|
||||
|
||||
defineProps<{
|
||||
projects: PaginatedResult<Project>;
|
||||
resetAnchor?: Element;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
@ -19,7 +20,7 @@ function updatePage(newPage: number) {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Pagination v-if="projects?.result" :items="projects.result" :server-pagination="projects.pagination" @update:page="updatePage">
|
||||
<Pagination v-if="projects?.result" :items="projects.result" :server-pagination="projects.pagination" :reset-anchor="resetAnchor" @update:page="updatePage">
|
||||
<template #default="{ item }">
|
||||
<ProjectCard :project="item" />
|
||||
</template>
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit b1fa62478f6bbe642691ce5e63eccc46dcb55fed
|
||||
Subproject commit 40934b519e888430c310de214548e27a67d13966
|
@ -1,7 +1,7 @@
|
||||
<script setup lang="ts">
|
||||
import { Menu, MenuButton, MenuItem, MenuItems } from "@headlessui/vue";
|
||||
import { useI18n } from "vue-i18n";
|
||||
import { computed, isRef, ref, watch } from "vue";
|
||||
import { computed, isRef, Ref, ref, watch } from "vue";
|
||||
import { useHead } from "@vueuse/head";
|
||||
import { useRoute, useRouter } from "vue-router";
|
||||
import { PaginatedResult, Project } from "hangar-api";
|
||||
@ -143,6 +143,9 @@ if (isRef(meta.script)) {
|
||||
meta.script = (meta.script || []) as [];
|
||||
meta.script.push(script);
|
||||
}
|
||||
|
||||
const pageChangeScrollAnchor: Ref<Element | null> = ref(null);
|
||||
|
||||
useHead(meta);
|
||||
</script>
|
||||
|
||||
@ -150,7 +153,7 @@ useHead(meta);
|
||||
<div>
|
||||
<Container class="flex flex-col items-center gap-4">
|
||||
<Alert v-if="loggedOut" type="success">{{ i18n.t("hangar.loggedOut") }}</Alert>
|
||||
<h1 class="text-3xl font-bold uppercase text-center mt-4">{{ i18n.t("hangar.projectSearch.title") }}</h1>
|
||||
<h1 ref="pageChangeScrollAnchor" class="text-3xl font-bold uppercase text-center mt-4">{{ i18n.t("hangar.projectSearch.title") }}</h1>
|
||||
<h2 class="text-1xl text-center mb-2">{{ i18n.t("hangar.projectSearch.subTitle") }}</h2>
|
||||
<!-- Search Bar -->
|
||||
<div class="relative rounded-md flex shadow-md w-full max-w-screen-md">
|
||||
@ -207,7 +210,7 @@ useHead(meta);
|
||||
<Container lg="flex items-start gap-6">
|
||||
<!-- Projects -->
|
||||
<div v-if="projects" class="w-full min-w-0 mb-5 flex flex-col gap-2 lg:mb-0">
|
||||
<ProjectList :projects="projects" @update:page="(newPage) => (page = newPage)" />
|
||||
<ProjectList :projects="projects" :reset-anchor="pageChangeScrollAnchor" @update:page="(newPage) => (page = newPage)" />
|
||||
</div>
|
||||
<!-- Sidebar -->
|
||||
<Card accent class="min-w-300px flex flex-col gap-4">
|
||||
|
Loading…
Reference in New Issue
Block a user