Forráskód Böngészése

fix:优化xlog命令窗,增加内置命令

Jerry Liang 2 hónapja
szülő
commit
25209118fe

+ 55 - 22
src/views/xlog/component/xlogCommand.vue

@@ -57,13 +57,14 @@ import { sendXlogCmd } from '@/service/xlog'
 import { useXlogViewsStateStore } from '@/stores/modules/views/xlogViewsState'
 import type { XlogCmdListData } from '@/stores/modules/views/xlogViewsState'
 
-const xlogViewsStateStore = useXlogViewsStateStore()
-
-const { uuid, sn } = defineProps<{
+const { uuid, sn, version } = defineProps<{
   uuid: string
   sn: string
+  version: string
 }>()
 
+const xlogViewsStateStore = useXlogViewsStateStore()
+
 let inputCmdIndex = -1
 let inputCmdTemp = ''
 const inputCmd = ref<string>('')
@@ -95,18 +96,48 @@ function toBashC(cmd: string): string {
 }
 
 // 常用命令
-const commonCmd: { cmd: string; version: string }[] = [
-  { cmd: 'head -10 /opt/config/EmuPara/EmuParaDevInfo.json', version: 'ALL' },
-  { cmd: 'rm -v /opt/app1/configuser/xlog_remote.xml', version: 'ALL' },
-  { cmd: 'rm -v /home/root/ExportFile/IbgLog/*_UsrRtData*.txt', version: '1.0' },
-  { cmd: 'rm -v /home/root/ExportFile/IbgLog/*_AgApRtData*.txt', version: '1.0' },
-  { cmd: 'rm -v /home/root/ExportFile/IbgLog/*_devdata.txt', version: '1.0' },
-  { cmd: 'rm -v /home/root/ExportFile/IbgLog/*_Power.txt', version: '1.0' },
-  { cmd: 'rm1 -v /home/root/ExportFile/IbgLog/*_Power.txt', version: '1.0' },
-  { cmd: 'rm2 -v /home/root/ExportFile/IbgLog/*_Power.txt', version: '1.0' },
-  { cmd: 'rm3 -v /home/root/ExportFile/IbgLog/*_Power.txt', version: '1.0' },
-  { cmd: 'rm4 -v /home/root/ExportFile/IbgLog/*_Power.txt', version: '1.0' },
-  { cmd: 'rm5 -v /home/root/ExportFile/IbgLog/*_Power.txt', version: '1.0' },
+const commonCmd: { cmd: string; version: string; brief: string }[] = [
+  {
+    cmd: 'head -10 /opt/config/EmuPara/EmuParaDevInfo.json',
+    version: 'ALL',
+    brief: '查看版本信息',
+  },
+  { cmd: 'rm -v /opt/app1/configuser/xlog_remote.xml', version: 'ALL', brief: '退出xlog' },
+  {
+    cmd: 'ls -l /home/root/ExportFile/IbgLog/',
+    version: 'xlog v1.0',
+    brief: '查看本地缓存数据',
+  },
+  {
+    cmd: 'rm -v /home/root/ExportFile/IbgLog/*_UsrRtData*.txt',
+    version: 'xlog v1.0',
+    brief: '清除本地缓存数据',
+  },
+  {
+    cmd: 'rm -v /home/root/ExportFile/IbgLog/*_AgApRtData*.txt',
+    version: 'xlog v1.0',
+    brief: '清除本地缓存数据',
+  },
+  {
+    cmd: 'rm -v /home/root/ExportFile/IbgLog/*_devdata.txt',
+    version: 'xlog v1.0',
+    brief: '清除本地缓存数据',
+  },
+  {
+    cmd: 'rm -v /home/root/ExportFile/IbgLog/*_Power.txt',
+    version: 'xlog v1.0',
+    brief: '清除本地缓存数据',
+  },
+  {
+    cmd: 'ls -l /home/root/ExportFile/AwsOfflineFile/',
+    version: 'xlog v2.0',
+    brief: '查看本地缓存数据',
+  },
+  {
+    cmd: 'rm -v /home/root/ExportFile/AwsOfflineFile/*',
+    version: 'xlog v2.0',
+    brief: '清除本地缓存数据',
+  },
 ]
 
 // 历史命令
@@ -151,13 +182,15 @@ const inputCmdOptions = computed<Array<AutoCompleteGroupOption | AutoCompleteOpt
         type: 'group',
         label: 'common',
         key: 'common',
-        children: commonCmd.map((item) => {
-          return {
-            label: item.cmd,
-            value: `common__${item.cmd}`,
-            version: item.version, // 用于显示版本标签
-          } satisfies SelectOption
-        }),
+        children: commonCmd
+          .filter((item) => item.version === 'ALL' || item.version === version)
+          .map((item) => {
+            return {
+              label: item.cmd,
+              value: `common__${item.cmd}`,
+              version: item.version, // 用于显示版本标签
+            } satisfies SelectOption
+          }),
       },
     ] satisfies AutoCompleteGroupOption[]
   },

+ 9 - 2
src/views/xlog/index.vue

@@ -1,12 +1,18 @@
 <template>
   <div class="main-wrap p-4 flex flex-col gap-y-2">
     <NAlert type="info" closable @after-leave="updateMaxHeight">
-      模拟xlog终端 - {{ uuid }} - {{ sn }}
+      模拟xlog终端 - {{ uuid }} - {{ sn }} - {{ version }}
     </NAlert>
     <div :style="cardHeight">
       <NCard ref="mainCardRef" class="h-full" content-class="h-full">
         <div class="h-full">
-          <XlogCommand ref="xlogCommandRef" class="h-full" :uuid="uuid" :sn="sn" />
+          <XlogCommand
+            ref="xlogCommandRef"
+            class="h-full"
+            :uuid="uuid"
+            :sn="sn"
+            :version="version"
+          />
         </div>
       </NCard>
     </div>
@@ -31,5 +37,6 @@ const cardHeight = computed(() => {
 const route = useRoute()
 // 获取 SN & UUID
 const sn = route.query.sn as string
+const version = route.query.version as string
 const uuid = route.params.uuid as string
 </script>

+ 59 - 30
src/views/xlog/manage.vue

@@ -17,7 +17,12 @@
             </template>
             新增xlog
           </NButton>
-          <NButton type="info" @click="handleQueryClick" :loading="isRequestLoading" :disabled="isRequestLoading">
+          <NButton
+            type="info"
+            @click="handleQueryClick"
+            :loading="isRequestLoading"
+            :disabled="isRequestLoading"
+          >
             <template #icon>
               <span class="i-ph:magnifying-glass" />
             </template>
@@ -32,9 +37,21 @@
         </div>
       </div>
       <div>
-        <NDataTable ref="dataTableRef" v-model:checked-row-keys="checkedRowKeys" :remote="true" :min-height="166.6"
-          :max-height="maxHeight" size="small" :columns="tableColumns" :data="tableData" :row-key="tableRowKey"
-          :loading="isRequestLoading" striped :single-line="false" :row-props="rowProps" />
+        <NDataTable
+          ref="dataTableRef"
+          v-model:checked-row-keys="checkedRowKeys"
+          :remote="true"
+          :min-height="166.6"
+          :max-height="maxHeight"
+          size="small"
+          :columns="tableColumns"
+          :data="tableData"
+          :row-key="tableRowKey"
+          :loading="isRequestLoading"
+          striped
+          :single-line="false"
+          :row-props="rowProps"
+        />
         <div class="mt-3 flex items-end justify-between">
           <div class="flex items-center gap-x-3">
             <span>已选择&nbsp;{{ checkedRowKeys.length }}&nbsp; 条</span>
@@ -43,12 +60,17 @@
         </div>
       </div>
     </NCard>
-    <NDropdown placement="bottom-start" trigger="manual" v-bind="dropdownOptions" :show="showDropdown" />
+    <NDropdown
+      placement="bottom-start"
+      trigger="manual"
+      v-bind="dropdownOptions"
+      :show="showDropdown"
+    />
   </div>
 </template>
 
 <script setup lang="tsx">
-import { h } from 'vue'
+import { h, version } from 'vue'
 import { useRouter } from 'vue-router'
 import { NButton, NDataTable, NForm, NNumberAnimation } from 'naive-ui'
 import type { DataTableColumns, PaginationProps, DropdownProps } from 'naive-ui'
@@ -67,9 +89,9 @@ const { maxHeight } = useDataTable(dataTableRef)
 const isRequestLoading = ref(false)
 const showDropdown = ref(false)
 const checkedRowKeys = ref<Array<number | string>>([])
-const contextmenuUUID = ref<string | undefined>(undefined)
+const contextmenu = ref<XlogSiteItemInfo | undefined>(undefined)
 
-interface XlogSiteFilterForm extends Partial<XlogSiteItemInfo> { }
+interface XlogSiteFilterForm extends Partial<XlogSiteItemInfo> {}
 
 const [form, , resetForm] = useResettableReactive<XlogSiteFilterForm>({
   sn: '',
@@ -89,7 +111,7 @@ const paginationPrefix: PaginationProps['prefix'] = (info) => {
     itemCount && (
       <div>
         <span>总&nbsp; </span>
-        < NNumberAnimation
+        <NNumberAnimation
           from={prevUserListTotal.value}
           to={itemCount}
           onFinish={() => {
@@ -107,7 +129,7 @@ const dropdownOptions = reactive<DropdownProps>({
   y: 0,
   options: [
     {
-      label: () => <span class='text-green-500'> 查看 </span>,
+      label: () => <span class="text-green-500"> 查看 </span>,
       key: 'view',
     },
   ],
@@ -116,9 +138,9 @@ const dropdownOptions = reactive<DropdownProps>({
   },
   onSelect: (key: string) => {
     showDropdown.value = false
-    if (contextmenuUUID.value === undefined) return
+    if (contextmenu.value === undefined) return
     if (key === 'view') {
-      itemView(contextmenuUUID.value, "")
+      itemView(contextmenu.value.uuid, contextmenu.value.sn, contextmenu.value.version)
     }
   },
 })
@@ -135,7 +157,7 @@ function createColumns(): DataTableColumns<XlogSiteItemInfo> {
   return [
     {
       type: 'selection',
-      fixed: 'left'
+      fixed: 'left',
     },
     {
       title: 'SN',
@@ -158,17 +180,21 @@ function createColumns(): DataTableColumns<XlogSiteItemInfo> {
       fixed: 'right',
       render(row) {
         return h('div', { class: 'flex justify-center gap-4 p-x-4' }, [
-          h(NButton, {
-            type: "success",
-            strong: true,
-            size: 'small',
-            onClick: () => itemView(row.uuid, "")
-          }, {
-            default: () => '查看'
-          })
+          h(
+            NButton,
+            {
+              type: 'success',
+              strong: true,
+              size: 'small',
+              onClick: () => itemView(row.uuid, row.sn, row.version),
+            },
+            {
+              default: () => '查看',
+            },
+          ),
         ])
-      }
-    }
+      },
+    },
   ]
 }
 
@@ -179,7 +205,7 @@ function rowProps(row: XlogSiteItemInfo) {
       e.preventDefault()
       showDropdown.value = false
       nextTick().then(() => {
-        contextmenuUUID.value = row.uuid
+        contextmenu.value = row
         showDropdown.value = true
         dropdownOptions.x = e.clientX
         dropdownOptions.y = e.clientY
@@ -209,10 +235,10 @@ const tablePagination = reactive<PaginationProps>({
   },
 })
 
-const itemView = (uuid: string, sn: string) => {
+const itemView = (uuid: string, sn: string, version: string) => {
   router.push({
     path: `/xlog-terminal/${uuid}`,
-    query: { sn },
+    query: { sn, version },
   })
 }
 
@@ -221,7 +247,11 @@ interface XlogSiteListFilter {
   uuid?: string
 }
 
-const queryXlogSiteList = async (pageSize: number, pageNum: number, filter?: XlogSiteListFilter) => {
+const queryXlogSiteList = async (
+  pageSize: number,
+  pageNum: number,
+  filter?: XlogSiteListFilter,
+) => {
   const siteList = await getManageList(pageSize, pageNum, filter)
   tableData.value = siteList.data
   tablePagination.itemCount = siteList.total
@@ -234,7 +264,7 @@ const handleListQuery = () => {
   // 处理过滤条件
   const filter = {
     sn: form.sn,
-    uuid: form.uuid
+    uuid: form.uuid,
   }
 
   queryXlogSiteList(pageSize, page, filter)
@@ -243,5 +273,4 @@ const handleListQuery = () => {
 onMounted(() => {
   handleListQuery()
 })
-
-</script>
+</script>