Fix: 优化代码结构

This commit is contained in:
2025-07-16 14:48:09 +08:00
parent 9d57758154
commit ccaa10f25b
3 changed files with 45 additions and 30 deletions

33
src/config/navigation.ts Normal file
View File

@ -0,0 +1,33 @@
export interface NavigationItem {
title: string
to: string
icon?: string
component?: string
}
export const navigationConfig: NavigationItem[] = [
{
title: 'paperTubeWeightCalculate',
to: '/calculators/paper-tube-weight',
},
{
title: 'beltSpecificationCalculate',
to: '/calculators/belt-specification',
},
{
title: 'paperRollWeightLengthCalculate',
to: '/calculators/paper-roll-weight-length',
},
{
title: 'paperTubeProductionCalculate',
to: '/calculators/paper-tube-production',
},
{
title: 'paperTapeWidthAngleCalculate',
to: '/calculators/paper-tape-width-angle',
},
{
title: 'multiLayerPaperTapeWidthAngleCalculate',
to: '/calculators/multi-layer-paper-tape-width-angle',
},
]

View File

@ -133,9 +133,11 @@
class="pa-6" class="pa-6"
fluid fluid
/> />
<v-fade-transition mode="hide-on-leave"> <router-view v-slot="{ Component }">
<router-view /> <v-fade-transition hide-on-leave>
</v-fade-transition> <component :is="Component" />
</v-fade-transition>
</router-view>
</v-main> </v-main>
<!-- 页脚 --> <!-- 页脚 -->
@ -156,6 +158,7 @@
<script lang="ts" setup> <script lang="ts" setup>
import { computed, onMounted, onUnmounted, ref } from 'vue' import { computed, onMounted, onUnmounted, ref } from 'vue'
import { useI18n } from 'vue-i18n' import { useI18n } from 'vue-i18n'
import { navigationConfig } from '@/config/navigation'
const { t, locale } = useI18n() const { t, locale } = useI18n()
@ -244,32 +247,12 @@
}) })
const menuItems = computed(() => { const menuItems = computed(() => {
return [ return navigationConfig.map((item, _) => {
{ return {
title: t('paperTubeWeightCalculate'), title: t(item.title),
to: '/calculators/paper-tube-weight', to: item.to,
}, }
{ })
title: t('beltSpecificationCalculate'),
to: '/calculators/belt-specification',
},
{
title: t('paperRollWeightLengthCalculate'),
to: '/calculators/paper-roll-weight-length',
},
{
title: t('paperTubeProductionCalculate'),
to: '/calculators/paper-tube-production',
},
{
title: t('paperTapeWidthAngleCalculate'),
to: '/calculators/paper-tape-width-angle',
},
{
title: t('multiLayerPaperTapeWidthAngleCalculate'),
to: '/calculators/multi-layer-paper-tape-width-angle',
},
]
}) })
function toggleLanguage () { function toggleLanguage () {

View File

@ -3,7 +3,6 @@
<router-view /> <router-view />
</v-main> </v-main>
<AppFooter />
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>