vite-plugin-build-version-file 0.1.13 → 0.1.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -4
- package/dist/client.cjs +2 -1
- package/dist/client.mjs +2 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -390,7 +390,7 @@ import { clearUrlCache } from 'vite-plugin-build-version-file/client'
|
|
|
390
390
|
await clearUrlCache('/vue-app/')
|
|
391
391
|
```
|
|
392
392
|
|
|
393
|
-
`url`
|
|
393
|
+
`url` 可省略;省略时默认使用 `location.origin + location.pathname`,不包含当前 query/hash:
|
|
394
394
|
|
|
395
395
|
```ts
|
|
396
396
|
await clearUrlCache()
|
|
@@ -399,7 +399,7 @@ await clearUrlCache()
|
|
|
399
399
|
Vue hash 路由会原样保留,缓存时间戳写在 `#` 前,确保服务器能够收到:
|
|
400
400
|
|
|
401
401
|
```text
|
|
402
|
-
https://
|
|
402
|
+
https://xxxx/pc/?_=随机值#/login?redirect=/dashboard/analysis
|
|
403
403
|
```
|
|
404
404
|
|
|
405
405
|
该方法仅支持同源 URL。它会绕过缓存请求 URL、强制刷新原 URL、通过隐藏 iframe 再次加载页面,最后携带随机时间戳跳转到该 URL。创建 iframe 前会销毁同一页面中已有的缓存刷新 iframe。单次请求或 iframe 加载失败不会阻断最终跳转。
|
|
@@ -856,7 +856,7 @@ import { clearUrlCache } from 'vite-plugin-build-version-file/client'
|
|
|
856
856
|
await clearUrlCache('/vue-app/')
|
|
857
857
|
```
|
|
858
858
|
|
|
859
|
-
The `url` argument is optional. When omitted,
|
|
859
|
+
The `url` argument is optional. When omitted, `location.origin + location.pathname` is used without the current query/hash:
|
|
860
860
|
|
|
861
861
|
```ts
|
|
862
862
|
await clearUrlCache()
|
|
@@ -865,7 +865,7 @@ await clearUrlCache()
|
|
|
865
865
|
Vue hash routes are preserved. The cache-busting timestamp is added before `#` so the server receives it:
|
|
866
866
|
|
|
867
867
|
```text
|
|
868
|
-
https://
|
|
868
|
+
https://xxx.cn/pc/?_=random-value#/login?redirect=/dashboard/analysis
|
|
869
869
|
```
|
|
870
870
|
|
|
871
871
|
This method only supports same-origin URLs. It bypasses the cached URL, forces a refresh of the original URL, loads the page again in a hidden iframe, and finally navigates to the URL with a random timestamp. Any existing cache-refresh iframe created by this method is removed before a new one is created. A failed request or iframe load does not prevent the final navigation.
|
package/dist/client.cjs
CHANGED
|
@@ -59,8 +59,9 @@ function loadIframe(url) {
|
|
|
59
59
|
document.documentElement.appendChild(iframe);
|
|
60
60
|
});
|
|
61
61
|
}
|
|
62
|
-
async function clearUrlCache(url = window.location.
|
|
62
|
+
async function clearUrlCache(url = window.location.origin + window.location.pathname) {
|
|
63
63
|
const targetUrl = new URL(url, window.location.href).href;
|
|
64
|
+
console.info(`[vite-plugin-build-version] Clear cache for ${targetUrl}`);
|
|
64
65
|
await Promise.allSettled([
|
|
65
66
|
fetch(createCacheBustedUrl(targetUrl), { cache: "no-store" }).then(
|
|
66
67
|
(response) => response.arrayBuffer()
|
package/dist/client.mjs
CHANGED
|
@@ -35,8 +35,9 @@ function loadIframe(url) {
|
|
|
35
35
|
document.documentElement.appendChild(iframe);
|
|
36
36
|
});
|
|
37
37
|
}
|
|
38
|
-
async function clearUrlCache(url = window.location.
|
|
38
|
+
async function clearUrlCache(url = window.location.origin + window.location.pathname) {
|
|
39
39
|
const targetUrl = new URL(url, window.location.href).href;
|
|
40
|
+
console.info(`[vite-plugin-build-version] Clear cache for ${targetUrl}`);
|
|
40
41
|
await Promise.allSettled([
|
|
41
42
|
fetch(createCacheBustedUrl(targetUrl), { cache: "no-store" }).then(
|
|
42
43
|
(response) => response.arrayBuffer()
|