Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(frontend): webconsole输入面板组件逻辑优化 #7764 #7947

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 14 additions & 12 deletions dbm-ui/frontend/src/views/db-manage/common/webconsole/Index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@
@remove-tab="handleClickClearScreen" />
<RawSwitcher
v-if="dbType === DBTypes.REDIS"
v-model="isRaw"
:db-type="dbType" />
v-model="isRaw" />
<ClearScreen @change="handleClickClearScreen" />
<ExportData @export="handleClickExport" />
<UsageHelp
Expand All @@ -30,12 +29,12 @@
</div>
<div class="content-main">
<KeepAlive>
<ConsolePanel
<Component
:is="consolePanelMap[dbType]"
v-if="clusterInfo"
:key="clusterInfo.id"
ref="consolePanelRef"
v-model="clusterInfo"
:db-type="dbType"
:cluster="clusterInfo"
:raw="isRaw"
:style="currentFontConfig" />
</KeepAlive>
Expand All @@ -59,13 +58,12 @@
import screenfull from 'screenfull';
import { useI18n } from 'vue-i18n';

import { queryAllTypeCluster } from '@services/source/dbbase';

import { DBTypes } from '@common/const';

import ClearScreen from './components/ClearScreen.vue';
import ClusterTabs from './components/ClusterTabs.vue';
import ConsolePanel from './components/console-panel/Index.vue';
import ClusterTabs, { type ClusterItem } from './components/ClusterTabs.vue';
import MysqlConsolePanel from './components/console-panel/mysql/Index.vue';
import RedisConsolePanel from './components/console-panel/redis/Index.vue';
import ExportData from './components/ExportData.vue';
import FontSetting from './components/FontSetting.vue';
import FullScreen from './components/FullScreen.vue';
Expand All @@ -76,17 +74,21 @@
dbType?: DBTypes;
}

type ClusterItem = ServiceReturnType<typeof queryAllTypeCluster>[number];

const props = withDefaults(defineProps<Props>(), {
dbType: DBTypes.MYSQL,
});

const { t } = useI18n();

const consolePanelMap = {
[DBTypes.MYSQL]: MysqlConsolePanel,
[DBTypes.TENDBCLUSTER]: MysqlConsolePanel,
[DBTypes.REDIS]: RedisConsolePanel,
} as Record<DBTypes, any>;

const rootRef = ref();
const clusterTabsRef = ref();
const consolePanelRef = ref<InstanceType<typeof ConsolePanel>>();
const consolePanelRef = ref<InstanceType<typeof MysqlConsolePanel>>();
const clusterInfo = ref<ClusterItem>();
const currentFontConfig = ref({
fontSize: '12px',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
import { messageWarn } from '@utils';
type ClusterItem = ServiceReturnType<typeof queryAllTypeCluster>[number];
export type ClusterItem = ServiceReturnType<typeof queryAllTypeCluster>[number];
interface Props {
dbType: DBTypes;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,14 @@
<script lang="ts" setup>
import { useI18n } from 'vue-i18n';

import { DBTypes } from '@common/const';

interface Props {
dbType: DBTypes;
}

const props = defineProps<Props>();

const { t } = useI18n();

const modelValue = defineModel<boolean | undefined>({
default: undefined,
});

const handleRawSwitch = (value: boolean) => {
modelValue.value = props.dbType === DBTypes.REDIS ? value : undefined;
modelValue.value = value;
};
</script>

Expand Down
Loading
Loading