Skip to content

Commit

Permalink
feat: most practices
Browse files Browse the repository at this point in the history
  • Loading branch information
Baiqiang committed Oct 10, 2024
1 parent c4ddd8f commit abca9dc
Show file tree
Hide file tree
Showing 8 changed files with 3,549 additions and 1,666 deletions.
3 changes: 3 additions & 0 deletions components/app/header.vue
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@ async function changeLocale(code: string) {
<NuxtLink :to="`/profile/${user.wcaId || user.id}`" :class="menuClass">
{{ $t('user.solutions') }}
</NuxtLink>
<NuxtLink :to="`/practice/${user.wcaId || user.id}`" :class="menuClass">
{{ $t('user.practices') }}
</NuxtLink>
<NuxtLink to="/user/likes" :class="menuClass">
{{ $t('user.likes') }}
</NuxtLink>
Expand Down
2 changes: 2 additions & 0 deletions messages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ export default {
avatar: 'Avatar',
changeName: 'Change Name',
solutions: 'My Solutions',
practices: 'My Practices',
},
admin: {
title: 'Admin',
Expand Down Expand Up @@ -404,6 +405,7 @@ export default {
},
latest: 'Latest Practice',
mostAttended: 'Most Attended',
mostPractices: 'Most Practices',
index: 'Practice #{index}',
previous: 'Previous',
next: 'Next',
Expand Down
2 changes: 2 additions & 0 deletions messages/zh-CN.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ export default {
avatar: '头像',
changeName: '修改名称',
solutions: '我的解法',
practices: '我的练习',
},
admin: {
title: '管理',
Expand Down Expand Up @@ -404,6 +405,7 @@ export default {
},
latest: '最新练习',
mostAttended: '最多参加',
mostPractices: '最多练习',
index: '练习 {index}',
previous: '上一个',
next: '下一个',
Expand Down
52 changes: 26 additions & 26 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,37 +13,37 @@
},
"dependencies": {
"insertionfinder": "^0.5.0",
"tailwind-merge": "^2.4.0",
"three": "^0.162.0",
"two.js": "^0.8.13",
"vue": "^3.4.21",
"vue-router": "^4.3.0"
"tailwind-merge": "^2.5.3",
"three": "^0.169.0",
"two.js": "^0.8.14",
"vue": "^3.5.11",
"vue-router": "^4.4.5"
},
"devDependencies": {
"@antfu/eslint-config": "^2.8.1",
"@freeloop/nuxt-transitions": "^0.1.7",
"@antfu/eslint-config": "^3.7.3",
"@freeloop/nuxt-transitions": "^0.1.8",
"@nuxt/devtools": "latest",
"@nuxtjs/eslint-config-typescript": "^12.1.0",
"@nuxtjs/eslint-module": "^4.1.0",
"@nuxtjs/google-fonts": "^3.1.3",
"@nuxtjs/i18n": "^8.1.1",
"@nuxtjs/tailwindcss": "^6.11.4",
"@pinia-plugin-persistedstate/nuxt": "^1.2.0",
"@pinia/nuxt": "^0.5.1",
"@tailwindcss/forms": "^0.5.7",
"@types/three": "^0.162.0",
"@vite-pwa/assets-generator": "^0.2.4",
"@vite-pwa/nuxt": "^0.6.0",
"@vueuse/core": "^10.9.0",
"@vueuse/nuxt": "^10.9.0",
"dayjs-nuxt": "^2.1.9",
"eslint": "^8.57.0",
"@nuxtjs/google-fonts": "^3.2.0",
"@nuxtjs/i18n": "^8.5.5",
"@nuxtjs/tailwindcss": "^6.12.1",
"@pinia-plugin-persistedstate/nuxt": "^1.2.1",
"@pinia/nuxt": "^0.5.5",
"@tailwindcss/forms": "^0.5.9",
"@types/three": "^0.169.0",
"@vite-pwa/assets-generator": "^0.2.6",
"@vite-pwa/nuxt": "^0.10.5",
"@vueuse/core": "^11.1.0",
"@vueuse/nuxt": "^11.1.0",
"dayjs-nuxt": "^2.1.11",
"eslint": "^9.12.0",
"less": "^4.2.0",
"nuxt": "^3.10.3",
"nuxt-gtag": "^2.0.5",
"nuxt-icon": "^0.6.9",
"pinia": "^2.1.7",
"postcss-html": "^1.6.0",
"typescript": "^5.4.2"
"nuxt": "^3.13.2",
"nuxt-gtag": "^3.0.1",
"nuxt-icon": "^0.6.10",
"pinia": "^2.2.4",
"postcss-html": "^1.7.0",
"typescript": "^5.6.3"
}
}
18 changes: 18 additions & 0 deletions pages/practice/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
const { data } = await useApi<{
latest: Practice[]
mostAttended: Practice[]
mostPractices: User[]
}>('/practice')
const latest = ref(data.value?.latest || [])
const mostAttended = ref(data.value?.mostAttended || [])
const mostPractices = ref(data.value?.mostPractices || [])
const { t } = useI18n()
useSeoMeta({
title: t('practice.title'),
Expand Down Expand Up @@ -42,6 +44,22 @@ useSeoMeta({
/>
</div>
</div>
<div class="col-span-12 md:col-span-6 lg:col-span-4">
<h2 class="my-2 font-bold text-lg">
{{ $t('practice.mostPractices') }}
</h2>
<div>
<NuxtLink
v-for="user in mostPractices"
:key="user.id"
class="flex items-center gap-2 text-blue-500"
:to="`/practice/${user.wcaId || user.id}`"
>
<UserAvatarName :user="user" :link="false" />
{{ user.practices }}
</NuxtLink>
</div>
</div>
</div>
</div>
</template>
1 change: 0 additions & 1 deletion pages/practice/new.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ const { t } = useI18n()
useSeoMeta({
title: t('practice.new.title'),
})
const user = useUser()
const router = useRouter()
const form = useNewPracticeForm()
const localForm = useLocalStorage('practice.new', form.$state)
Expand Down
1 change: 1 addition & 0 deletions utils/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export interface User {
avatar: string
avatarThumb: string
roles: Role[]
practices: number
}

export interface AdminUser extends User {
Expand Down
Loading

0 comments on commit abca9dc

Please sign in to comment.