update: 首页代码优化

This commit is contained in:
easy 2023-03-16 15:34:24 +08:00
parent db3c66d3b7
commit 2f7a4f718b
8 changed files with 37 additions and 38 deletions

View File

@ -34,8 +34,11 @@ const props = defineProps({
const { cardData, cardTitle } = toRefs(props);
const jumpPage = (item: bootConfig) => {
if (item.auth === undefined || item.auth) _jumpPage(item.link, item.params);
else message.warning('暂无权限,请联系管理员');
if (item.auth === undefined || item.auth) {
_jumpPage(item.link, item.params);
} else {
message.warning('暂无权限,请联系管理员');
}
};
</script>

View File

@ -37,8 +37,11 @@ const { cardData, cardTitle } = toRefs(props);
const { jumpPage: _jumpPage } = useMenuStore();
const jumpPage = (item: bootConfig) => {
if (item.auth === undefined || item.auth) _jumpPage(item.link, item.params);
else message.warning('暂无权限,请联系管理员');
if (item.auth === undefined || item.auth) {
_jumpPage(item.link, item.params);
} else {
message.warning('暂无权限,请联系管理员');
}
};
</script>

View File

@ -13,7 +13,7 @@
<j-row :gutter="24">
<j-col :span="12"><DeviceCountCard /></j-col>
<j-col :span="12"><BasicCountCard /></j-col>
<j-col :span="24" style="margin-top: 24px;">
<j-col :span="24" style="margin-top: 24px">
<PlatformPicCard image="/images/home/content1.svg" />
</j-col>
</j-row>
@ -157,7 +157,7 @@ const deviceStepDetails: recommendList[] = [
linkUrl: 'device/Instance',
auth: devicePermission('import'),
params: {
type: 'import'
type: 'import',
},
},
];
@ -227,17 +227,4 @@ const opsStepDetails: recommendList[] = [
const productDialogVisible = ref(false);
const deviceDialogVisible = ref(false);
// ---- {save:true}
// ----- {id: 'xxxx', tab:'xxx'}
// ---- {save: true}
// ----
// ----
// -----
// ----
</script>

View File

@ -46,9 +46,6 @@ const opsBootConfig: bootConfig[] = [
english: 'STEP3',
label: '实时监控',
link: 'link/DashBoard',
params: {
type: 'add',
},
},
];
const opsStepDetails: recommendList[] = [

View File

@ -38,7 +38,9 @@ const props = defineProps({
//
const jumpPage = (row: recommendList) => {
if (row.auth === false) return message.warning('暂无权限,请联系管理员');
if (row.auth === false) {
return message.warning('暂无权限,请联系管理员');
}
row.onClick ? row.onClick(row) : _jumpPage(row.linkUrl, row.params);
};
</script>

View File

@ -52,7 +52,9 @@ const props = defineProps<{
//
const confirm = () => {
if (selectedKeys.value.length < 1) return message.warn('请选择设备');
if (selectedKeys.value.length < 1) {
return message.warn('请选择设备');
}
emits('confirm', selectedKeys.value[0]);
emits('update:visible', false);
};

View File

@ -46,8 +46,8 @@ const form = ref({
const productList = ref<[productItem] | []>([]);
const getOptions = () => {
getProductList_api().then((resp: any) => {
productList.value = resp.result
getProductList_api().then(({ result }: any) => {
productList.value = result
.filter((i: any) => !i?.accessId)
.map((item: { name: any; id: any }) => ({
label: item.name,

View File

@ -1,6 +1,6 @@
<template>
<page-container>
<div class="iot-home-container" v-loading="loading">
<div class="iot-home-container">
<InitHome v-if="currentView === 'init'" @refresh="setCurrentView" />
<DeviceHome v-else-if="currentView === 'device'" />
<DevOpsHome v-else-if="currentView === 'ops'" />
@ -54,25 +54,26 @@ import { getMe_api, getView_api } from '@/api/home';
import { getAppInfo_api } from '@/api/system/apply';
const currentView = ref<string>('');
const loading = ref<boolean>(true);
const clientId = useUserInfo().$state.userInfos.id;
const secureKey = ref<string>('');
const showKey = ref(false);
//
const setCurrentView = () => {
getView_api().then((resp: any) => {
if (resp.status === 200) {
if (resp.result) {
if (resp.result.username === 'admin')
currentView.value = 'comprehensive';
else currentView.value = resp.result?.content;
} else currentView.value = 'init';
getView_api().then(({ status, result }: any) => {
if (status === 200) {
currentView.value = 'init';
if (result) {
currentView.value =
result.username === 'admin'
? 'comprehensive'
: result?.content;
}
}
});
};
if (isNoCommunity) {
// api
// api
getMe_api().then((resp: any) => {
if (resp && resp.status === 200) {
const isApiUser = resp.result.dimensions.find(
@ -85,10 +86,14 @@ if (isNoCommunity) {
getAppInfo_api(clientId).then((resp: any) => {
secureKey.value = resp.result.apiServer.secureKey;
});
} else setCurrentView();
} else {
setCurrentView();
}
}
});
} else setCurrentView();
} else {
setCurrentView();
}
</script>
<style lang="less" scoped>