@@ -57,6 +57,80 @@ const LANG_TABS: { value: LangKey; textValue: string }[] = [
5757]
5858const activeLang = ref <LangKey >(' zh-cn' )
5959
60+ // One name input + one milkdown editor serve all 4 languages: the editor is
61+ // reused, and switching activeLang drives its `:language` prop, which makes
62+ // the editor replaceAll() its content with the new language's intro. We expose
63+ // the active language's name/intro as proxies so the single controls read and
64+ // write the right form field.
65+ const activeName = computed <string >({
66+ get() {
67+ switch (activeLang .value ) {
68+ case ' zh-tw' :
69+ return form .name_zh_tw
70+ case ' ja-jp' :
71+ return form .name_ja_jp
72+ case ' en-us' :
73+ return form .name_en_us
74+ default :
75+ return form .name_zh_cn
76+ }
77+ },
78+ set(v ) {
79+ switch (activeLang .value ) {
80+ case ' zh-tw' :
81+ form .name_zh_tw = v
82+ break
83+ case ' ja-jp' :
84+ form .name_ja_jp = v
85+ break
86+ case ' en-us' :
87+ form .name_en_us = v
88+ break
89+ default :
90+ form .name_zh_cn = v
91+ }
92+ }
93+ })
94+ const activeIntro = computed (() => {
95+ switch (activeLang .value ) {
96+ case ' zh-tw' :
97+ return form .intro_zh_tw
98+ case ' ja-jp' :
99+ return form .intro_ja_jp
100+ case ' en-us' :
101+ return form .intro_en_us
102+ default :
103+ return form .intro_zh_cn
104+ }
105+ })
106+ const setActiveIntro = (val : string ) => {
107+ switch (activeLang .value ) {
108+ case ' zh-tw' :
109+ form .intro_zh_tw = val
110+ break
111+ case ' ja-jp' :
112+ form .intro_ja_jp = val
113+ break
114+ case ' en-us' :
115+ form .intro_en_us = val
116+ break
117+ default :
118+ form .intro_zh_cn = val
119+ }
120+ }
121+ const namePlaceholder = computed (() => {
122+ switch (activeLang .value ) {
123+ case ' zh-tw' :
124+ return ' 繁體中文名稱'
125+ case ' ja-jp' :
126+ return ' 日本語タイトル'
127+ case ' en-us' :
128+ return ' English title'
129+ default :
130+ return ' 例如:你和她和她的恋爱'
131+ }
132+ })
133+
60134interface FormState {
61135 name_en_us: string
62136 name_ja_jp: string
@@ -400,53 +474,18 @@ const handleSubmit = async () => {
400474 color =" primary"
401475 size =" sm"
402476 />
403- <div v-for =" lang in LANG_TABS" :key =" lang.value" >
404- <div v-show =" activeLang === lang.value" class =" space-y-3" >
405- <label class =" block" >
406- <span class =" text-default-700 text-sm" >标题</span >
407- <KunInput
408- v-if =" lang.value === 'zh-cn'"
409- v-model =" form.name_zh_cn"
410- placeholder =" 例如:你和她和她的恋爱"
411- />
412- <KunInput
413- v-else-if =" lang.value === 'zh-tw'"
414- v-model =" form.name_zh_tw"
415- placeholder =" 繁體中文名稱"
416- />
417- <KunInput
418- v-else-if =" lang.value === 'ja-jp'"
419- v-model =" form.name_ja_jp"
420- placeholder =" 日本語タイトル"
421- />
422- <KunInput
423- v-else
424- v-model =" form.name_en_us"
425- placeholder =" English title"
426- />
427- </label >
428- <label class =" block" >
429- <span class =" text-default-700 text-sm" >简介 (Markdown)</span >
430- <KunTextarea
431- v-if =" lang.value === 'zh-cn'"
432- v-model =" form.intro_zh_cn"
433- :rows =" 10"
434- placeholder =" 支持 Markdown 语法"
435- />
436- <KunTextarea
437- v-else-if =" lang.value === 'zh-tw'"
438- v-model =" form.intro_zh_tw"
439- :rows =" 10"
440- />
441- <KunTextarea
442- v-else-if =" lang.value === 'ja-jp'"
443- v-model =" form.intro_ja_jp"
444- :rows =" 10"
445- />
446- <KunTextarea v-else v-model =" form.intro_en_us" :rows =" 10" />
447- </label >
448- </div >
449- </div >
477+ <label class =" block space-y-1" >
478+ <span class =" text-default-700 text-sm" >标题</span >
479+ <KunInput v-model =" activeName" :placeholder =" namePlaceholder" />
480+ </label >
481+ <label class =" block space-y-1" >
482+ <span class =" text-default-700 text-sm" >简介 (Markdown)</span >
483+ <KunMilkdownDualEditorProvider
484+ :value-markdown =" activeIntro"
485+ :language =" activeLang"
486+ @set-markdown =" setActiveIntro"
487+ />
488+ </label >
450489 </div >
451490
452491 <!-- ─── 基本信息:rating + language + aliases + is_minor ────── -->
0 commit comments