wzyyy 3 سال پیش
والد
کامیت
90dbaa501b

+ 14 - 3
src/pages/media/Stream/Detail/index.tsx

@@ -6,6 +6,7 @@ import { useParams } from 'umi';
 import { QuestionCircleOutlined } from '@ant-design/icons';
 import SipComponent from '@/components/SipComponent';
 import { onlyMessage, testIP } from '@/utils/util';
+import useLocation from '@/hooks/route/useLocation';
 
 interface RTPComponentProps {
   onChange?: (data: any) => void;
@@ -126,6 +127,14 @@ const Detail = () => {
   const params = useParams<{ id: string }>();
   const [form] = Form.useForm();
   const [providers, setProviders] = useState<any[]>([]);
+  const locations = useLocation();
+  const [view, setView] = useState<boolean>(false);
+
+  useEffect(() => {
+    if (locations && locations.state) {
+      setView(locations.state.view);
+    }
+  }, [locations]);
 
   useEffect(() => {
     service.queryProviders().then((resp) => {
@@ -347,9 +356,11 @@ const Detail = () => {
             </Col>
             <Col span={24}>
               <Form.Item>
-                <Button type="primary" htmlType="submit">
-                  保存
-                </Button>
+                {!view && (
+                  <Button type="primary" htmlType="submit">
+                    保存
+                  </Button>
+                )}
               </Form.Item>
             </Col>
           </Row>

+ 23 - 2
src/pages/media/Stream/index.tsx

@@ -5,11 +5,12 @@ import { Card, Col, Empty, Pagination, Row } from 'antd';
 import { useEffect, useState } from 'react';
 import Service from '@/pages/media/Stream/service';
 import { getMenuPathByParams, MENUS_CODE } from '@/utils/menu';
-import { useHistory } from 'umi';
+import useHistory from '@/hooks/route/useHistory';
 import {
   CloseCircleOutlined,
   DeleteOutlined,
   EditOutlined,
+  EyeOutlined,
   PlayCircleOutlined,
   PlusOutlined,
 } from '@ant-design/icons';
@@ -28,7 +29,7 @@ export const StreamModel = model<{
 });
 
 const Stream = () => {
-  const history = useHistory<Record<string, string>>();
+  const history = useHistory();
   const [param, setParam] = useState<any>({ pageSize: 10, terms: [] });
   const permissionCode = 'media/Stream';
   const { permission } = PermissionButton.usePermission(permissionCode);
@@ -122,6 +123,26 @@ const Stream = () => {
                     <Col key={item.id} span={12}>
                       <StreamCard
                         {...item}
+                        detail={
+                          <PermissionButton
+                            type="link"
+                            isPermission={permission.view}
+                            style={{ padding: 0, fontSize: 24, color: '#fff' }}
+                            key="view"
+                            onClick={() => {
+                              history.push(
+                                `${getMenuPathByParams(
+                                  MENUS_CODE['media/Stream/Detail'],
+                                  item.id,
+                                )}`,
+                                { view: true },
+                              );
+                              StreamModel.current = { ...item };
+                            }}
+                          >
+                            <EyeOutlined />
+                          </PermissionButton>
+                        }
                         actions={[
                           <PermissionButton
                             isPermission={permission.update}

+ 112 - 89
src/pages/oauth/index.tsx

@@ -22,6 +22,7 @@ const Oauth = () => {
   const [appName, setAppName] = useState<string>('');
   const [params, setParams] = useState<any>({});
   const [internal, setLinternal] = useState<any>();
+  const loadingRef = useRef<boolean>(true);
 
   const loginRef = useRef<Partial<LoginParam>>({});
   const loginForm = useMemo(
@@ -139,8 +140,14 @@ const Oauth = () => {
       setIsLogin(false);
       getCode();
       initApplication(data.client_id || params.client_id);
+      // setTimeout(()=>{
+      //   loadingRef.current=false
+      // })
     } else {
       setIsLogin(false);
+      // setTimeout(()=>{
+      //   loadingRef.current=false
+      // })
     }
   };
 
@@ -180,34 +187,44 @@ const Oauth = () => {
   }, []);
 
   useEffect(() => {
-    let redirectUrl;
-    const items = {
-      // code: getQueryVariable('code'),
-      client_id: getQueryVariable('client_id'),
-      state: getQueryVariable('state'),
-      redirect_uri: decodeURIComponent(getQueryVariable('redirect_uri')),
-      response_type: getQueryVariable('response_type'),
-      scope: getQueryVariable('scope'),
+    // console.log('..............')
+    const init = async () => {
+      await Promise.resolve().then(() => {
+        // console.log(1, loadingRef.current)
+        let redirectUrl;
+        const items = {
+          client_id: getQueryVariable('client_id'),
+          state: getQueryVariable('state'),
+          redirect_uri: decodeURIComponent(getQueryVariable('redirect_uri')),
+          response_type: getQueryVariable('response_type'),
+          scope: getQueryVariable('scope'),
+        };
+        const item = getQueryVariable('internal');
+        if (items.redirect_uri) {
+          const orgin = items.redirect_uri.split('/').slice(0, 3);
+          const url = `${orgin.join('/')}/%23/${items.redirect_uri?.split('redirect=')[1]}`;
+          redirectUrl = `${items.redirect_uri?.split('redirect=')[0]}redirect=${url}`;
+        }
+        getLoginUser({
+          ...items,
+          internal: getQueryVariable('internal'),
+          redirect_uri: redirectUrl,
+        });
+        setLinternal(item);
+        setParams({
+          ...items,
+          redirect_uri: redirectUrl,
+        });
+      });
+      // debugger;
+      await Promise.resolve().then(() => {
+        // console.log(2, loadingRef.current)
+        // debugger;
+        loadingRef.current = false;
+        // console.log(3, loadingRef.current)
+      });
     };
-    const item = getQueryVariable('internal');
-    if (items.redirect_uri) {
-      // console.log(items.redirect_uri,'params')
-      const orgin = items.redirect_uri.split('/').slice(0, 3);
-      // console.log(orgin)
-      const url = `${orgin.join('/')}/%23/${items.redirect_uri?.split('redirect=')[1]}`;
-      redirectUrl = `${items.redirect_uri?.split('redirect=')[0]}redirect=${url}`;
-    }
-    getLoginUser({
-      ...items,
-      internal: getQueryVariable('internal'),
-      redirect_uri: redirectUrl,
-    });
-    setLinternal(item);
-    setParams({
-      ...items,
-      redirect_uri: redirectUrl,
-    });
-    // console.log(items, '11111111111')
+    init();
   }, [window.location]);
 
   //未登录状态
@@ -233,69 +250,75 @@ const Oauth = () => {
   };
 
   return (
-    <div
-      className="oauth"
-      style={{
-        width: '100%',
-        height: '100vh',
-        background: `url(${bindPage}) no-repeat`,
-        backgroundSize: '100% 100%',
-      }}
-    >
-      <div className="oauth-header">
-        <div className="oauth-header-left">
-          <img src={logo} />
-        </div>
-        {/* <div className="oauth-header-right">
-          <a style={{ color: 'rgb(0 0 0 / 70%)' }}>{userName || '-'}</a>
-          <div className="oauth-header-right-connect">|</div>
-                    <a
-                        style={{ color: 'rgb(0 0 0 / 70%)' }}
-                        onClick={(() => {
-                            setIsLogin(false)
-                        })}
-                    >切换账号</a>
-        </div> */}
-      </div>
-      <div className="oauth-content">
-        {isLogin ? (
-          <>
-            <div className="oauth-content-header">
-              <img src={headerImg} />
-            </div>
-            <div className="oauth-content-content">
-              <div className="oauth-content-content-text">
-                {`您正在授权登录,${appName || '-'}将获得以下权限:`}
-              </div>
-              <ul>
-                <li>{`关联${userName}账号`}</li>
-                <li>获取您的个人信息 </li>
-              </ul>
+    <>
+      {loadingRef.current ? (
+        <></>
+      ) : (
+        <div
+          className="oauth"
+          style={{
+            width: '100%',
+            height: '100vh',
+            background: `url(${bindPage}) no-repeat`,
+            backgroundSize: '100% 100%',
+          }}
+        >
+          <div className="oauth-header">
+            <div className="oauth-header-left">
+              <img src={logo} />
             </div>
-            <div className="oauth-content-button">
-              <Button
-                type="primary"
-                onClick={() => {
-                  goOAuth2();
-                }}
-              >
-                同意授权
-              </Button>
-              <Button
-                onClick={() => {
-                  localStorage.removeItem('X-Access-Token');
-                  setIsLogin(false);
-                }}
-              >
-                切换账号
-              </Button>
-            </div>
-          </>
-        ) : (
-          loginPage()
-        )}
-      </div>
-    </div>
+            {/* <div className="oauth-header-right">
+        <a style={{ color: 'rgb(0 0 0 / 70%)' }}>{userName || '-'}</a>
+        <div className="oauth-header-right-connect">|</div>
+                  <a
+                      style={{ color: 'rgb(0 0 0 / 70%)' }}
+                      onClick={(() => {
+                          setIsLogin(false)
+                      })}
+                  >切换账号</a>
+      </div> */}
+          </div>
+          <div className="oauth-content">
+            {isLogin ? (
+              <>
+                <div className="oauth-content-header">
+                  <img src={headerImg} />
+                </div>
+                <div className="oauth-content-content">
+                  <div className="oauth-content-content-text">
+                    {`您正在授权登录,${appName || '-'}将获得以下权限:`}
+                  </div>
+                  <ul>
+                    <li>{`关联${userName}账号`}</li>
+                    <li>获取您的个人信息 </li>
+                  </ul>
+                </div>
+                <div className="oauth-content-button">
+                  <Button
+                    type="primary"
+                    onClick={() => {
+                      goOAuth2();
+                    }}
+                  >
+                    同意授权
+                  </Button>
+                  <Button
+                    onClick={() => {
+                      localStorage.removeItem('X-Access-Token');
+                      setIsLogin(false);
+                    }}
+                  >
+                    切换账号
+                  </Button>
+                </div>
+              </>
+            ) : (
+              loginPage()
+            )}
+          </div>
+        </div>
+      )}
+    </>
   );
 };
 export default Oauth;

+ 14 - 1
src/pages/system/Apply/Save/index.tsx

@@ -265,6 +265,11 @@ const Save = () => {
         data.id = data.apiServer.appId;
       }
     }
+    //api客户端  accessTokenProperty grantType 默认参数
+    // if(data.integrationModes.includes('apiClient')){
+    //   data.apiClient.authConfig.grantType='authorization_code'
+    //   data.apiClient.authConfig.accessTokenProperty='access_token'
+    // }
     //独立应用,单点登录需要api配置和单点登录配置
     if (
       data.provider === 'internal-standalone' &&
@@ -770,7 +775,7 @@ const Save = () => {
             gridSpan: 2,
             layout: 'vertical',
             labelAlign: 'left',
-            tooltip: '访问iot平台接口的地址',
+            tooltip: '访问第三方平台接口的地址',
           },
           required: true,
           'x-component': 'Input',
@@ -1099,6 +1104,14 @@ const Save = () => {
                 'x-component-props': {
                   placeholder: '请输入回调地址',
                 },
+                'x-reactions': {
+                  dependencies: ['provider'],
+                  fulfill: {
+                    state: {
+                      visible: '{{$deps[0] && $deps[0]!=="third-party"}}',
+                    },
+                  },
+                },
               },
               'apiServer.roleIdList': {
                 title: '角色',

+ 8 - 2
src/pages/system/Role/index.tsx

@@ -1,5 +1,5 @@
 import { PageContainer } from '@ant-design/pro-layout';
-import React, { useRef, useState } from 'react';
+import React, { useEffect, useRef, useState } from 'react';
 import { DeleteOutlined, EditOutlined, PlusOutlined } from '@ant-design/icons';
 import type { ActionType, ProColumns } from '@jetlinks/pro-table';
 import Service from './service';
@@ -11,13 +11,14 @@ import { PermissionButton } from '@/components';
 import { onlyMessage } from '@/utils/util';
 import ProTable from '@jetlinks/pro-table';
 import SearchComponent from '@/components/SearchComponent';
-import { useDomFullHeight } from '@/hooks';
+import { useDomFullHeight, useLocation } from '@/hooks';
 import Save from './Save';
 
 export const service = new Service('role');
 
 const Role: React.FC = observer(() => {
   const intl = useIntl();
+  const location = useLocation();
   const actionRef = useRef<ActionType>();
   const permissionCode = 'system/Role';
   const { permission } = PermissionButton.usePermission(permissionCode);
@@ -140,6 +141,11 @@ const Role: React.FC = observer(() => {
   ];
 
   const [param, setParam] = useState({});
+  useEffect(() => {
+    if ((location as any).query?.save === 'true') {
+      setMode('add');
+    }
+  }, [location]);
 
   return (
     <PageContainer>