Skip to content

Commit

Permalink
Merge branch 'ppy-sb:develop' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
miwate authored Mar 6, 2024
2 parents a77210f + d349d28 commit 1dd3bf5
Show file tree
Hide file tree
Showing 19 changed files with 2,516 additions and 2,188 deletions.
4,438 changes: 2,361 additions & 2,077 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

7 changes: 1 addition & 6 deletions src/app.vue
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
<script lang="ts" setup>
const safari = shallowRef(false)
const scrollY = useScrollYObserver()
const { status } = useZoomModal()
onBeforeMount(() => {
safari.value = useSafariDetector()
})
</script>

<template>
Expand All @@ -17,7 +12,7 @@ onBeforeMount(() => {
<NuxtLayout
id="layout"
viewport
:class="[safari ? 'safari' : 'not-safari']"
:class="safariDetector() ? 'safari' : 'not-safari'"
class="drawer-content zoom-modal-container overflow-x-clip"
:data-l1-status="status"
data-l2-status="hidden"
Expand Down
5 changes: 3 additions & 2 deletions src/components/app/nav/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { useSession } from '~/store/session'
const scrollY = useScrollYObserver()
const { t } = useI18n()
const session = useSession()
const route = useRoute()
const searchModalWrapper = shallowRef<{
searchModal: {
Expand Down Expand Up @@ -135,15 +136,15 @@ function clearFocus() {
</li>
<div class="divider my-0" />
<li>
<nuxt-link-locale :to="{ name: 'auth-logout' }" @click="clearFocus">
<nuxt-link-locale :to="{ name: 'auth-logout', query: { redirect: route.fullPath } }" @click="clearFocus">
<icon name="majesticons:logout-half-circle-line" class="w-5 h-5" size="100%" />
{{ $t('global.logout') }}
</nuxt-link-locale>
</li>
</template>
<template v-else>
<li>
<nuxt-link-locale :to="{ name: 'auth-login' }" @click="clearFocus">
<nuxt-link-locale :to="{ name: 'auth-login', query: { redirect: route.fullPath } }" @click="clearFocus">
<icon name="majesticons:login-half-circle-line" class="w-5 h-5" size="100%" />
{{ $t('global.login') }}
</nuxt-link-locale>
Expand Down
2 changes: 1 addition & 1 deletion src/components/app/search-modal.client.vue
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ const {
:key="`searchResult-page-${index}`"
>
<nuxt-link-locale
:to="(page.route as typeof page.route | undefined)"
:to="(page.route() as typeof page.route | undefined)"
@click="closeModal()"
>
<div class="flex items-center gap-2">
Expand Down
16 changes: 12 additions & 4 deletions src/components/userpage/heading.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { useSession } from '~/store/session'
import userpageStore from '~/store/userpage'
const page = userpageStore()
const route = useRoute()
const { t, locale } = useI18n()
const app$ = useNuxtApp()
const session = useSession()
Expand Down Expand Up @@ -38,9 +39,6 @@ const { data: live, refresh: reloadLiveData } = useAsyncData(async () =>
? await app$.$client.user.status.query({ id: page.user.id })
: null,
)
onMounted(() => {
onBeforeUnmount(() => clearInterval(setInterval(reloadLiveData, 5000)))
})
const isMutualFriend = computed(
() => data.value?.relationWithMe?.mutual?.includes(MutualRelationship.MutualFriend) || false,
)
Expand All @@ -55,10 +53,20 @@ const friendButtonContent = computed(
() => data.value?.friendCount || t('add-as-friend'),
)
const pendingRelation = ref(false)
onMounted(() => {
onBeforeUnmount(() => clearInterval(setInterval(reloadLiveData, 5000)))
})
async function toggleFriend() {
pendingRelation.value = true
if (!session.loggedIn) {
return
return navigateTo({
name: 'auth-login',
query: {
redirect: route.fullPath,
},
})
}
if (!page.user) {
return
Expand Down
3 changes: 2 additions & 1 deletion src/components/userpage/score-rank-composition.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ function createStyleObject(count: number) {
</script>

<template>
<VDropdown v-if="composition" :triggers="['hover', 'focus', 'click']">
<!-- https://github.com/Akryum/floating-vue/issues/1006#issuecomment-1882647191 -->
<VDropdown v-if="composition" :triggers="['hover', 'focus', 'click']" aria-id="score-composition">
<div v-if="totalCount" class="relative">
<div class="multi-progress-bar-container bg-emerald-200">
<div
Expand Down
30 changes: 17 additions & 13 deletions src/composables/useSearchablePages.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function admin() {

export const pages: {
render: () => JSX.Element
route: RouteLocationRaw
route: (() => RouteLocationRaw)
keyword?: string[]
show?(keyword: string): boolean
}[] = [
Expand All @@ -33,9 +33,9 @@ export const pages: {
{useI18n({ useScope: 'global' }).t('global.login')}
</>
),
route: {
route: () => ({
name: 'auth-login',
},
}),
keyword: ['login', 'sign in'],
show: notLoggedIn,
},
Expand All @@ -46,9 +46,9 @@ export const pages: {
{useI18n({ useScope: 'global' }).t('global.register')}
</>
),
route: {
route: () => ({
name: 'auth-register',
},
}),
keyword: ['register', 'sign up'],
show: notLoggedIn,
},
Expand All @@ -64,9 +64,9 @@ export const pages: {
{useI18n({ useScope: 'global' }).t('titles.admin-panel')}
</>
),
route: {
route: () => ({
name: 'admin',
},
}),
keyword: ['settings', 'admin'],
show: admin,
},
Expand All @@ -85,9 +85,9 @@ export const pages: {
{useI18n({ useScope: 'global' }).t('titles.relations')}
</>
),
route: {
route: () => ({
name: 'me-relations',
},
}),
keyword: ['settings', 'friends', 'blocks', 'relationship', 'revoke'],
show: loggedIn,
},
Expand All @@ -98,9 +98,9 @@ export const pages: {
{useI18n({ useScope: 'global' }).t('titles.settings')}
</>
),
route: {
route: () => ({
name: 'me-settings',
},
}),
keyword: ['settings', 'preference', 'profile', 'edit', 'change'],
show: loggedIn,
},
Expand All @@ -115,9 +115,13 @@ export const pages: {
{useI18n({ useScope: 'global' }).t('global.logout')}
</>
),
route: {
route: () => ({
name: 'auth-logout',
},
query: {
redirect: useRoute().fullPath,
ignoreAction: '',
},
}),
keyword: ['logout', 'sign out'],
show: loggedIn,
},
Expand Down
4 changes: 0 additions & 4 deletions src/layouts/default.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
<script setup>
const fullYear = new Date().getFullYear()
</script>

<template>
<div class="flex flex-col">
<slot />
Expand Down
4 changes: 2 additions & 2 deletions src/pages/auth/logout.vue
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<script lang="ts" setup>
import { useSession } from '~/store/session'
const $router = useRouter()
const router = useRouter()
const session = useSession()
const { t } = useI18n()
onMounted(async () => {
await session.destroy()
setTimeout(() => $router.push('/'), 1000)
setTimeout(() => router.push(router.currentRoute.value.query.redirect?.toString() || '/'), 1000)
})
</script>

Expand Down
4 changes: 0 additions & 4 deletions src/pages/me/relations.vue
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,6 @@ fr-FR:
</template>
<span v-if="pendingUser.has(user.id)" class="loading loading-spinner loading-xs md:loading-md" />
</button>

<!-- <t-button class="btn-shadow" :loading="pendingUser.has(user.id)" variant="warning" size="xs" class="md:btn-sm" @click="toggleBlock(user)">
{{ pendingUser.has(user.id) ? '' : isBlocked(user) ? 'remove block' : 'regret' }}
</t-button> -->
</div>
</div>
</div>
Expand Down
109 changes: 71 additions & 38 deletions src/pages/user/[handle].vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<script setup async lang="ts">
import { useIntersectionObserver } from '@vueuse/core'
import { UserRole } from '~/def/user'
import userpageStore from '~/store/userpage'
import { useSession } from '~/store/session'
definePageMeta({
alias: [
Expand All @@ -15,6 +17,7 @@ const { t } = useI18n()
const page = userpageStore()
const h = useRequestURL()
await page.init()
const session = useSession()
const switcherState = computed(() => `${page.switcher.mode} - ${page.switcher.ruleset} - ${page.switcher.rankingSystem}`)
const userWithAppName = computed(() => `${page.user?.name} - ${app.$i18n.t('server.name')}`)
Expand Down Expand Up @@ -80,29 +83,39 @@ onMounted(() => {

<i18n lang="yaml">
en-GB:
error-occured: Oops...
error-occurred: Oops...
unknown-error: something went wrong.
back: bring me back
retry: try again
banned: This account has been restricted.
self-banned: Your account has been restricted. Visibility of your profile is limited to you and {server}'s staff.
mode-no-data: Player hasn't played this mode yet.

zh-CN:
error-occured: 抱歉
error-occurred: 抱歉
unknown-error: 出现了一些小问题。
back: 返回之前的页面
retry: 重新加载
banned: 该账号处于封禁状态。
self-banned: 你的账号处于封禁状态。你的个人资料只能由你和{server}的工作人员查看。
mode-no-data: Ta 还没有玩过这个模式。

fr-FR:
error-occured: Oups...
error-occurred: Oups...
unknown-error: Une erreur est survenue.
back: Revenir en arrière
retry: Réessayez
# TODO: translated by gpt.
banned: Ce compte a été restreint.
self-banned: Votre compte a été restreint. La visibilité de votre profil est limitée à vous-même et au personnel de {server}.
mode-no-data: Le joueur n'a pas encore joué à ce mode.
</i18n>

<template>
<section v-if="page.error" class="flex grow">
<div class="flex flex-col items-center justify-center gap-3 m-auto">
<h1 class="text-3xl">
{{ t('error-occured') }}
{{ t('error-occurred') }}
</h1>
<h2 v-if="page.error.message !== ''" class="text-2xl">
{{ page.error.message }}
Expand All @@ -122,50 +135,70 @@ fr-FR:
</section>

<div v-else-if="page.user" ref="handle" class="flex flex-col justify-stretch">
<div v-if="page.user.roles.includes(UserRole.Restricted)" class="container mx-auto custom-container">
<div role="alert" class="alert alert-error">
<svg xmlns="http://www.w3.org/2000/svg" class="stroke-current shrink-0 h-6 w-6" fill="none" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10 14l2-2m0 0l2-2m-2 2l-2-2m2 2l2 2m7-2a9 9 0 11-18 0 9 9 0 0118 0z" /></svg>
<span v-if="page.user.id === session.user?.id">{{ t('self-banned', { server: t('server.name') }) }}</span>
<span v-else>{{ t('banned') }}</span>
</div>
</div>
<userpage-heading id="heading" ref="heading" />
<userpage-profile />
<userpage-ranking-system-switcher class="z-10" />
<div class="container mx-auto custom-container">
<userpage-statistics id="statistics" ref="statistics" />
<userpage-score-rank-composition />
</div>
<div id="bestScores" ref="bestScores" class="container py-2 mx-auto custom-container">
<userpage-best-scores v-if="page.currentRankingSystem" />
</div>
<div id="topScores" ref="topScores" class="container py-4 mx-auto custom-container">
<userpage-top-scores v-if="page.currentRankingSystem" />
</div>
<client-only>
<teleport to="body">
<div class="sticky btm-nav fuck">
<template v-for="(isVisible, el) of visible" :key="el">
<a
v-if="icons[el]" :class="{
active: isVisible,
}" :href="`#${el}`"
>
<icon :name="icons[el]" size="2em" />
</a>
<a
v-else :class="{
active: isVisible,
}" :href="`#${el}`"
>
{{ el }}
</a>
</template>
<template v-if="page.currentStatistic?.level === 0">
<div class="container custom-container py-20 mx-auto">
<h1 class="text-center text-3xl text-gbase-400 dark:text-gbase-600">
{{ t('mode-no-data') }}
</h1>
</div>
</template>
<template v-else>
<userpage-ranking-system-switcher class="z-10" />
<div class="container mx-auto custom-container">
<userpage-statistics id="statistics" ref="statistics" />
<userpage-score-rank-composition />
</div>
<template v-if="page.currentRankingSystem">
<div id="bestScores" ref="bestScores" class="container py-2 mx-auto custom-container">
<userpage-best-scores />
</div>
<div id="topScores" ref="topScores" class="container py-4 mx-auto custom-container">
<userpage-top-scores />
</div>
</teleport>
</client-only>
</template>
<client-only>
<teleport to="body">
<div class="sticky btm-nav up-nav-item">
<template v-for="(isVisible, el) of visible" :key="el">
<a
v-if="icons[el]" :class="{
active: isVisible,
}" :href="`#${el}`"
>
<icon :name="icons[el]" size="2em" />
</a>
<a
v-else :class="{
active: isVisible,
}" :href="`#${el}`"
>
{{ el }}
</a>
</template>
</div>
</teleport>
</client-only>
</template>
</div>
</template>
<style lang="postcss" scoped>
.fuck {
.up-nav-item {
justify-content: center;
}
.fuck>* {
.up-nav-item>* {
@apply md:basis-32
}
</style>
1 change: 1 addition & 0 deletions src/server/backend/$base/server/session/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export abstract class SessionProvider<TSession extends Session<string>> {
...data,
lastSeen: new Date(),
} as TSession

await this.store.set(sessionId, _session)
return sessionId
}
Expand Down
Loading

0 comments on commit 1dd3bf5

Please sign in to comment.