Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Nov 8, 2022. It is now read-only.

Commita17fb84

Browse files
committed
fix(route): use history.pushState intead of next build-in
1 parentafc09a4 commita17fb84

File tree

2 files changed

+11
-12
lines changed

2 files changed

+11
-12
lines changed

‎containers/Route/logic.js‎

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import{useEffect}from'react'
2-
import{buildLog,getMainPath,getSubPath,Global}from'@utils'
2+
import{Global,buildLog,getMainPath,getSubPath}from'@utils'
33

44
/* eslint-disable-next-line */
55
constlog=buildLog('L:Route')
@@ -12,6 +12,9 @@ const browserHistoryBtnClicked = popstate => {
1212
Global.location=popstate.state.as
1313
}
1414

15+
// ###############################
16+
// init & uninit
17+
// ###############################
1518
exportconstinit=(_store,routeObj)=>{
1619
if(store)returnfalse
1720

@@ -28,10 +31,6 @@ export const init = (_store, routeObj) => {
2831

2932
exportconstuninit=()=>{}
3033

31-
// ###############################
32-
// init & uninit
33-
// ###############################
34-
3534
exportconstuseInit=(_store,routeObj)=>{
3635
useEffect(()=>{
3736
store=_store
@@ -45,5 +44,3 @@ export const useInit = (_store, routeObj) => {
4544
Global.onpopstate=browserHistoryBtnClicked
4645
},[_store,routeObj])
4746
}
48-
49-
exportconstholder=1

‎containers/Route/store.js‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55

66
import{typesast,getParent}from'mobx-state-tree'
77
importRfrom'ramda'
8-
importRouterfrom'next/router'
8+
//import Router from 'next/router'
99

1010
import{PAGE_SIZE}from'@config'
11-
import{onClient,markStates,buildLog,serializeQuery}from'@utils'
11+
import{Global,onClient,markStates,buildLog,serializeQuery}from'@utils'
1212

1313
/* eslint-disable-next-line */
1414
constlog=buildLog('S:RouteStore')
@@ -47,18 +47,20 @@ const RouteStore = t
4747

4848
if(page&&String(page)==='1')query=R.omit(['page'],query)
4949

50-
constallQueryString=serializeQuery(query)
50+
//const allQueryString = serializeQuery(query)
5151
constqueryString=serializeQuery(R.omit(['mainPath','subPath'],query))
5252

53-
consturl=`/${allQueryString}`
53+
//const url = `/${allQueryString}`
5454
constasPath=`/${self.mainPath}/${self.subPath}${queryString}`
5555

5656
// NOTE: shallow option only works for same page url
5757
// if page is diffrent, it will cause page reload
5858
/* console.log('push url: ', url) */
59-
Router.push(url,asPath,{shallow:true})
59+
//Router.push(url, asPath, { shallow: true })
6060
// see: https://stackoverflow.com/questions/824349/modify-the-url-without-reloading-the-page
6161
/* return Global.history.pushState({}, null, url) */
62+
// NOTE: Router.push(url, asPath, { shallow: true }) is not working on pruction env
63+
returnGlobal.history.pushState({},null,asPath)
6264
},
6365
markState(sobj){
6466
markStates(sobj,self)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp