|
1 | 1 | import { defineComponent, PropType, ref, computed, watch } from 'vue'; |
2 | | -import { ConfigDto, IEntryState, ISectionState, Section } from "@/client/apiGen"; |
3 | | -import { CheckBox, Popover, TextInput, Button, theme } from '@munet/ui'; |
| 2 | +import { ConfigDto } from "@/client/apiGen"; |
| 3 | +import { TextInput, theme, WhateverNaviBar } from '@munet/ui'; |
4 | 4 | import _ from "lodash"; |
5 | | -import ProblemsDisplay from "@/components/ProblemsDisplay"; |
6 | 5 | import configSortStub from './configSort.yaml' |
7 | 6 | import { useMagicKeys, whenever } from "@vueuse/core"; |
8 | | -import ConfigEntry from './ConfigEntry'; |
9 | | -import { getSectionPanelOverride, getNameForPath, getBigSectionName } from './utils'; |
10 | | -import comments from "./modComments.yaml"; |
| 7 | +import { getBigSectionName } from './utils'; |
11 | 8 | import { useI18n } from 'vue-i18n'; |
12 | | -import { locale } from "@/locales"; |
13 | | - |
14 | | -const ConfigSection = defineComponent({ |
15 | | - props: { |
16 | | - section: { type: Object as PropType<Section>, required: true }, |
17 | | - entryStates: { type: Object as PropType<Record<string, IEntryState>>, required: true }, |
18 | | - sectionState: { type: Object as PropType<ISectionState>, required: true }, |
19 | | - isCommunity: Boolean, |
20 | | - }, |
21 | | - setup(props, { emit }) { |
22 | | - const { t, te } = useI18n(); |
23 | | - |
24 | | - const CustomPanel = getSectionPanelOverride(props.section.path!) |
25 | | - const customPanelPosition: 'top' | 'bottom' | 'override' = comments.customPanelPosition[props.section.path!] || 'override'; |
26 | | - const comment = computed(() => { |
27 | | - const localeKey = 'mod.commentOverrides.' + props.section.path!.replace(/\./g, '_'); |
28 | | - if (te(localeKey)) { |
29 | | - return t(localeKey); |
30 | | - } |
31 | | - if (locale.value.startsWith('zh')) { |
32 | | - return props.section.attribute?.comment?.commentZh; |
33 | | - } |
34 | | - return props.section.attribute?.comment?.commentEn; |
35 | | - }) |
36 | | - |
37 | | - return () => <div class="flex flex-col gap-2 p-1 border-transparent border-solid border-1px rd hover:border-[oklch(0.68_0.17_var(--hue))]"> |
38 | | - {!props.section.attribute!.alwaysEnabled && <div class="flex gap-2 items-start" |
39 | | - // @ts-ignore |
40 | | - title={props.section.path!} |
41 | | - > |
42 | | - <div class="ml-1 text-lg w-9em shrink-0">{getNameForPath(props.section.path!, props.section.path!.split('.').pop()!, props.section.attribute?.comment?.nameZh)}</div> |
43 | | - <div class="flex flex-col gap-2 w-full ws-pre-line"> |
44 | | - <div class="flex gap-2 h-28px items-center"> |
45 | | - <CheckBox v-model:value={props.sectionState.enabled}>{props.sectionState.enabled ? '开' : '关'}</CheckBox> |
46 | | - {comments.shouldEnableOptions[props.section.path!] && !props.sectionState.enabled && <ProblemsDisplay problems={[t('mod.needEnableOption')]}/>} |
47 | | - {props.isCommunity && <Popover trigger="hover">{{ |
48 | | - trigger: () => <div class="i-ic-baseline-info text-lg c-neutral-5"/>, |
49 | | - default: () => <div> |
50 | | - <div class="text-lg mb-2">{t('mod.community.title')}</div> |
51 | | - <div class="text-sm whitespace-pre-line lh-1.7em">{t('mod.community.description')}</div> |
52 | | - </div> |
53 | | - }}</Popover>} |
54 | | - </div> |
55 | | - {comment.value} |
56 | | - </div> |
57 | | - </div>} |
58 | | - {props.sectionState.enabled && <> |
59 | | - {customPanelPosition === 'top' && <CustomPanel entryStates={props.entryStates} sectionState={props.sectionState} section={props.section}/>} |
60 | | - {(CustomPanel && customPanelPosition === 'override') ? |
61 | | - <CustomPanel entryStates={props.entryStates} sectionState={props.sectionState} section={props.section}/> : |
62 | | - !!props.section.entries?.length && <div class="flex flex-col gap-2 p-l-15 max-[900px]:p-l-10 max-[500px]:p-l-5!"> |
63 | | - {props.section.entries?.filter(it => !it.attribute?.hideWhenDefault || (it.attribute?.hideWhenDefault && !props.entryStates[it.path!].isDefault)) |
64 | | - .map((entry) => <ConfigEntry key={entry.path!} entry={entry} entryState={props.entryStates[entry.path!]}/>)} |
65 | | - </div>} |
66 | | - {customPanelPosition === 'bottom' && <CustomPanel entryStates={props.entryStates} sectionState={props.sectionState} section={props.section}/>} |
67 | | - </>} |
68 | | - </div>; |
69 | | - }, |
70 | | -}); |
| 9 | +import ConfigSection from './ConfigSection'; |
71 | 10 |
|
72 | 11 | export default defineComponent({ |
73 | 12 | props: { |
@@ -175,26 +114,14 @@ export default defineComponent({ |
175 | 114 | )} |
176 | 115 | </div> |
177 | 116 | <div class="flex flex-col h-full"> |
| 117 | + <div class="min-[900px]:hidden shrink-0"> |
| 118 | + <WhateverNaviBar items={allTabs.value.map(tab => ({ |
| 119 | + name: tab.label, |
| 120 | + onClick: () => activeTab.value = tab.key, |
| 121 | + selected: activeTab.value === tab.key, |
| 122 | + }))}/> |
| 123 | + </div> |
178 | 124 | <div class="flex gap-2 p-2 shrink-0"> |
179 | | - <div class={["min-[900px]:hidden"]}> |
180 | | - <Popover trigger="click">{{ |
181 | | - trigger: () => <Button variant="secondary" size="small"><span class="i-ic-baseline-menu text-lg"/></Button>, |
182 | | - default: () => <div class="flex flex-col gap-0.5"> |
183 | | - {allTabs.value.map(tab => |
184 | | - <div |
185 | | - key={tab.key} |
186 | | - class={[ |
187 | | - 'px-3 py-1.5 rd cursor-pointer text-sm', |
188 | | - activeTab.value === tab.key && theme.value.listItemSelect, theme.value.listItemHover, |
189 | | - ]} |
190 | | - onClick={() => activeTab.value = tab.key} |
191 | | - > |
192 | | - {tab.label} |
193 | | - </div> |
194 | | - )} |
195 | | - </div> |
196 | | - }}</Popover> |
197 | | - </div> |
198 | 125 | <TextInput v-model:value={search.value} placeholder={t('mod.searchPlaceholder')} ref={searchRef} innerClass="h-42px!" class="flex-1"/> |
199 | 126 | </div> |
200 | 127 | <div ref={scrollContainerRef} class="of-y-auto cst flex-1 p-2 pt-0 text-14px"> |
|
0 commit comments