chore: update

This commit is contained in:
Anthony Fu 2021-08-20 12:58:29 +08:00
parent cddf30638a
commit 4c22495ea6
3 changed files with 22 additions and 16 deletions

View File

@ -1,8 +1,10 @@
import { createI18n } from 'vue-i18n' import { createI18n } from 'vue-i18n'
import { UserModule } from '~/types' import { UserModule } from '~/types'
// import i18n resources // Import i18n resources
// https://vitejs.dev/guide/features.html#glob-import // https://vitejs.dev/guide/features.html#glob-import
//
// Don't need this? Try vitesse-lite: https://github.com/antfu/vitesse-lite
const messages = Object.fromEntries( const messages = Object.fromEntries(
Object.entries( Object.entries(
import.meta.globEager('../../locales/*.y(a)?ml')) import.meta.globEager('../../locales/*.y(a)?ml'))

View File

@ -1,6 +1,8 @@
import { createPinia } from 'pinia' import { createPinia } from 'pinia'
import { UserModule } from '~/types' import { UserModule } from '~/types'
// Setup Pinia
// https://pinia.esm.dev/
export const install: UserModule = ({ isClient, initialState, app }) => { export const install: UserModule = ({ isClient, initialState, app }) => {
const pinia = createPinia() const pinia = createPinia()
app.use(pinia) app.use(pinia)

View File

@ -8,10 +8,9 @@ const router = useRouter()
const { t } = useI18n() const { t } = useI18n()
const user = useUserStore() const user = useUserStore()
watch(() => props.name, (name) => { watchEffect(() => {
user.setNewName(name) user.setNewName(props.name)
}, { immediate: true }) })
</script> </script>
<template> <template>
@ -22,24 +21,27 @@ watch(() => props.name, (name) => {
<p> <p>
{{ t('intro.hi', { name: props.name }) }} {{ t('intro.hi', { name: props.name }) }}
</p> </p>
<template v-if="user.otherNames.length">
<p class="text-sm">
{{ t('intro.aka') }}:
<ul>
<li v-for="name in user.otherNames">
{{ name }}
</li>
</ul>
</p>
</template>
<p class="text-sm opacity-50"> <p class="text-sm opacity-50">
<em>{{ t('intro.dynamic-route') }}</em> <em>{{ t('intro.dynamic-route') }}</em>
</p> </p>
<template v-if="user.otherNames.length">
<p class="text-sm mt-4">
<span class="opacity-75">{{ t('intro.aka') }}:</span>
<ul>
<li v-for="name in user.otherNames" :key="name">
<router-link :to="`/hi/${name}`" replace>
{{ name }}
</router-link>
</li>
</ul>
</p>
</template>
<div> <div>
<button <button
class="btn m-3 text-sm mt-8" class="btn m-3 text-sm mt-6"
@click="router.back()" @click="router.back()"
> >
{{ t('button.back') }} {{ t('button.back') }}