當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript react-router.browserHistory類代碼示例

本文整理匯總了TypeScript中react-router.browserHistory的典型用法代碼示例。如果您正苦於以下問題:TypeScript browserHistory類的具體用法?TypeScript browserHistory怎麽用?TypeScript browserHistory使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了browserHistory類的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: searchOffsetChange

function* searchOffsetChange(action: WorkSearchAction): any {
  browserHistory.push({
    pathname: 'works',
    query: {
      ...browserHistory.getCurrentLocation().query,
      offset: action.offset,
    },
  })
}
開發者ID:aconly,項目名稱:explorer-web,代碼行數:9,代碼來源:NavbarSaga.ts

示例2: VerifiedAccount

function* VerifiedAccount(action: any): SagaIterator {
  const toastId = toast.info('Verifying account...', {
    className: 'toast',
  })

  try {
    const { token, password } = action.payload
    yield put(Actions.LoadingPage.onLoadingOn())

    const data = yield call(GetApiTokensFrost, token, password)
    yield put(Actions.VerifiedAccount.onVerifiedAccountSuccess())

    yield put(Actions.LoadingPage.onLoadingFull())
    yield put(Actions.SignOut.onSignOut({ redirectLogin: false }))
    yield put(Actions.SetTokenLogin.onSetTokenLogin(data))

    yield call(delay, 1000)

    browserHistory.push('/dashboard')

    toast.success('Your account has been verified!', {
      className: 'toast',
      autoClose: 2500,
    })
  } catch (e) {
    yield put(Actions.LoadingPage.onLoadingFull())
    yield put(Actions.VerifiedAccount.onVerifiedAccountError(e))
    yield call(delay, 300)
    yield put(Actions.VerifiedAccount.onVerifiedAccountClearError())

    if (e.includes('Email already verified')) {
      browserHistory.push('/dashboard')
      toast.info(e, {
        className: 'toast',
        autoClose: 2500,
      })
    } else if (e.includes('Expired token')) {
      const message = 'This link has expired. Please login and request a new validation email.'
      toast.update(toastId, {
        render: message,
        type: toast.TYPE.ERROR,
        className: 'toast',
        autoClose: false,
      })
    } else
      toast.update(toastId, {
        render: e,
        type: toast.TYPE.ERROR,
        autoClose: false,
        className: 'toast',
      })
  }
}
開發者ID:aconly,項目名稱:frost-web,代碼行數:53,代碼來源:VerifiedAccount.saga.ts

示例3: ChangePasswordToken

function* ChangePasswordToken(action: any): SagaIterator {
  try {
    const { token, password } = action.payload
    yield put(Actions.LoadingPage.onLoadingOn())

    const data = yield call(ChangePasswordTokenFrost, token, password)
    yield put(Actions.ChangePasswordToken.onChangePasswordTokenSuccess(data))

    yield put(Actions.LoadingPage.onLoadingFull())
    yield put(Actions.SignOut.onSignOut({ redirectLogin: false }))
    yield put(Actions.SetTokenLogin.onSetTokenLogin(data))

    yield call(delay, 1000)

    browserHistory.push('/dashboard')

    toast.success('Your password has been updated!', {
      className: 'toast',
      autoClose: 2500,
    })
  } catch (e) {
    yield put(Actions.LoadingPage.onLoadingFull())
    yield put(Actions.ChangePasswordToken.onChangePasswordTokenError(e))
    yield call(delay, 300)
    yield put(Actions.ChangePasswordToken.onChangePasswordTokenClearError())

    toast.error(e, {
      className: 'toast',
      autoClose: 2500,
    })
  }
}
開發者ID:aconly,項目名稱:frost-web,代碼行數:32,代碼來源:ChangePasswordToken.saga.ts

示例4: failCB

 function failCB(ex:any):void {
     toast("error", "some error", "error");
     console.log(ex);
     if(ex.status === 401){
         browserHistory.push('/login?failed=true');
     }
 }
開發者ID:uryyyyyyy,項目名稱:play2sample,代碼行數:7,代碼來源:ActionCreators.ts

示例5: SignOut

function SignOut(action: any): void {
  try {
    if (!(action.payload && action.payload.redirectLogin === false)) browserHistory.push('/login')
  } catch (e) {
    // Todo: Error message in UI
  }
}
開發者ID:aconly,項目名稱:frost-web,代碼行數:7,代碼來源:SignOut.saga.ts

示例6: Chance

const newNode = () => {
  const chance = new Chance();
  const id = chance.guid();
  browserHistory.push(`/${id}`)
  return {
    type: action.NEW_NODE,
    payload: { keys: [id], values: {[id]: {id, name: '', recipe: ''}}}
  }
};
開發者ID:phdog,項目名稱:typeahead,代碼行數:9,代碼來源:data.ts

示例7: dispatch

 request.then(response => {
   try {
     browserHistory.push('/');
     dispatch(flushSearch());
     dispatch(fetchData());
     } catch (e) {
     throw e
   } finally {
     dispatch(resRecieved());
   }
 }).catch(e => {
開發者ID:phdog,項目名稱:typeahead,代碼行數:11,代碼來源:data.ts

示例8: HandleEvent

 public static HandleEvent(roomID : string) {
   Hub.socket.inRoom = true;
   browserHistory.push(`/${roomID}`);
   Hub.logger.logSuccess(`> Joined room: ${roomID}`);
   if(Hub.youtube.IsPlayerReady())
   {
     Hub.socket.getYoutubePlayerState();
   }
   else
   {
     Hub.dispatcher.addEventListener("youtube_player_ready", JoinRoomSuccessEvent.OnYoutubePlayerLoaded);
   }
 }
開發者ID:andwoo,項目名稱:grouptube2,代碼行數:13,代碼來源:JoinRoomEvents.ts

示例9: pickBy

export const updateQueryParams = (updatedQueryParams: object): void => {
  const currentQueryString = window.location.search
  const newQueryParams = pickBy(
    {
      ...qs.parse(currentQueryString, {ignoreQueryPrefix: true}),
      ...updatedQueryParams,
    },
    v => !!v
  )

  const newQueryString = qs.stringify(newQueryParams)

  browserHistory.replace(`${window.location.pathname}?${newQueryString}`)
}
開發者ID:influxdata,項目名稱:influxdb,代碼行數:14,代碼來源:queryParams.ts

示例10: navigateTo

export function navigateTo(path, event?) {{{
    if (last_navigateTo.path === path && Date.now() - last_navigateTo.timestamp < 100) {
        /* debounce, this is for elements that need to have both onClick and onMouseUp to
         * handle various use cases in different browsers */
        console.log('navigate debounce');
        return false;
    }

    last_navigateTo.path = path;
    last_navigateTo.timestamp = Date.now();

    if (event && shouldOpenNewTab(event)) {
        window.open(path, "_blank");
    } else {
        browserHistory.push(path);
    }
}}}
開發者ID:PowerOlive,項目名稱:online-go.com,代碼行數:17,代碼來源:misc.ts


注:本文中的react-router.browserHistory類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。