mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-10-29 10:16:09 +08:00
feat: 文本编辑器记住上次设置 (#4445)
Refs https://github.com/1Panel-dev/1Panel/issues/4397 Refs https://github.com/1Panel-dev/1Panel/issues/4266
This commit is contained in:
parent
ef075df3fe
commit
1e2c85e771
1 changed files with 7 additions and 0 deletions
|
|
@ -93,6 +93,8 @@ interface EditorConfig {
|
|||
const open = ref(false);
|
||||
const loading = ref(false);
|
||||
const fileName = ref('');
|
||||
const codeThemeKey = 'code-theme';
|
||||
const warpKey = 'code-warp';
|
||||
|
||||
type WordWrapOptions = 'off' | 'on' | 'wordWrapColumn' | 'bounded';
|
||||
|
||||
|
|
@ -149,6 +151,7 @@ const changeLanguage = () => {
|
|||
|
||||
const changeTheme = () => {
|
||||
monaco.editor.setTheme(config.theme);
|
||||
localStorage.setItem(codeThemeKey, config.theme);
|
||||
};
|
||||
|
||||
const changeEOL = () => {
|
||||
|
|
@ -156,6 +159,7 @@ const changeEOL = () => {
|
|||
};
|
||||
|
||||
const changeWarp = () => {
|
||||
localStorage.setItem(warpKey, config.wordWrap);
|
||||
editor.updateOptions({
|
||||
wordWrap: config.wordWrap,
|
||||
});
|
||||
|
|
@ -217,6 +221,9 @@ const acceptParams = (props: EditProps) => {
|
|||
config.language = props.language;
|
||||
fileName.value = props.name;
|
||||
config.eol = monaco.editor.EndOfLineSequence.LF;
|
||||
|
||||
config.theme = localStorage.getItem(codeThemeKey) || 'vs-dark';
|
||||
config.wordWrap = (localStorage.getItem(warpKey) as WordWrapOptions) || 'on';
|
||||
open.value = true;
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue