diff --git a/config/webpack.config.js b/config/webpack.config.js index 4af9f123..d30665cd 100644 --- a/config/webpack.config.js +++ b/config/webpack.config.js @@ -3,6 +3,7 @@ const fs = require("fs"); const path = require("path"); const webpack = require("webpack"); +// const resolve = require("resolve"); const HtmlWebpackPlugin = require("html-webpack-plugin"); const CaseSensitivePathsPlugin = require("case-sensitive-paths-webpack-plugin"); const InlineChunkHtmlPlugin = require("react-dev-utils/InlineChunkHtmlPlugin"); @@ -18,7 +19,10 @@ const modules = require("./modules"); const getClientEnvironment = require("./env"); const ModuleNotFoundPlugin = require("react-dev-utils/ModuleNotFoundPlugin"); const ReactRefreshWebpackPlugin = require("@pmmmwh/react-refresh-webpack-plugin"); - +// const ForkTsCheckerWebpackPlugin = +// process.env.TSC_COMPILE_ON_ERROR === "true" +// ? require("react-dev-utils/ForkTsCheckerWarningWebpackPlugin") +// : require("react-dev-utils/ForkTsCheckerWebpackPlugin"); const createEnvironmentHash = require("./webpack/persistentCache/createEnvironmentHash"); // Source maps are resource heavy and can cause out of memory issue for large source files. const shouldUseSourceMap = process.env.GENERATE_SOURCEMAP !== "false"; @@ -44,6 +48,7 @@ const imageInlineSizeLimit = parseInt(process.env.IMAGE_INLINE_SIZE_LIMIT || "10 // Check if TypeScript is setup const useTypeScript = fs.existsSync(paths.appTsConfig); +// const useTypeScript = false; // Get the path to the uncompiled service worker (if it exists). const swSrc = paths.swSrc; @@ -497,6 +502,49 @@ module.exports = function (webpackEnv) { // See https://github.com/cra-template/pwa/issues/13#issuecomment-722667270 maximumFileSizeToCacheInBytes: 5 * 1024 * 1024 }) + // // TypeScript type checking + // useTypeScript && + // new ForkTsCheckerWebpackPlugin({ + // async: isEnvDevelopment, + // typescript: { + // typescriptPath: resolve.sync("typescript", { + // basedir: paths.appNodeModules + // }), + // configOverwrite: { + // compilerOptions: { + // sourceMap: isEnvProduction ? shouldUseSourceMap : isEnvDevelopment, + // skipLibCheck: true, + // inlineSourceMap: false, + // declarationMap: false, + // noEmit: true, + // incremental: true, + // tsBuildInfoFile: paths.appTsBuildInfoFile + // } + // }, + // context: paths.appPath, + // diagnosticOptions: { + // syntactic: true + // }, + // mode: "write-references" + // // profile: true, + // }, + // issue: { + // // This one is specifically to match during CI tests, + // // as micromatch doesn't match + // // '../cra-template-typescript/template/src/App.tsx' + // // otherwise. + // include: [{ file: "../**/src/**/*.{ts,tsx}" }, { file: "**/src/**/*.{ts,tsx}" }], + // exclude: [ + // { file: "**/src/**/__tests__/**" }, + // { file: "**/src/**/?(*.){spec|test}.*" }, + // { file: "**/src/setupProxy.*" }, + // { file: "**/src/setupTests.*" } + // ] + // }, + // logger: { + // infrastructure: "silent" + // } + // }) ].filter(Boolean), // Turn off performance processing because we utilize // our own hints via the FileSizeReporter diff --git a/src/app/config.ts b/src/app/config.ts index 44befb19..6bdbc676 100644 --- a/src/app/config.ts +++ b/src/app/config.ts @@ -1,8 +1,8 @@ // const BASE_URL = `${location.origin}/api`; +// const BASE_URL = `https://dev.voce.chat/api`; const BASE_URL = process.env.REACT_APP_RELEASE ? `${location.origin}/api` : `https://dev.voce.chat/api`; -// const BASE_URL = `https://dev.voce.chat/api`; export const CACHE_VERSION = `0.3.1`; export const ContentTypes = { text: "text/plain", diff --git a/src/app/services/base.query.ts b/src/app/services/base.query.ts index d9a6263b..5853d576 100644 --- a/src/app/services/base.query.ts +++ b/src/app/services/base.query.ts @@ -45,6 +45,7 @@ const baseQueryWithTokenCheck = async (args, api, extraOptions) => { // 先检查token是否过期,过期则renew const { token, refreshToken, expireTime = +new Date() } = api.getState().authData; let result = null; + console.log("base check", whiteList.includes(api.endpoint), api.endpoint); if (!whiteList.includes(api.endpoint) && dayjs().isAfter(new Date(expireTime - 20 * 1000))) { // 快过期了,renew waitingForRenew = baseQuery( diff --git a/src/common/hook/useUploadFile.ts b/src/common/hook/useUploadFile.ts index 687d9e0d..2dbf92eb 100644 --- a/src/common/hook/useUploadFile.ts +++ b/src/common/hook/useUploadFile.ts @@ -7,7 +7,6 @@ import { useAppDispatch, useAppSelector } from "../../app/store"; import { Message } from "../../types/channel"; import { UploadFileResponse } from "../../types/message"; -// todo: check props type interface IProps { context: "channel" | "user"; id: number; diff --git a/src/index.tsx b/src/index.tsx index cddb8697..b1c3e971 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -7,7 +7,7 @@ import "./assets/base.css"; import "animate.css"; import "./common/DayjsSetting"; import "./common/TippySetting"; -import * as serviceWorkerRegistration from "./serviceWorkerRegistration"; +import { register } from "./serviceWorkerRegistration"; import MarkdownStyleOverride from "./common/component/MarkdownStyleOverride"; import ReduxRoutes from "./routes"; import NewVersion from "./common/component/NewVersion"; @@ -25,7 +25,7 @@ root.render( ); -serviceWorkerRegistration.register({ +register({ // onSuccess: () => { // toast.success("Service Worker Installed"); // }, diff --git a/src/routes/home/usePreload.ts b/src/routes/home/usePreload.ts index e64f6ff4..a74a9cbe 100644 --- a/src/routes/home/usePreload.ts +++ b/src/routes/home/usePreload.ts @@ -35,18 +35,13 @@ export default function usePreload() { setStreamingReady(false); }; }, []); - - useEffect(() => { - if (rehydrated) { - getUsers(); - getServer(); - getFavorites(); - } - }, [rehydrated]); const canStreaming = !!loginUid && rehydrated && !!token; console.log("ttt", loginUid, rehydrated, token); useEffect(() => { + getServer(); + getUsers(); + getFavorites(); setStreamingReady(canStreaming); }, [canStreaming]);