zoukankan      html  css  js  c++  java
  • [OHIF-Viewers]医疗数字阅片-医学影像-redux-token实操-给 OHIF-Viewer 增加自定义 token 身份认证

    [OHIF-Viewers]医疗数字阅片-医学影像-redux-token实操

    需要更改地方

    修改: platform/core/src/redux/actions.js
    修改: platform/core/src/redux/reducers/index.js
    新文件: platform/core/src/redux/reducers/token.js
    修改: platform/viewer/src/App.js

    actions.js

    +export const setToken =token=>({
    +  type:'SET_TOKEN',
    +  token
    +})
    
    setStudyData,
    setServers,
    +setToken,
    };

    reducers/index.js

    import viewports from './viewports';
    +import Token from './token'
    ……
    viewports,
    +Token,

    reducers/token.js

    //默认state
    export const defaultState = {
      token: 1,
    };
    
    const Token = (state = defaultState, action) => {
      switch (action.type) {
        case 'SET_TOKEN': //不使用样板文件
          // return { ...state, token: action.token }; //旧的state一起返回
              return action.token;//只返回新值
        default:
          return state;
      }
    };
    
    export default Token;

    src/App.js

    +import {setToken} from "@ohif/core/src/redux/actions";//直连引入setToken
    //设置token
    +store.dispatch(setToken(this.getQueryToken('token')?this.getQueryToken('token'):'00'));
    +console.log(store.getState().token);
    
    +//获取url 参数
    +getQueryToken(name) {
    +       var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
    +       var r = window.location.search.substr(1).match(reg);
    +       if (r != null) return unescape(r[2]);
    +        return null;
    +    }
  • 相关阅读:
    Github的基本使用
    Java Web工程搭建方法
    程序中使用百度地图
    Flutter 依赖的那些事儿
    Flutter Widgets (Container/Row/Column/Image)
    Flutter 安装
    UWP FillRowViewPanel
    UWP Composition API
    UWP Composition API
    UWP Jenkins + NuGet + MSBuild 手把手教你做自动UWP Build 和 App store包
  • 原文地址:https://www.cnblogs.com/landv/p/13355412.html
Copyright © 2011-2022 走看看