⚡ 优化缓存策略.
This commit is contained in:
@@ -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