@@ -10,11 +10,10 @@ 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 } from "@element-plus/icons-vue"
1515import ElementIcon from "../element-ui/icon"
1616import { locale } from "@util/i18n"
17- import { IS_EDGE } from "@util/constant/environment"
1817
1918type _MenuItem = {
2019 title : keyof MenuMessage
@@ -35,37 +34,46 @@ type _RouteProps = {
3534}
3635
3736/**
38- * Use TU_CAO_PAGE, if the locale is Chinese
39- *
40- * @since 0.9.0
37+ * Generate menu items after locale initialized
4138 */
42- let realFeedbackLink : string = GITHUB_ISSUE_ADD
43- if ( locale === 'zh_CN' ) {
44- realFeedbackLink = TU_CAO_PAGE
45- }
46-
47- const OTHER_MENU_ITEMS : _MenuItem [ ] = [ {
48- title : 'feedback' ,
49- href : realFeedbackLink ,
50- icon : ChatSquare ,
51- index : '_feedback'
52- } ]
53- HOME_PAGE && OTHER_MENU_ITEMS . push ( {
54- title : 'rate' ,
55- href : HOME_PAGE ,
56- icon : Sugar ,
57- index : '_rate'
58- } )
59- OTHER_MENU_ITEMS . push ( {
60- title : 'meat' ,
61- href : MEAT_URL ,
62- icon : Food ,
63- index : '_meat'
64- } )
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+ }
6574
66- // All menu items
67- const ALL_MENU : _MenuGroup [ ] = [
68- {
75+ // All menu items
76+ return [ {
6977 title : 'data' ,
7078 children : [ {
7179 title : 'dataReport' ,
@@ -112,9 +120,9 @@ const ALL_MENU: _MenuGroup[] = [
112120 } ]
113121 } , {
114122 title : 'other' ,
115- children : OTHER_MENU_ITEMS
116- }
117- ]
123+ children : otherMenuItems
124+ } ]
125+ }
118126
119127function openMenu ( route : string , title : I18nKey , routeProps : UnwrapRef < _RouteProps > ) {
120128 const routerVal = routeProps . router
@@ -175,7 +183,7 @@ const _default = defineComponent({
175183
176184 return ( ) => h ( ElMenu ,
177185 { defaultActive : routeProps . current . path } ,
178- ( ) => ALL_MENU . map ( menu => renderMenu ( menu , routeProps ) )
186+ ( ) => generateMenus ( ) . map ( menu => renderMenu ( menu , routeProps ) )
179187 )
180188 }
181189} )
0 commit comments