WebUI: Apply cache id to all loaded resources

This includes html files and js/css assets loaded via MooTools.

PR #22945.
Closes #18712.
This commit is contained in:
Thomas Piccirello
2025-07-20 10:32:18 +02:00
committed by GitHub
parent e3141ce449
commit c962a6b1d7
12 changed files with 129 additions and 47 deletions

View File

@@ -196,6 +196,7 @@ const initializeWindows = () => {
if (urls && (urls.length > 0)) {
contentURL.search = new URLSearchParams({
v: CACHEID,
urls: urls.map(encodeURIComponent).join("|")
});
}
@@ -231,7 +232,7 @@ const initializeWindows = () => {
icon: "images/torrent-creator.svg",
title: "QBT_TR(Torrent Creator)QBT_TR[CONTEXT=TorrentCreator]",
loadMethod: "xhr",
contentURL: "views/torrentcreator.html",
contentURL: "views/torrentcreator.html?v=${CACHEID}",
scrollbars: true,
maximizable: true,
paddingVertical: 0,
@@ -258,11 +259,11 @@ const initializeWindows = () => {
title: "QBT_TR(Options)QBT_TR[CONTEXT=OptionsDialog]",
loadMethod: "xhr",
toolbar: true,
contentURL: "views/preferences.html",
contentURL: "views/preferences.html?v=${CACHEID}",
require: {
css: ["css/Tabs.css"]
css: ["css/Tabs.css?v=${CACHEID}"]
},
toolbarURL: "views/preferencesToolbar.html",
toolbarURL: "views/preferencesToolbar.html?v=${CACHEID}",
maximizable: false,
closable: true,
paddingVertical: 0,
@@ -284,7 +285,7 @@ const initializeWindows = () => {
id: id,
title: "QBT_TR(Manage Cookies)QBT_TR[CONTEXT=CookiesDialog]",
loadMethod: "xhr",
contentURL: "views/cookies.html",
contentURL: "views/cookies.html?v=${CACHEID}",
maximizable: false,
paddingVertical: 0,
paddingHorizontal: 0,
@@ -306,7 +307,7 @@ const initializeWindows = () => {
icon: "images/qbittorrent-tray.svg",
title: "QBT_TR(Upload local torrent)QBT_TR[CONTEXT=HttpServer]",
loadMethod: "iframe",
contentURL: "upload.html",
contentURL: "upload.html?v=${CACHEID}",
addClass: "windowFrame", // fixes iframe scrolling on iOS Safari
scrollbars: true,
maximizable: false,
@@ -324,6 +325,7 @@ const initializeWindows = () => {
globalUploadLimitFN = () => {
const contentURL = new URL("speedlimit.html", window.location);
contentURL.search = new URLSearchParams({
v: CACHEID,
hashes: "global",
type: "upload",
});
@@ -350,6 +352,7 @@ const initializeWindows = () => {
const contentURL = new URL("speedlimit.html", window.location);
contentURL.search = new URLSearchParams({
v: CACHEID,
hashes: hashes.join("|"),
type: "upload",
});
@@ -396,6 +399,7 @@ const initializeWindows = () => {
const contentURL = new URL("shareratio.html", window.location);
contentURL.search = new URLSearchParams({
v: CACHEID,
hashes: hashes.join("|"),
// if all torrents have same share ratio, display that share ratio. else use the default
orig: torrentsHaveSameShareRatio ? shareRatio : ""
@@ -472,6 +476,7 @@ const initializeWindows = () => {
globalDownloadLimitFN = () => {
const contentURL = new URL("speedlimit.html", window.location);
contentURL.search = new URLSearchParams({
v: CACHEID,
hashes: "global",
type: "download",
});
@@ -498,7 +503,7 @@ const initializeWindows = () => {
icon: "images/qbittorrent-tray.svg",
title: "QBT_TR(Statistics)QBT_TR[CONTEXT=StatsDialog]",
loadMethod: "xhr",
contentURL: "views/statistics.html",
contentURL: "views/statistics.html?v=${CACHEID}",
maximizable: false,
padding: 10,
width: loadWindowWidth(id, 285),
@@ -519,6 +524,7 @@ const initializeWindows = () => {
const contentURL = new URL("speedlimit.html", window.location);
contentURL.search = new URLSearchParams({
v: CACHEID,
hashes: hashes.join("|"),
type: "download",
});
@@ -550,7 +556,7 @@ const initializeWindows = () => {
hashes: hashes,
forceDeleteFiles: forceDeleteFiles
},
contentURL: "views/confirmdeletion.html",
contentURL: "views/confirmdeletion.html?v=${CACHEID}",
onContentLoaded: (w) => {
MochaUI.resizeWindow(w, { centered: true });
MochaUI.centerWindow(w);
@@ -628,7 +634,7 @@ const initializeWindows = () => {
hashes: hashes,
enable: enableAutoTMM
},
contentURL: "views/confirmAutoTMM.html"
contentURL: "views/confirmAutoTMM.htm?v=${CACHEID}l"
});
}
else {
@@ -660,7 +666,7 @@ const initializeWindows = () => {
id: "confirmRecheckDialog",
title: "QBT_TR(Recheck confirmation)QBT_TR[CONTEXT=confirmRecheckDialog]",
data: { hashes: hashes },
contentURL: "views/confirmRecheck.html"
contentURL: "views/confirmRecheck.htm?v=${CACHEID}l"
});
}
else {
@@ -702,6 +708,7 @@ const initializeWindows = () => {
const contentURL = new URL("setlocation.html", window.location);
contentURL.search = new URLSearchParams({
v: CACHEID,
hashes: hashes.join("|"),
path: encodeURIComponent(torrentsTable.getRow(hashes[0]).full_data.save_path)
});
@@ -732,6 +739,7 @@ const initializeWindows = () => {
const contentURL = new URL("rename.html", window.location);
contentURL.search = new URLSearchParams({
v: CACHEID,
hash: hashes[0],
name: row.full_data.name
});
@@ -763,7 +771,7 @@ const initializeWindows = () => {
title: "QBT_TR(Renaming)QBT_TR[CONTEXT=TransferListWidget]",
data: { hash: hash, selectedRows: [] },
loadMethod: "xhr",
contentURL: "rename_files.html",
contentURL: "rename_files.html?v=${CACHEID}",
scrollbars: false,
resizable: true,
maximizable: false,
@@ -831,7 +839,7 @@ const initializeWindows = () => {
hashes: hashes,
isDeletingVisibleTorrents: true
},
contentURL: "views/confirmdeletion.html",
contentURL: "views/confirmdeletion.html?v=${CACHEID}",
onContentLoaded: (w) => {
MochaUI.resizeWindow(w, { centered: true });
MochaUI.centerWindow(w);
@@ -867,6 +875,7 @@ const initializeWindows = () => {
const contentURL = new URL("newcategory.html", window.location);
contentURL.search = new URLSearchParams({
v: CACHEID,
action: "set",
hashes: hashes.join("|")
});
@@ -909,6 +918,7 @@ const initializeWindows = () => {
createCategoryFN = () => {
const contentURL = new URL("newcategory.html", window.location);
contentURL.search = new URLSearchParams({
v: CACHEID,
action: "create"
});
new MochaUI.Window({
@@ -930,6 +940,7 @@ const initializeWindows = () => {
createSubcategoryFN = (category) => {
const contentURL = new URL("newcategory.html", window.location);
contentURL.search = new URLSearchParams({
v: CACHEID,
action: "createSubcategory",
categoryName: `${category}/`
});
@@ -952,6 +963,7 @@ const initializeWindows = () => {
editCategoryFN = (category) => {
const contentURL = new URL("newcategory.html", window.location);
contentURL.search = new URLSearchParams({
v: CACHEID,
action: "edit",
categoryName: category
});
@@ -1015,6 +1027,7 @@ const initializeWindows = () => {
const contentURL = new URL("newtag.html", window.location);
contentURL.search = new URLSearchParams({
v: CACHEID,
action: "set",
hashes: hashes.join("|")
});
@@ -1063,6 +1076,7 @@ const initializeWindows = () => {
createTagFN = () => {
const contentURL = new URL("newtag.html", window.location);
contentURL.search = new URLSearchParams({
v: CACHEID,
action: "create"
});
new MochaUI.Window({
@@ -1117,6 +1131,7 @@ const initializeWindows = () => {
const contentURL = new URL("confirmtrackerdeletion.html", window.location);
contentURL.search = new URLSearchParams({
v: CACHEID,
host: trackerHost,
urls: [...trackerMap.get(trackerHost).keys()].map(encodeURIComponent).join("|")
});
@@ -1310,12 +1325,12 @@ const initializeWindows = () => {
icon: "images/qbittorrent-tray.svg",
title: "QBT_TR(About qBittorrent)QBT_TR[CONTEXT=AboutDialog]",
loadMethod: "xhr",
contentURL: "views/about.html",
contentURL: "views/about.html?v=${CACHEID}",
require: {
css: ["css/Tabs.css"]
css: ["css/Tabs.css?v=${CACHEID}"]
},
toolbar: true,
toolbarURL: "views/aboutToolbar.html",
toolbarURL: "views/aboutToolbar.html?v=${CACHEID}",
padding: 10,
width: loadWindowWidth(id, 570),
height: loadWindowHeight(id, 360),