minor: cleanup code

This commit is contained in:
kerms 2024-06-15 16:56:52 +08:00
parent 949ef16e7f
commit 981b0fbfed
7 changed files with 11 additions and 13 deletions

View File

@ -8,6 +8,7 @@
"devh": ". ./set_env.sh && vite --host", "devh": ". ./set_env.sh && vite --host",
"build": "run-p type-check \"build-only {@}\" --", "build": "run-p type-check \"build-only {@}\" --",
"preview": ". ./set_env.sh && vite preview", "preview": ". ./set_env.sh && vite preview",
"previewh": ". ./set_env.sh && vite preview --host",
"build-only": ". ./set_env.sh && vite build", "build-only": ". ./set_env.sh && vite build",
"build:dev": ". ./set_env.sh && vite build --mode development", "build:dev": ". ./set_env.sh && vite build --mode development",
"type-check": "vue-tsc --build --force", "type-check": "vue-tsc --build --force",

View File

@ -40,7 +40,7 @@ let websocketService: IWebsocketService;
onMounted(() => { onMounted(() => {
logHelloMessage(); logHelloMessage();
let host = ""; let host: string;
if (isDevMode()) { if (isDevMode()) {
host = import.meta.env.VITE_DEVICE_HOST_NAME || "dap.local"; host = import.meta.env.VITE_DEVICE_HOST_NAME || "dap.local";
} else { } else {

View File

@ -1,5 +1,5 @@
import {registerModule} from "@/router/msgRouter"; import {registerModule} from "@/router/msgRouter";
import {type ApiJsonMsg, ControlEvent, type ControlMsg, ControlMsgType, WtModuleID} from "@/api"; import {type ApiJsonMsg, type ControlMsg, ControlMsgType, WtModuleID} from "@/api";
import {isDevMode} from "@/composables/buildMode"; import {isDevMode} from "@/composables/buildMode";
import {useDataFlowStore} from "@/stores/useDataFlowStore"; import {useDataFlowStore} from "@/stores/useDataFlowStore";
import {type IInstanceList, WtDataFlowCmd} from "@/api/apiDataFlow"; import {type IInstanceList, WtDataFlowCmd} from "@/api/apiDataFlow";

View File

@ -293,7 +293,6 @@ export const useDataViewerStore = defineStore('text-viewer', () => {
const appendedLength = frameBreakAfterSequence.value ? frameBreakSequenceNormalized.value.length : 0; const appendedLength = frameBreakAfterSequence.value ? frameBreakSequenceNormalized.value.length : 0;
/* else after the first match, skip the matchArr at the beginning of array in subsequent match */ /* else after the first match, skip the matchArr at the beginning of array in subsequent match */
const skipLength = frameBreakAfterSequence.value ? 0 : frameBreakSequenceNormalized.value.length; const skipLength = frameBreakAfterSequence.value ? 0 : frameBreakSequenceNormalized.value.length;
let remain = false;
let startIndex = 0; let startIndex = 0;
inputArray.forEach(array => { inputArray.forEach(array => {
@ -314,7 +313,7 @@ export const useDataViewerStore = defineStore('text-viewer', () => {
result.push(array.subarray(startIndex, array.length)); result.push(array.subarray(startIndex, array.length));
} }
}); });
remain = startIndex < inputArray[inputArray.length - 1].length; const remain = startIndex < inputArray[inputArray.length - 1].length;
return {result, remain}; return {result, remain};
} }
}, { }, {
@ -343,7 +342,7 @@ export const useDataViewerStore = defineStore('text-viewer', () => {
const encoder = new TextEncoder(); const encoder = new TextEncoder();
input = unescapeString(input); input = unescapeString(input);
const encodedStr = encoder.encode(input); const encodedStr = encoder.encode(input);
addSegment(encodedStr, isRX); addSegment(encodedStr, isRX, doSend);
} }
function addSegment(input: Uint8Array, isRX: boolean, doSend: boolean = false) { function addSegment(input: Uint8Array, isRX: boolean, doSend: boolean = false) {
@ -456,7 +455,6 @@ export const useDataViewerStore = defineStore('text-viewer', () => {
return encoder.encode(str); return encoder.encode(str);
}) })
const dataArchive: IDataArchive[] = [];
const dataBuf: IDataBuf[] = []; const dataBuf: IDataBuf[] = [];
const dataBufLength = ref(0); const dataBufLength = ref(0);
@ -477,7 +475,7 @@ export const useDataViewerStore = defineStore('text-viewer', () => {
const batchUpdateTime = ref(80); /* ms */ const batchUpdateTime = ref(80); /* ms */
let batchStartIndex: number = 0; let batchStartIndex: number = 0;
watch(batchUpdateTime, value => { watch(batchUpdateTime, () => {
if (batchDataUpdateIntervalID >= 0) { if (batchDataUpdateIntervalID >= 0) {
clearInterval(batchDataUpdateIntervalID); clearInterval(batchDataUpdateIntervalID);
batchDataUpdateIntervalID = -1; batchDataUpdateIntervalID = -1;
@ -538,7 +536,7 @@ export const useDataViewerStore = defineStore('text-viewer', () => {
softRefreshFilterBuf(); softRefreshFilterBuf();
} }
function softRefreshFilterBuf(delayTime: number = 0) { function softRefreshFilterBuf() {
/* handle filtered buf array */ /* handle filtered buf array */
const totalBufLength = dataBuf.length - batchStartIndex + dataFiltered.length; const totalBufLength = dataBuf.length - batchStartIndex + dataFiltered.length;
@ -605,7 +603,7 @@ export const useDataViewerStore = defineStore('text-viewer', () => {
TxByteCountLocal = item.length; TxByteCountLocal = item.length;
} }
let str = "" let str: string;
str = decodeUtf8(item); str = decodeUtf8(item);
str = escapeHTML(str); str = escapeHTML(str);
str = strToHTML(str); str = strToHTML(str);

View File

@ -1,6 +1,6 @@
import {defineStore} from "pinia"; import {defineStore} from "pinia";
import {type Ref, ref} from "vue"; import {type Ref, ref} from "vue";
import type {AttachInfo, InstanceInfo} from "@/api/apiDataFlow"; import type {InstanceInfo} from "@/api/apiDataFlow";
export const useDataFlowStore = defineStore('data_flow', () => { export const useDataFlowStore = defineStore('data_flow', () => {
const instanceList: Ref<InstanceInfo[]> = ref([]); const instanceList: Ref<InstanceInfo[]> = ref([]);

View File

@ -61,7 +61,6 @@ import {breakpointsTailwind, useBreakpoints} from '@vueuse/core'
import {useDataViewerStore} from '@/stores/dataViewerStore'; import {useDataViewerStore} from '@/stores/dataViewerStore';
import * as api from '@/api'; import * as api from '@/api';
import {ControlEvent} from '@/api'; import {ControlEvent} from '@/api';
import * as uart from '@/api/apiUart';
import { import {
type IUartMsgBaud, type IUartMsgBaud,
type IUartMsgConfig, type IUartMsgConfig,
@ -214,7 +213,7 @@ function mouseResize(e: MouseEvent) {
function touchResize(e: TouchEvent) { function touchResize(e: TouchEvent) {
let t = e.touches[0]; let t = e.touches[0];
let f = 0; let f: number;
if (layoutMode.value === 'row') { if (layoutMode.value === 'row') {
f = t.clientX; f = t.clientX;

View File

@ -438,7 +438,7 @@ watch(() => store.showVirtualScroll, () => {
} }
}); });
const handleScroll = (ev: Event) => { const handleScroll = () => {
if (store.forceToBottom) { if (store.forceToBottom) {
if (vuetifyVirtualScrollBarRef.value.scrollTop - lastScrollHeight < 0) { if (vuetifyVirtualScrollBarRef.value.scrollTop - lastScrollHeight < 0) {
store.forceToBottom = false; store.forceToBottom = false;