🎨 修改代码规范.

This commit is contained in:
lijiahang
2024-12-26 13:51:41 +08:00
parent 9017ada3aa
commit 00ea709f9e
19 changed files with 115 additions and 89 deletions

View File

@@ -9,7 +9,8 @@
<a-link target="_blank" :href="`https://github.com/dromara/orion-visor/releases/tag/v${version}`">v{{ version }}</a-link>
</a-space>
<span class="copyright">
Copyright<icon-copyright /> 2023 - {{ new Date().getFullYear() }} Jiahang Li, All rights reserved.
Copyright<icon-copyright /> 2023 - {{ new Date().getFullYear() }} <a href="https://dromara.org">Dromara</a>, All rights reserved. Designed by
<a href="https://orionsec.cn" target="_blank">Jiahang Li.</a>
</span>
</a-space>
</a-layout-footer>

View File

@@ -22,7 +22,13 @@
</td>
<!-- 子菜单 -->
<td>
<a-checkbox :value="childrenMenu.id">
<!-- 默认路由 -->
<a-checkbox v-if="childrenMenu.component === DEFAULT_ROUTE_NAME"
:value="childrenMenu.id">
{{ childrenMenu.name }} <span class="span-red">(必选)</span>
</a-checkbox>
<!-- 普通子菜单 -->
<a-checkbox v-else :value="childrenMenu.id">
{{ childrenMenu.name }}
</a-checkbox>
</td>
@@ -73,6 +79,7 @@
import type { MenuQueryResponse } from '@/api/system/menu';
import { useCacheStore } from '@/store';
import { ref, watch } from 'vue';
import { DEFAULT_ROUTE_NAME } from '@/router/constants';
import { findNode, flatNodeKeys, flatNodes } from '@/utils/tree';
const cacheStore = useCacheStore();

View File

@@ -39,7 +39,11 @@
return props.modelValue;
},
set(e) {
emits('update:modelValue', e);
if (e) {
emits('update:modelValue', e);
} else {
emits('update:modelValue', null);
}
}
});

View File

@@ -40,7 +40,15 @@
return props.modelValue;
},
set(e) {
emits('update:modelValue', e);
if (e) {
emits('update:modelValue', e);
} else {
if (props.multiple) {
emits('update:modelValue', []);
} else {
emits('update:modelValue', null);
}
}
}
});
const optionData = ref<Array<SelectOptionData>>([]);

View File

@@ -39,7 +39,15 @@
return props.modelValue;
},
set(e) {
emits('update:modelValue', e);
if (e) {
emits('update:modelValue', e);
} else {
if (props.multiple) {
emits('update:modelValue', []);
} else {
emits('update:modelValue', null);
}
}
}
});
const optionData = ref<Array<SelectOptionData>>([]);

View File

@@ -43,7 +43,7 @@
// 跳转到指定页
onBeforeMount(() => {
const key = route.query.key;
const key = route.query.key as string;
if (key) {
activeKey.value = Number(key);
}

View File

@@ -30,12 +30,12 @@
// 跳转日志
onMounted(async () => {
const idParam = route.query.id;
const keyParam = route.query.key;
const idParam = route.query.id as string;
const keyParam = route.query.key as string;
if (idParam) {
await panel.value?.openLog(Number.parseInt(idParam as string));
await panel.value?.openLog(Number.parseInt(idParam));
} else if (keyParam) {
await panel.value?.openLog(Number.parseInt(keyParam as string));
await panel.value?.openLog(Number.parseInt(keyParam));
}
});

View File

@@ -3,7 +3,7 @@
<a-table row-key="id"
ref="tableRef"
:loading="loading"
:columns="columns"
:columns="hostColumns"
:data="row.hosts"
:expandable="expandable"
:scroll="{ y: '100%' }"
@@ -105,7 +105,7 @@
import { deleteExecCommandHostLog } from '@/api/exec/exec-command-log';
import { Message } from '@arco-design/web-vue';
import useLoading from '@/hooks/loading';
import columns from '../types/host-table.columns';
import { hostColumns } from '../types/table.columns';
import { execHostStatusKey, ExecHostStatus } from '@/components/exec/log/const';
import { useDictStore } from '@/store';
import { useExpandable } from '@/hooks/table';

View File

@@ -102,7 +102,7 @@
row-key="id"
ref="tableRef"
:loading="loading"
:columns="columns"
:columns="tableColumns"
:row-selection="rowSelection"
:expandable="expandable"
:data="tableRenderData"
@@ -218,7 +218,7 @@
} from '@/api/exec/exec-command-log';
import { Message } from '@arco-design/web-vue';
import useLoading from '@/hooks/loading';
import columns from '../types/table.columns';
import { tableColumns } from '../types/table.columns';
import { ExecStatus, execStatusKey } from '@/components/exec/log/const';
import { useExpandable, useTablePagination, useRowSelection } from '@/hooks/table';
import { useDictStore } from '@/store';

View File

@@ -1,57 +0,0 @@
import type { TableColumnData } from '@arco-design/web-vue/es/table/interface';
import { isNumber } from '@/utils/is';
const columns = [
{
title: 'id',
dataIndex: 'id',
slotName: 'id',
width: 100,
align: 'left',
fixed: 'left',
}, {
title: '执行主机',
dataIndex: 'hostName',
slotName: 'hostName',
align: 'left',
ellipsis: true,
tooltip: true,
}, {
title: '退出码',
dataIndex: 'exitCode',
slotName: 'exitCode',
align: 'left',
width: 118,
render: ({ record }) => {
return isNumber(record.exitCode) ? record.exitCode : '-';
},
}, {
title: '执行状态',
dataIndex: 'status',
slotName: 'status',
align: 'left',
width: 118,
}, {
title: '错误信息',
dataIndex: 'errorMessage',
slotName: 'errorMessage',
align: 'left',
ellipsis: true,
tooltip: true,
width: 168,
}, {
title: '执行时间',
dataIndex: 'startTime',
slotName: 'startTime',
align: 'left',
width: 190,
}, {
title: '操作',
slotName: 'handle',
width: 258,
align: 'center',
fixed: 'right',
},
] as TableColumnData[];
export default columns;

View File

@@ -1,6 +1,8 @@
import type { TableColumnData } from '@arco-design/web-vue/es/table/interface';
import { isNumber } from '@/utils/is';
const columns = [
// 表格列
export const tableColumns = [
{
title: 'id',
dataIndex: 'id',
@@ -51,4 +53,56 @@ const columns = [
},
] as TableColumnData[];
export default columns;
// 主机列
export const hostColumns = [
{
title: 'id',
dataIndex: 'id',
slotName: 'id',
width: 100,
align: 'left',
fixed: 'left',
}, {
title: '执行主机',
dataIndex: 'hostName',
slotName: 'hostName',
align: 'left',
ellipsis: true,
tooltip: true,
}, {
title: '退出码',
dataIndex: 'exitCode',
slotName: 'exitCode',
align: 'left',
width: 118,
render: ({ record }) => {
return isNumber(record.exitCode) ? record.exitCode : '-';
},
}, {
title: '执行状态',
dataIndex: 'status',
slotName: 'status',
align: 'left',
width: 118,
}, {
title: '错误信息',
dataIndex: 'errorMessage',
slotName: 'errorMessage',
align: 'left',
ellipsis: true,
tooltip: true,
width: 168,
}, {
title: '执行时间',
dataIndex: 'startTime',
slotName: 'startTime',
align: 'left',
width: 190,
}, {
title: '操作',
slotName: 'handle',
width: 258,
align: 'center',
fixed: 'right',
},
] as TableColumnData[];

View File

@@ -60,12 +60,12 @@
// 跳转日志
onMounted(async () => {
const idParam = route.query.id;
const keyParam = route.query.key;
const idParam = route.query.id as string;
const keyParam = route.query.key as string;
if (idParam) {
await openLogWithId(Number.parseInt(idParam as string));
await openLogWithId(Number.parseInt(idParam));
} else if (keyParam) {
await openLogWithId(Number.parseInt(keyParam as string));
await openLogWithId(Number.parseInt(keyParam));
}
});

View File

@@ -36,9 +36,9 @@
};
onMounted(() => {
const idParam = route.query.id;
const idParam = route.query.id as string;
if (idParam) {
init(Number.parseInt(idParam as string));
init(Number.parseInt(idParam));
}
});

View File

@@ -3,7 +3,7 @@
<a-table row-key="id"
ref="tableRef"
:loading="loading"
:columns="columns"
:columns="hostColumns"
:data="row.hosts"
:expandable="expandable"
:scroll="{ y: '100%' }"
@@ -106,7 +106,7 @@
import { execHostStatusKey, ExecHostStatus } from '@/components/exec/log/const';
import { useDictStore } from '@/store';
import useLoading from '@/hooks/loading';
import columns from '@/views/exec/exec-command-log/types/host-table.columns';
import { hostColumns } from '@/views/exec/exec-command-log/types/table.columns';
import { useExpandable } from '@/hooks/table';
import { dateFormat, formatDuration } from '@/utils';
import { downloadExecJobLogFile } from '@/api/exec/exec-job-log';

View File

@@ -138,7 +138,7 @@
onBeforeMount(() => {
// 打开默认 tab
let openTab;
const tab = route.query.tab;
const tab = route.query.tab as string;
if (tab) {
openTab = Object.values(TerminalTabs).find(s => s.key === tab);
}
@@ -167,9 +167,9 @@
// 加载主机
await loadHosts();
// 默认连接主机
const connect = route.query.connect;
const connect = route.query.connect as string;
if (connect) {
const connectHostId = Number.parseInt(connect as string);
const connectHostId = Number.parseInt(connect);
const connectHost = hosts.hostList.find(s => s.id === connectHostId);
// 打开连接
if (connectHost) {

View File

@@ -35,9 +35,9 @@
// 跳转到指定页
onBeforeMount(() => {
const key = route.query.key;
const key = route.query.key as string;
if (key) {
activeKey.value = key as string;
activeKey.value = key;
}
});