mirror of https://github.com/halo-dev/halo
refactor: add t parameter for plugin bundle resources (#4804)
#### What type of PR is this? /area console /kind improvement /milestone 2.11.x #### What this PR does / why we need it: 为插件的 bundle.css 和 bundle.js 重定向请求添加时间戳参数,防止被浏览器、Nginx、CDN 服务缓存,导致插件的资源不能及时更新。 #### Which issue(s) this PR fixes: Fixes #4803 #### Special notes for your reviewer: 测试方式: 1. 在 Firefox 浏览器测试启动和停止若干插件,观察插件提供的 UI 样式是否正常即可。 #### Does this PR introduce a user-facing change? ```release-note 优化 Console 端插件捆绑资源的请求,防止在操作插件状态之后无法及时更新资源。 ```pull/4819/head
parent
2d743123bf
commit
a8a5413460
|
@ -21,7 +21,7 @@ export async function setupPluginModules(app: App) {
|
||||||
const { load } = useScriptTag(
|
const { load } = useScriptTag(
|
||||||
`${
|
`${
|
||||||
import.meta.env.VITE_API_URL
|
import.meta.env.VITE_API_URL
|
||||||
}/apis/api.console.halo.run/v1alpha1/plugins/-/bundle.js`
|
}/apis/api.console.halo.run/v1alpha1/plugins/-/bundle.js?t=${Date.now()}`
|
||||||
);
|
);
|
||||||
|
|
||||||
await load();
|
await load();
|
||||||
|
@ -45,7 +45,7 @@ export async function setupPluginModules(app: App) {
|
||||||
await loadStyle(
|
await loadStyle(
|
||||||
`${
|
`${
|
||||||
import.meta.env.VITE_API_URL
|
import.meta.env.VITE_API_URL
|
||||||
}/apis/api.console.halo.run/v1alpha1/plugins/-/bundle.css`
|
}/apis/api.console.halo.run/v1alpha1/plugins/-/bundle.css?t=${Date.now()}`
|
||||||
);
|
);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
const message = i18n.global.t("core.plugin.loader.toast.style_load_failed");
|
const message = i18n.global.t("core.plugin.loader.toast.style_load_failed");
|
||||||
|
|
|
@ -2,7 +2,7 @@ export function loadStyle(href: string) {
|
||||||
return new Promise(function (resolve, reject) {
|
return new Promise(function (resolve, reject) {
|
||||||
let shouldAppend = false;
|
let shouldAppend = false;
|
||||||
let el: HTMLLinkElement | null = document.querySelector(
|
let el: HTMLLinkElement | null = document.querySelector(
|
||||||
'script[src="' + href + '"]'
|
'link[href="' + href + '"]'
|
||||||
);
|
);
|
||||||
if (!el) {
|
if (!el) {
|
||||||
el = document.createElement("link");
|
el = document.createElement("link");
|
||||||
|
|
Loading…
Reference in New Issue