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

View File

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

View File

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

View File

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

View File

@ -38,7 +38,9 @@ const props = defineProps({
// //
const jumpPage = (row: recommendList) => { 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); row.onClick ? row.onClick(row) : _jumpPage(row.linkUrl, row.params);
}; };
</script> </script>

View File

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

View File

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

View File

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