fix: 首页自测 优化

This commit is contained in:
easy 2023-03-09 15:05:05 +08:00
parent 4dcbf18939
commit 80faeb5f0f
5 changed files with 26 additions and 37 deletions

View File

@ -28,34 +28,19 @@
<script setup lang="ts">
import { message } from 'ant-design-vue';
import { bootConfig } from "../typing";
import { bootConfig } from '../typing';
import { useMenuStore } from '@/store/menu';
const router = useRouter();
const props = defineProps({
cardData: Array<bootConfig>,
cardTitle: String,
});
const { cardData, cardTitle } = toRefs(props);
const { jumpPage: _jumpPage } = useMenuStore();
const jumpPage = (row: bootConfig): void => {
if (row.auth && row.link) {
router.push(`${row.link}${objToParams(row.params || {})}`);
} else {
message.warning('暂无权限,请联系管理员');
}
};
const objToParams = (source: object): string => {
if (Object.prototype.toString.call(source) === '[object Object]') {
const paramsArr = <any>[];
// 使for ints
Object.entries(source).forEach(([prop, value]) => {
if (typeof value === 'object') value = JSON.stringify(value);
paramsArr.push(`${prop}=${value}`);
});
if (paramsArr.length > 0) return '?' + paramsArr.join('&');
}
return '';
const jumpPage = (item: bootConfig) => {
if (item.auth === undefined || item.auth) _jumpPage(item.link, item.params);
else message.warning('暂无权限,请联系管理员');
};
</script>

View File

@ -182,10 +182,7 @@ const opsBootConfig: bootConfig[] = [
{
english: 'STEP3',
label: '实时监控',
link: 'link/Dashboard',
params: {
save: true,
},
link: 'link/DashBoard',
image: '/images/home/guide-home6.png',
},
];

View File

@ -32,12 +32,12 @@ const opsBootConfig: bootConfig[] = [
{
english: 'STEP1',
label: '设备接入配置',
link: 'link/accessConfig',
link: 'link/AccessConfig',
},
{
english: 'STEP2',
label: '日志排查',
link: 'link/Log',
link: 'Log',
params: {
key: 'system',
},
@ -45,7 +45,7 @@ const opsBootConfig: bootConfig[] = [
{
english: 'STEP3',
label: '实时监控',
link: 'link/dashboard',
link: 'link/DashBoard',
params: {
type: 'add',
},

View File

@ -26,13 +26,19 @@ const { jumpPage } = useMenuStore();
const projectNum = ref(0);
const deviceNum = ref(0);
const menuPermission = useMenuStore().hasPermission;
const getData = () => {
getDeviceCount_api().then((resp: any) => {
deviceNum.value = resp.result;
});
getProductCount_api({}).then((resp: any) => {
projectNum.value = resp.result;
});
//
menuPermission('device/Product') &&
getDeviceCount_api().then((resp: any) => {
deviceNum.value = resp.result;
});
//
menuPermission('device/Instance') &&
getProductCount_api({}).then((resp: any) => {
projectNum.value = resp.result;
});
};
getData();
</script>

View File

@ -52,9 +52,10 @@ const secureKey = ref<string>('');
const setCurrentView = () => {
getView_api().then((resp: any) => {
if (resp.status === 200) {
if (resp.result) currentView.value = resp.result?.content;
else if (resp.result.username === 'admin') {
currentView.value = 'comprehensive';
if (resp.result) {
if (resp.result.username === 'admin')
currentView.value = 'comprehensive';
else currentView.value = resp.result?.content;
} else currentView.value = 'init';
}
});