style(sj_1.1.0-beta3): 修复日志组件样式
This commit is contained in:
parent
7e8195d7f9
commit
46f0754f6e
@ -40,8 +40,9 @@ const visible = defineModel<boolean>('show', {
|
|||||||
default: false
|
default: false
|
||||||
});
|
});
|
||||||
|
|
||||||
const isAutoScroll = ref(true);
|
const isAutoScroll = ref(false);
|
||||||
const isFullscreen = ref(true);
|
const isFullscreen = ref(true);
|
||||||
|
const expandedNames = ref<string[]>([]);
|
||||||
const virtualListInst = ref<VirtualListInst>();
|
const virtualListInst = ref<VirtualListInst>();
|
||||||
const syncTime = ref(1);
|
const syncTime = ref(1);
|
||||||
const logList = ref<Api.JobLog.JobMessage[]>([]);
|
const logList = ref<Api.JobLog.JobMessage[]>([]);
|
||||||
@ -105,11 +106,13 @@ async function getLogList() {
|
|||||||
fromIndex = logData.fromIndex;
|
fromIndex = logData.fromIndex;
|
||||||
if (logData.message) {
|
if (logData.message) {
|
||||||
logList.value.push(...logData.message);
|
logList.value.push(...logData.message);
|
||||||
logList.value.sort((a, b) => Number.parseInt(a.time_stamp, 10) - Number.parseInt(b.time_stamp, 10));
|
logList.value
|
||||||
|
.sort((a, b) => Number.parseInt(a.time_stamp, 10) - Number.parseInt(b.time_stamp, 10))
|
||||||
|
.forEach((item, index) => (item.index = index));
|
||||||
}
|
}
|
||||||
if (!finished.value && syncTime.value !== 0) {
|
if (!finished.value && syncTime.value !== 0) {
|
||||||
nextTick(() => {
|
nextTick(() => {
|
||||||
if (isAutoScroll.value) virtualListInst.value?.scrollTo({ position: 'bottom' });
|
if (isAutoScroll.value) virtualListInst.value?.scrollTo({ position: 'bottom', debounce: true });
|
||||||
});
|
});
|
||||||
clearTimeout(interval.value);
|
clearTimeout(interval.value);
|
||||||
interval.value = setTimeout(getLogList, syncTime.value * 1000);
|
interval.value = setTimeout(getLogList, syncTime.value * 1000);
|
||||||
@ -238,7 +241,8 @@ const SnailLogComponent = defineComponent({
|
|||||||
return () => <NEmpty class="h-full flex-center" size="huge" />;
|
return () => <NEmpty class="h-full flex-center" size="huge" />;
|
||||||
}
|
}
|
||||||
|
|
||||||
const throwableComponent = (throwable: string) => {
|
const throwableComponent = (message: Api.JobLog.JobMessage) => {
|
||||||
|
const throwable = message.throwable;
|
||||||
if (!throwable) {
|
if (!throwable) {
|
||||||
return <></>;
|
return <></>;
|
||||||
}
|
}
|
||||||
@ -247,27 +251,37 @@ const SnailLogComponent = defineComponent({
|
|||||||
return <></>;
|
return <></>;
|
||||||
}
|
}
|
||||||
const restOfText = throwable.replace(/^.+(\n|$)/m, '');
|
const restOfText = throwable.replace(/^.+(\n|$)/m, '');
|
||||||
return (
|
return <NCollapseItem title={firstLine[0]} name={message.index}>{`${restOfText}`}</NCollapseItem>;
|
||||||
<NCollapse>
|
};
|
||||||
<NCollapseItem title={firstLine[0]} name="1">
|
|
||||||
{`${restOfText}`}
|
const handleUpdateExpanded = (val: string[]) => {
|
||||||
</NCollapseItem>
|
expandedNames.value = val;
|
||||||
</NCollapse>
|
};
|
||||||
);
|
|
||||||
|
const handleResize = () => {
|
||||||
|
expandedNames.value = [];
|
||||||
};
|
};
|
||||||
|
|
||||||
return () => (
|
return () => (
|
||||||
<code class="snail-log">
|
<code class="snail-log">
|
||||||
|
<NCollapse
|
||||||
|
accordion
|
||||||
|
v-model:expanded-names={expandedNames.value}
|
||||||
|
on-update:expanded-names={handleUpdateExpanded}
|
||||||
|
>
|
||||||
<NVirtualList
|
<NVirtualList
|
||||||
ref={virtualListInst}
|
ref={virtualListInst}
|
||||||
class="virtual-list"
|
class="virtual-list"
|
||||||
itemSize={85}
|
itemSize={85}
|
||||||
|
item-resizable
|
||||||
|
padding-bottom={16}
|
||||||
items={logList.value}
|
items={logList.value}
|
||||||
scrollbar-props={{ xScrollable: true }}
|
scrollbar-props={{ xScrollable: true }}
|
||||||
|
on-resize={handleResize}
|
||||||
>
|
>
|
||||||
{{
|
{{
|
||||||
default: ({ item: message }: { item: Api.JobLog.JobMessage }) => (
|
default: ({ item: message }: { item: Api.JobLog.JobMessage }) => (
|
||||||
<pre key={message.time_stamp} class="min-h-85px">
|
<pre key={message.index} class="min-h-85px min-w-full">
|
||||||
<div>
|
<div>
|
||||||
<span class="log-hljs-time inline-block">{timestampToDate(message.time_stamp)}</span>
|
<span class="log-hljs-time inline-block">{timestampToDate(message.time_stamp)}</span>
|
||||||
<span
|
<span
|
||||||
@ -278,12 +292,13 @@ const SnailLogComponent = defineComponent({
|
|||||||
</div>
|
</div>
|
||||||
<div class="log-hljs-location">{`${message.location}: `}</div>
|
<div class="log-hljs-location">{`${message.location}: `}</div>
|
||||||
<div class="pl-6px">- {`${message.message}`}</div>
|
<div class="pl-6px">- {`${message.message}`}</div>
|
||||||
<div>{throwableComponent(message.throwable)}</div>
|
<div>{throwableComponent(message)}</div>
|
||||||
<NDivider />
|
<NDivider />
|
||||||
</pre>
|
</pre>
|
||||||
)
|
)
|
||||||
}}
|
}}
|
||||||
</NVirtualList>
|
</NVirtualList>
|
||||||
|
</NCollapse>
|
||||||
</code>
|
</code>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -355,11 +370,11 @@ const SnailLogComponent = defineComponent({
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<div v-if="logList.length === 0" class="h-full flex-center">
|
<div v-if="logList.length === 0" class="empty-height flex-center">
|
||||||
<NEmpty v-if="logList.length === 0 && finished" />
|
<NEmpty v-if="logList.length === 0 && finished" />
|
||||||
<NSpin v-if="logList.length === 0 && !finished" />
|
<NSpin v-if="logList.length === 0 && !finished" />
|
||||||
</div>
|
</div>
|
||||||
<SnailLogComponent />
|
<SnailLogComponent v-if="logList.length > 0" />
|
||||||
</NDrawerContent>
|
</NDrawerContent>
|
||||||
</NDrawer>
|
</NDrawer>
|
||||||
<NCard v-else :bordered="false" :title="title" size="small" class="h-full sm:flex-1-hidden card-wrapper">
|
<NCard v-else :bordered="false" :title="title" size="small" class="h-full sm:flex-1-hidden card-wrapper">
|
||||||
@ -416,7 +431,7 @@ const SnailLogComponent = defineComponent({
|
|||||||
padding: 0;
|
padding: 0;
|
||||||
|
|
||||||
.virtual-list {
|
.virtual-list {
|
||||||
height: calc(100vh - 101px);
|
min-height: calc(100vh - 101px);
|
||||||
max-height: calc(100vh - 101px);
|
max-height: calc(100vh - 101px);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -493,7 +508,17 @@ const SnailLogComponent = defineComponent({
|
|||||||
width: calc(50vw - 72px);
|
width: calc(50vw - 72px);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.empty-height {
|
||||||
|
min-height: calc(100vh - 101px);
|
||||||
|
max-height: calc(100vh - 101px);
|
||||||
|
}
|
||||||
|
|
||||||
:deep(.n-collapse-item__content-inner) {
|
:deep(.n-collapse-item__content-inner) {
|
||||||
padding-top: 0 !important;
|
padding-top: 0 !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
:deep(.v-vl-items) {
|
||||||
|
display: inline-block !important;
|
||||||
|
min-width: 100%;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
1
src/typings/api.d.ts
vendored
1
src/typings/api.d.ts
vendored
@ -1307,6 +1307,7 @@ declare namespace Api {
|
|||||||
};
|
};
|
||||||
|
|
||||||
type JobMessage = {
|
type JobMessage = {
|
||||||
|
index: number;
|
||||||
level: JobLevel;
|
level: JobLevel;
|
||||||
host: string;
|
host: string;
|
||||||
port: string;
|
port: string;
|
||||||
|
Loading…
Reference in New Issue
Block a user