refactor: 修改 tag selector.
This commit is contained in:
@@ -24,8 +24,8 @@ public class TerminalPreferenceModel implements PreferenceModel {
|
|||||||
@Schema(description = "暗色主题")
|
@Schema(description = "暗色主题")
|
||||||
private String darkTheme;
|
private String darkTheme;
|
||||||
|
|
||||||
@Schema(description = "终端主题")
|
@Schema(description = "新建连接类型")
|
||||||
private JSONObject themeSchema;
|
private String newConnectionType;
|
||||||
|
|
||||||
@Schema(description = "显示设置")
|
@Schema(description = "显示设置")
|
||||||
private JSONObject displaySetting;
|
private JSONObject displaySetting;
|
||||||
@@ -33,6 +33,9 @@ public class TerminalPreferenceModel implements PreferenceModel {
|
|||||||
@Schema(description = "背景设置")
|
@Schema(description = "背景设置")
|
||||||
private JSONObject backgroundSetting;
|
private JSONObject backgroundSetting;
|
||||||
|
|
||||||
|
@Schema(description = "终端主题")
|
||||||
|
private JSONObject themeSchema;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@Builder
|
@Builder
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ public class TerminalPreferenceStrategy implements IPreferenceStrategy<TerminalP
|
|||||||
public TerminalPreferenceModel getDefault() {
|
public TerminalPreferenceModel getDefault() {
|
||||||
return TerminalPreferenceModel.builder()
|
return TerminalPreferenceModel.builder()
|
||||||
.darkTheme("dark")
|
.darkTheme("dark")
|
||||||
.themeSchema(new JSONObject())
|
.newConnectionType("group")
|
||||||
.displaySetting(TerminalPreferenceModel.DisplaySettingModel.builder()
|
.displaySetting(TerminalPreferenceModel.DisplaySettingModel.builder()
|
||||||
.fontFamily("_")
|
.fontFamily("_")
|
||||||
.fontSize(15)
|
.fontSize(15)
|
||||||
@@ -31,6 +31,7 @@ public class TerminalPreferenceStrategy implements IPreferenceStrategy<TerminalP
|
|||||||
.toJson()
|
.toJson()
|
||||||
)
|
)
|
||||||
.backgroundSetting(new JSONObject())
|
.backgroundSetting(new JSONObject())
|
||||||
|
.themeSchema(new JSONObject())
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,11 @@
|
|||||||
@exceed-limit="() => { emits('onLimited', limit, `最多选择${limit}个tag`) }"
|
@exceed-limit="() => { emits('onLimited', limit, `最多选择${limit}个tag`) }"
|
||||||
multiple
|
multiple
|
||||||
allow-clear>
|
allow-clear>
|
||||||
|
<template #option="{ data: { label } }">
|
||||||
|
<a-tag :color="dataColor(label, tagColor)">
|
||||||
|
{{ label }}
|
||||||
|
</a-tag>
|
||||||
|
</template>
|
||||||
</a-select>
|
</a-select>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -23,7 +28,7 @@
|
|||||||
import type { TagCreateRequest } from '@/api/meta/tag';
|
import type { TagCreateRequest } from '@/api/meta/tag';
|
||||||
import { ref, computed, onBeforeMount } from 'vue';
|
import { ref, computed, onBeforeMount } from 'vue';
|
||||||
import { useCacheStore } from '@/store';
|
import { useCacheStore } from '@/store';
|
||||||
import { Message } from '@arco-design/web-vue';
|
import { dataColor } from '@/utils';
|
||||||
import { createTag } from '@/api/meta/tag';
|
import { createTag } from '@/api/meta/tag';
|
||||||
import useLoading from '@/hooks/loading';
|
import useLoading from '@/hooks/loading';
|
||||||
|
|
||||||
@@ -33,6 +38,10 @@
|
|||||||
limit: Number,
|
limit: Number,
|
||||||
type: String,
|
type: String,
|
||||||
allowCreate: Boolean,
|
allowCreate: Boolean,
|
||||||
|
tagColor: {
|
||||||
|
type: Array as PropType<Array<string>>,
|
||||||
|
default: () => []
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const emits = defineEmits(['update:modelValue', 'onLimited']);
|
const emits = defineEmits(['update:modelValue', 'onLimited']);
|
||||||
@@ -95,7 +104,10 @@
|
|||||||
// 插入 options
|
// 插入 options
|
||||||
optionData.value.push({
|
optionData.value.push({
|
||||||
label: name,
|
label: name,
|
||||||
value: id
|
value: id,
|
||||||
|
tagProps: {
|
||||||
|
color: dataColor(name, props.tagColor)
|
||||||
|
}
|
||||||
});
|
});
|
||||||
return id;
|
return id;
|
||||||
};
|
};
|
||||||
@@ -109,6 +121,9 @@
|
|||||||
return {
|
return {
|
||||||
label: s.name,
|
label: s.name,
|
||||||
value: s.id,
|
value: s.id,
|
||||||
|
tagProps: {
|
||||||
|
color: dataColor(s.name, props.tagColor)
|
||||||
|
}
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import type { TerminalDisplaySetting, TerminalPreference, TerminalState, Termina
|
|||||||
import { defineStore } from 'pinia';
|
import { defineStore } from 'pinia';
|
||||||
import { getPreference, updatePreferencePartial } from '@/api/user/preference';
|
import { getPreference, updatePreferencePartial } from '@/api/user/preference';
|
||||||
import { Message } from '@arco-design/web-vue';
|
import { Message } from '@arco-design/web-vue';
|
||||||
import { useDark } from '@vueuse/core';
|
import { useDark, useDebounceFn } from '@vueuse/core';
|
||||||
import { DEFAULT_SCHEMA } from '@/views/host-ops/terminal/types/terminal.theme';
|
import { DEFAULT_SCHEMA } from '@/views/host-ops/terminal/types/terminal.theme';
|
||||||
|
|
||||||
// 暗色主题
|
// 暗色主题
|
||||||
@@ -24,17 +24,13 @@ export default defineStore('terminal', {
|
|||||||
}),
|
}),
|
||||||
preference: {
|
preference: {
|
||||||
darkTheme: 'auto',
|
darkTheme: 'auto',
|
||||||
themeSchema: {} as TerminalThemeSchema,
|
newConnectionType: 'group',
|
||||||
displaySetting: {} as TerminalDisplaySetting
|
displaySetting: {} as TerminalDisplaySetting,
|
||||||
|
themeSchema: {} as TerminalThemeSchema
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
// 修改暗色主题
|
|
||||||
changeDarkTheme(dark: boolean) {
|
|
||||||
this.isDarkTheme = dark;
|
|
||||||
},
|
|
||||||
|
|
||||||
// 加载终端偏好
|
// 加载终端偏好
|
||||||
async fetchPreference() {
|
async fetchPreference() {
|
||||||
try {
|
try {
|
||||||
@@ -56,8 +52,53 @@ export default defineStore('terminal', {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
// 更新终端偏好
|
// 修改暗色主题
|
||||||
async updatePreference() {
|
changeDarkTheme(darkTheme: string) {
|
||||||
|
this.preference.darkTheme = darkTheme;
|
||||||
|
if (darkTheme === DarkTheme.DARK) {
|
||||||
|
// 暗色
|
||||||
|
this.isDarkTheme = true;
|
||||||
|
} else if (darkTheme === DarkTheme.LIGHT) {
|
||||||
|
// 亮色
|
||||||
|
this.isDarkTheme = false;
|
||||||
|
} else if (darkTheme === DarkTheme.AUTO) {
|
||||||
|
// 自动配色
|
||||||
|
this.isDarkTheme = this.preference.themeSchema.dark;
|
||||||
|
}
|
||||||
|
// 同步配置
|
||||||
|
this.updateTerminalPreference();
|
||||||
|
},
|
||||||
|
|
||||||
|
// 修改显示配置
|
||||||
|
changeDisplaySetting(displaySetting: TerminalDisplaySetting) {
|
||||||
|
this.preference.displaySetting = displaySetting;
|
||||||
|
// 同步配置
|
||||||
|
this.updateTerminalPreference();
|
||||||
|
},
|
||||||
|
|
||||||
|
// 选择终端主题
|
||||||
|
changeThemeSchema(themeSchema: TerminalThemeSchema) {
|
||||||
|
this.preference.themeSchema = themeSchema;
|
||||||
|
// 切换主题配色
|
||||||
|
if (this.preference.darkTheme === DarkTheme.AUTO) {
|
||||||
|
this.isDarkTheme = themeSchema.dark;
|
||||||
|
}
|
||||||
|
// 同步配置
|
||||||
|
this.updateTerminalPreference();
|
||||||
|
},
|
||||||
|
|
||||||
|
// 切换新建连接类型
|
||||||
|
changeNewConnectionType(newConnectionType: string) {
|
||||||
|
this.preference.newConnectionType = newConnectionType;
|
||||||
|
// 同步配置
|
||||||
|
this.updateTerminalPreference();
|
||||||
|
},
|
||||||
|
|
||||||
|
// 更新终端偏好-防抖
|
||||||
|
updateTerminalPreference() {
|
||||||
|
// 初始化函数
|
||||||
|
if (!this.updateTerminalPreferenceFn) {
|
||||||
|
this.updateTerminalPreferenceFn = useDebounceFn(async () => {
|
||||||
try {
|
try {
|
||||||
// 修改配置
|
// 修改配置
|
||||||
await updatePreferencePartial({
|
await updatePreferencePartial({
|
||||||
@@ -67,7 +108,11 @@ export default defineStore('terminal', {
|
|||||||
} catch (e) {
|
} catch (e) {
|
||||||
Message.error('同步失败');
|
Message.error('同步失败');
|
||||||
}
|
}
|
||||||
},
|
}, 1500);
|
||||||
|
}
|
||||||
|
// 更新
|
||||||
|
this.updateTerminalPreferenceFn();
|
||||||
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -3,13 +3,27 @@ import type { Ref } from 'vue';
|
|||||||
export interface TerminalState {
|
export interface TerminalState {
|
||||||
isDarkTheme: Ref<boolean>;
|
isDarkTheme: Ref<boolean>;
|
||||||
preference: TerminalPreference;
|
preference: TerminalPreference;
|
||||||
|
|
||||||
|
updateTerminalPreferenceFn?: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 终端配置
|
// 终端配置
|
||||||
export interface TerminalPreference {
|
export interface TerminalPreference {
|
||||||
darkTheme: string,
|
darkTheme: string;
|
||||||
themeSchema: TerminalThemeSchema,
|
newConnectionType: string;
|
||||||
displaySetting: TerminalDisplaySetting,
|
displaySetting: TerminalDisplaySetting;
|
||||||
|
themeSchema: TerminalThemeSchema;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 显示设置
|
||||||
|
export interface TerminalDisplaySetting {
|
||||||
|
fontFamily?: string;
|
||||||
|
fontSize?: number;
|
||||||
|
lineHeight?: number;
|
||||||
|
fontWeight?: string | number;
|
||||||
|
fontWeightBold?: string | number;
|
||||||
|
cursorStyle?: string;
|
||||||
|
cursorBlink?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 终端主题
|
// 终端主题
|
||||||
@@ -42,14 +56,3 @@ export interface TerminalThemeSchema {
|
|||||||
|
|
||||||
[key: string]: unknown;
|
[key: string]: unknown;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 显示设置
|
|
||||||
export interface TerminalDisplaySetting {
|
|
||||||
fontFamily?: string;
|
|
||||||
fontSize?: number;
|
|
||||||
lineHeight?: number;
|
|
||||||
fontWeight?: string | number;
|
|
||||||
fontWeightBold?: string | number;
|
|
||||||
cursorStyle?: string;
|
|
||||||
cursorBlink?: boolean;
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -40,7 +40,10 @@ export function md5(plain: string): string {
|
|||||||
/**
|
/**
|
||||||
* 获取数据颜色
|
* 获取数据颜色
|
||||||
*/
|
*/
|
||||||
export function dataColor(str: string, colors: string[]): string {
|
export function dataColor(str: string, colors: string[], defaultColor = ''): string {
|
||||||
|
if (!colors?.length) {
|
||||||
|
return defaultColor;
|
||||||
|
}
|
||||||
let total = 0;
|
let total = 0;
|
||||||
for (let i = 0; i < str.length; i++) {
|
for (let i = 0; i < str.length; i++) {
|
||||||
total += str.charCodeAt(i);
|
total += str.charCodeAt(i);
|
||||||
|
|||||||
@@ -78,6 +78,7 @@
|
|||||||
:allowCreate="false"
|
:allowCreate="false"
|
||||||
:limit="0"
|
:limit="0"
|
||||||
type="HOST"
|
type="HOST"
|
||||||
|
:tagColor="tagColor"
|
||||||
placeholder="请选择主机标签" />
|
placeholder="请选择主机标签" />
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
</a-form>
|
</a-form>
|
||||||
|
|||||||
@@ -43,6 +43,7 @@
|
|||||||
:allowCreate="true"
|
:allowCreate="true"
|
||||||
:limit="5"
|
:limit="5"
|
||||||
type="HOST"
|
type="HOST"
|
||||||
|
:tagColor="tagColor"
|
||||||
placeholder="请选择主机标签"
|
placeholder="请选择主机标签"
|
||||||
@onLimited="onLimitedTag" />
|
@onLimited="onLimitedTag" />
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
@@ -68,6 +69,7 @@
|
|||||||
import { pick } from 'lodash';
|
import { pick } from 'lodash';
|
||||||
import TagMultiSelector from '@/components/meta/tag/tag-multi-selector.vue';
|
import TagMultiSelector from '@/components/meta/tag/tag-multi-selector.vue';
|
||||||
import HostGroupTreeSelector from '@/components/asset/host-group/host-group-tree-selector.vue';
|
import HostGroupTreeSelector from '@/components/asset/host-group/host-group-tree-selector.vue';
|
||||||
|
import { tagColor } from '@/views/asset/host-list/types/const';
|
||||||
|
|
||||||
const { visible, setVisible } = useVisible();
|
const { visible, setVisible } = useVisible();
|
||||||
const { loading, setLoading } = useLoading();
|
const { loading, setLoading } = useLoading();
|
||||||
|
|||||||
@@ -32,6 +32,7 @@
|
|||||||
:allowCreate="false"
|
:allowCreate="false"
|
||||||
:limit="0"
|
:limit="0"
|
||||||
type="HOST"
|
type="HOST"
|
||||||
|
:tagColor="tagColor"
|
||||||
placeholder="请选择主机标签" />
|
placeholder="请选择主机标签" />
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
</a-query-header>
|
</a-query-header>
|
||||||
|
|||||||
@@ -56,6 +56,7 @@
|
|||||||
import { computed } from 'vue';
|
import { computed } from 'vue';
|
||||||
import IconActions from '../layout/icon-actions.vue';
|
import IconActions from '../layout/icon-actions.vue';
|
||||||
import { useTerminalStore } from '@/store';
|
import { useTerminalStore } from '@/store';
|
||||||
|
import { DarkTheme } from '@/store/modules/terminal';
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
modelValue: {
|
modelValue: {
|
||||||
@@ -82,10 +83,9 @@
|
|||||||
click: () => emits('share')
|
click: () => emits('share')
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
// FIXME 持久化
|
|
||||||
icon: terminalStore.isDarkTheme ? 'icon-sun-fill' : 'icon-moon-fill',
|
icon: terminalStore.isDarkTheme ? 'icon-sun-fill' : 'icon-moon-fill',
|
||||||
content: terminalStore.isDarkTheme ? '点击切换为亮色模式' : '点击切换为暗色模式',
|
content: terminalStore.isDarkTheme ? '点击切换为亮色模式' : '点击切换为暗色模式',
|
||||||
click: () => terminalStore.changeDarkTheme(!terminalStore.isDarkTheme)
|
click: () => terminalStore.changeDarkTheme(terminalStore.isDarkTheme ? DarkTheme.LIGHT : DarkTheme.DARK)
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
icon: isFullscreen.value ? 'icon-fullscreen-exit' : 'icon-fullscreen',
|
icon: isFullscreen.value ? 'icon-fullscreen-exit' : 'icon-fullscreen',
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
import { InnerTabs } from '../../types/terminal.const';
|
import { InnerTabs } from '../../types/terminal.const';
|
||||||
import IconActions from './icon-actions.vue';
|
import IconActions from './icon-actions.vue';
|
||||||
|
|
||||||
const emits = defineEmits(['switchTab', 'copyAddress']);
|
const emits = defineEmits(['switchTab']);
|
||||||
|
|
||||||
// 顶部操作
|
// 顶部操作
|
||||||
const topActions: Array<SidebarAction> = [
|
const topActions: Array<SidebarAction> = [
|
||||||
@@ -31,11 +31,6 @@
|
|||||||
content: '新建连接',
|
content: '新建连接',
|
||||||
click: () => emits('switchTab', InnerTabs.NEW_CONNECTION)
|
click: () => emits('switchTab', InnerTabs.NEW_CONNECTION)
|
||||||
},
|
},
|
||||||
{
|
|
||||||
icon: 'icon-copy',
|
|
||||||
content: '复制主机IP',
|
|
||||||
click: () => emits('copyAddress')
|
|
||||||
},
|
|
||||||
];
|
];
|
||||||
|
|
||||||
// 底部操作
|
// 底部操作
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
type="button"
|
type="button"
|
||||||
class="usn"
|
class="usn"
|
||||||
:options="toOptions(NewConnectionTypeKey)"
|
:options="toOptions(NewConnectionTypeKey)"
|
||||||
@change="changeConnectionType" />
|
@change="changeNewConnectionType" />
|
||||||
<!-- 过滤 -->
|
<!-- 过滤 -->
|
||||||
<a-auto-complete v-model="filterValue"
|
<a-auto-complete v-model="filterValue"
|
||||||
class="host-filter"
|
class="host-filter"
|
||||||
@@ -80,15 +80,16 @@
|
|||||||
import { onBeforeMount, ref } from 'vue';
|
import { onBeforeMount, ref } from 'vue';
|
||||||
import { NewConnectionType, NewConnectionTypeKey } from '../../types/terminal.const';
|
import { NewConnectionType, NewConnectionTypeKey } from '../../types/terminal.const';
|
||||||
import useLoading from '@/hooks/loading';
|
import useLoading from '@/hooks/loading';
|
||||||
import { useDictStore } from '@/store';
|
import { useDictStore, useTerminalStore } from '@/store';
|
||||||
import { dataColor } from '@/utils';
|
import { dataColor } from '@/utils';
|
||||||
import { tagColor } from '@/views/asset/host-list/types/const';
|
import { tagColor } from '@/views/asset/host-list/types/const';
|
||||||
import HostsView from './hosts-view.vue';
|
import HostsView from './hosts-view.vue';
|
||||||
|
|
||||||
const { loading, setLoading } = useLoading();
|
const { loading, setLoading } = useLoading();
|
||||||
const { toOptions } = useDictStore();
|
const { toOptions } = useDictStore();
|
||||||
|
const { preference, changeNewConnectionType } = useTerminalStore();
|
||||||
|
|
||||||
const newConnectionType = ref(NewConnectionType.GROUP);
|
const newConnectionType = ref(preference.newConnectionType || NewConnectionType.GROUP);
|
||||||
const filterValue = ref('');
|
const filterValue = ref('');
|
||||||
const filterOptions = ref<Array<SelectOptionData>>([]);
|
const filterOptions = ref<Array<SelectOptionData>>([]);
|
||||||
const hosts = ref<AuthorizedHostQueryResponse>({} as AuthorizedHostQueryResponse);
|
const hosts = ref<AuthorizedHostQueryResponse>({} as AuthorizedHostQueryResponse);
|
||||||
@@ -124,11 +125,6 @@
|
|||||||
}).forEach(s => filterOptions.value.push(s));
|
}).forEach(s => filterOptions.value.push(s));
|
||||||
};
|
};
|
||||||
|
|
||||||
// 修改连接类型
|
|
||||||
const changeConnectionType = () => {
|
|
||||||
// FIXME 持久化类型
|
|
||||||
};
|
|
||||||
|
|
||||||
// 初始化
|
// 初始化
|
||||||
const init = async () => {
|
const init = async () => {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -79,7 +79,7 @@
|
|||||||
<div class="terminal-example">
|
<div class="terminal-example">
|
||||||
<span class="terminal-example-label">预览效果</span>
|
<span class="terminal-example-label">预览效果</span>
|
||||||
<div class="terminal-example-wrapper"
|
<div class="terminal-example-wrapper"
|
||||||
:style="{ background: preference.themeSchema.background }">
|
:style="{ background: preference.themeSchema?.background }">
|
||||||
<terminal-example :theme="preference.themeSchema"
|
<terminal-example :theme="preference.themeSchema"
|
||||||
ref="previewTerminal" />
|
ref="previewTerminal" />
|
||||||
</div>
|
</div>
|
||||||
@@ -96,22 +96,19 @@
|
|||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import type { TerminalDisplaySetting } from '@/store/modules/terminal/types';
|
import type { TerminalDisplaySetting } from '@/store/modules/terminal/types';
|
||||||
import { onMounted, ref, watch } from 'vue';
|
import { ref, watch } from 'vue';
|
||||||
import { useDictStore, useTerminalStore } from '@/store';
|
import { useDictStore, useTerminalStore } from '@/store';
|
||||||
import { fontFamilyKey, fontSizeKey, fontWeightKey, fontFamilySuffix, cursorStyleKey } from '../../types/terminal.const';
|
import { fontFamilyKey, fontSizeKey, fontWeightKey, fontFamilySuffix, cursorStyleKey } from '../../types/terminal.const';
|
||||||
import { labelFilter } from '@/types/form';
|
import { labelFilter } from '@/types/form';
|
||||||
import { useDebounceFn } from '@vueuse/core';
|
|
||||||
import TerminalExample from '../view-setting/terminal-example.vue';
|
import TerminalExample from '../view-setting/terminal-example.vue';
|
||||||
|
|
||||||
const { toOptions } = useDictStore();
|
const { toOptions } = useDictStore();
|
||||||
const { preference, updatePreference } = useTerminalStore();
|
const { preference, changeDisplaySetting } = useTerminalStore();
|
||||||
|
|
||||||
// 同步用户偏好 - 防抖函数
|
|
||||||
const sync = useDebounceFn(updatePreference, 1500);
|
|
||||||
const previewTerminal = ref();
|
const previewTerminal = ref();
|
||||||
const formModel = ref<TerminalDisplaySetting>({});
|
const formModel = ref<TerminalDisplaySetting>({ ...preference.displaySetting });
|
||||||
|
|
||||||
// 监听主题变化
|
// 监听主题变化 动态修改预览样式
|
||||||
watch(() => preference.themeSchema, (v) => {
|
watch(() => preference.themeSchema, (v) => {
|
||||||
if (!v) {
|
if (!v) {
|
||||||
return;
|
return;
|
||||||
@@ -129,7 +126,7 @@
|
|||||||
if (!options) {
|
if (!options) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// 修改配置
|
// 修改预览终端配置
|
||||||
Object.keys(v).forEach(key => {
|
Object.keys(v).forEach(key => {
|
||||||
if (key === 'fontFamily') {
|
if (key === 'fontFamily') {
|
||||||
options[key] = (formModel.value as any)[key] + fontFamilySuffix;
|
options[key] = (formModel.value as any)[key] + fontFamilySuffix;
|
||||||
@@ -137,19 +134,12 @@
|
|||||||
options[key] = (formModel.value as any)[key];
|
options[key] = (formModel.value as any)[key];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
preference.displaySetting = formModel.value;
|
|
||||||
// 同步
|
// 同步
|
||||||
sync();
|
changeDisplaySetting(formModel.value);
|
||||||
// 聚焦
|
// 聚焦
|
||||||
previewTerminal.value.term.focus();
|
previewTerminal.value.term.focus();
|
||||||
}, { deep: true });
|
}, { deep: true });
|
||||||
|
|
||||||
// 设置默认配置
|
|
||||||
onMounted(() => {
|
|
||||||
// 触发 watch 函数
|
|
||||||
formModel.value = { ...preference.displaySetting };
|
|
||||||
});
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="less" scoped>
|
<style lang="less" scoped>
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
class="usn"
|
class="usn"
|
||||||
size="mini"
|
size="mini"
|
||||||
type="button"
|
type="button"
|
||||||
@change="checkDarkTheme"
|
@change="changeDarkTheme"
|
||||||
:options="toOptions(darkThemeKey)">
|
:options="toOptions(darkThemeKey)">
|
||||||
</a-radio-group>
|
</a-radio-group>
|
||||||
</div>
|
</div>
|
||||||
@@ -34,7 +34,7 @@
|
|||||||
color: theme.dark ? 'rgba(255, 255, 255, .8)' : 'rgba(0, 0, 0, .8)',
|
color: theme.dark ? 'rgba(255, 255, 255, .8)' : 'rgba(0, 0, 0, .8)',
|
||||||
userSelect: 'none'
|
userSelect: 'none'
|
||||||
}"
|
}"
|
||||||
@click="checkTheme(theme)">
|
@click="changeThemeSchema(theme)">
|
||||||
<!-- 样例 -->
|
<!-- 样例 -->
|
||||||
<terminal-example :theme="{ ...theme, cursor: theme.background }" />
|
<terminal-example :theme="{ ...theme, cursor: theme.background }" />
|
||||||
<!-- 选中按钮 -->
|
<!-- 选中按钮 -->
|
||||||
@@ -53,48 +53,14 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import type { TerminalThemeSchema } from '@/store/modules/terminal/types';
|
|
||||||
import { darkThemeKey } from '../../types/terminal.const';
|
import { darkThemeKey } from '../../types/terminal.const';
|
||||||
import ThemeSchema from '../../types/terminal.theme';
|
import ThemeSchema from '../../types/terminal.theme';
|
||||||
import { useDebounceFn } from '@vueuse/core';
|
|
||||||
import { useDictStore, useTerminalStore } from '@/store';
|
import { useDictStore, useTerminalStore } from '@/store';
|
||||||
import { DarkTheme } from '@/store/modules/terminal';
|
|
||||||
import TerminalExample from './terminal-example.vue';
|
import TerminalExample from './terminal-example.vue';
|
||||||
|
|
||||||
const { updatePreference, changeDarkTheme, preference } = useTerminalStore();
|
const { changeThemeSchema, changeDarkTheme, preference } = useTerminalStore();
|
||||||
const { toOptions } = useDictStore();
|
const { toOptions } = useDictStore();
|
||||||
|
|
||||||
// 同步用户偏好 - 防抖函数
|
|
||||||
const sync = useDebounceFn(updatePreference, 1500);
|
|
||||||
|
|
||||||
// 修改暗色主题
|
|
||||||
const checkDarkTheme = (value: string) => {
|
|
||||||
preference.darkTheme = value;
|
|
||||||
if (value === DarkTheme.DARK) {
|
|
||||||
// 暗色
|
|
||||||
changeDarkTheme(true);
|
|
||||||
} else if (value === DarkTheme.LIGHT) {
|
|
||||||
// 亮色
|
|
||||||
changeDarkTheme(false);
|
|
||||||
} else if (value === DarkTheme.AUTO) {
|
|
||||||
// 自动配色
|
|
||||||
changeDarkTheme(preference.themeSchema.dark);
|
|
||||||
}
|
|
||||||
// 同步用户偏好
|
|
||||||
sync();
|
|
||||||
};
|
|
||||||
|
|
||||||
// 选择终端主题
|
|
||||||
const checkTheme = (theme: TerminalThemeSchema) => {
|
|
||||||
preference.themeSchema = theme;
|
|
||||||
// 切换主题配色
|
|
||||||
if (preference.darkTheme === DarkTheme.AUTO) {
|
|
||||||
changeDarkTheme(theme.dark);
|
|
||||||
}
|
|
||||||
// 同步用户偏好
|
|
||||||
sync();
|
|
||||||
};
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="less" scoped>
|
<style lang="less" scoped>
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ INSERT INTO `dict_value` VALUES (8, 6, 'systemMenuVisible', '0', '隐藏', '{\"c
|
|||||||
INSERT INTO `dict_value` VALUES (9, 6, 'systemMenuVisible', '1', '显示', '{\"color\": \"blue\"}', 20, '2023-10-27 00:25:30', '2023-10-27 00:25:58', '1', '1', 0);
|
INSERT INTO `dict_value` VALUES (9, 6, 'systemMenuVisible', '1', '显示', '{\"color\": \"blue\"}', 20, '2023-10-27 00:25:30', '2023-10-27 00:25:58', '1', '1', 0);
|
||||||
INSERT INTO `dict_value` VALUES (10, 7, 'systemMenuCache', '0', '不缓存', '{}', 10, '2023-10-27 00:26:15', '2023-10-27 00:26:15', '1', '1', 0);
|
INSERT INTO `dict_value` VALUES (10, 7, 'systemMenuCache', '0', '不缓存', '{}', 10, '2023-10-27 00:26:15', '2023-10-27 00:26:15', '1', '1', 0);
|
||||||
INSERT INTO `dict_value` VALUES (11, 7, 'systemMenuCache', '1', '缓存', '{}', 20, '2023-10-27 00:26:25', '2023-10-27 00:26:25', '1', '1', 0);
|
INSERT INTO `dict_value` VALUES (11, 7, 'systemMenuCache', '1', '缓存', '{}', 20, '2023-10-27 00:26:25', '2023-10-27 00:26:25', '1', '1', 0);
|
||||||
INSERT INTO `dict_value` VALUES (12, 8, 'dictValueType', 'STRING', '字符串', '{\"color\": \"blue\"}', 10, '2023-10-27 01:49:18', '2023-10-27 01:49:18', '1', '1', 0);
|
INSERT INTO `dict_value` VALUES (12, 8, 'dictValueType', 'STRING', '字符串', '{\"color\": \"arcoblue\"}', 10, '2023-10-27 01:49:18', '2023-10-27 01:49:18', '1', '1', 0);
|
||||||
INSERT INTO `dict_value` VALUES (13, 8, 'dictValueType', 'INTEGER', '整数', '{\"color\": \"arcoblue\"}', 20, '2023-10-27 01:54:30', '2023-10-27 01:54:30', '1', '1', 0);
|
INSERT INTO `dict_value` VALUES (13, 8, 'dictValueType', 'INTEGER', '整数', '{\"color\": \"arcoblue\"}', 20, '2023-10-27 01:54:30', '2023-10-27 01:54:30', '1', '1', 0);
|
||||||
INSERT INTO `dict_value` VALUES (14, 8, 'dictValueType', 'DECIMAL', '小数', '{\"color\": \"purple\"}', 30, '2023-10-27 01:54:43', '2023-10-27 01:54:43', '1', '1', 0);
|
INSERT INTO `dict_value` VALUES (14, 8, 'dictValueType', 'DECIMAL', '小数', '{\"color\": \"purple\"}', 30, '2023-10-27 01:54:43', '2023-10-27 01:54:43', '1', '1', 0);
|
||||||
INSERT INTO `dict_value` VALUES (15, 8, 'dictValueType', 'BOOLEAN', '布尔值', '{\"color\": \"pinkpurple\"}', 40, '2023-10-27 01:54:54', '2023-10-27 01:54:54', '1', '1', 0);
|
INSERT INTO `dict_value` VALUES (15, 8, 'dictValueType', 'BOOLEAN', '布尔值', '{\"color\": \"pinkpurple\"}', 40, '2023-10-27 01:54:54', '2023-10-27 01:54:54', '1', '1', 0);
|
||||||
|
|||||||
@@ -17,3 +17,8 @@ ADD COLUMN `update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TI
|
|||||||
ADD COLUMN `creator` varchar(64) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '创建人' AFTER update_time,
|
ADD COLUMN `creator` varchar(64) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '创建人' AFTER update_time,
|
||||||
ADD COLUMN `updater` varchar(64) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '更新人' AFTER creator,
|
ADD COLUMN `updater` varchar(64) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '更新人' AFTER creator,
|
||||||
ADD COLUMN `deleted` tinyint(1) DEFAULT '0' COMMENT '是否删除 0未删除 1已删除' AFTER updater;
|
ADD COLUMN `deleted` tinyint(1) DEFAULT '0' COMMENT '是否删除 0未删除 1已删除' AFTER updater;
|
||||||
|
|
||||||
|
-- 删除已删除的元数据
|
||||||
|
DELETE FROM dict_key WHERE deleted = 1;
|
||||||
|
DELETE FROM dict_value WHERE deleted = 1;
|
||||||
|
DELETE FROM system_menu WHERE deleted = 1;
|
||||||
|
|||||||
Reference in New Issue
Block a user