• [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;
    +    }
  • 相关阅读:
    Elasticsearch 分词
    Elasticsearch:文档乐观锁控制 if_seq_no与if_primary_term
    调用javaAPI访问hive
    sqoop笔记
    hive学习
    添加用户到sudo组
    HTTP协议用的TCP但是只建立单向连接
    Hadoop基本操作
    Hadoop原理介绍
    sed用法
  • 原文地址:https://www.cnblogs.com/landv/p/13355412.html
Copyright © 2020-2023  润新知