Skip to content

Commit 20ab9f1

Browse files
committed
improve url change logic
1 parent e0a5b74 commit 20ab9f1

File tree

4 files changed

+364
-665
lines changed

4 files changed

+364
-665
lines changed

packages/reshow-url/compile.sh

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,37 @@
11
#!/bin/sh
22

3-
npm run build
3+
develop(){
4+
echo "Develop Mode";
5+
npm run build
6+
}
7+
8+
killBy(){
9+
ps auxwwww | grep $1 | grep -v grep | awk '{print $2}' | xargs -I{} kill -9 {}
10+
}
11+
12+
stop(){
13+
DIR="$( cd "$(dirname "$0")" ; pwd -P )"
14+
killBy ${DIR}/node_modules/.bin/babel
15+
}
16+
17+
watch(){
18+
stop
19+
npm run build:cjs:ui -- --watch &
20+
npm run build:cjs:src -- --watch &
21+
npm run build:es:ui -- --watch &
22+
npm run build:es:src -- --watch &
23+
}
24+
25+
case "$1" in
26+
watch)
27+
watch
28+
;;
29+
stop)
30+
stop
31+
;;
32+
*)
33+
develop
34+
;;
35+
esac
36+
37+
exit $?

packages/reshow-url/package.json

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "reshow-url",
3-
"version": "0.2.2",
3+
"version": "0.2.3",
44
"description": "reshow url util",
55
"main": "./build/cjs/src/index.js",
66
"module": "./build/es/src/index.js",
@@ -25,10 +25,15 @@
2525
},
2626
"scripts": {
2727
"clean": "find ./build -name '*.*' | xargs rm -rf",
28-
"build:cjs": "BABEL_ENV=cjs babel src -d build/cjs/src --root-mode upward && BABEL_ENV=cjs babel ui -d build/cjs/ui --root-mode upward",
29-
"build:es": "BABEL_ENV=es babel src -d build/es/src --root-mode upward && BABEL_ENV=es babel ui -d build/es/ui --root-mode upward",
28+
"build:cjs": "npm run build:cjs:src && npm run build:cjs:ui",
29+
"build:cjs:src": "BABEL_ENV=cjs babel src -d build/cjs/src --root-mode upward",
30+
"build:cjs:ui": "BABEL_ENV=cjs babel ui -d build/cjs/ui --root-mode upward",
31+
"build:es": "npm run build:es:src && npm run build:es:ui",
32+
"build:es:src": "BABEL_ENV=es babel src -d build/es/src --root-mode upward",
33+
"build:es:ui": "BABEL_ENV=es babel ui -d build/es/ui --root-mode upward",
3034
"build": "npm run clean && npm run build:cjs && npm run build:es",
31-
"mocha": "mocha -r jsdom-global/register 'build/cjs/**/__tests__/*.js'",
35+
"mochaFor": "mocha -r jsdom-global/register",
36+
"mocha": "npm run mochaFor -- 'build/cjs/**/__tests__/*.js'",
3237
"test": "npm run build && npm run mocha",
3338
"prepublishOnly": "npm run test"
3439
},

packages/reshow-url/ui/organisms/ClientRoute.jsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,12 @@ class ClientRoute extends Reshow {
2727
};
2828

2929
getPath() {
30-
const nextThemePath = this.getGlobalPath()
31-
? this.resetGlobalPath()
32-
: this.getUrlChangeState(this.props.url || doc().URL)?.themePath ||
33-
this.resetGlobalPath();
34-
this.resetGlobalPath(nextThemePath);
30+
let nextThemePath = this.getUrlChangeState(this.props.url || doc().URL)?.themePath;
31+
if (!nextThemePath) {
32+
nextThemePath = this.resetGlobalPath();
33+
} else {
34+
this.resetGlobalPath(nextThemePath);
35+
}
3536
return nextThemePath;
3637
}
3738

0 commit comments

Comments
 (0)