@@ -6,10 +6,46 @@ import { KeyCodeName } from "./types/KeyCodeName";
66import { getNameForPath } from "./utils" ;
77import comments from "./modComments.yaml" ;
88import { KeyCodeID } from "./types/KeyCodeID" ;
9+ import { VKCode } from "./types/VKCode" ;
910import { useI18n } from 'vue-i18n' ;
1011import { locale } from "@/locales" ;
1112import { ENTRY_LABEL_CLASS } from "./constants" ;
1213
14+ /* t需要传入是Vue的i18n翻译函数 */
15+ export function optionsIoKeyMap ( t : ( key : string ) => string ) : { label : string , value : string } [ ] {
16+ return [
17+ { label : t ( 'mod.ioKeyMap.disabled' ) , value : 'None' } ,
18+ { label : t ( 'mod.ioKeyMap.select' ) , value : 'Select' } ,
19+ { label : t ( 'mod.ioKeyMap.select1P' ) , value : 'Select1P' } ,
20+ { label : t ( 'mod.ioKeyMap.select2P' ) , value : 'Select2P' } ,
21+ { label : t ( 'mod.ioKeyMap.service' ) , value : 'Service' } ,
22+ { label : t ( 'mod.ioKeyMap.test' ) , value : 'Test' } ,
23+ { label : t ( 'mod.ioKeyMap.customFn' ) + "1" , value : 'CustomFn1' } ,
24+ { label : t ( 'mod.ioKeyMap.customFn' ) + "2" , value : 'CustomFn2' } ,
25+ { label : t ( 'mod.ioKeyMap.customFn' ) + "3" , value : 'CustomFn3' } ,
26+ { label : t ( 'mod.ioKeyMap.customFn' ) + "4" , value : 'CustomFn4' } ,
27+ ] ;
28+ }
29+
30+ export function optionsKeyCodeOrName ( t : ( key : string ) => string ) : { label : string , value : string } [ ] {
31+ return Object . entries ( KeyCodeName ) . map ( ( [ label , value ] ) => {
32+ if ( label . startsWith ( "CustomFn" ) ) { // "自定义功能键"需要单独i18n
33+ const suffix = label . slice ( 'CustomFn' . length ) ;
34+ return { label : t ( 'mod.ioKeyMap.customFn' ) + suffix , value } ;
35+ }
36+ return { label, value } ; // 其他的则沿用枚举中的值
37+ } ) ;
38+ }
39+
40+ export function optionsVKCode ( t : ( key : string ) => string ) : { label : string , value : string } [ ] {
41+ return Object . entries ( VKCode ) . map ( ( [ label , value ] ) => {
42+ if ( label == "None" ) { // 单独翻译为“禁用”
43+ return { label : t ( 'mod.disable' ) , value } ;
44+ }
45+ return { label, value } ; // 其他的则沿用枚举中的值
46+ } ) ;
47+ }
48+
1349export default defineComponent ( {
1450 props : {
1551 entry : { type : Object as PropType < Entry > , required : true } ,
@@ -18,15 +54,6 @@ export default defineComponent({
1854 setup ( props , { emit } ) {
1955 const { t, te } = useI18n ( ) ;
2056
21- const optionsIoKeyMap = [
22- { label : t ( 'mod.ioKeyMap.disabled' ) , value : 'None' } ,
23- { label : t ( 'mod.ioKeyMap.select' ) , value : 'Select' } ,
24- { label : t ( 'mod.ioKeyMap.select1P' ) , value : 'Select1P' } ,
25- { label : t ( 'mod.ioKeyMap.select2P' ) , value : 'Select2P' } ,
26- { label : t ( 'mod.ioKeyMap.service' ) , value : 'Service' } ,
27- { label : t ( 'mod.ioKeyMap.test' ) , value : 'Test' } ,
28- ] ;
29-
3057 const optionsSoundChannel = [ 'None' , 'P1SpeakerLeft' , 'P1SpeakerRight' , 'P1HeadphoneLeft' , 'P1HeadphoneRight' , 'P2SpeakerLeft' , 'P2SpeakerRight' , 'P2HeadphoneLeft' , 'P2HeadphoneRight' ]
3158 . map ( channel => ( { label : t ( 'mod.soundChannel.' + channel ) , value : channel } ) ) ;
3259
@@ -74,13 +101,14 @@ export default defineComponent({
74101 case 'System.Single' :
75102 return < NumberInput innerClass = "h-42px!" v-model :value = { props . entryState . value } step = { .1 } decimal = { 4 } /> ;
76103 case 'AquaMai.Config.Types.KeyCodeOrName' :
77- return < Select v-model :value = { props . entryState . value } options = { Object . entries ( KeyCodeName ) . map ( ( [ label , value ] ) => ( { label , value } ) ) } /> ;
104+ return < Select v-model :value = { props . entryState . value } options = { optionsKeyCodeOrName ( t ) } /> ;
78105 case 'AquaMai.Config.Types.KeyCodeID' :
79106 return < Select v-model :value = { props . entryState . value } options = { Object . entries ( KeyCodeID ) . map ( ( [ label , value ] ) => ( { label, value} ) ) } /> ;
80107 case 'AquaMai.Config.Types.IOKeyMap' :
81- return < Select v-model :value = { props . entryState . value } options = { optionsIoKeyMap } /> ;
82108 case 'AquaMai.Config.Types.AdxKeyMap' :
83- return < Select v-model :value = { props . entryState . value } options = { optionsIoKeyMap } /> ;
109+ return < Select v-model :value = { props . entryState . value } options = { optionsIoKeyMap ( t ) } /> ;
110+ case 'AquaMai.Config.Types.VKCode' :
111+ return < Select v-model :value = { props . entryState . value } options = { optionsVKCode ( t ) } /> ;
84112 case 'AquaMai.Config.Types.SoundChannel' :
85113 return < Select v-model :value = { props . entryState . value } options = { optionsSoundChannel } /> ;
86114 }
0 commit comments