refactor: getLocalAuthData
This commit is contained in:
+17
-16
@@ -4,7 +4,7 @@
|
||||
"private": true,
|
||||
"homepage": "https://voce.chat",
|
||||
"dependencies": {
|
||||
"@emoji-mart/react": "^1.0.1",
|
||||
"@emoji-mart/react": "^1.1.0",
|
||||
"@metamask/onboarding": "^1.0.1",
|
||||
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.10",
|
||||
"@react-oauth/google": "^0.5.1",
|
||||
@@ -14,7 +14,7 @@
|
||||
"@toast-ui/editor": "^3.2.1",
|
||||
"@toast-ui/editor-plugin-code-syntax-highlight": "^3.1.0",
|
||||
"@toast-ui/react-editor": "^3.2.2",
|
||||
"@types/node": "^18.11.10",
|
||||
"@types/node": "^18.11.15",
|
||||
"@types/react": "^18.0.26",
|
||||
"@types/react-dom": "^18.0.9",
|
||||
"@udecode/plate": "16.8",
|
||||
@@ -25,25 +25,26 @@
|
||||
"copy-image-clipboard": "^2.1.2",
|
||||
"css-loader": "^6.7.2",
|
||||
"css-minimizer-webpack-plugin": "^4.2.2",
|
||||
"dayjs": "^1.11.6",
|
||||
"dayjs": "^1.11.7",
|
||||
"dotenv": "^16.0.3",
|
||||
"dotenv-expand": "^9.0.0",
|
||||
"emoji-mart": "5.3.3",
|
||||
"emoji-mart": "5.4.0",
|
||||
"eslint": "^8.29.0",
|
||||
"file-loader": "^6.2.0",
|
||||
"firebase": "^9.14.0",
|
||||
"firebase": "^9.15.0",
|
||||
"fs-extra": "^11.1.0",
|
||||
"html-webpack-plugin": "^5.5.0",
|
||||
"i18next": "^22.0.7",
|
||||
"i18next": "^22.4.5",
|
||||
"i18next-browser-languagedetector": "^7.0.1",
|
||||
"i18next-http-backend": "^2.0.2",
|
||||
"i18next-http-backend": "^2.1.0",
|
||||
"linkify-it": "3.0.3",
|
||||
"linkify-plugin-mention": "^3.0.4",
|
||||
"linkifyjs": "^3.0.5",
|
||||
"localforage": "^1.10.0",
|
||||
"lodash": "^4.17.21",
|
||||
"masonry-layout": "^4.2.2",
|
||||
"mini-css-extract-plugin": "^2.7.1",
|
||||
"mini-css-extract-plugin": "^2.7.2",
|
||||
"qrcode.react": "^3.1.0",
|
||||
"react": "^18.2.0",
|
||||
"react-circular-progressbar": "^2.1.0",
|
||||
"react-dev-utils": "^12.0.1",
|
||||
@@ -52,12 +53,12 @@
|
||||
"react-dom": "^18.2.0",
|
||||
"react-helmet": "^6.1.0",
|
||||
"react-hot-toast": "^2.4.0",
|
||||
"react-i18next": "^12.0.0",
|
||||
"react-i18next": "^12.1.1",
|
||||
"react-icons": "^4.7.1",
|
||||
"react-linkify": "^1.0.0-alpha",
|
||||
"react-redux": "^8.0.5",
|
||||
"react-refresh": "0.14.0",
|
||||
"react-router-dom": "^6.4.4",
|
||||
"react-router-dom": "^6.4.5",
|
||||
"react-scripts": "^5.0.1",
|
||||
"react-string-replace": "^1.1.0",
|
||||
"react-syntax-highlighter": "^15.5.0",
|
||||
@@ -71,10 +72,10 @@
|
||||
"source-map-loader": "^4.0.1",
|
||||
"style-loader": "^3.3.1",
|
||||
"styled-components": "^5.3.6",
|
||||
"styled-reset": "^4.4.3",
|
||||
"styled-reset": "^4.4.4",
|
||||
"terser-webpack-plugin": "^5.3.6",
|
||||
"tippy.js": "^6.3.7",
|
||||
"typescript": "^4.9.3",
|
||||
"typescript": "^4.9.4",
|
||||
"webpack": "^5.75.0",
|
||||
"webpack-dev-server": "^4.11.1",
|
||||
"webpack-manifest-plugin": "^5.0.0",
|
||||
@@ -128,8 +129,8 @@
|
||||
"@types/react-linkify": "^1.0.1",
|
||||
"@types/react-syntax-highlighter": "^15.5.5",
|
||||
"@types/styled-components": "^5.1.26",
|
||||
"@typescript-eslint/eslint-plugin": "^5.45.0",
|
||||
"@typescript-eslint/parser": "^5.45.0",
|
||||
"@typescript-eslint/eslint-plugin": "^5.46.1",
|
||||
"@typescript-eslint/parser": "^5.46.1",
|
||||
"@welldone-software/why-did-you-render": "^7.0.1",
|
||||
"autoprefixer": "^10.4.13",
|
||||
"babel-loader": "^9.1.0",
|
||||
@@ -145,10 +146,10 @@
|
||||
"lint-staged": "^13.1.0",
|
||||
"md5-file": "^5.0.0",
|
||||
"patch-package": "^6.5.0",
|
||||
"postcss": "^8.4.19",
|
||||
"postcss": "^8.4.20",
|
||||
"postcss-loader": "^7.0.2",
|
||||
"postinstall-postinstall": "^2.1.0",
|
||||
"prettier": "^2.8.0",
|
||||
"prettier": "^2.8.1",
|
||||
"tailwindcss": "^3.2.4"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { useEffect, useState, useCallback, useRef } from "react";
|
||||
import toast from "react-hot-toast";
|
||||
import BASE_URL, { KEY_EXPIRE, KEY_REFRESH_TOKEN, KEY_TOKEN } from "../../../app/config";
|
||||
import BASE_URL from "../../../app/config";
|
||||
import { setReady } from "../../../app/slices/ui";
|
||||
import {
|
||||
fillChannels,
|
||||
@@ -23,6 +23,7 @@ import { ServerEvent, UsersStateEvent } from "../../../types/sse";
|
||||
import { isNull, omitBy } from "lodash";
|
||||
import { useRenewMutation } from "../../../app/services/auth";
|
||||
import dayjs from "dayjs";
|
||||
import { getLocalAuthData } from "../../utils";
|
||||
|
||||
const getQueryString = (params: { [key: string]: string }) => {
|
||||
const sp = new URLSearchParams();
|
||||
@@ -33,13 +34,7 @@ const getQueryString = (params: { [key: string]: string }) => {
|
||||
});
|
||||
return sp.toString();
|
||||
};
|
||||
const getLocalAuthData = () => {
|
||||
return {
|
||||
token: localStorage.getItem(KEY_TOKEN) || "",
|
||||
refreshToken: localStorage.getItem(KEY_REFRESH_TOKEN) || "",
|
||||
expireTime: Number(localStorage.getItem(KEY_EXPIRE) || +new Date())
|
||||
};
|
||||
};
|
||||
|
||||
let SSE: EventSource | undefined = undefined;
|
||||
let connectionIsOpen = false;
|
||||
let aliveInter: number = 0;
|
||||
|
||||
@@ -32,6 +32,7 @@ export const resources = {
|
||||
} as const;
|
||||
i18n.on("languageChanged", (lng) => {
|
||||
console.log("changed", lng);
|
||||
// 匹配dayjs的多语言关键字
|
||||
dayjs.locale(lng === 'zh' ? "zh-cn" : lng === 'jp' ? "ja" : lng);
|
||||
});
|
||||
i18n
|
||||
|
||||
Reference in New Issue
Block a user