fix(i18n): disable cache by appending version numbers

This commit is contained in:
Aaron Liu 2023-02-08 13:53:48 +08:00
parent 09a5168b23
commit d4dc124e99
4 changed files with 14 additions and 6 deletions

View File

@ -648,6 +648,12 @@ module.exports = function(webpackEnv) {
// https://github.com/jmblog/how-to-optimize-momentjs-with-webpack
// You can remove this if you don't use Moment.js:
new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/),
new webpack.DefinePlugin({
ASSETS_VERSION: JSON.stringify(
require("../package.json").version
),
}),
// Generate a service worker script that will precache, and keep up to date,
// the HTML & assets that are part of the Webpack build.
isEnvProduction &&

View File

@ -292,7 +292,9 @@ export default function WebDAV() {
</Tooltip>
<Tooltip
placement="top"
title={t("setting.delete")}
title={t(
"setting.delete"
)}
onClick={() =>
deleteAccount(id)
}

View File

@ -8,6 +8,8 @@ import ChainedBackend, { ChainedBackendOptions } from "i18next-chained-backend";
import LanguageDetector from "i18next-browser-languagedetector";
import LocalStorageBackend from "i18next-localstorage-backend";
declare let ASSETS_VERSION: string;
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
// @ts-ignore
i18n.use(ChainedBackend)
@ -32,6 +34,7 @@ i18n.use(ChainedBackend)
expirationTime: 7 * 24 * 60 * 60 * 1000, // 7 days
},
{
queryStringParams: { v: ASSETS_VERSION },
loadPath: "/locales/{{lng}}/{{ns}}.json",
},
],

View File

@ -1,5 +1,3 @@
import { getResumeCtx } from "../component/Uploader/core/utils";
export const sizeToString = (bytes) => {
if (bytes === 0 || bytes === "0") return "0 B";
const k = 1024;
@ -157,10 +155,9 @@ export function vhCheck() {
}
export const removeI18nCache = () => {
for (let i = 0, len = localStorage.length; i < len; i++) {
const key = localStorage.key(i);
Object.keys(localStorage).forEach(function (key) {
if (key && key.startsWith("i18next_res_")) {
localStorage.removeItem(key);
}
}
});
};