Skip to content

Commit

Permalink
update localstorage filter
Browse files Browse the repository at this point in the history
  • Loading branch information
bluezhan committed May 15, 2021
1 parent 16dcb2b commit ff3033e
Show file tree
Hide file tree
Showing 11 changed files with 37 additions and 32 deletions.
6 changes: 3 additions & 3 deletions docs/asset-manifest.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"files": {
"main.css": "/some-cool-things-with-you/static/css/main.88e4cba6.chunk.css",
"main.js": "/some-cool-things-with-you/static/js/main.bd8dcbff.chunk.js",
"main.js.map": "/some-cool-things-with-you/static/js/main.bd8dcbff.chunk.js.map",
"main.js": "/some-cool-things-with-you/static/js/main.5aee718d.chunk.js",
"main.js.map": "/some-cool-things-with-you/static/js/main.5aee718d.chunk.js.map",
"runtime-main.js": "/some-cool-things-with-you/static/js/runtime-main.0317f4f9.js",
"runtime-main.js.map": "/some-cool-things-with-you/static/js/runtime-main.0317f4f9.js.map",
"static/css/2.fbce98fc.chunk.css": "/some-cool-things-with-you/static/css/2.fbce98fc.chunk.css",
Expand All @@ -20,6 +20,6 @@
"static/css/2.fbce98fc.chunk.css",
"static/js/2.1477f937.chunk.js",
"static/css/main.88e4cba6.chunk.css",
"static/js/main.bd8dcbff.chunk.js"
"static/js/main.5aee718d.chunk.js"
]
}
2 changes: 1 addition & 1 deletion docs/index.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/some-cool-things-with-you/avatar5.jpg"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="Web site created using create-react-app"/><link rel="apple-touch-icon" href="/some-cool-things-with-you/logo192.png"/><link rel="manifest" href="/some-cool-things-with-you/manifest.json"/><title>Cool things with you</title><link href="/some-cool-things-with-you/static/css/2.fbce98fc.chunk.css" rel="stylesheet"><link href="/some-cool-things-with-you/static/css/main.88e4cba6.chunk.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div><script>var _hmt=_hmt||[];!function(){var e=document.createElement("script");e.src="https://hm.baidu.com/hm.js?d91d91125d1720b23e7b4ae92107e360";var t=document.getElementsByTagName("script")[0];t.parentNode.insertBefore(e,t)}()</script><script>!function(e){function t(t){for(var n,i,a=t[0],c=t[1],l=t[2],f=0,p=[];f<a.length;f++)i=a[f],Object.prototype.hasOwnProperty.call(o,i)&&o[i]&&p.push(o[i][0]),o[i]=0;for(n in c)Object.prototype.hasOwnProperty.call(c,n)&&(e[n]=c[n]);for(s&&s(t);p.length;)p.shift()();return u.push.apply(u,l||[]),r()}function r(){for(var e,t=0;t<u.length;t++){for(var r=u[t],n=!0,a=1;a<r.length;a++){var c=r[a];0!==o[c]&&(n=!1)}n&&(u.splice(t--,1),e=i(i.s=r[0]))}return e}var n={},o={1:0},u=[];function i(t){if(n[t])return n[t].exports;var r=n[t]={i:t,l:!1,exports:{}};return e[t].call(r.exports,r,r.exports,i),r.l=!0,r.exports}i.e=function(e){var t=[],r=o[e];if(0!==r)if(r)t.push(r[2]);else{var n=new Promise((function(t,n){r=o[e]=[t,n]}));t.push(r[2]=n);var u,a=document.createElement("script");a.charset="utf-8",a.timeout=120,i.nc&&a.setAttribute("nonce",i.nc),a.src=function(e){return i.p+"static/js/"+({}[e]||e)+"."+{3:"dd6caffe"}[e]+".chunk.js"}(e);var c=new Error;u=function(t){a.onerror=a.onload=null,clearTimeout(l);var r=o[e];if(0!==r){if(r){var n=t&&("load"===t.type?"missing":t.type),u=t&&t.target&&t.target.src;c.message="Loading chunk "+e+" failed.\n("+n+": "+u+")",c.name="ChunkLoadError",c.type=n,c.request=u,r[1](c)}o[e]=void 0}};var l=setTimeout((function(){u({type:"timeout",target:a})}),12e4);a.onerror=a.onload=u,document.head.appendChild(a)}return Promise.all(t)},i.m=e,i.c=n,i.d=function(e,t,r){i.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},i.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},i.t=function(e,t){if(1&t&&(e=i(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(i.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var n in e)i.d(r,n,function(t){return e[t]}.bind(null,n));return r},i.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return i.d(t,"a",t),t},i.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},i.p="/some-cool-things-with-you/",i.oe=function(e){throw console.error(e),e};var a=this["webpackJsonpsome-cool-things-with-you"]=this["webpackJsonpsome-cool-things-with-you"]||[],c=a.push.bind(a);a.push=t,a=a.slice();for(var l=0;l<a.length;l++)t(a[l]);var s=c;r()}([])</script><script src="/some-cool-things-with-you/static/js/2.1477f937.chunk.js"></script><script src="/some-cool-things-with-you/static/js/main.bd8dcbff.chunk.js"></script></body></html>
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/some-cool-things-with-you/avatar5.jpg"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="Web site created using create-react-app"/><link rel="apple-touch-icon" href="/some-cool-things-with-you/logo192.png"/><link rel="manifest" href="/some-cool-things-with-you/manifest.json"/><title>Cool things with you</title><link href="/some-cool-things-with-you/static/css/2.fbce98fc.chunk.css" rel="stylesheet"><link href="/some-cool-things-with-you/static/css/main.88e4cba6.chunk.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div><script>var _hmt=_hmt||[];!function(){var e=document.createElement("script");e.src="https://hm.baidu.com/hm.js?d91d91125d1720b23e7b4ae92107e360";var t=document.getElementsByTagName("script")[0];t.parentNode.insertBefore(e,t)}()</script><script>!function(e){function t(t){for(var n,i,a=t[0],c=t[1],l=t[2],f=0,p=[];f<a.length;f++)i=a[f],Object.prototype.hasOwnProperty.call(o,i)&&o[i]&&p.push(o[i][0]),o[i]=0;for(n in c)Object.prototype.hasOwnProperty.call(c,n)&&(e[n]=c[n]);for(s&&s(t);p.length;)p.shift()();return u.push.apply(u,l||[]),r()}function r(){for(var e,t=0;t<u.length;t++){for(var r=u[t],n=!0,a=1;a<r.length;a++){var c=r[a];0!==o[c]&&(n=!1)}n&&(u.splice(t--,1),e=i(i.s=r[0]))}return e}var n={},o={1:0},u=[];function i(t){if(n[t])return n[t].exports;var r=n[t]={i:t,l:!1,exports:{}};return e[t].call(r.exports,r,r.exports,i),r.l=!0,r.exports}i.e=function(e){var t=[],r=o[e];if(0!==r)if(r)t.push(r[2]);else{var n=new Promise((function(t,n){r=o[e]=[t,n]}));t.push(r[2]=n);var u,a=document.createElement("script");a.charset="utf-8",a.timeout=120,i.nc&&a.setAttribute("nonce",i.nc),a.src=function(e){return i.p+"static/js/"+({}[e]||e)+"."+{3:"dd6caffe"}[e]+".chunk.js"}(e);var c=new Error;u=function(t){a.onerror=a.onload=null,clearTimeout(l);var r=o[e];if(0!==r){if(r){var n=t&&("load"===t.type?"missing":t.type),u=t&&t.target&&t.target.src;c.message="Loading chunk "+e+" failed.\n("+n+": "+u+")",c.name="ChunkLoadError",c.type=n,c.request=u,r[1](c)}o[e]=void 0}};var l=setTimeout((function(){u({type:"timeout",target:a})}),12e4);a.onerror=a.onload=u,document.head.appendChild(a)}return Promise.all(t)},i.m=e,i.c=n,i.d=function(e,t,r){i.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},i.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},i.t=function(e,t){if(1&t&&(e=i(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(i.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var n in e)i.d(r,n,function(t){return e[t]}.bind(null,n));return r},i.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return i.d(t,"a",t),t},i.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},i.p="/some-cool-things-with-you/",i.oe=function(e){throw console.error(e),e};var a=this["webpackJsonpsome-cool-things-with-you"]=this["webpackJsonpsome-cool-things-with-you"]||[],c=a.push.bind(a);a.push=t,a=a.slice();for(var l=0;l<a.length;l++)t(a[l]);var s=c;r()}([])</script><script src="/some-cool-things-with-you/static/js/2.1477f937.chunk.js"></script><script src="/some-cool-things-with-you/static/js/main.5aee718d.chunk.js"></script></body></html>
2 changes: 2 additions & 0 deletions docs/static/js/main.5aee718d.chunk.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions docs/static/js/main.5aee718d.chunk.js.map

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions docs/static/js/main.bd8dcbff.chunk.js

This file was deleted.

1 change: 0 additions & 1 deletion docs/static/js/main.bd8dcbff.chunk.js.map

This file was deleted.

4 changes: 2 additions & 2 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ function App() {
<Link to='/bad-to-good'>
<CircularText text="Bad To Good" emoji="🥝" color="green"/>
</Link>
<Link to='/best-answer'>
<CircularText text="Best Answer" emoji="🍋" color="cyan"/>
<Link to='/best-questions'>
<CircularText text="Best Question" emoji="🍋" color="cyan"/>
</Link>
<Link to='/abcdefg'>
<CircularText text="A B C D E F G" emoji="🍓" color="timber"/>
Expand Down
2 changes: 1 addition & 1 deletion src/Router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const Router = () => (
<Route exact path='/' component={Bad2Good}/>
<Route path='/land-of-lory' component={Land4glory}/>
<Route path='/bad-to-good' component={Bad2Good}/>
<Route path='/best-answer' component={Answer}/>
<Route path='/best-questions' component={Answer}/>
<Route path='/abcdefg' component={Abcdefg}/>
</Switch>
)
Expand Down
24 changes: 13 additions & 11 deletions src/pages/Answer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,24 +36,26 @@ function Answer() {
return codeJson.ocean[currentIndex];
}

const [data, setDate] = React.useState(codeJson.ocean[0]);
const [data, setDate] = React.useState(codeJson.ocean[currentIndex]);
const [btnState, setBtnState] = React.useState({
disabled: false
});


useEffect(()=>{
useEffect(() => {
const getInfo: any[] = JSON.parse(window.localStorage.getItem("bestquestions") || "[]");
const currentInfo = codeJson.ocean[currentIndex];
const o = {
id: currentInfo.id,
title: currentInfo.code.substring(0, currentInfo.code.indexOf("\n")),
language: currentInfo.language,
usage: "15:00",
time: dayjs().format('hh:mm:ss DD/MM/YYYY')
if(!getInfo.some((item: any) => item.id == currentInfo.id)) {
const o = {
id: currentInfo.id,
title: currentInfo.code.substring(0, currentInfo.code.indexOf("\n")),
language: currentInfo.language,
usage: "15:00",
times: 0,
time: dayjs().format('hh:mm:ss DD/MM/YYYY')
}
getInfo.push(o);
window.localStorage.setItem("bestquestions", JSON.stringify(getInfo));
}
getInfo.push(o);
window.localStorage.setItem("bestquestions", JSON.stringify(getInfo))
}, [currentIndex])

const goodCodeHtml = {
Expand Down
23 changes: 13 additions & 10 deletions src/pages/Bad2Good/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,21 +54,24 @@ function Bad2Good() {
return codeJson.ocean[currentIndex];
}

useEffect(()=>{
useEffect(() => {
const getInfo: any[] = JSON.parse(window.localStorage.getItem("bad2good") || "[]");
const currentInfo = codeJson.ocean[currentIndex];
const o = {
id: currentInfo.language + currentInfo.id,
title: (currentIndex + 1) + "、"+ currentInfo.description.substring(0, currentInfo.description.indexOf("\n")),
language: currentInfo.language,
usage: "15:00",
time: dayjs().format('hh:mm:ss DD/MM/YYYY')
if(!getInfo.some((item: any) => item.id == currentInfo.id)) {
const o = {
id: currentInfo.language + currentInfo.id,
title: (currentIndex + 1) + "、"+ currentInfo.description.substring(0, currentInfo.description.indexOf("\n")),
language: currentInfo.language,
usage: "15:00",
times: 0,
time: dayjs().format('hh:mm:ss DD/MM/YYYY')
}
getInfo.push(o);
window.localStorage.setItem("bad2good", JSON.stringify(getInfo))
}
getInfo.push(o);
window.localStorage.setItem("bad2good", JSON.stringify(getInfo))
}, [currentIndex])

const [data, setDate] = React.useState(codeJson.ocean[0]);
const [data, setDate] = React.useState(codeJson.ocean[currentIndex]);
const [btnState, setBtnState] = React.useState({
disabled: false
});
Expand Down
2 changes: 1 addition & 1 deletion src/pages/Land4glory/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ function Land4glory() {
<h2>Land of lory</h2>
<table className="gridtable">
<tr>
<th>Bad to good</th><th>best questions</th>
<th>Bad to good</th><th>Best questions</th>
</tr>
{/* <tr>
<td>
Expand Down

0 comments on commit ff3033e

Please sign in to comment.