Skip to content

Commit

Permalink
fix: fix setDiagnosticsOptions
Browse files Browse the repository at this point in the history
  • Loading branch information
wwsun committed May 4, 2023
1 parent 09d2f52 commit fab6e2e
Show file tree
Hide file tree
Showing 5 changed files with 1,233 additions and 1,101 deletions.
163 changes: 79 additions & 84 deletions src/components/Setting/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,96 +7,91 @@ import { configTheme } from '@utils/initEditor';
import { THEMES } from '@utils/consts';

const Setting: React.FC<{
getTarget?: () => HTMLElement | null,
autoPrettier?: boolean,
onAutoPrettierChange?: (e: any) => void,
defaultTheme?: string,
disablePrettier?: boolean,
getTarget?: () => HTMLElement | null;
autoPrettier?: boolean;
onAutoPrettierChange?: (e: any) => void;
defaultTheme?: string;
disablePrettier?: boolean;
}> = ({
getTarget,
autoPrettier,
onAutoPrettierChange,
defaultTheme = 'OneDarkPro',
disablePrettier = false,
getTarget,
autoPrettier,
onAutoPrettierChange,
defaultTheme = 'GithubLightDefault',
disablePrettier = false,
}) => {
const [visible, setVisible] = useState(false);
const [theme, setTheme] = useState(defaultTheme);
const [visible, setVisible] = useState(false);
const [theme, setTheme] = useState(defaultTheme);

useEffect(() => {
configTheme(defaultTheme);
// eslint-disable-next-line
}, []);
useEffect(() => {
configTheme(defaultTheme);
}, []);

return (
<React.Fragment>
return (
<React.Fragment>
<div
className="music-monaco-editor-setting-button"
onClick={() => setVisible(true)}>
<SettingIcon
style={{
width: '16px',
height: '16px',
}}
/>
</div>
<Modal
destroyOnClose
onClose={() => setVisible(false)}
visible={visible}
getTarget={getTarget}>
<div className="music-monaco-editor-setting">
<div className="music-monaco-editor-setting-header">
设置
<div
className="music-monaco-editor-setting-button"
onClick={() => setVisible(true) }>
<SettingIcon
style={{
width: '20px',
height: '20px',
}} />
onClick={() => setVisible(false)}
className="music-monaco-editor-setting-header-close">
<Close
style={{
width: '12px',
height: '12px',
}}
/>
</div>
<Modal
destroyOnClose
onClose={() => setVisible(false) }
visible={visible}
getTarget={getTarget}>
<div className="music-monaco-editor-setting">
<div className="music-monaco-editor-setting-header">
设置
<div
onClick={() => setVisible(false)}
className="music-monaco-editor-setting-header-close">
<Close style={{
width: '12px',
height: '12px'
}} />
</div>
</div>
<div className="music-monaco-editor-setting-content">
{
disablePrettier ? null : (
<div className="music-monaco-editor-input-row">
<div className="music-monaco-editor-input-name">
prettier
</div>
<div className="music-monaco-editor-input-value">
<input
defaultChecked={autoPrettier}
type="checkbox"
onChange={onAutoPrettierChange}/>
<label>prettier on save</label>
</div>
</div>
)
}
<div className="music-monaco-editor-input-row">
<div className="music-monaco-editor-input-name">
主题选择
</div>
<div className="music-monaco-editor-input-value">
<Select
value={theme}
getContainer={getTarget}
onChange={(v) => {
setTheme(v);
configTheme(v);
}}>
{
THEMES.map(theme => (
<Select.Menu label={theme} value={theme} key={theme} />
))
}
</Select>
</div>
</div>
</div>
</div>
<div className="music-monaco-editor-setting-content">
{disablePrettier ? null : (
<div className="music-monaco-editor-input-row">
<div className="music-monaco-editor-input-name">prettier</div>
<div className="music-monaco-editor-input-value">
<input
defaultChecked={autoPrettier}
type="checkbox"
onChange={onAutoPrettierChange}
/>
<label>prettier on save</label>
</div>
</Modal>
</React.Fragment>
)
}
</div>
)}
<div className="music-monaco-editor-input-row">
<div className="music-monaco-editor-input-name">主题选择</div>
<div className="music-monaco-editor-input-value">
<Select
value={theme}
getContainer={getTarget}
onChange={(v) => {
setTheme(v);
configTheme(v);
}}>
{THEMES.map((theme) => (
<Select.Menu label={theme} value={theme} key={theme} />
))}
</Select>
</div>
</div>
</div>
</div>
</Modal>
</React.Fragment>
);
};

export default Setting;
Loading

0 comments on commit fab6e2e

Please sign in to comment.