Browse Source

pdf 下载

zhaojijng 2 years ago
parent
commit
76bf48ff7a
1 changed files with 33 additions and 4 deletions
  1. 33 4
      src/layouts/index.jsx

+ 33 - 4
src/layouts/index.jsx

@@ -9,20 +9,29 @@ import NavMenu from '@/components/navMenu';
 
 export default (props) => {
   const { menuVisible, closeMenu, toggleMenu } = useModel('controller');
-
+  const { initialState, setInitialState } = useModel('@@initialState');
   const [notifyList] = useState([
     {
       title: '管理员操作指南',
       id: 'notify1',
       content: '具体介绍管理员权限下的管理功能及相关操作说明。',
+      name: '行政端操作指南.pdf',
+      url: 'http://10.100.28.79/image-service/common/file_get?systemId=dataPlatform&key=%E8%A1%8C%E6%94%BF%E7%AB%AF%E6%93%8D%E4%BD%9C%E6%89%8B%E5%86%8C20220419.pdf',
+    },
+    {
+      title: 'sagacare介绍',
+      id: 'notify2',
+      content: '环境健康主动管理服务',
+      name: 'saga销售手册.pdf',
+      url: 'http://10.100.28.79/image-service/common/file_get?systemId=dataPlatform&key=sagacare%E4%BB%8B%E7%BB%8D.pdf',
     },
-    { title: 'sagacare介绍', id: 'notify2', content: '环境健康主动管理服务' },
   ]);
   const showMenuClick = () => {
     toggleMenu();
   };
 
   const openNotification = () => {
+    //打开通知框
     notifyList.map((item, index) => {
       notification.open({
         key: item.id,
@@ -30,17 +39,26 @@ export default (props) => {
         description: item.content,
         duration: 0,
         onClick: () => {
-          console.log('Notification Clicked!');
+          console.log('Notification Clicked!', item);
+          // 下载pdf 需产品给出
+          //const downLoadUrl = '';
+          const a = document.createElement('a');
+          a.href = item.url;
+          a.target = '_blank';
+          a.download = item.name;
+          a.click();
         },
         icon: <SmileOutlined style={{ color: '#108ee9', fontSize: 32 }} />,
         style: {
           width: 400,
           borderRadius: 30,
+          cursor: 'pointer',
         },
         closeIcon: <></>,
       });
     });
   };
+  //关闭提醒框
   const closeNotify = () => {
     //console.log('close-notify');
     notifyList.map((item, index) => {
@@ -48,7 +66,18 @@ export default (props) => {
     });
   };
 
-  useEffect(() => {
+  useEffect(async () => {
+    // debugger;
+    // console.log('enviroment-layout', initialState);
+    // const currentUser = await initialState?.fetchUser?.();
+    // debugger;
+    // if (currentUser) {
+    //   setInitialState((s) => {
+    //     return { ...s, currentUser: currentUser };
+    //   });
+    // }
+
+    //关闭
     document.querySelector('#root').addEventListener('click', closeNotify, true);
     const { REACT_APP_ENV } = process.env;
     console.log('REACT_APP_ENV', REACT_APP_ENV);