Scope files jobs and plugins to request profile

This commit is contained in:
ekko
2026-05-24 09:25:52 +08:00
committed by ekko
parent 289a958684
commit 9708a6a521
23 changed files with 353 additions and 117 deletions
+1 -1
View File
@@ -46,7 +46,7 @@ export function isStoredSuperAdmin(): boolean {
return getStoredUserRole() === 'super_admin'
}
function getActiveProfileName(): string | null {
export function getActiveProfileName(): string | null {
return localStorage.getItem('hermes_active_profile_name')
}
+3 -1
View File
@@ -1,4 +1,4 @@
import { getApiKey, getBaseUrlValue } from '../client'
import { getActiveProfileName, getApiKey, getBaseUrlValue } from '../client'
/**
* Construct a download URL with auth token as query parameter.
@@ -27,6 +27,8 @@ export function getDownloadUrl(filePath: string, fileName?: string): string {
const decodedName = decodeURIComponent(fileName)
params.set('name', decodedName)
}
const profileName = getActiveProfileName()
if (profileName) params.set('profile', profileName)
const token = getApiKey()
if (token) params.set('token', token)
return `${base}/api/hermes/download?${params.toString()}`
+5 -1
View File
@@ -1,4 +1,4 @@
import { request, getApiKey, getBaseUrlValue } from '../client'
import { request, getActiveProfileName, getApiKey, getBaseUrlValue } from '../client'
export interface FileEntry {
name: string
@@ -83,6 +83,8 @@ export async function uploadFiles(targetDir: string, files: File[]): Promise<{ n
const headers: Record<string, string> = {}
const token = getApiKey()
if (token) headers['Authorization'] = `Bearer ${token}`
const profileName = getActiveProfileName()
if (profileName) headers['X-Hermes-Profile'] = profileName
const res = await fetch(url, { method: 'POST', headers, body: formData })
if (!res.ok) {
@@ -97,6 +99,8 @@ export function getFileDownloadUrl(relativePath: string, fileName?: string): str
const base = getBaseUrlValue()
const params = new URLSearchParams({ path: relativePath })
if (fileName) params.set('name', fileName)
const profileName = getActiveProfileName()
if (profileName) params.set('profile', profileName)
const token = getApiKey()
if (token) params.set('token', token)
return `${base}/api/hermes/download?${params.toString()}`