import {computed, designComponent, getComponentCls, useClassCache} from "@peryl/react-compose"; import Dropdown from "../Dropdown"; import DropdownOption from "../DropdownOption"; import i18n from "../i18n"; import Icon from "../Icon"; import {ThemeShape} from "../../uses/useStyle"; import PageThemeUtils from "../PageThemeUtils"; export const ThemeShapeSelector = designComponent({ name: 'theme-shape-selector', props: { reloadOnChange: { type: Boolean }, onlyCache: { type: Boolean }, }, emits: { onChange: (shape: typeof ThemeShape.TYPE) => true, }, setup({ props, event: { emit } }) { const radiusOptions = computed((): { label: string, val: string | undefined }[] => [ { label: i18n.$it('theme.radiusOptions.round').d('圆角'), val: undefined }, { label: i18n.$it('theme.radiusOptions.square').d('小圆角'), val: ThemeShape.square }, { label: i18n.$it('theme.radiusOptions.none').d('无圆角'), val: ThemeShape.none }, ]); const change = (shape: typeof ThemeShape.TYPE) => { PageThemeUtils.shape(shape, props.onlyCache || props.reloadOnChange); emit.onChange(shape); props.reloadOnChange && window.location.reload(); }; const classes = useClassCache(() => [ getComponentCls('theme-selector'), getComponentCls('theme-shape-selector'), ]); return () => ( (
), popper: () => radiusOptions.value.map(opt => ( change(opt.val as any)}/> )), }} /> ); }, });