重构代码.
This commit is contained in:
@@ -70,7 +70,7 @@
|
||||
v-model:selectedKeys="selectedKeys"
|
||||
:row-selection="rowSelection"
|
||||
:data="tableRenderData"
|
||||
:pagination="pagination"
|
||||
:pagination="pagination as PaginationProps"
|
||||
@page-change="(page) => fetchTableData(page, pagination.pageSize)"
|
||||
@page-size-change="(size) => fetchTableData(pagination.current, size)"
|
||||
:bordered="false">
|
||||
@@ -111,7 +111,7 @@
|
||||
<script lang="ts" setup>
|
||||
import { reactive, ref } from 'vue';
|
||||
import { batchDelete${vue.featureEntity}, delete${vue.featureEntity}, get${vue.featureEntity}Page, ${vue.featureEntity}QueryRequest, ${vue.featureEntity}QueryResponse } from '@/api/${vue.module}/${vue.feature}';
|
||||
import { Message } from '@arco-design/web-vue';
|
||||
import { Message, PaginationProps } from '@arco-design/web-vue';
|
||||
import useLoading from '@/hooks/loading';
|
||||
import columns from '../types/table.columns';
|
||||
import { defaultPagination, defaultRowSelection } from '@/types/table';
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import axios from 'axios';
|
||||
import { UserState } from '@/store/modules/user/types';
|
||||
|
||||
/**
|
||||
* 登陆请求
|
||||
|
||||
@@ -22,9 +22,9 @@
|
||||
|
||||
const emits = defineEmits(['update:modelValue']);
|
||||
|
||||
const value = computed({
|
||||
const value = computed<number>({
|
||||
get() {
|
||||
return props.modelValue;
|
||||
return props.modelValue as number;
|
||||
},
|
||||
set(e) {
|
||||
if (e) {
|
||||
|
||||
@@ -22,9 +22,9 @@
|
||||
|
||||
const emits = defineEmits(['update:modelValue']);
|
||||
|
||||
const value = computed({
|
||||
const value = computed<number>({
|
||||
get() {
|
||||
return props.modelValue;
|
||||
return props.modelValue as number;
|
||||
},
|
||||
set(e) {
|
||||
if (e) {
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
v-if="type === 'number'"
|
||||
:style="{ width: '80px' }"
|
||||
size="small"
|
||||
:default-value="defaultValue"
|
||||
:default-value="defaultValue as number"
|
||||
@change="handleChange"
|
||||
/>
|
||||
<a-switch
|
||||
|
||||
@@ -82,7 +82,7 @@
|
||||
async function readMessage(data: MessageListType) {
|
||||
const ids = data.map((item) => item.id);
|
||||
await setMessageStatus({ ids });
|
||||
fetchSourceData();
|
||||
await fetchSourceData();
|
||||
}
|
||||
|
||||
const renderList = computed(() => {
|
||||
@@ -101,6 +101,7 @@
|
||||
};
|
||||
const formatUnreadLength = (type: string) => {
|
||||
const list = getUnreadList(type);
|
||||
// FIXME
|
||||
return list.length ? `(${list.length})` : ``;
|
||||
};
|
||||
const handleItemClick = (items: MessageListType) => {
|
||||
|
||||
@@ -5,14 +5,14 @@
|
||||
@select="actionSelect">
|
||||
<span
|
||||
class="arco-tag arco-tag-size-medium arco-tag-checked"
|
||||
:class="{ 'link-activated': itemData.fullPath === $route.fullPath }"
|
||||
@click="goto(itemData)">
|
||||
:class="{ 'link-activated': itemData?.fullPath === $route.fullPath }"
|
||||
@click="goto(itemData as TagProps)">
|
||||
<span class="tag-link">
|
||||
{{ itemData.title }}
|
||||
</span>
|
||||
<span
|
||||
class="arco-icon-hover arco-tag-icon-hover arco-icon-hover-size-medium arco-tag-close-btn"
|
||||
@click.stop="tagClose(itemData, index)">
|
||||
@click.stop="tagClose(itemData as TagProps, index)">
|
||||
<icon-close />
|
||||
</span>
|
||||
</span>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<a-select v-model:model-value="value"
|
||||
:placeholder="placeholder"
|
||||
:options="optionData"
|
||||
:limit=limit
|
||||
:limit="limit as number"
|
||||
@exceed-limit="onLimited"
|
||||
multiple
|
||||
:allow-create="allowCreate"
|
||||
@@ -17,13 +17,13 @@
|
||||
</script>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, computed } from 'vue';
|
||||
import { ref, computed, PropType } from 'vue';
|
||||
import { useCacheStore } from '@/store';
|
||||
import { Message, SelectOptionData } from '@arco-design/web-vue';
|
||||
import { createTag, TagCreateRequest, TagType } from '@/api/meta/tag';
|
||||
import { createTag, TagCreateRequest } from '@/api/meta/tag';
|
||||
|
||||
const props = defineProps({
|
||||
modelValue: Array,
|
||||
modelValue: Array as PropType<Array<number>>,
|
||||
placeholder: String,
|
||||
limit: Number,
|
||||
type: String,
|
||||
@@ -32,9 +32,9 @@
|
||||
|
||||
const emits = defineEmits(['update:modelValue']);
|
||||
|
||||
const value = computed({
|
||||
const value = computed<Array<number>>({
|
||||
get() {
|
||||
return props.modelValue;
|
||||
return props.modelValue as Array<number>;
|
||||
},
|
||||
async set(e) {
|
||||
await checkCreateTag(e as Array<any>);
|
||||
@@ -103,7 +103,7 @@
|
||||
|
||||
// 超出限制
|
||||
const onLimited = () => {
|
||||
Message.warning(`最多选择${props.limit}个tag`);
|
||||
Message.warning(`最多选择${ props.limit }个tag`);
|
||||
};
|
||||
|
||||
</script>
|
||||
|
||||
@@ -3,15 +3,15 @@ import { Message } from '@arco-design/web-vue';
|
||||
|
||||
export default function useCopy() {
|
||||
const { isSupported, copy: c, text, copied } = useClipboard();
|
||||
const copy = (value: string, tips = `${value} 已复制`) => {
|
||||
return c(value)
|
||||
.then(() => {
|
||||
const copy = async (value: string, tips = `${ value } 已复制`) => {
|
||||
try {
|
||||
await c(value);
|
||||
if (tips) {
|
||||
Message.success(tips);
|
||||
}
|
||||
}).catch(() => {
|
||||
} catch {
|
||||
Message.error('复制失败');
|
||||
});
|
||||
}
|
||||
};
|
||||
return {
|
||||
isSupported,
|
||||
|
||||
@@ -53,7 +53,7 @@
|
||||
:loading="loading"
|
||||
:columns="columns"
|
||||
:data="tableRenderData"
|
||||
:pagination="pagination"
|
||||
:pagination="pagination as PaginationProps"
|
||||
@page-change="(page) => fetchTableData(page, pagination.pageSize)"
|
||||
@page-size-change="(size) => fetchTableData(pagination.current, size)"
|
||||
:bordered="false">
|
||||
@@ -120,7 +120,7 @@
|
||||
<script lang="ts" setup>
|
||||
import { reactive, ref } from 'vue';
|
||||
import { deleteHostIdentity, getHostIdentityPage, HostIdentityQueryRequest, HostIdentityQueryResponse } from '@/api/asset/host-identity';
|
||||
import { Message } from '@arco-design/web-vue';
|
||||
import { Message, PaginationProps } from '@arco-design/web-vue';
|
||||
import useLoading from '@/hooks/loading';
|
||||
import columns from '../types/table.columns';
|
||||
import { defaultPagination } from '@/types/table';
|
||||
@@ -135,7 +135,7 @@
|
||||
|
||||
const tableRenderData = ref<HostIdentityQueryResponse[]>([]);
|
||||
const { loading, setLoading } = useLoading();
|
||||
const emits = defineEmits(['openAdd', 'openUpdate', 'openViewKey']);
|
||||
const emits = defineEmits(['openAdd', 'openUpdate', 'openKeyView']);
|
||||
|
||||
const cacheStore = useCacheStore();
|
||||
const pagination = reactive(defaultPagination());
|
||||
|
||||
@@ -173,12 +173,14 @@
|
||||
|
||||
// 选择公钥文件
|
||||
const selectPublicFile = async (fileList: FileItem[]) => {
|
||||
// FIXME
|
||||
formModel.publicKey = await readFileText(fileList[0].file as File);
|
||||
formRef.value.clearValidate('publicKey');
|
||||
};
|
||||
|
||||
// 选择私钥文件
|
||||
const selectPrivateFile = async (fileList: FileItem[]) => {
|
||||
// FIXME
|
||||
formModel.privateKey = await readFileText(fileList[0].file as File);
|
||||
formRef.value.clearValidate('privateKey');
|
||||
};
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
:loading="loading"
|
||||
:columns="columns"
|
||||
:data="tableRenderData"
|
||||
:pagination="pagination"
|
||||
:pagination="pagination as PaginationProps"
|
||||
@page-change="(page) => fetchTableData(page, pagination.pageSize)"
|
||||
@page-size-change="(size) => fetchTableData(pagination.current, size)"
|
||||
:bordered="false">
|
||||
@@ -93,7 +93,7 @@
|
||||
<script lang="ts" setup>
|
||||
import { reactive, ref } from 'vue';
|
||||
import { deleteHostKey, getHostKeyPage, HostKeyQueryRequest, HostKeyQueryResponse } from '@/api/asset/host-key';
|
||||
import { Message } from '@arco-design/web-vue';
|
||||
import { Message, PaginationProps } from '@arco-design/web-vue';
|
||||
import useLoading from '@/hooks/loading';
|
||||
import columns from '../types/table.columns';
|
||||
import { defaultPagination } from '@/types/table';
|
||||
|
||||
@@ -44,7 +44,9 @@
|
||||
const cacheStore = useCacheStore();
|
||||
|
||||
const record = ref();
|
||||
const config = ref<Record<string, any>>({});
|
||||
const config = ref<Record<string, any>>({
|
||||
SSH: undefined
|
||||
});
|
||||
|
||||
// 打开
|
||||
const open = async (e: any) => {
|
||||
@@ -58,6 +60,7 @@
|
||||
config.value[s.type] = s;
|
||||
});
|
||||
} catch ({ message }) {
|
||||
// FIXME
|
||||
Message.error(`配置加载失败 ${message}`);
|
||||
setVisible(false);
|
||||
} finally {
|
||||
|
||||
@@ -54,6 +54,7 @@
|
||||
label="主机密码"
|
||||
:rules="passwordRules"
|
||||
label-col-flex="60px">
|
||||
<!-- FIXME -->
|
||||
<a-input-password v-model="formModel.password"
|
||||
:disabled="!formModel.useNewPassword && formModel.hasPassword"
|
||||
placeholder="主机密码" />
|
||||
|
||||
@@ -74,7 +74,7 @@
|
||||
:loading="loading"
|
||||
:columns="columns"
|
||||
:data="tableRenderData"
|
||||
:pagination="pagination"
|
||||
:pagination="pagination as PaginationProps"
|
||||
@page-change="(page) => fetchTableData(page, pagination.pageSize)"
|
||||
@page-size-change="(size) => fetchTableData(pagination.current, size)"
|
||||
:bordered="false">
|
||||
|
||||
@@ -30,4 +30,6 @@ export interface HostSshConfig {
|
||||
charset?: string;
|
||||
fileNameCharset?: string;
|
||||
fileContentCharset?: string;
|
||||
useNewPassword?: boolean;
|
||||
hasPassword?: boolean;
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
const userStore = useUserStore();
|
||||
const userInfo = computed(() => {
|
||||
return {
|
||||
name: userStore.name,
|
||||
name: userStore.nickname,
|
||||
};
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
<a-form-item v-if="formModel.type !== MenuTypeEnum.FUNCTION.value"
|
||||
field="icon"
|
||||
label="菜单图标">
|
||||
<icon-picker v-model:icon="formModel.icon">
|
||||
<icon-picker v-model:icon="formModel.icon as string">
|
||||
<template #iconSelect>
|
||||
<a-input v-model="formModel.icon" placeholder="请选择菜单图标" />
|
||||
</template>
|
||||
|
||||
@@ -88,7 +88,9 @@
|
||||
// 渲染对象
|
||||
const renderRecord = (record: any) => {
|
||||
Object.keys(roleRecord).forEach(k => {
|
||||
roleRecord[k] = record[k];
|
||||
if (record.hasOwnProperty(k)) {
|
||||
roleRecord[k] = record[k];
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@
|
||||
:loading="loading"
|
||||
:columns="columns"
|
||||
:data="tableRenderData"
|
||||
:pagination="pagination"
|
||||
:pagination="pagination as PaginationProps"
|
||||
@page-change="(page) => fetchTableData(page, pagination.pageSize)"
|
||||
@page-size-change="(size) => fetchTableData(pagination.current, size)"
|
||||
:bordered="false">
|
||||
@@ -125,7 +125,7 @@
|
||||
<script lang="ts" setup>
|
||||
import { reactive, ref } from 'vue';
|
||||
import { deleteRole, getRolePage, updateRoleStatus, RoleQueryRequest, RoleQueryResponse } from '@/api/user/role';
|
||||
import { Message } from '@arco-design/web-vue';
|
||||
import { Message, PaginationProps } from '@arco-design/web-vue';
|
||||
import useLoading from '@/hooks/loading';
|
||||
import columns from '../types/table.columns';
|
||||
import { RoleStatusEnum } from '../types/enum.types';
|
||||
|
||||
@@ -66,7 +66,7 @@
|
||||
:loading="loading"
|
||||
:columns="columns"
|
||||
:data="tableRenderData"
|
||||
:pagination="pagination"
|
||||
:pagination="pagination as PaginationProps"
|
||||
@page-change="(page) => fetchTableData(page, pagination.pageSize)"
|
||||
@page-size-change="(size) => fetchTableData(pagination.current, size)"
|
||||
:bordered="false">
|
||||
@@ -146,7 +146,7 @@
|
||||
<script lang="ts" setup>
|
||||
import { reactive, ref } from 'vue';
|
||||
import { deleteUser, getUserPage, updateUserStatus, UserQueryRequest, UserQueryResponse } from '@/api/user/user';
|
||||
import { Message } from '@arco-design/web-vue';
|
||||
import { Message, PaginationProps } from '@arco-design/web-vue';
|
||||
import useLoading from '@/hooks/loading';
|
||||
import columns from '../types/table.columns';
|
||||
import { UserStatusEnum } from '../types/enum.types';
|
||||
|
||||
Reference in New Issue
Block a user