Skip to content

Commit 8500956

Browse files
committed
update
1 parent 85b6ffb commit 8500956

File tree

5 files changed

+28
-42
lines changed

5 files changed

+28
-42
lines changed

.eslintignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
# service-center/src/views/ServiceAgreement.vue
22
# service-landing/src/views/ServiceAgreement.vue
33
# service-landing/src/views/RealName.vue
4-
serviceWorker.js
5-
history.js
64
src/page/echartBox/index.js
75
src/page/heightEchart/index.js
86
src/page/chinaMap/index.js
97
src/page/useCallBack/index.js
8+
src/serviceWorker.js

package.json

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -72,29 +72,19 @@
7272
"webpack": "4.39.1",
7373
"webpack-dev-server": "3.2.1",
7474
"webpack-manifest-plugin": "2.0.4",
75-
"workbox-webpack-plugin": "4.3.1"
76-
},
77-
"lint-staged": {
78-
"src/*.{js,jsx,mjs,ts,tsx}": [
79-
"node_modules/.bin/prettier --write",
80-
"node_modules/.bin/eslint --fix",
81-
"git add"
82-
],
83-
"src/*.{css,scss,less,json,html,md,markdown}": [
84-
"node_modules/.bin/prettier --write",
85-
"git add"
86-
]
75+
"workbox-webpack-plugin": "4.3.1",
76+
"history": "^4.7.2"
8777
},
8878
"husky": {
8979
"hooks": {
90-
"pre-commit": "lint-staged"
80+
"pre-commit": "npm run lint && pretty-quick --staged"
9181
}
9282
},
9383
"scripts": {
9484
"start": "node scripts/start.js",
9585
"build": "node scripts/build.js",
9686
"test": "node scripts/test.js",
97-
"lint": "eslint src"
87+
"lint": "eslint src --fix"
9888
},
9989
"eslintConfig": {
10090
"extends": "react-app"
@@ -174,7 +164,6 @@
174164
"eslint-plugin-prettier": "^3.1.1",
175165
"eslint-plugin-react": "^7.12.4",
176166
"husky": "^3.1.0",
177-
"lint-staged": "^9.4.3",
178167
"prettier": "1.19.1",
179168
"pretty-quick": "^2.0.1",
180169
"react-router-dom": "^5.1.2"

src/history.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { createHashHistory } from 'history';
1+
import { createHashHistory } from "history";
22

33
const history = createHashHistory();
44
export default history;

src/router/index.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,12 @@ function RouteLink({ location }) {
139139

140140
function RouteQuery({ location }) {
141141
console.log("query传参", location);
142-
return <h2>About: {location.query ? `name:${location.query.name}, time: ${location.query.time}` : "No Click"}</h2>;
142+
return (
143+
<h2>
144+
About:
145+
{location.query ? `name:${location.query.name}, time: ${location.query.time}` : "No Click"}
146+
</h2>
147+
);
143148
}
144149

145150
function RouteParams({ location }) {

src/serviceWorker.js

Lines changed: 16 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,15 @@
1111
// opt-in, read https://bit.ly/CRA-PWA
1212

1313
const isLocalhost = Boolean(
14-
window.location.hostname === 'localhost' ||
14+
window.location.hostname === "localhost" ||
1515
// [::1] is the IPv6 localhost address.
16-
window.location.hostname === '[::1]' ||
16+
window.location.hostname === "[::1]" ||
1717
// 127.0.0.1/8 is considered localhost for IPv4.
18-
window.location.hostname.match(
19-
/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/
20-
)
18+
window.location.hostname.match(/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/)
2119
);
2220

2321
export function register(config) {
24-
if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) {
22+
if (process.env.NODE_ENV === "production" && "serviceWorker" in navigator) {
2523
// The URL constructor is available in all browsers that support SW.
2624
const publicUrl = new URL(process.env.PUBLIC_URL, window.location.href);
2725
if (publicUrl.origin !== window.location.origin) {
@@ -31,7 +29,7 @@ export function register(config) {
3129
return;
3230
}
3331

34-
window.addEventListener('load', () => {
32+
window.addEventListener("load", () => {
3533
const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`;
3634

3735
if (isLocalhost) {
@@ -42,8 +40,8 @@ export function register(config) {
4240
// service worker/PWA documentation.
4341
navigator.serviceWorker.ready.then(() => {
4442
console.log(
45-
'This web app is being served cache-first by a service ' +
46-
'worker. To learn more, visit https://bit.ly/CRA-PWA'
43+
"This web app is being served cache-first by a service " +
44+
"worker. To learn more, visit https://bit.ly/CRA-PWA"
4745
);
4846
});
4947
} else {
@@ -64,14 +62,14 @@ function registerValidSW(swUrl, config) {
6462
return;
6563
}
6664
installingWorker.onstatechange = () => {
67-
if (installingWorker.state === 'installed') {
65+
if (installingWorker.state === "installed") {
6866
if (navigator.serviceWorker.controller) {
6967
// At this point, the updated precached content has been fetched,
7068
// but the previous service worker will still serve the older
7169
// content until all client tabs are closed.
7270
console.log(
73-
'New content is available and will be used when all ' +
74-
'tabs for this page are closed. See https://bit.ly/CRA-PWA.'
71+
"New content is available and will be used when all " +
72+
"tabs for this page are closed. See https://bit.ly/CRA-PWA."
7573
);
7674

7775
// Execute callback
@@ -82,7 +80,7 @@ function registerValidSW(swUrl, config) {
8280
// At this point, everything has been precached.
8381
// It's the perfect time to display a
8482
// "Content is cached for offline use." message.
85-
console.log('Content is cached for offline use.');
83+
console.log("Content is cached for offline use.");
8684

8785
// Execute callback
8886
if (config && config.onSuccess) {
@@ -94,7 +92,7 @@ function registerValidSW(swUrl, config) {
9492
};
9593
})
9694
.catch(error => {
97-
console.error('Error during service worker registration:', error);
95+
console.error("Error during service worker registration:", error);
9896
});
9997
}
10098

@@ -103,11 +101,8 @@ function checkValidServiceWorker(swUrl, config) {
103101
fetch(swUrl)
104102
.then(response => {
105103
// Ensure service worker exists, and that we really are getting a JS file.
106-
const contentType = response.headers.get('content-type');
107-
if (
108-
response.status === 404 ||
109-
(contentType != null && contentType.indexOf('javascript') === -1)
110-
) {
104+
const contentType = response.headers.get("content-type");
105+
if (response.status === 404 || (contentType != null && contentType.indexOf("javascript") === -1)) {
111106
// No service worker found. Probably a different app. Reload the page.
112107
navigator.serviceWorker.ready.then(registration => {
113108
registration.unregister().then(() => {
@@ -120,14 +115,12 @@ function checkValidServiceWorker(swUrl, config) {
120115
}
121116
})
122117
.catch(() => {
123-
console.log(
124-
'No internet connection found. App is running in offline mode.'
125-
);
118+
console.log("No internet connection found. App is running in offline mode.");
126119
});
127120
}
128121

129122
export function unregister() {
130-
if ('serviceWorker' in navigator) {
123+
if ("serviceWorker" in navigator) {
131124
navigator.serviceWorker.ready.then(registration => {
132125
registration.unregister();
133126
});

0 commit comments

Comments
 (0)