Use globalThis instead of window for global object access (S7764)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-10 07:37:37 +08:00
parent 81df955845
commit a54b4cc7bb
2 changed files with 4 additions and 4 deletions

View File

@@ -271,7 +271,7 @@ export const useFilesStore = defineStore("filesStore", {
* @param {number} id - The file ID.
*/
async deleteFile(type, id) {
if (id === null || id === undefined || isNaN(id)) {
if (id === null || id === undefined || Number.isNaN(Number(id))) {
console.error("Delete File API Error: invalid id");
return;
}
@@ -317,13 +317,13 @@ export const useFilesStore = defineStore("filesStore", {
const response = await apiClient.get(`${getFileApiBase(type, id)}/csv`);
const csvData = response.data;
const blob = new Blob([csvData], { type: "text/csv" });
const url = window.URL.createObjectURL(blob);
const url = globalThis.URL.createObjectURL(blob);
const link = document.createElement("a");
link.href = url;
link.download = `${fileName}.csv`;
link.click();
window.URL.revokeObjectURL(url);
globalThis.URL.revokeObjectURL(url);
} catch (error) {
apiError(error, "Failed to download.");
}

View File

@@ -81,7 +81,7 @@ export const useLoginStore = defineStore("loginStore", {
}
// Only allow relative paths to prevent open redirect attacks
if (decodedUrl.startsWith("/") && !decodedUrl.startsWith("//")) {
window.location.href = decodedUrl;
globalThis.location.href = decodedUrl;
return;
}
}