import { useI18n } from '@/hooks' import { useSettingActions, useSettingGetters } from '@/store' import { getDefaultSettingConfig } from '@/store/modules/setting/constant' import { LAYOUT_MODES, LayoutSettings } from '@ray-template/admin-shell' import { layoutHostKey } from '../host-context' import { useLayout } from '../useLayout' export default defineComponent({ name: 'LayoutSettings', props: { showDescription: Boolean }, setup(props) { const { t } = useI18n('layout') const { layouts, activeLayoutId, updateLayout } = useLayout() const { getLayoutConfig, getLocaleLanguage } = useSettingGetters() const { updateSettingState } = useSettingActions() const host = inject(layoutHostKey, null) return () => ( { if (updateLayout(id) && host) host.draftRenderer.value = void 0 }} choices={layouts.value.map((definition) => { const mode = LAYOUT_MODES.find((id) => id === definition.id) const label = typeof definition.label === 'string' ? definition.label : definition.label[ getLocaleLanguage.value === 'zh-CN' ? 'zh-CN' : 'en-US' ] return { id: definition.id, label, preview: definition.preview ?? mode ?? definition.fallbackMode ?? 'side', disabled: definition.selectable === false, hint: mode ? t(`modeHint.${mode}`) : void 0, } })} layout={getLayoutConfig.value} defaults={getDefaultSettingConfig().layoutConfig} translate={t} update={(value) => { updateSettingState('layoutConfig', value) if (value.mode && host) host.draftRenderer.value = void 0 }} /> ) }, })