diff --git a/.stylelintrc.json b/.stylelintrc.json new file mode 100644 index 0000000000000000000000000000000000000000..c4d3198f56f74ebde1a7024ec3a848b02a9206c3 --- /dev/null +++ b/.stylelintrc.json @@ -0,0 +1,28 @@ +{ + "extends": ["stylelint-config-standard", "stylelint-config-prettier"], + "rules": { + "selector-pseudo-class-no-unknown": null, + "shorthand-property-no-redundant-values": null, + "at-rule-empty-line-before": null, + "at-rule-name-space-after": null, + "comment-empty-line-before": null, + "declaration-bang-space-before": null, + "declaration-empty-line-before": null, + "function-comma-newline-after": null, + "function-name-case": null, + "function-parentheses-newline-inside": null, + "function-max-empty-lines": null, + "function-whitespace-after": null, + "number-leading-zero": null, + "number-no-trailing-zeros": null, + "rule-empty-line-before": null, + "selector-combinator-space-after": null, + "selector-descendant-combinator-no-non-space": null, + "selector-list-comma-newline-after": null, + "selector-pseudo-element-colon-notation": null, + "unit-no-unknown": null, + "no-descending-specificity": null, + "value-list-max-empty-lines": null, + "no-missing-end-of-source-newline": null + } +} diff --git a/src/pages/Account/Center/Center.js b/src/pages/Account/Center/Center.js index 6e579524b7de85c58ea03217635e7463480fcf2a..f61aff9bde2089d6477f251f70edc5e4a4a64ec6 100644 --- a/src/pages/Account/Center/Center.js +++ b/src/pages/Account/Center/Center.js @@ -148,9 +148,9 @@ export default class Center extends PureComponent {
标签
- {currentUser.tags - .concat(newTags) - .map(item => {item.label})} + {currentUser.tags.concat(newTags).map(item => ( + {item.label} + ))} {inputVisible && ( { if (response.status >= 200 && response.status < 300) { return response; } @@ -32,7 +32,26 @@ function checkStatus(response) { error.name = response.status; error.response = response; throw error; -} +}; + +const cachedSave = (response, hashcode) => { + /** + * Clone a response data and store it in sessionStorage + * Does not support data other than json, Cache only json + */ + let contentType = response.headers.get('Content-Type'); + if (contentType && contentType.match(/application\/json/i)) { + // All data is saved as text + response + .clone() + .text() + .then(content => { + sessionStorage.setItem(hashcode, content); + sessionStorage.setItem(hashcode + ':timestamp', Date.now()); + }); + } + return response; +}; /** * Requests a URL, returning a promise. @@ -47,7 +66,7 @@ export default function request(url, options = {}) { * Produce fingerprints based on url and parameters * Maybe url has the same parameters */ - const fingerprint = url + options.body ? JSON.stringify(options.body) : ''; + const fingerprint = url + (options.body ? JSON.stringify(options.body) : ''); const hashcode = hash .sha256() .update(fingerprint) @@ -77,8 +96,8 @@ export default function request(url, options = {}) { }; } } - let cached = localStorage.getItem(hashcode); - let whenCached = localStorage.getItem(hashcode + ':timestamp'); + let cached = sessionStorage.getItem(hashcode); + let whenCached = sessionStorage.getItem(hashcode + ':timestamp'); const expirys = options.expirys || 60; if (cached !== null && whenCached !== null && expirys !== false) { let age = (Date.now() - whenCached) / 1000; @@ -86,30 +105,13 @@ export default function request(url, options = {}) { let response = new Response(new Blob([cached])); return response.json(); } else { - localStorage.removeItem(hashcode); - localStorage.removeItem(hashcode + ':timestamp'); + sessionStorage.removeItem(hashcode); + sessionStorage.removeItem(hashcode + ':timestamp'); } } return fetch(url, newOptions) .then(checkStatus) - .then(response => { - /** - * Clone a response data and store it in localStorage - * Does not support data other than json, Cache only json - */ - let contentType = response.headers.get('Content-Type'); - if (contentType && contentType.match(/application\/json/i)) { - // All data is saved as text - response - .clone() - .text() - .then(content => { - localStorage.setItem(hashcode, content); - localStorage.setItem(hashcode + ':timestamp', Date.now()); - }); - } - return response; - }) + .then(cachedSave) .then(response => { // DELETE and 204 do not return data by default // using .json will report an error. diff --git a/stylelint.config.js b/stylelint.config.js deleted file mode 100644 index 2363deec3028b0f60fd97caee7c62eb060d5dd8e..0000000000000000000000000000000000000000 --- a/stylelint.config.js +++ /dev/null @@ -1,28 +0,0 @@ -export default { - extends: ['stylelint-config-standard', 'stylelint-config-prettier'], - rules: { - 'selector-pseudo-class-no-unknown': null, - 'shorthand-property-no-redundant-values': null, - 'at-rule-empty-line-before': null, - 'at-rule-name-space-after': null, - 'comment-empty-line-before': null, - 'declaration-bang-space-before': null, - 'declaration-empty-line-before': null, - 'function-comma-newline-after': null, - 'function-name-case': null, - 'function-parentheses-newline-inside': null, - 'function-max-empty-lines': null, - 'function-whitespace-after': null, - 'number-leading-zero': null, - 'number-no-trailing-zeros': null, - 'rule-empty-line-before': null, - 'selector-combinator-space-after': null, - 'selector-descendant-combinator-no-non-space': null, - 'selector-list-comma-newline-after': null, - 'selector-pseudo-element-colon-notation': null, - 'unit-no-unknown': null, - 'no-descending-specificity': null, - 'value-list-max-empty-lines': null, - 'no-missing-end-of-source-newline': null, - }, -};