⚡ 优化缓存策略.
This commit is contained in:
@@ -170,8 +170,8 @@
|
||||
// 调用删除接口
|
||||
await delete${vue.featureEntity}(id);
|
||||
Message.success('删除成功');
|
||||
// 重新加载数据
|
||||
fetchCardData();
|
||||
// 重新加载
|
||||
reload();
|
||||
} catch (e) {
|
||||
} finally {
|
||||
setLoading(false);
|
||||
@@ -182,6 +182,7 @@
|
||||
|
||||
// 重新加载
|
||||
const reload = () => {
|
||||
// 重新加载数据
|
||||
fetchCardData();
|
||||
};
|
||||
|
||||
|
||||
@@ -189,8 +189,8 @@
|
||||
await batchDelete${vue.featureEntity}(selectedKeys.value);
|
||||
Message.success(`成功删除 ${selectedKeys.value.length} 条数据`);
|
||||
selectedKeys.value = [];
|
||||
// 重新加载数据
|
||||
fetchTableData();
|
||||
// 重新加载
|
||||
reload();
|
||||
} catch (e) {
|
||||
} finally {
|
||||
setLoading(false);
|
||||
@@ -207,8 +207,8 @@
|
||||
// 调用删除接口
|
||||
await delete${vue.featureEntity}(id);
|
||||
Message.success('删除成功');
|
||||
// 重新加载数据
|
||||
fetchTableData();
|
||||
// 重新加载
|
||||
reload();
|
||||
} catch (e) {
|
||||
} finally {
|
||||
setLoading(false);
|
||||
@@ -217,6 +217,7 @@
|
||||
|
||||
// 重新加载
|
||||
const reload = () => {
|
||||
// 重新加载数据
|
||||
fetchTableData();
|
||||
};
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
<script lang="ts" setup>
|
||||
import type { TreeNodeData } from '@arco-design/web-vue';
|
||||
import { computed, onBeforeMount, ref } from 'vue';
|
||||
import { computed, onActivated, onMounted, ref } from 'vue';
|
||||
import { useCacheStore } from '@/store';
|
||||
import useLoading from '@/hooks/loading';
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
const treeData = ref<Array<TreeNodeData>>([]);
|
||||
|
||||
// 初始化选项
|
||||
onBeforeMount(async () => {
|
||||
const initOptions = async () => {
|
||||
setLoading(true);
|
||||
try {
|
||||
treeData.value = await cacheStore.loadHostGroups();
|
||||
@@ -52,7 +52,11 @@
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// 初始化选项
|
||||
onMounted(initOptions);
|
||||
onActivated(initOptions);
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
|
||||
<script lang="ts" setup>
|
||||
import type { SelectOptionData } from '@arco-design/web-vue';
|
||||
import { computed, onBeforeMount, ref } from 'vue';
|
||||
import { computed, onActivated, onMounted, ref } from 'vue';
|
||||
import { useCacheStore } from '@/store';
|
||||
import useLoading from '@/hooks/loading';
|
||||
|
||||
@@ -60,7 +60,7 @@
|
||||
const optionData = ref<Array<SelectOptionData>>([]);
|
||||
|
||||
// 初始化选项
|
||||
onBeforeMount(async () => {
|
||||
const initOptions = async () => {
|
||||
setLoading(true);
|
||||
try {
|
||||
const hostIdentities = props.authorized
|
||||
@@ -77,7 +77,11 @@
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// 初始化选项
|
||||
onMounted(initOptions);
|
||||
onActivated(initOptions);
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
<script lang="ts" setup>
|
||||
import type { SelectOptionData } from '@arco-design/web-vue';
|
||||
import { computed, onBeforeMount, ref } from 'vue';
|
||||
import { computed, onActivated, onMounted, ref } from 'vue';
|
||||
import { useCacheStore } from '@/store';
|
||||
import useLoading from '@/hooks/loading';
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
const optionData = ref<Array<SelectOptionData>>([]);
|
||||
|
||||
// 初始化选项
|
||||
onBeforeMount(async () => {
|
||||
const initOptions = async () => {
|
||||
setLoading(true);
|
||||
try {
|
||||
const hostKeys = props.authorized
|
||||
@@ -61,7 +61,12 @@
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// 初始化选项
|
||||
onMounted(initOptions);
|
||||
onActivated(initOptions);
|
||||
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
<script lang="ts" setup>
|
||||
import type { SelectOptionData } from '@arco-design/web-vue';
|
||||
import type { HostType } from '@/api/asset/host';
|
||||
import { computed, onBeforeMount, ref } from 'vue';
|
||||
import { computed, onActivated, onMounted, ref } from 'vue';
|
||||
import { useCacheStore } from '@/store';
|
||||
import useLoading from '@/hooks/loading';
|
||||
|
||||
@@ -51,7 +51,7 @@
|
||||
const optionData = ref<Array<SelectOptionData>>([]);
|
||||
|
||||
// 初始化选项
|
||||
onBeforeMount(async () => {
|
||||
const initOptions = async () => {
|
||||
setLoading(true);
|
||||
try {
|
||||
const hosts = await cacheStore.loadHosts(props.type);
|
||||
@@ -66,7 +66,11 @@
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// 初始化选项
|
||||
onMounted(initOptions);
|
||||
onActivated(initOptions);
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
<script lang="ts" setup>
|
||||
import type { SelectOptionData } from '@arco-design/web-vue';
|
||||
import { computed, onBeforeMount, ref } from 'vue';
|
||||
import { computed, onActivated, onMounted, ref } from 'vue';
|
||||
import { useCacheStore } from '@/store';
|
||||
import { labelFilter } from '@/types/form';
|
||||
import useLoading from '@/hooks/loading';
|
||||
@@ -57,7 +57,7 @@
|
||||
const optionData = ref<Array<SelectOptionData>>([]);
|
||||
|
||||
// 初始化选项
|
||||
onBeforeMount(async () => {
|
||||
const initOptions = async () => {
|
||||
setLoading(true);
|
||||
try {
|
||||
const dictKeys = await cacheStore.loadExecJobs();
|
||||
@@ -71,7 +71,11 @@
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// 初始化选项
|
||||
onMounted(initOptions);
|
||||
onActivated(initOptions);
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
<script lang="ts" setup>
|
||||
import type { SelectOptionData } from '@arco-design/web-vue';
|
||||
import type { TagCreateRequest } from '@/api/meta/tag';
|
||||
import { ref, computed, onBeforeMount } from 'vue';
|
||||
import { ref, computed, onMounted, onActivated } from 'vue';
|
||||
import { useCacheStore } from '@/store';
|
||||
import { dataColor } from '@/utils';
|
||||
import { createTag } from '@/api/meta/tag';
|
||||
@@ -113,7 +113,7 @@
|
||||
};
|
||||
|
||||
// 初始化选项
|
||||
onBeforeMount(async () => {
|
||||
const initOptions = async () => {
|
||||
setLoading(true);
|
||||
try {
|
||||
const tags = await cacheStore.loadTags(props.type as string);
|
||||
@@ -130,7 +130,11 @@
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// 初始化选项
|
||||
onMounted(initOptions);
|
||||
onActivated(initOptions);
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
<script lang="ts" setup>
|
||||
import type { SelectOptionData } from '@arco-design/web-vue';
|
||||
import { computed, onBeforeMount, ref } from 'vue';
|
||||
import { computed, onActivated, onMounted, ref } from 'vue';
|
||||
import { useCacheStore } from '@/store';
|
||||
import { labelFilter } from '@/types/form';
|
||||
import useLoading from '@/hooks/loading';
|
||||
@@ -59,7 +59,7 @@
|
||||
const optionData = ref<Array<SelectOptionData>>([]);
|
||||
|
||||
// 初始化选项
|
||||
onBeforeMount(async () => {
|
||||
const initOptions = async () => {
|
||||
setLoading(true);
|
||||
try {
|
||||
const dictKeys = await cacheStore.loadDictKeys();
|
||||
@@ -74,7 +74,11 @@
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// 初始化选项
|
||||
onMounted(initOptions);
|
||||
onActivated(initOptions);
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
<script lang="ts" setup>
|
||||
import type { TreeNodeData } from '@arco-design/web-vue';
|
||||
import { useCacheStore } from '@/store';
|
||||
import { computed, onBeforeMount, ref } from 'vue';
|
||||
import { computed, onActivated, onMounted, ref } from 'vue';
|
||||
import { MenuType } from '@/views/system/menu/types/const';
|
||||
import { titleFilter } from '@/types/form';
|
||||
import useLoading from '@/hooks/loading';
|
||||
@@ -47,7 +47,8 @@
|
||||
}
|
||||
});
|
||||
|
||||
onBeforeMount(async () => {
|
||||
// 初始化选项
|
||||
const initOptions = async () => {
|
||||
let render = (arr: any[]): TreeNodeData[] => {
|
||||
return arr.map((s) => {
|
||||
// 为 function 返回空
|
||||
@@ -81,7 +82,11 @@
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// 初始化选项
|
||||
onMounted(initOptions);
|
||||
onActivated(initOptions);
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
<script lang="ts" setup>
|
||||
import type { SelectOptionData } from '@arco-design/web-vue';
|
||||
import { computed, onBeforeMount, ref } from 'vue';
|
||||
import { computed, onActivated, onMounted, ref } from 'vue';
|
||||
import { useCacheStore } from '@/store';
|
||||
import { RoleStatus } from '@/views/user/role/types/const';
|
||||
import { labelFilter } from '@/types/form';
|
||||
@@ -54,7 +54,7 @@
|
||||
const optionData = ref<Array<SelectOptionData>>([]);
|
||||
|
||||
// 初始化选项
|
||||
onBeforeMount(async () => {
|
||||
const initOptions = async () => {
|
||||
setLoading(true);
|
||||
try {
|
||||
const roles = await cacheStore.loadRoles();
|
||||
@@ -69,7 +69,11 @@
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// 初始化选项
|
||||
onMounted(initOptions);
|
||||
onActivated(initOptions);
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
<script lang="ts" setup>
|
||||
import type { SelectOptionData } from '@arco-design/web-vue';
|
||||
import { computed, ref, onMounted } from 'vue';
|
||||
import { computed, ref, onMounted, onActivated } from 'vue';
|
||||
import { useCacheStore } from '@/store';
|
||||
import { labelFilter } from '@/types/form';
|
||||
import useLoading from '@/hooks/loading';
|
||||
@@ -53,7 +53,7 @@
|
||||
const optionData = ref<Array<SelectOptionData>>([]);
|
||||
|
||||
// 初始化选项
|
||||
onMounted(async () => {
|
||||
const initOptions = async () => {
|
||||
setLoading(true);
|
||||
try {
|
||||
// 加载用户列表
|
||||
@@ -68,7 +68,11 @@
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// 初始化选项
|
||||
onMounted(initOptions);
|
||||
onActivated(initOptions);
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
// 缓存类型
|
||||
export type CacheType = 'users' | 'menus' | 'roles'
|
||||
| 'hostGroups' | 'hostKeys' | 'hostIdentities'
|
||||
| 'hostGroups' | 'hostKeys' | 'hostIdentities' | 'host_*'
|
||||
| 'dictKeys'
|
||||
| 'execJob'
|
||||
| 'authorizedHostKeys' | 'authorizedHostIdentities'
|
||||
| 'commandSnippetGroups' | 'pathBookmarkGroups'
|
||||
| 'commandSnippets' | 'pathBookmarks'
|
||||
| 'execJob'
|
||||
| '*_Tags' | 'preference_*' | 'system_setting_*' | 'footer_setting'
|
||||
| string
|
||||
|
||||
export interface CacheState {
|
||||
|
||||
@@ -264,8 +264,6 @@
|
||||
doFetchTableData({ page, limit, ...form });
|
||||
};
|
||||
|
||||
defineExpose({ fetchTableData });
|
||||
|
||||
// 打开清空
|
||||
const openClear = () => {
|
||||
emits('openClear', { ...formModel, id: undefined });
|
||||
@@ -293,8 +291,8 @@
|
||||
await deleteTerminalConnectLog(selectedKeys.value);
|
||||
Message.success(`成功删除 ${selectedKeys.value.length} 条数据`);
|
||||
selectedKeys.value = [];
|
||||
// 重新加载数据
|
||||
fetchTableData();
|
||||
// 重新加载
|
||||
reload();
|
||||
} catch (e) {
|
||||
} finally {
|
||||
setLoading(false);
|
||||
@@ -309,14 +307,22 @@
|
||||
await deleteTerminalConnectLog([record.id]);
|
||||
Message.success('删除成功');
|
||||
selectedKeys.value = [];
|
||||
// 重新加载数据
|
||||
fetchTableData();
|
||||
// 重新加载
|
||||
reload();
|
||||
} catch (e) {
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
// 重新加载
|
||||
const reload = () => {
|
||||
// 重新加载数据
|
||||
fetchTableData();
|
||||
};
|
||||
|
||||
defineExpose({ reload });
|
||||
|
||||
onMounted(() => {
|
||||
// 当前用户
|
||||
const action = route.query.action as string;
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
@open-detail="(s) => detailModal.open(s)" />
|
||||
<!-- 清空模态框 -->
|
||||
<connect-log-clear-modal ref="clearModal"
|
||||
@clear="() => table.fetchTableData()" />
|
||||
@clear="() => table.reload()" />
|
||||
<!-- 详情模态框 -->
|
||||
<connect-log-detail-drawer ref="detailModal" />
|
||||
</div>
|
||||
@@ -19,8 +19,8 @@
|
||||
</script>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, onBeforeMount, onUnmounted } from 'vue';
|
||||
import { useCacheStore, useDictStore } from '@/store';
|
||||
import { ref, onBeforeMount } from 'vue';
|
||||
import { useDictStore } from '@/store';
|
||||
import { dictKeys } from './types/const';
|
||||
import ConnectLogTable from './components/connect-log-table.vue';
|
||||
import ConnectLogClearModal from './components/connect-log-clear-modal.vue';
|
||||
@@ -38,12 +38,6 @@
|
||||
render.value = true;
|
||||
});
|
||||
|
||||
// 重置缓存
|
||||
onUnmounted(() => {
|
||||
const cacheStore = useCacheStore();
|
||||
cacheStore.reset('users');
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
</script>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, onBeforeMount, onUnmounted } from 'vue';
|
||||
import { useCacheStore, useDictStore } from '@/store';
|
||||
import { ref, onBeforeMount } from 'vue';
|
||||
import { useDictStore } from '@/store';
|
||||
import { dictKeys } from './types/const';
|
||||
import ConnectSessionTable from './components/connect-session-table.vue';
|
||||
|
||||
@@ -26,12 +26,6 @@
|
||||
render.value = true;
|
||||
});
|
||||
|
||||
// 重置缓存
|
||||
onUnmounted(() => {
|
||||
const cacheStore = useCacheStore();
|
||||
cacheStore.reset('users');
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
|
||||
@@ -247,8 +247,8 @@
|
||||
await deleteTerminalSftpLog(selectedKeys.value);
|
||||
Message.success(`成功删除 ${selectedKeys.value.length} 条数据`);
|
||||
selectedKeys.value = [];
|
||||
// 重新加载数据
|
||||
fetchTableData();
|
||||
// 重新加载
|
||||
reload();
|
||||
} catch (e) {
|
||||
} finally {
|
||||
setLoading(false);
|
||||
@@ -263,14 +263,20 @@
|
||||
await deleteTerminalSftpLog([record.id]);
|
||||
Message.success('删除成功');
|
||||
selectedKeys.value = [];
|
||||
// 重新加载数据
|
||||
fetchTableData();
|
||||
// 重新加载
|
||||
reload();
|
||||
} catch (e) {
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
// 重新加载
|
||||
const reload = () => {
|
||||
// 重新加载数据
|
||||
fetchTableData();
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
fetchTableData();
|
||||
});
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
</script>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, onBeforeMount, onUnmounted } from 'vue';
|
||||
import { useCacheStore, useDictStore } from '@/store';
|
||||
import { ref, onBeforeMount } from 'vue';
|
||||
import { useDictStore } from '@/store';
|
||||
import { dictKeys } from './types/const';
|
||||
import SftpLogTable from './components/sftp-log-table.vue';
|
||||
|
||||
@@ -26,12 +26,6 @@
|
||||
render.value = true;
|
||||
});
|
||||
|
||||
// 重置缓存
|
||||
onUnmounted(() => {
|
||||
const cacheStore = useCacheStore();
|
||||
cacheStore.reset('users');
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
|
||||
@@ -25,13 +25,12 @@
|
||||
</script>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { onBeforeMount, onUnmounted, ref } from 'vue';
|
||||
import { useCacheStore, useDictStore } from '@/store';
|
||||
import { onBeforeMount, ref } from 'vue';
|
||||
import { useDictStore } from '@/store';
|
||||
import { GrantTabs, dictKeys } from './types/const';
|
||||
import { useRoute } from 'vue-router';
|
||||
|
||||
const route = useRoute();
|
||||
const cacheStore = useCacheStore();
|
||||
|
||||
const activeKey = ref();
|
||||
|
||||
@@ -49,11 +48,6 @@
|
||||
}
|
||||
});
|
||||
|
||||
// 卸载时清除 cache
|
||||
onUnmounted(() => {
|
||||
cacheStore.reset('users', 'roles', 'hostGroups', 'hostKeys', 'hostIdentities');
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
|
||||
@@ -155,7 +155,7 @@
|
||||
import { deleteHostIdentity, getHostIdentityPage } from '@/api/asset/host-identity';
|
||||
import { Message, Modal } from '@arco-design/web-vue';
|
||||
import usePermission from '@/hooks/permission';
|
||||
import { useDictStore } from '@/store';
|
||||
import { useCacheStore, useDictStore } from '@/store';
|
||||
import { copy } from '@/hooks/copy';
|
||||
import { GrantKey, GrantRouteName } from '@/views/asset/grant/types/const';
|
||||
import { IdentityType, identityTypeKey } from '../types/const';
|
||||
@@ -165,6 +165,7 @@
|
||||
|
||||
const list = ref<HostIdentityQueryResponse[]>([]);
|
||||
|
||||
const cacheStore = useCacheStore();
|
||||
const cardColLayout = useCardColLayout();
|
||||
const pagination = useCardPagination();
|
||||
const { toOptions, getDictValue } = useDictStore();
|
||||
@@ -199,8 +200,8 @@
|
||||
// 调用删除接口
|
||||
await deleteHostIdentity(id);
|
||||
Message.success('删除成功');
|
||||
// 重新加载数据
|
||||
fetchCardData();
|
||||
// 重新加载
|
||||
reload();
|
||||
} catch (e) {
|
||||
} finally {
|
||||
setLoading(false);
|
||||
@@ -211,7 +212,10 @@
|
||||
|
||||
// 重新加载
|
||||
const reload = () => {
|
||||
// 重新加载数据
|
||||
fetchCardData();
|
||||
// 清空缓存
|
||||
cacheStore.reset('hostIdentities', 'authorizedHostIdentities');
|
||||
};
|
||||
|
||||
defineExpose({ reload });
|
||||
|
||||
@@ -182,7 +182,7 @@
|
||||
import useLoading from '@/hooks/loading';
|
||||
import usePermission from '@/hooks/permission';
|
||||
import { copy } from '@/hooks/copy';
|
||||
import { useDictStore } from '@/store';
|
||||
import { useCacheStore, useDictStore } from '@/store';
|
||||
import { useTablePagination, useRowSelection } from '@/hooks/table';
|
||||
import { GrantKey, GrantRouteName } from '@/views/asset/grant/types/const';
|
||||
import { IdentityType, identityTypeKey } from '../types/const';
|
||||
@@ -190,6 +190,7 @@
|
||||
|
||||
const emits = defineEmits(['openAdd', 'openUpdate', 'openKeyView']);
|
||||
|
||||
const cacheStore = useCacheStore();
|
||||
const pagination = useTablePagination();
|
||||
const rowSelection = useRowSelection();
|
||||
const { toOptions, getDictValue } = useDictStore();
|
||||
@@ -215,8 +216,8 @@
|
||||
// 调用删除接口
|
||||
await deleteHostIdentity(id);
|
||||
Message.success('删除成功');
|
||||
// 重新加载数据
|
||||
fetchTableData();
|
||||
// 重新加载
|
||||
reload();
|
||||
} catch (e) {
|
||||
} finally {
|
||||
setLoading(false);
|
||||
@@ -231,8 +232,8 @@
|
||||
await batchDeleteHostIdentity(selectedKeys.value);
|
||||
Message.success(`成功删除 ${selectedKeys.value.length} 条数据`);
|
||||
selectedKeys.value = [];
|
||||
// 重新加载数据
|
||||
fetchTableData();
|
||||
// 重新加载
|
||||
reload();
|
||||
} catch (e) {
|
||||
} finally {
|
||||
setLoading(false);
|
||||
@@ -241,7 +242,10 @@
|
||||
|
||||
// 重新加载
|
||||
const reload = () => {
|
||||
// 重新加载数据
|
||||
fetchTableData();
|
||||
// 清空缓存
|
||||
cacheStore.reset('hostIdentities', 'authorizedHostIdentities');
|
||||
};
|
||||
|
||||
defineExpose({ reload });
|
||||
|
||||
@@ -28,8 +28,8 @@
|
||||
</script>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, computed, onUnmounted, onBeforeMount } from 'vue';
|
||||
import { useAppStore, useCacheStore, useDictStore } from '@/store';
|
||||
import { ref, computed, onBeforeMount } from 'vue';
|
||||
import { useAppStore, useDictStore } from '@/store';
|
||||
import { dictKeys } from './types/const';
|
||||
import HostIdentityCardList from './components/host-identity-card-list.vue';
|
||||
import HostIdentityTable from './components/host-identity-table.vue';
|
||||
@@ -41,7 +41,6 @@
|
||||
const modal = ref();
|
||||
const keyDrawer = ref();
|
||||
const appStore = useAppStore();
|
||||
const cacheStore = useCacheStore();
|
||||
|
||||
const renderTable = computed(() => appStore.hostIdentityView === 'table');
|
||||
|
||||
@@ -60,12 +59,6 @@
|
||||
await dictStore.loadKeys(dictKeys);
|
||||
});
|
||||
|
||||
// 卸载时清除 cache
|
||||
onUnmounted(() => {
|
||||
const cacheStore = useCacheStore();
|
||||
cacheStore.reset('hostKeys');
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
|
||||
@@ -84,6 +84,7 @@
|
||||
import type { HostKeyQueryRequest, HostKeyQueryResponse } from '@/api/asset/host-key';
|
||||
import { useCardPagination, useCardColLayout } from '@/hooks/card';
|
||||
import { reactive, ref, onMounted } from 'vue';
|
||||
import { useCacheStore } from '@/store';
|
||||
import useLoading from '@/hooks/loading';
|
||||
import { resetObject } from '@/utils';
|
||||
import fieldConfig from '../types/card.fields';
|
||||
@@ -95,6 +96,7 @@
|
||||
|
||||
const list = ref<HostKeyQueryResponse[]>([]);
|
||||
|
||||
const cacheStore = useCacheStore();
|
||||
const cardColLayout = useCardColLayout();
|
||||
const pagination = useCardPagination();
|
||||
const { loading, setLoading } = useLoading();
|
||||
@@ -116,8 +118,8 @@
|
||||
// 调用删除接口
|
||||
await deleteHostKey(id);
|
||||
Message.success('删除成功');
|
||||
// 重新加载数据
|
||||
fetchCardData();
|
||||
// 重新加载
|
||||
reload();
|
||||
} catch (e) {
|
||||
} finally {
|
||||
setLoading(false);
|
||||
@@ -128,7 +130,10 @@
|
||||
|
||||
// 重新加载
|
||||
const reload = () => {
|
||||
// 重新加载数据
|
||||
fetchCardData();
|
||||
// 清空缓存
|
||||
cacheStore.reset('hostKeys', 'authorizedHostKeys');
|
||||
};
|
||||
|
||||
defineExpose({ reload });
|
||||
|
||||
@@ -135,6 +135,7 @@
|
||||
import { reactive, ref, onMounted } from 'vue';
|
||||
import { deleteHostKey, batchDeleteHostKey, getHostKeyPage } from '@/api/asset/host-key';
|
||||
import { Message } from '@arco-design/web-vue';
|
||||
import { useCacheStore } from '@/store';
|
||||
import useLoading from '@/hooks/loading';
|
||||
import columns from '../types/table.columns';
|
||||
import { useTablePagination, useRowSelection } from '@/hooks/table';
|
||||
@@ -142,6 +143,7 @@
|
||||
|
||||
const emits = defineEmits(['openAdd', 'openUpdate', 'openView']);
|
||||
|
||||
const cacheStore = useCacheStore();
|
||||
const pagination = useTablePagination();
|
||||
const rowSelection = useRowSelection();
|
||||
const { loading, setLoading } = useLoading();
|
||||
@@ -156,16 +158,14 @@
|
||||
});
|
||||
|
||||
// 删除当前行
|
||||
const deleteRow = async ({ id }: {
|
||||
id: number
|
||||
}) => {
|
||||
const deleteRow = async (record: HostKeyQueryResponse) => {
|
||||
try {
|
||||
setLoading(true);
|
||||
// 调用删除接口
|
||||
await deleteHostKey(id);
|
||||
await deleteHostKey(record.id);
|
||||
Message.success('删除成功');
|
||||
// 重新加载数据
|
||||
fetchTableData();
|
||||
// 重新加载
|
||||
reload();
|
||||
} catch (e) {
|
||||
} finally {
|
||||
setLoading(false);
|
||||
@@ -180,8 +180,8 @@
|
||||
await batchDeleteHostKey(selectedKeys.value);
|
||||
Message.success(`成功删除 ${selectedKeys.value.length} 条数据`);
|
||||
selectedKeys.value = [];
|
||||
// 重新加载数据
|
||||
fetchTableData();
|
||||
// 重新加载
|
||||
reload();
|
||||
} catch (e) {
|
||||
} finally {
|
||||
setLoading(false);
|
||||
@@ -190,7 +190,10 @@
|
||||
|
||||
// 重新加载
|
||||
const reload = () => {
|
||||
// 重新加载数据
|
||||
fetchTableData();
|
||||
// 清空缓存
|
||||
cacheStore.reset('hostKeys', 'authorizedHostKeys');
|
||||
};
|
||||
|
||||
defineExpose({ reload });
|
||||
|
||||
@@ -234,7 +234,7 @@
|
||||
import { Message, Modal } from '@arco-design/web-vue';
|
||||
import { HostOsType, hostOsTypeKey, hostStatusKey, HostType, hostTypeKey, tagColor } from '../types/const';
|
||||
import { copy } from '@/hooks/copy';
|
||||
import { useDictStore } from '@/store';
|
||||
import { useCacheStore, useDictStore } from '@/store';
|
||||
import { GrantKey, GrantRouteName } from '@/views/asset/grant/types/const';
|
||||
import useLoading from '@/hooks/loading';
|
||||
import fieldConfig from '../types/card.fields';
|
||||
@@ -243,6 +243,7 @@
|
||||
|
||||
const emits = defineEmits(['openAdd', 'openUpdate', 'openUpdateConfig', 'openHostGroup', 'openCopy']);
|
||||
|
||||
const cacheStore = useCacheStore();
|
||||
const cardColLayout = useCardColLayout();
|
||||
const pagination = useCardPagination();
|
||||
const { loading, setLoading } = useLoading();
|
||||
@@ -308,8 +309,8 @@
|
||||
// 调用删除接口
|
||||
await deleteHost(id);
|
||||
Message.success('删除成功');
|
||||
// 重新加载数据
|
||||
fetchCardData();
|
||||
// 重新加载
|
||||
reload();
|
||||
} catch (e) {
|
||||
} finally {
|
||||
setLoading(false);
|
||||
@@ -320,7 +321,10 @@
|
||||
|
||||
// 重新加载
|
||||
const reload = () => {
|
||||
// 重新加载数据
|
||||
fetchCardData();
|
||||
// 清空缓存
|
||||
cacheStore.reset('host_SSH');
|
||||
};
|
||||
|
||||
defineExpose({ reload });
|
||||
|
||||
@@ -269,7 +269,7 @@
|
||||
import { Message, Modal } from '@arco-design/web-vue';
|
||||
import { tagColor, hostTypeKey, hostStatusKey, HostType, HostOsType, hostOsTypeKey } from '../types/const';
|
||||
import { useTablePagination, useRowSelection } from '@/hooks/table';
|
||||
import { useDictStore } from '@/store';
|
||||
import { useCacheStore, useDictStore } from '@/store';
|
||||
import { copy } from '@/hooks/copy';
|
||||
import { dataColor } from '@/utils';
|
||||
import useLoading from '@/hooks/loading';
|
||||
@@ -280,6 +280,7 @@
|
||||
|
||||
const emits = defineEmits(['openCopy', 'openAdd', 'openUpdate', 'openUpdateConfig', 'openHostGroup']);
|
||||
|
||||
const cacheStore = useCacheStore();
|
||||
const pagination = useTablePagination();
|
||||
const rowSelection = useRowSelection();
|
||||
const { loading, setLoading } = useLoading();
|
||||
@@ -334,8 +335,8 @@
|
||||
// 调用删除接口
|
||||
await deleteHost(record.id);
|
||||
Message.success('删除成功');
|
||||
// 重新加载数据
|
||||
fetchTableData();
|
||||
// 重新加载
|
||||
reload();
|
||||
} catch (e) {
|
||||
} finally {
|
||||
setLoading(false);
|
||||
@@ -350,8 +351,8 @@
|
||||
await batchDeleteHost(selectedKeys.value);
|
||||
Message.success(`成功删除 ${selectedKeys.value.length} 条数据`);
|
||||
selectedKeys.value = [];
|
||||
// 重新加载数据
|
||||
fetchTableData();
|
||||
// 重新加载
|
||||
reload();
|
||||
} catch (e) {
|
||||
} finally {
|
||||
setLoading(false);
|
||||
@@ -360,11 +361,16 @@
|
||||
|
||||
// 重新加载
|
||||
const reload = () => {
|
||||
// 重新加载数据
|
||||
fetchTableData();
|
||||
// 清空缓存
|
||||
cacheStore.reset('host_SSH');
|
||||
};
|
||||
|
||||
defineExpose({ reload });
|
||||
|
||||
defineExpose({ reload });
|
||||
|
||||
// 加载数据
|
||||
const doFetchTableData = async (request: HostQueryRequest) => {
|
||||
try {
|
||||
|
||||
@@ -34,8 +34,8 @@
|
||||
</script>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { computed, ref, onUnmounted, onBeforeMount } from 'vue';
|
||||
import { useAppStore, useCacheStore, useDictStore } from '@/store';
|
||||
import { computed, ref, onBeforeMount } from 'vue';
|
||||
import { useAppStore, useDictStore } from '@/store';
|
||||
import { dictKeys } from './types/const';
|
||||
import HostTable from './components/host-table.vue';
|
||||
import HostCardList from './components/host-card-list.vue';
|
||||
@@ -50,7 +50,6 @@
|
||||
const hostGroup = ref();
|
||||
|
||||
const appStore = useAppStore();
|
||||
const cacheStore = useCacheStore();
|
||||
|
||||
const renderTable = computed(() => appStore.hostView === 'table');
|
||||
|
||||
@@ -69,11 +68,6 @@
|
||||
await dictStore.loadKeys(dictKeys);
|
||||
});
|
||||
|
||||
// 卸载时清除 cache
|
||||
onUnmounted(() => {
|
||||
cacheStore.reset('hostKeys', 'hostIdentities', 'hostGroups', 'HOST_Tags');
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
|
||||
@@ -264,8 +264,8 @@
|
||||
await batchDeleteExecCommandLog(selectedKeys.value);
|
||||
Message.success(`成功删除 ${selectedKeys.value.length} 条数据`);
|
||||
selectedKeys.value = [];
|
||||
// 重新加载数据
|
||||
fetchTableData();
|
||||
// 重新加载
|
||||
reload();
|
||||
} catch (e) {
|
||||
} finally {
|
||||
setLoading(false);
|
||||
@@ -273,16 +273,14 @@
|
||||
};
|
||||
|
||||
// 删除当前行
|
||||
const deleteRow = async ({ id }: {
|
||||
id: number
|
||||
}) => {
|
||||
const deleteRow = async (record: ExecLogQueryResponse) => {
|
||||
try {
|
||||
setLoading(true);
|
||||
// 调用删除接口
|
||||
await deleteExecCommandLog(id);
|
||||
await deleteExecCommandLog(record.id);
|
||||
Message.success('删除成功');
|
||||
// 重新加载数据
|
||||
fetchTableData();
|
||||
// 重新加载
|
||||
reload();
|
||||
} catch (e) {
|
||||
} finally {
|
||||
setLoading(false);
|
||||
@@ -381,6 +379,14 @@
|
||||
});
|
||||
};
|
||||
|
||||
// 重新加载
|
||||
const reload = () => {
|
||||
// 重新加载数据
|
||||
fetchTableData();
|
||||
};
|
||||
|
||||
defineExpose({ reload });
|
||||
|
||||
// 加载数据
|
||||
const doFetchTableData = async (request: ExecLogQueryRequest) => {
|
||||
try {
|
||||
@@ -403,10 +409,6 @@
|
||||
doFetchTableData({ page, limit, ...form });
|
||||
};
|
||||
|
||||
defineExpose({
|
||||
fetchTableData
|
||||
});
|
||||
|
||||
onMounted(() => {
|
||||
// 当前用户
|
||||
const action = route.query.action as string;
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
@open-clear="openClearModal" />
|
||||
<!-- 清理模态框 -->
|
||||
<exec-command-log-clear-modal ref="clearModal"
|
||||
@clear="clearCallback" />
|
||||
@clear="() => tableRef.reload()" />
|
||||
<!-- 执行日志模态框 -->
|
||||
<exec-log-panel-modal ref="logModal"
|
||||
type="BATCH" />
|
||||
@@ -67,20 +67,13 @@
|
||||
// 跳转新页面
|
||||
openNewRoute({
|
||||
name: 'execCommand',
|
||||
query: {
|
||||
id
|
||||
}
|
||||
query: { id },
|
||||
});
|
||||
} else {
|
||||
logModal.value.open(id);
|
||||
}
|
||||
};
|
||||
|
||||
// 清理回调
|
||||
const clearCallback = () => {
|
||||
tableRef.value.fetchTableData();
|
||||
};
|
||||
|
||||
onBeforeMount(async () => {
|
||||
const dictStore = useDictStore();
|
||||
await dictStore.loadKeys(dictKeys);
|
||||
|
||||
@@ -264,6 +264,21 @@
|
||||
emits('openClear', { ...formModel, id: undefined, description: undefined });
|
||||
};
|
||||
|
||||
// 删除当前行
|
||||
const deleteRow = async (record: ExecLogQueryResponse) => {
|
||||
try {
|
||||
setLoading(true);
|
||||
// 调用删除接口
|
||||
await deleteExecJobLog(record.id);
|
||||
Message.success('删除成功');
|
||||
// 重新加载
|
||||
reload();
|
||||
} catch (e) {
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
// 删除选中行
|
||||
const deleteSelectedRows = async () => {
|
||||
try {
|
||||
@@ -272,31 +287,22 @@
|
||||
await batchDeleteExecJobLog(selectedKeys.value);
|
||||
Message.success(`成功删除 ${selectedKeys.value.length} 条数据`);
|
||||
selectedKeys.value = [];
|
||||
// 重新加载数据
|
||||
fetchTableData();
|
||||
// 重新加载
|
||||
reload();
|
||||
} catch (e) {
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
// 删除当前行
|
||||
const deleteRow = async ({ id }: {
|
||||
id: number
|
||||
}) => {
|
||||
try {
|
||||
setLoading(true);
|
||||
// 调用删除接口
|
||||
await deleteExecJobLog(id);
|
||||
Message.success('删除成功');
|
||||
// 重新加载数据
|
||||
fetchTableData();
|
||||
} catch (e) {
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
// 重新加载
|
||||
const reload = () => {
|
||||
// 重新加载数据
|
||||
fetchTableData();
|
||||
};
|
||||
|
||||
defineExpose({ reload });
|
||||
|
||||
// 中断执行
|
||||
const doInterruptExecJob = async (record: ExecLogQueryResponse) => {
|
||||
try {
|
||||
@@ -395,10 +401,6 @@
|
||||
doFetchTableData({ page, limit, ...form });
|
||||
};
|
||||
|
||||
defineExpose({
|
||||
fetchTableData
|
||||
});
|
||||
|
||||
onMounted(() => {
|
||||
// 加载数据
|
||||
fetchTableData();
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
@open-clear="openClearModal" />
|
||||
<!-- 清理模态框 -->
|
||||
<exec-job-log-clear-modal ref="clearModal"
|
||||
@clear="clearCallback" />
|
||||
@clear="() => tableRef.reload()" />
|
||||
<!-- 执行日志模态框 -->
|
||||
<exec-log-panel-modal ref="logModal"
|
||||
type="JOB" />
|
||||
@@ -70,20 +70,13 @@
|
||||
// 跳转新页面
|
||||
openNewRoute({
|
||||
name: 'execJobLogView',
|
||||
query: {
|
||||
id
|
||||
}
|
||||
query: { id },
|
||||
});
|
||||
} else {
|
||||
logModal.value.open(id);
|
||||
}
|
||||
};
|
||||
|
||||
// 清理回调
|
||||
const clearCallback = () => {
|
||||
tableRef.value.fetchTableData();
|
||||
};
|
||||
|
||||
onBeforeMount(async () => {
|
||||
const dictStore = useDictStore();
|
||||
await dictStore.loadKeys(dictKeys);
|
||||
|
||||
@@ -215,7 +215,7 @@
|
||||
import columns from '../types/table.columns';
|
||||
import { ExecJobStatus, execJobStatusKey, execStatusKey } from '../types/const';
|
||||
import { useTablePagination, useRowSelection } from '@/hooks/table';
|
||||
import { useDictStore, useUserStore } from '@/store';
|
||||
import { useCacheStore, useDictStore, useUserStore } from '@/store';
|
||||
import { useRoute } from 'vue-router';
|
||||
import { copy } from '@/hooks/copy';
|
||||
import { dateFormat } from '@/utils';
|
||||
@@ -224,6 +224,7 @@
|
||||
const emits = defineEmits(['openAdd', 'openUpdate', 'openDetail', 'updateExecUser', 'testCron']);
|
||||
|
||||
const route = useRoute();
|
||||
const cacheStore = useCacheStore();
|
||||
const pagination = useTablePagination();
|
||||
const rowSelection = useRowSelection();
|
||||
const { loading, setLoading } = useLoading();
|
||||
@@ -242,16 +243,14 @@
|
||||
});
|
||||
|
||||
// 删除当前行
|
||||
const deleteRow = async ({ id }: {
|
||||
id: number
|
||||
}) => {
|
||||
const deleteRow = async (record: ExecJobQueryResponse) => {
|
||||
try {
|
||||
setLoading(true);
|
||||
// 调用删除接口
|
||||
await deleteExecJob(id);
|
||||
await deleteExecJob(record.id);
|
||||
Message.success('删除成功');
|
||||
// 重新加载数据
|
||||
fetchTableData();
|
||||
// 重新加载
|
||||
reload();
|
||||
} catch (e) {
|
||||
} finally {
|
||||
setLoading(false);
|
||||
@@ -266,8 +265,8 @@
|
||||
await batchDeleteExecJob(selectedKeys.value);
|
||||
Message.success(`成功删除 ${selectedKeys.value.length} 条数据`);
|
||||
selectedKeys.value = [];
|
||||
// 重新加载数据
|
||||
fetchTableData();
|
||||
// 重新加载
|
||||
reload();
|
||||
} catch (e) {
|
||||
} finally {
|
||||
setLoading(false);
|
||||
@@ -276,7 +275,10 @@
|
||||
|
||||
// 重新加载
|
||||
const reload = () => {
|
||||
// 重新加载数据
|
||||
fetchTableData();
|
||||
// 清空缓存
|
||||
cacheStore.reset('execJob');
|
||||
};
|
||||
|
||||
defineExpose({ reload });
|
||||
|
||||
@@ -153,16 +153,14 @@
|
||||
});
|
||||
|
||||
// 删除当前行
|
||||
const deleteRow = async ({ id }: {
|
||||
id: number
|
||||
}) => {
|
||||
const deleteRow = async (record: ExecTemplateQueryResponse) => {
|
||||
try {
|
||||
setLoading(true);
|
||||
// 调用删除接口
|
||||
await deleteExecTemplate(id);
|
||||
await deleteExecTemplate(record.id);
|
||||
Message.success('删除成功');
|
||||
// 重新加载数据
|
||||
fetchTableData();
|
||||
// 重新加载
|
||||
reload();
|
||||
} catch (e) {
|
||||
} finally {
|
||||
setLoading(false);
|
||||
@@ -177,8 +175,8 @@
|
||||
await batchDeleteExecTemplate(selectedKeys.value);
|
||||
Message.success(`成功删除 ${selectedKeys.value.length} 条数据`);
|
||||
selectedKeys.value = [];
|
||||
// 重新加载数据
|
||||
fetchTableData();
|
||||
// 重新加载
|
||||
reload();
|
||||
} catch (e) {
|
||||
} finally {
|
||||
setLoading(false);
|
||||
@@ -187,6 +185,7 @@
|
||||
|
||||
// 重新加载
|
||||
const reload = () => {
|
||||
// 重新加载数据
|
||||
fetchTableData();
|
||||
};
|
||||
|
||||
|
||||
@@ -238,8 +238,8 @@
|
||||
await batchDeleteUploadTask(selectedKeys.value);
|
||||
Message.success(`成功删除 ${selectedKeys.value.length} 条数据`);
|
||||
selectedKeys.value = [];
|
||||
// 重新加载数据
|
||||
fetchTableData();
|
||||
// 重新加载
|
||||
reload();
|
||||
} catch (e) {
|
||||
} finally {
|
||||
setLoading(false);
|
||||
@@ -247,22 +247,26 @@
|
||||
};
|
||||
|
||||
// 删除当前行
|
||||
const deleteRow = async ({ id }: {
|
||||
id: number
|
||||
}) => {
|
||||
const deleteRow = async (record: UploadTaskQueryResponse) => {
|
||||
try {
|
||||
setLoading(true);
|
||||
// 调用删除接口
|
||||
await deleteUploadTask(id);
|
||||
await deleteUploadTask(record.id);
|
||||
Message.success('删除成功');
|
||||
// 重新加载数据
|
||||
fetchTableData();
|
||||
// 重新加载
|
||||
reload();
|
||||
} catch (e) {
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
// 重新加载
|
||||
const reload = () => {
|
||||
// 重新加载数据
|
||||
fetchTableData();
|
||||
};
|
||||
|
||||
// 加载状态
|
||||
const pullTaskStatus = async () => {
|
||||
const unCompleteIdList = tableRenderData.value
|
||||
@@ -303,10 +307,6 @@
|
||||
doFetchTableData({ page, limit, ...form });
|
||||
};
|
||||
|
||||
defineExpose({
|
||||
fetchTableData
|
||||
});
|
||||
|
||||
onMounted(() => {
|
||||
// 加载数据
|
||||
fetchTableData();
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
@open-clear="(e) => clear.open(e)" />
|
||||
<!-- 清理模态框 -->
|
||||
<upload-task-clear-modal ref="clear"
|
||||
@clear="clearCallback" />
|
||||
@clear="() => table.reload()" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -26,11 +26,6 @@
|
||||
const table = ref();
|
||||
const clear = ref();
|
||||
|
||||
// 清理回调
|
||||
const clearCallback = () => {
|
||||
table.value.fetchTableData();
|
||||
};
|
||||
|
||||
// 加载字典值
|
||||
onBeforeMount(async () => {
|
||||
const dictStore = useDictStore();
|
||||
|
||||
@@ -197,8 +197,6 @@
|
||||
|
||||
// 卸载处理
|
||||
onUnmounted(() => {
|
||||
// 卸载时清除 cache
|
||||
useCacheStore().reset('authorizedHostKeys', 'authorizedHostIdentities', 'commandSnippetGroups', 'pathBookmarkGroups');
|
||||
// 去除 body style
|
||||
document.body.removeAttribute('terminal-theme');
|
||||
// 重置 title
|
||||
|
||||
@@ -173,11 +173,11 @@
|
||||
|
||||
const emits = defineEmits(['openAdd', 'openUpdate', 'openView']);
|
||||
|
||||
const cacheStore = useCacheStore();
|
||||
const pagination = useTablePagination();
|
||||
const rowSelection = useRowSelection();
|
||||
const { loading, setLoading } = useLoading();
|
||||
const { toOptions, getDictValue } = useDictStore();
|
||||
const cacheStore = useCacheStore();
|
||||
|
||||
const selectedKeys = ref<number[]>([]);
|
||||
const tableRenderData = ref<DictKeyQueryResponse[]>([]);
|
||||
@@ -188,17 +188,14 @@
|
||||
});
|
||||
|
||||
// 删除当前行
|
||||
const deleteRow = async ({ id }: {
|
||||
id: number
|
||||
}) => {
|
||||
const deleteRow = async (record: DictKeyQueryResponse) => {
|
||||
try {
|
||||
setLoading(true);
|
||||
// 调用删除接口
|
||||
await deleteDictKey(id);
|
||||
await deleteDictKey(record.id);
|
||||
Message.success('删除成功');
|
||||
cacheStore.reset('dictKeys');
|
||||
// 重新加载数据
|
||||
fetchTableData();
|
||||
// 重新加载
|
||||
reload();
|
||||
} catch (e) {
|
||||
} finally {
|
||||
setLoading(false);
|
||||
@@ -213,9 +210,8 @@
|
||||
await batchDeleteDictKey(selectedKeys.value);
|
||||
Message.success(`成功删除 ${selectedKeys.value.length} 条数据`);
|
||||
selectedKeys.value = [];
|
||||
cacheStore.reset('dictKeys');
|
||||
// 重新加载数据
|
||||
fetchTableData();
|
||||
// 重新加载
|
||||
reload();
|
||||
} catch (e) {
|
||||
} finally {
|
||||
setLoading(false);
|
||||
@@ -224,7 +220,9 @@
|
||||
|
||||
// 重新加载
|
||||
const reload = () => {
|
||||
// 重新加载数据
|
||||
fetchTableData();
|
||||
// 清空缓存
|
||||
cacheStore.reset('dictKeys');
|
||||
};
|
||||
|
||||
|
||||
@@ -175,8 +175,8 @@
|
||||
await batchDeleteDictValue(selectedKeys.value);
|
||||
Message.success(`成功删除 ${selectedKeys.value.length} 条数据`);
|
||||
selectedKeys.value = [];
|
||||
// 重新加载数据
|
||||
fetchTableData();
|
||||
// 重新加载
|
||||
reload();
|
||||
} catch (e) {
|
||||
} finally {
|
||||
setLoading(false);
|
||||
@@ -190,8 +190,8 @@
|
||||
// 调用删除接口
|
||||
await deleteDictValue(record.id);
|
||||
Message.success('删除成功');
|
||||
// 重新加载数据
|
||||
fetchTableData();
|
||||
// 重新加载
|
||||
reload();
|
||||
} catch (e) {
|
||||
} finally {
|
||||
setLoading(false);
|
||||
@@ -200,6 +200,7 @@
|
||||
|
||||
// 重新加载
|
||||
const reload = () => {
|
||||
// 重新加载数据
|
||||
fetchTableData();
|
||||
};
|
||||
|
||||
|
||||
@@ -24,9 +24,8 @@
|
||||
</script>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, onUnmounted } from 'vue';
|
||||
import { ref } from 'vue';
|
||||
import { historyType } from './types/const';
|
||||
import { useCacheStore } from '@/store';
|
||||
import { rollbackDictValue } from '@/api/system/dict-value';
|
||||
import DictValueTable from './components/dict-value-table.vue';
|
||||
import DictValueFormModal from './components/dict-value-form-modal.vue';
|
||||
@@ -35,18 +34,12 @@
|
||||
const table = ref();
|
||||
const modal = ref();
|
||||
const history = ref();
|
||||
const cacheStore = useCacheStore();
|
||||
|
||||
// 回滚
|
||||
const rollback = async (id: number, valueId: number) => {
|
||||
await rollbackDictValue({ id, valueId });
|
||||
};
|
||||
|
||||
// 卸载时清除 cache
|
||||
onUnmounted(() => {
|
||||
cacheStore.reset('dictKeys');
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
|
||||
@@ -18,11 +18,11 @@
|
||||
</script>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, onBeforeMount } from 'vue';
|
||||
import { useDictStore } from '@/store';
|
||||
import { dictKeys } from './types/const';
|
||||
import MenuTable from '@/views/system/menu/components/menu-table.vue';
|
||||
import MenuFormModal from '@/views/system/menu/components/menu-form-modal.vue';
|
||||
import { ref, onBeforeMount, onUnmounted } from 'vue';
|
||||
import { useCacheStore, useDictStore } from '@/store';
|
||||
import { dictKeys } from './types/const';
|
||||
|
||||
const table = ref();
|
||||
const modal = ref();
|
||||
@@ -35,10 +35,4 @@
|
||||
render.value = true;
|
||||
});
|
||||
|
||||
// 卸载时清除 cache
|
||||
onUnmounted(() => {
|
||||
const cacheStore = useCacheStore();
|
||||
cacheStore.reset('menus');
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
@@ -120,6 +120,14 @@
|
||||
jsonView.value.open(getLogDetail(record));
|
||||
};
|
||||
|
||||
// 重新加载
|
||||
const reload = () => {
|
||||
// 重新加载数据
|
||||
fetchTableData();
|
||||
};
|
||||
|
||||
defineExpose({ reload });
|
||||
|
||||
// 加载数据
|
||||
const doFetchTableData = async (request: OperatorLogQueryRequest) => {
|
||||
try {
|
||||
@@ -151,10 +159,6 @@
|
||||
doFetchTableData({ page, limit, ...form });
|
||||
};
|
||||
|
||||
defineExpose({
|
||||
fetchTableData
|
||||
});
|
||||
|
||||
// 初始化
|
||||
onMounted(async () => {
|
||||
// 加载字典值
|
||||
|
||||
@@ -181,8 +181,8 @@
|
||||
await deleteOperatorLog(selectedKeys.value);
|
||||
Message.success(`成功删除 ${selectedKeys.value.length} 条数据`);
|
||||
selectedKeys.value = [];
|
||||
// 重新加载数据
|
||||
fetchTableData();
|
||||
// 重新加载
|
||||
reload();
|
||||
} catch (e) {
|
||||
} finally {
|
||||
setLoading(false);
|
||||
@@ -197,14 +197,20 @@
|
||||
await deleteOperatorLog([record.id]);
|
||||
Message.success('删除成功');
|
||||
selectedKeys.value = [];
|
||||
// 重新加载数据
|
||||
fetchTableData();
|
||||
// 重新加载
|
||||
reload();
|
||||
} catch (e) {
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
// 重新加载
|
||||
const reload = () => {
|
||||
// 重新加载数据
|
||||
fetchTableData();
|
||||
};
|
||||
|
||||
// 加载数据
|
||||
const doFetchTableData = async (request: OperatorLogQueryRequest) => {
|
||||
try {
|
||||
@@ -228,8 +234,6 @@
|
||||
doFetchTableData({ page, limit, ...form });
|
||||
};
|
||||
|
||||
defineExpose({ fetchTableData });
|
||||
|
||||
// 初始化
|
||||
onMounted(() => {
|
||||
fetchTableData();
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
@open-clear="(s) => clearModal.open(s)" />
|
||||
<!-- 清理模态框 -->
|
||||
<operator-log-clear-modal ref="clearModal"
|
||||
@clear="() => table.fetchTableData()" />
|
||||
@clear="() => table.reload()" />
|
||||
<!-- json 查看器模态框 -->
|
||||
<json-editor-modal ref="jsonView" />
|
||||
</div>
|
||||
@@ -20,15 +20,13 @@
|
||||
|
||||
<script lang="ts" setup>
|
||||
import type { OperatorLogQueryResponse } from '@/api/user/operator-log';
|
||||
import { ref, onUnmounted, onBeforeMount } from 'vue';
|
||||
import { useCacheStore, useDictStore } from '@/store';
|
||||
import { ref, onBeforeMount } from 'vue';
|
||||
import { useDictStore } from '@/store';
|
||||
import { dictKeys, getLogDetail } from './types/const';
|
||||
import OperatorLogTable from './components/operator-log-table.vue';
|
||||
import OperatorLogClearModal from './components/operator-log-clear-modal.vue';
|
||||
import JsonEditorModal from '@/components/view/json-editor/modal/index.vue';
|
||||
|
||||
const cacheStore = useCacheStore();
|
||||
|
||||
const render = ref(false);
|
||||
const table = ref();
|
||||
const clearModal = ref();
|
||||
@@ -46,11 +44,6 @@
|
||||
render.value = true;
|
||||
});
|
||||
|
||||
// 卸载时清除 cache
|
||||
onUnmounted(() => {
|
||||
cacheStore.reset('users');
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
|
||||
@@ -139,11 +139,12 @@
|
||||
import { RoleStatus, roleStatusKey } from '../types/const';
|
||||
import { useTablePagination } from '@/hooks/table';
|
||||
import usePermission from '@/hooks/permission';
|
||||
import { useDictStore } from '@/store';
|
||||
import { useCacheStore, useDictStore } from '@/store';
|
||||
import { AdminRoleCode } from '@/types/const';
|
||||
|
||||
const emits = defineEmits(['openAdd', 'openUpdate', 'openGrant']);
|
||||
|
||||
const cacheStore = useCacheStore();
|
||||
const pagination = useTablePagination();
|
||||
const { hasPermission } = usePermission();
|
||||
const { loading, setLoading } = useLoading();
|
||||
@@ -173,8 +174,8 @@
|
||||
// 调用删除接口
|
||||
await deleteRole(record.id);
|
||||
Message.success('删除成功');
|
||||
// 重新加载数据
|
||||
fetchTableData();
|
||||
// 重新加载
|
||||
reload();
|
||||
} catch (e) {
|
||||
} finally {
|
||||
setLoading(false);
|
||||
@@ -183,7 +184,10 @@
|
||||
|
||||
// 重新加载
|
||||
const reload = () => {
|
||||
// 加载数据
|
||||
fetchTableData();
|
||||
// 清空缓存
|
||||
cacheStore.reset('roles');
|
||||
};
|
||||
|
||||
defineExpose({ reload });
|
||||
|
||||
@@ -21,8 +21,8 @@
|
||||
</script>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, onBeforeMount, onUnmounted } from 'vue';
|
||||
import { useCacheStore, useDictStore } from '@/store';
|
||||
import { ref, onBeforeMount } from 'vue';
|
||||
import { useDictStore } from '@/store';
|
||||
import { dictKeys } from './types/const';
|
||||
import RoleTable from './components/role-table.vue';
|
||||
import RoleFormModal from './components/role-form-modal.vue';
|
||||
@@ -39,12 +39,6 @@
|
||||
render.value = true;
|
||||
});
|
||||
|
||||
// 卸载时清除 cache
|
||||
onUnmounted(() => {
|
||||
const cacheStore = useCacheStore();
|
||||
cacheStore.reset('menus');
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
|
||||
@@ -183,11 +183,12 @@
|
||||
import { useTablePagination, useRowSelection } from '@/hooks/table';
|
||||
import usePermission from '@/hooks/permission';
|
||||
import { useRouter } from 'vue-router';
|
||||
import { useDictStore, useUserStore } from '@/store';
|
||||
import { useCacheStore, useDictStore, useUserStore } from '@/store';
|
||||
import { copy } from '@/hooks/copy';
|
||||
|
||||
const emits = defineEmits(['openAdd', 'openUpdate', 'openResetPassword', 'openGrantRole']);
|
||||
|
||||
const cacheStore = useCacheStore();
|
||||
const pagination = useTablePagination();
|
||||
const rowSelection = useRowSelection();
|
||||
const { hasPermission } = usePermission();
|
||||
@@ -217,8 +218,8 @@
|
||||
// 调用删除接口
|
||||
await deleteUser(record.id);
|
||||
Message.success('删除成功');
|
||||
// 重新加载数据
|
||||
fetchTableData();
|
||||
// 重新加载
|
||||
reload();
|
||||
} catch (e) {
|
||||
} finally {
|
||||
setLoading(false);
|
||||
@@ -233,8 +234,8 @@
|
||||
await batchDeleteUser(selectedKeys.value);
|
||||
Message.success(`成功删除 ${selectedKeys.value.length} 条数据`);
|
||||
selectedKeys.value = [];
|
||||
// 重新加载数据
|
||||
fetchTableData();
|
||||
// 重新加载
|
||||
reload();
|
||||
} catch (e) {
|
||||
} finally {
|
||||
setLoading(false);
|
||||
@@ -260,7 +261,10 @@
|
||||
|
||||
// 重新加载
|
||||
const reload = () => {
|
||||
// 加载数据
|
||||
fetchTableData();
|
||||
// 清空缓存
|
||||
cacheStore.reset('users');
|
||||
};
|
||||
|
||||
defineExpose({ reload });
|
||||
|
||||
@@ -24,13 +24,13 @@
|
||||
</script>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, onBeforeMount } from 'vue';
|
||||
import { useDictStore } from '@/store';
|
||||
import { dictKeys } from './types/const';
|
||||
import UserTable from './components/user-table.vue';
|
||||
import UserFormModal from './components/user-form-modal.vue';
|
||||
import UserResetPasswordFormModal from './components/user-reset-password-form-modal.vue';
|
||||
import UserGrantRolesFormModal from './components/user-grant-roles-form-modal.vue';
|
||||
import { ref, onBeforeMount, onUnmounted } from 'vue';
|
||||
import { useCacheStore, useDictStore } from '@/store';
|
||||
import { dictKeys } from './types/const';
|
||||
|
||||
const render = ref(false);
|
||||
const table = ref();
|
||||
@@ -45,12 +45,6 @@
|
||||
render.value = true;
|
||||
});
|
||||
|
||||
// 卸载时清除 cache
|
||||
onUnmounted(() => {
|
||||
const cacheStore = useCacheStore();
|
||||
cacheStore.reset('roles');
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
|
||||
Reference in New Issue
Block a user