|
1 | 1 | <script lang="ts">
|
2 |
| - import { onMount, onDestroy } from 'svelte'; |
3 |
| - import { isMatchedFilterText } from './logTool'; |
4 |
| - import { VConsoleLogStore as Store } from './log.store'; |
5 |
| - import LogRow from './logRow.svelte'; |
6 |
| - import LogCommand from './logCommand.svelte'; |
7 |
| - import Style from './log.less'; |
8 |
| - import type { IConsoleLogMethod, IVConsoleLog } from './log.model'; |
9 |
| - import RecycleScroller from '../component/recycleScroller/recycleScroller.svelte'; |
| 2 | + import { onMount, onDestroy } from "svelte"; |
| 3 | + import { isMatchedFilterText } from "./logTool"; |
| 4 | + import { VConsoleLogStore as Store } from "./log.store"; |
| 5 | + import LogRow from "./logRow.svelte"; |
| 6 | + import LogCommand from "./logCommand.svelte"; |
| 7 | + import Style from "./log.less"; |
| 8 | + import type { IConsoleLogMethod, IVConsoleLog } from "./log.model"; |
| 9 | + import RecycleScroller from "../component/recycleScroller/recycleScroller.svelte"; |
| 10 | + import type { IVConsoleTabOptions } from "../lib/plugin"; |
10 | 11 |
|
11 |
| - export let pluginId: string = 'default'; |
| 12 | + export let pluginId: string = "default"; |
12 | 13 | export let showCmd: boolean = false;
|
13 |
| - export let filterType: 'all' | IConsoleLogMethod = 'all'; |
| 14 | + export let filterType: "all" | IConsoleLogMethod = "all"; |
14 | 15 | export let showTimestamps: boolean = false;
|
15 | 16 |
|
16 | 17 | let isInited: boolean = false;
|
17 |
| - let filterText: string = ''; |
| 18 | + let filterText: string = ""; |
18 | 19 | let store: ReturnType<typeof Store.get>;
|
19 |
| - let scrollerHandler |
| 20 | + let scrollerHandler; |
20 | 21 |
|
21 | 22 | $: {
|
22 | 23 | if (!isInited) {
|
|
26 | 27 | }
|
27 | 28 | }
|
28 | 29 |
|
29 |
| - let logList: IVConsoleLog[] = [] |
| 30 | + let logList: IVConsoleLog[] = []; |
30 | 31 |
|
31 | 32 | $: {
|
32 |
| - logList = $store.logList.filter(log => |
33 |
| - // filterType |
34 |
| - (filterType === 'all' || filterType === log.type) |
35 |
| - && |
36 |
| - // filterText |
37 |
| - (filterText === '' || isMatchedFilterText(log, filterText)) |
38 |
| - ) |
| 33 | + logList = $store.logList.filter( |
| 34 | + (log) => |
| 35 | + // filterType |
| 36 | + (filterType === "all" || filterType === log.type) && |
| 37 | + // filterText |
| 38 | + (filterText === "" || isMatchedFilterText(log, filterText)) |
| 39 | + ); |
39 | 40 | }
|
40 | 41 |
|
41 | 42 | onMount(() => {
|
|
47 | 48 | });
|
48 | 49 |
|
49 | 50 | const onFilterText = (e) => {
|
50 |
| - filterText = e.detail.filterText || ''; |
| 51 | + filterText = e.detail.filterText || ""; |
51 | 52 | };
|
52 | 53 |
|
53 | 54 | export const scrollToTop = () => {
|
54 |
| - scrollerHandler.scrollTo(0, 500) |
55 |
| - } |
| 55 | + scrollerHandler.scrollTo(0, 500); |
| 56 | + }; |
56 | 57 |
|
57 | 58 | export const scrollToBottom = () => {
|
58 |
| - scrollerHandler.scrollTo(logList.length - 1, 500) |
59 |
| - } |
| 59 | + scrollerHandler.scrollTo(logList.length - 1, 500); |
| 60 | + }; |
| 61 | +
|
| 62 | + export const options: IVConsoleTabOptions = { |
| 63 | + fixedHeight: true, |
| 64 | + }; |
60 | 65 | </script>
|
61 | 66 |
|
62 | 67 | <div class="vc-plugin-content" class:vc-logs-has-cmd={showCmd}>
|
|
0 commit comments