@@ -10,7 +10,7 @@ import { ElIcon, ElMenu, ElMenuItem, ElMenuItemGroup, MenuItemRegistered } from
1010import { RouteLocationNormalizedLoaded , Router , useRoute , useRouter } from "vue-router"
1111import { I18nKey , t } from "@app/locale"
1212import { MenuMessage } from "@app/locale/components/menu"
13- import { GITHUB_ISSUE_ADD , HOME_PAGE , MEAT_URL , TU_CAO_PAGE } from "@util/constant/url"
13+ import { HOME_PAGE , MEAT_URL , TU_CAO_PAGE } from "@util/constant/url"
1414import { Aim , Calendar , ChatSquare , Folder , Food , HotWater , Rank , SetUp , Stopwatch , Sugar , Tickets , Timer , TrendCharts } from "@element-plus/icons-vue"
1515import ElementIcon from "../element-ui/icon"
1616import { locale } from "@util/i18n"
@@ -34,37 +34,46 @@ type _RouteProps = {
3434}
3535
3636/**
37- * Use TU_CAO_PAGE, if the locale is Chinese
38- *
39- * @since 0.9.0
37+ * Generate menu items after locale initialized
4038 */
41- let realFeedbackLink : string = GITHUB_ISSUE_ADD
42- if ( locale === 'zh_CN' ) {
43- realFeedbackLink = TU_CAO_PAGE
44- }
45-
46- const OTHER_MENU_ITEMS : _MenuItem [ ] = [ {
47- title : 'feedback' ,
48- href : realFeedbackLink ,
49- icon : ChatSquare ,
50- index : '_feedback'
51- } ]
52- HOME_PAGE && OTHER_MENU_ITEMS . push ( {
53- title : 'rate' ,
54- href : HOME_PAGE ,
55- icon : Sugar ,
56- index : '_rate'
57- } )
58- OTHER_MENU_ITEMS . push ( {
59- title : 'meat' ,
60- href : MEAT_URL ,
61- icon : Food ,
62- index : '_meat'
63- } )
39+ function generateMenus ( ) : _MenuGroup [ ] {
40+ /**
41+ * Use TU_CAO_PAGE, if the locale is Chinese
42+ *
43+ * @since 0.9.0
44+ */
45+ const isZhCn = locale === "zh_CN"
46+
47+ const otherMenuItems : _MenuItem [ ] = [ ]
48+ HOME_PAGE && otherMenuItems . push ( {
49+ title : 'rate' ,
50+ href : HOME_PAGE ,
51+ icon : Sugar ,
52+ index : '_rate'
53+ } )
54+ if ( isZhCn ) {
55+ otherMenuItems . push ( {
56+ title : 'feedback' ,
57+ href : TU_CAO_PAGE ,
58+ icon : ChatSquare ,
59+ index : '_feedback'
60+ } , {
61+ title : 'meat' ,
62+ href : MEAT_URL ,
63+ icon : Food ,
64+ index : '_meat'
65+ } )
66+ } else {
67+ otherMenuItems . push ( {
68+ title : 'translationMistake' ,
69+ href : 'https://github.com/sheepzh/timer/issues/new?assignees=&labels=locale&template=translation-------.md&title=Report+translation+mistakes' ,
70+ icon : ChatSquare ,
71+ index : '_i18n'
72+ } )
73+ }
6474
65- // All menu items
66- const ALL_MENU : _MenuGroup [ ] = [
67- {
75+ // All menu items
76+ return [ {
6877 title : 'data' ,
6978 children : [ {
7079 title : 'dashboard' ,
@@ -115,9 +124,9 @@ const ALL_MENU: _MenuGroup[] = [
115124 } ]
116125 } , {
117126 title : 'other' ,
118- children : OTHER_MENU_ITEMS
119- }
120- ]
127+ children : otherMenuItems
128+ } ]
129+ }
121130
122131function openMenu ( route : string , title : I18nKey , routeProps : UnwrapRef < _RouteProps > ) {
123132 const routerVal = routeProps . router
@@ -178,7 +187,7 @@ const _default = defineComponent({
178187
179188 return ( ) => h ( ElMenu ,
180189 { defaultActive : routeProps . current . path } ,
181- ( ) => ALL_MENU . map ( menu => renderMenu ( menu , routeProps ) )
190+ ( ) => generateMenus ( ) . map ( menu => renderMenu ( menu , routeProps ) )
182191 )
183192 }
184193} )
0 commit comments