refactor: show "row data" tab only when user is super admin

This commit is contained in:
yangsy
2025-09-05 17:47:25 +08:00
parent 3140539fa4
commit 2d0cbcab63
8 changed files with 32 additions and 8 deletions

View File

@@ -1,6 +1,7 @@
<script setup lang="ts">
import type { NdmDecoderDiagInfo } from '@/apis/domains';
import type { NdmCameraResultVO } from '@/apis/models';
import { useUserStore } from '@/stores/user';
import { destr } from 'destr';
import { NCard, NFlex, NTabPane, NTabs } from 'naive-ui';
import { computed, ref, toRefs } from 'vue';
@@ -13,6 +14,8 @@ const props = defineProps<{
ndmCamera: NdmCameraResultVO;
}>();
const userStore = useUserStore();
const { stationCode, ndmCamera } = toRefs(props);
const lastDiagInfo = computed(() => {
@@ -39,7 +42,7 @@ const selectedTab = ref('设备状态');
<CameraHistoryDiagCard :station-code="stationCode" :ndm-camera="ndmCamera" :key="ndmCamera.id" />
</NTabPane>
<!-- <NTabPane name="设备配置" tab="设备配置"></NTabPane> -->
<NTabPane name="原始数据" tab="原始数据">
<NTabPane v-if="userStore.isSuperAdmin" name="原始数据" tab="原始数据">
<pre>{{ { ...ndmCamera, lastDiagInfo } }}</pre>
</NTabPane>
</NTabs>

View File

@@ -1,6 +1,7 @@
<script setup lang="ts">
import type { NdmDecoderDiagInfo } from '@/apis/domains';
import type { NdmDecoderResultVO } from '@/apis/models';
import { useUserStore } from '@/stores/user';
import { destr } from 'destr';
import { NCard, NFlex, NTabPane, NTabs } from 'naive-ui';
import { computed, ref, toRefs } from 'vue';
@@ -15,6 +16,8 @@ const props = defineProps<{
ndmDecoder: NdmDecoderResultVO;
}>();
const userStore = useUserStore();
const { stationCode, ndmDecoder } = toRefs(props);
const lastDiagInfo = computed(() => {
@@ -55,7 +58,7 @@ const selectedTab = ref('设备状态');
<DecoderHistoryDiagCard :station-code="stationCode" :ndm-decoder="ndmDecoder" :key="ndmDecoder.id" />
</NTabPane>
<!-- <NTabPane name="设备配置" tab="设备配置"></NTabPane> -->
<NTabPane name="原始数据" tab="原始数据">
<NTabPane v-if="userStore.isSuperAdmin" name="原始数据" tab="原始数据">
<pre>{{ { ...ndmDecoder, lastDiagInfo } }}</pre>
</NTabPane>
</NTabs>

View File

@@ -1,5 +1,6 @@
<script setup lang="ts">
import type { NdmKeyboardResultVO } from '@/apis/models';
import { useUserStore } from '@/stores/user';
import { NCard, NFlex, NTabPane, NTabs } from 'naive-ui';
import { ref, toRefs } from 'vue';
@@ -11,6 +12,8 @@ const props = defineProps<{
ndmKeyboard: NdmKeyboardResultVO;
}>();
const userStore = useUserStore();
const { stationCode, ndmKeyboard } = toRefs(props);
const selectedTab = ref('设备状态');
@@ -29,7 +32,7 @@ const selectedTab = ref('设备状态');
<KeyboardHistoryDiagCard :station-code="stationCode" :ndm-keyboard="ndmKeyboard" :key="ndmKeyboard.id" />
</NTabPane>
<!-- <NTabPane name="设备配置" tab="设备配置"></NTabPane> -->
<NTabPane name="原始数据" tab="原始数据">
<NTabPane v-if="userStore.isSuperAdmin" name="原始数据" tab="原始数据">
<pre>{{ { ...ndmKeyboard } }}</pre>
</NTabPane>
</NTabs>

View File

@@ -1,6 +1,7 @@
<script setup lang="ts">
import type { NdmNvrDiagInfo } from '@/apis/domains';
import type { NdmNvrResultVO } from '@/apis/models';
import { useUserStore } from '@/stores/user';
import { destr } from 'destr';
import { NCard, NFlex, NTabPane, NTabs } from 'naive-ui';
import { computed, ref, toRefs } from 'vue';
@@ -17,6 +18,8 @@ const props = defineProps<{
ndmNvr: NdmNvrResultVO;
}>();
const userStore = useUserStore();
const { stationCode, ndmNvr } = toRefs(props);
const lastDiagInfo = computed(() => {
@@ -70,7 +73,7 @@ const selectedTab = ref('设备状态');
<NvrDiagHistoryCard :station-code="stationCode" :ndm-nvr="ndmNvr" :key="ndmNvr.id" />
</NTabPane>
<!-- <NTabPane name="设备配置" tab="设备配置"></NTabPane> -->
<NTabPane name="原始数据" tab="原始数据">
<NTabPane v-if="userStore.isSuperAdmin" name="原始数据" tab="原始数据">
<pre>{{ { ...ndmNvr, lastDiagInfo } }}</pre>
</NTabPane>
</NTabs>

View File

@@ -1,6 +1,7 @@
<script setup lang="ts">
import type { NdmSecurityBoxDiagInfo } from '@/apis/domains';
import type { NdmSecurityBoxResultVO } from '@/apis/models';
import { useUserStore } from '@/stores/user';
import { destr } from 'destr';
import { NCard, NFlex, NTabPane, NTabs } from 'naive-ui';
import { computed, ref, toRefs } from 'vue';
@@ -17,6 +18,8 @@ const props = defineProps<{
ndmSecurityBox: NdmSecurityBoxResultVO;
}>();
const userStore = useUserStore();
const { stationCode, ndmSecurityBox } = toRefs(props);
const lastDiagInfo = computed(() => {
@@ -66,7 +69,7 @@ const selectedTab = ref('设备状态');
<SecurityBoxHistoryDiagCard :station-code="stationCode" :ndm-security-box="ndmSecurityBox" :key="ndmSecurityBox.id" />
</NTabPane>
<!-- <NTabPane name="设备配置" tab="设备配置"></NTabPane> -->
<NTabPane name="原始数据" tab="原始数据">
<NTabPane v-if="userStore.isSuperAdmin" name="原始数据" tab="原始数据">
<pre>{{ { ...ndmSecurityBox, lastDiagInfo } }}</pre>
</NTabPane>
</NTabs>

View File

@@ -1,6 +1,7 @@
<script setup lang="ts">
import type { NdmServerDiagInfo } from '@/apis/domains';
import type { NdmServerResultVO } from '@/apis/models';
import { useUserStore } from '@/stores/user';
import { destr } from 'destr';
import { NCard, NFlex, NTabPane, NTabs } from 'naive-ui';
import { computed, ref, toRefs } from 'vue';
@@ -14,6 +15,8 @@ const props = defineProps<{
ndmServer: NdmServerResultVO;
}>();
const userStore = useUserStore();
const { stationCode, ndmServer } = toRefs(props);
const lastDiagInfo = computed(() => {
@@ -45,7 +48,7 @@ const selectedTab = ref('设备状态');
<ServerHistoryDiagCard :station-code="stationCode" :ndm-server="ndmServer" :key="ndmServer.id" />
</NTabPane>
<!-- <NTabPane name="设备配置" tab="设备配置"></NTabPane> -->
<NTabPane name="原始数据" tab="原始数据">
<NTabPane v-if="userStore.isSuperAdmin" name="原始数据" tab="原始数据">
<pre>{{ { ...ndmServer, lastDiagInfo } }}</pre>
</NTabPane>
</NTabs>

View File

@@ -1,6 +1,7 @@
<script setup lang="ts">
import type { NdmSwitchDiagInfo } from '@/apis/domains';
import type { NdmSwitchResultVO } from '@/apis/models';
import { useUserStore } from '@/stores/user';
import { destr } from 'destr';
import { NCard, NFlex, NTabPane, NTabs } from 'naive-ui';
import { computed, ref, toRefs } from 'vue';
@@ -15,6 +16,8 @@ const props = defineProps<{
ndmSwitch: NdmSwitchResultVO;
}>();
const userStore = useUserStore();
const { stationCode, ndmSwitch } = toRefs(props);
const lastDiagInfo = computed(() => {
@@ -47,7 +50,7 @@ const selectedTab = ref('设备状态');
<SwitchHistoryDiagCard :station-code="stationCode" :ndm-switch="ndmSwitch" :key="ndmSwitch.id" />
</NTabPane>
<!-- <NTabPane name="设备配置" tab="设备配置"></NTabPane> -->
<NTabPane name="原始数据" tab="原始数据">
<NTabPane v-if="userStore.isSuperAdmin" name="原始数据" tab="原始数据">
<pre>{{ { ...ndmSwitch, lastDiagInfo } }}</pre>
</NTabPane>
</NTabs>

View File

@@ -5,7 +5,7 @@ import { AesEncryption } from '@/utils/cipher';
import { getAppEnvConfig } from '@/utils/env';
import axios, { AxiosError } from 'axios';
import { defineStore } from 'pinia';
import { ref } from 'vue';
import { computed, ref } from 'vue';
import dayjs from 'dayjs';
import { useStationStore } from './station';
import { useQueryControlStore } from './query-control';
@@ -34,6 +34,8 @@ export const useUserStore = defineStore(
const userResourceList = ref<string[]>([]);
const lampLoginResultRecord = ref<Record<string, LoginResult> | null>(null);
const isSuperAdmin = computed(() => userInfo.value?.['id'] === '2');
const resetStore = () => {
userLoginResult.value = null;
userInfo.value = null;
@@ -145,6 +147,7 @@ export const useUserStore = defineStore(
return {
userLoginResult,
userInfo,
isSuperAdmin,
userResourceList,
lampLoginResultRecord,