🔨 优化批量执行日志跳转逻辑.

This commit is contained in:
lijiahang
2024-05-14 16:03:28 +08:00
parent a0717c3338
commit 2fa3eb2251
6 changed files with 70 additions and 118 deletions

View File

@@ -4,6 +4,8 @@ export const MessageStatus = {
READ: 1,
};
export const MESSAGE_CONFIG_KEY = 'messageConfig';
// 查询数量
export const messageLimit = 15;

View File

@@ -25,7 +25,7 @@
type="round"
checked-text="未读"
unchecked-text="全部"
@change="changeMessageStatus" />
@change="reloadAllMessage" />
<!-- 全部已读 -->
<a-button class="header-button"
type="text"
@@ -67,7 +67,7 @@
<script lang="ts" setup>
import type { MessageRecordResponse } from '@/api/system/message';
import { ref, onMounted } from 'vue';
import { ref, onMounted, onUnmounted } from 'vue';
import {
clearSystemMessage,
deleteSystemMessage,
@@ -79,7 +79,7 @@
import useLoading from '@/hooks/loading';
import { useRouter } from 'vue-router';
import { useDictStore } from '@/store';
import { dictKeys, messageClassifyKey, messageTypeKey, defaultClassify, messageLimit, MessageStatus } from './const';
import { dictKeys, messageClassifyKey, messageTypeKey, defaultClassify, MESSAGE_CONFIG_KEY, messageLimit, MessageStatus } from './const';
import List from './list.vue';
import Modal from './modal.vue';
import { clearHtmlTag, replaceHtmlTag } from '@/utils';
@@ -96,8 +96,8 @@
const hasMore = ref(true);
const modalRef = ref();
// 修改消息状态
const changeMessageStatus = async () => {
// 重新加载消息
const reloadAllMessage = async () => {
hasMore.value = true;
messageList.value = [];
// 查询数量
@@ -179,7 +179,7 @@
setMessageLoading(false);
}
// 查询消息
await changeMessageStatus();
await reloadAllMessage();
};
// 点击消息
@@ -239,7 +239,29 @@
});
// 获取消息
onMounted(changeMessageStatus);
onMounted(() => {
// 获取配置缓存
const item = localStorage.getItem(MESSAGE_CONFIG_KEY);
if (item) {
const config = JSON.parse(item) as Record<string, any>;
if (config?.currentClassify) {
currentClassify.value = config.currentClassify;
}
if (config?.queryUnread) {
queryUnread.value = config.queryUnread;
}
}
// 查询数据
reloadAllMessage();
});
// 设置缓存配置
onUnmounted(() => {
localStorage.setItem(MESSAGE_CONFIG_KEY, JSON.stringify({
currentClassify: currentClassify.value,
queryUnread: queryUnread.value,
}));
});
</script>

View File

@@ -139,18 +139,19 @@
display: flex;
flex-direction: column;
justify-content: space-between;
font-size: 16px;
font-size: 14px;
color: var(--color-text-1);
cursor: pointer;
&-title {
display: flex;
justify-content: space-between;
align-items: center;
align-items: flex-start;
&-text {
width: calc(100% - @actions-width - @gap);
display: block;
font-size: 15px;
font-weight: 600;
text-overflow: clip;
}
@@ -179,6 +180,8 @@
}
&-content {
display: block;
padding-bottom: 2px;
color: var(--color-text-1);
text-overflow: clip;
}

View File

@@ -1,51 +1,37 @@
import type { AppRouteRecordRaw } from '../types';
import { DEFAULT_LAYOUT, FULL_LAYOUT } from '../base';
import { DEFAULT_LAYOUT } from '../base';
const EXEC: AppRouteRecordRaw[] = [
{
name: 'execModule',
path: '/exec-module',
component: DEFAULT_LAYOUT,
children: [
{
name: 'execCommand',
path: '/exec-command',
component: () => import('@/views/exec/exec-command/index.vue'),
},
{
name: 'execCommandLog',
path: '/exec-log',
component: () => import('@/views/exec/exec-command-log/index.vue'),
},
{
name: 'batchUpload',
path: '/batch-upload',
component: () => import('@/views/exec/batch-upload/index.vue'),
},
{
name: 'uploadTask',
path: '/upload-task',
component: () => import('@/views/exec/upload-task/index.vue'),
},
{
name: 'execTemplate',
path: '/exec-template',
component: () => import('@/views/exec/exec-template/index.vue'),
},
],
},
{
name: 'execFullModule',
path: '/exec-full-module',
component: FULL_LAYOUT,
children: [
{
name: 'execCommandLogView',
path: '/exec-log-view',
component: () => import('@/views/exec/exec-command-log-view/index.vue'),
},
],
}
];
const EXEC: AppRouteRecordRaw = {
name: 'execModule',
path: '/exec-module',
component: DEFAULT_LAYOUT,
children: [
{
name: 'execCommand',
path: '/exec-command',
component: () => import('@/views/exec/exec-command/index.vue'),
},
{
name: 'execCommandLog',
path: '/exec-log',
component: () => import('@/views/exec/exec-command-log/index.vue'),
},
{
name: 'batchUpload',
path: '/batch-upload',
component: () => import('@/views/exec/batch-upload/index.vue'),
},
{
name: 'uploadTask',
path: '/upload-task',
component: () => import('@/views/exec/upload-task/index.vue'),
},
{
name: 'execTemplate',
path: '/exec-template',
component: () => import('@/views/exec/exec-template/index.vue'),
},
],
};
export default EXEC;

View File

@@ -1,61 +0,0 @@
<template>
<div class="container">
<div class="wrapper">
<exec-log-panel ref="log"
type="BATCH"
:visible-back="false" />
</div>
</div>
</template>
<script lang="ts">
export default {
name: 'execCommandLogView'
};
</script>
<script lang="ts" setup>
import { onMounted, ref, nextTick } from 'vue';
import { useRoute } from 'vue-router';
import { getExecCommandLog } from '@/api/exec/exec-command-log';
import ExecLogPanel from '@/components/exec/log/panel/index.vue';
const route = useRoute();
const log = ref();
// 初始化
const init = async (id: number) => {
// 获取执行日志
const { data } = await getExecCommandLog(id);
// 打开日志
await nextTick(() => {
setTimeout(() => {
log.value.open(data);
}, 50);
});
};
onMounted(() => {
const idParam = route.query.id;
if (idParam) {
init(Number.parseInt(idParam as string));
}
});
</script>
<style lang="less" scoped>
.container {
width: 100%;
height: 100%;
position: relative;
padding: 16px;
background: var(--color-fill-2);
.wrapper {
width: 100%;
height: 100%;
position: relative;
}
}
</style>

View File

@@ -69,7 +69,7 @@
if (newWindow) {
// 跳转新页面
openNewRoute({
name: 'execCommandLogView',
name: 'execCommand',
query: {
id
}