mirror of
https://github.com/lWolvesl/antigravity-usage-monitor.git
synced 2026-11-27 01:19:25 +08:00
fix(panel): use native browser downloads for standalone web exports
- Gate /api/export-file and /api/reveal-file calls behind isHostEmbeddedWebview so standalone browser sessions invoke showSaveFilePicker or Blob downloads directly without expiring user activation - Reject /api/export-file, /api/reveal-file, and __exportFileAction requests in standalone-server.mjs so ssh -L tunnels and local reverse proxies never write files or spawn xdg-open on the server host
This commit is contained in:
@@ -46,7 +46,7 @@ function getPickerTypesForFilename(filename, mimeType) {
|
||||
* @returns {Promise<boolean>}
|
||||
*/
|
||||
export async function revealExportedFile(filePath) {
|
||||
if (!filePath) return false;
|
||||
if (!filePath || !isHostEmbeddedWebview()) return false;
|
||||
try {
|
||||
const res = await callSidecarApi('/api/reveal-file', {
|
||||
method: 'POST',
|
||||
@@ -118,25 +118,25 @@ async function runExportPipelineWithFeedback({
|
||||
backendPayload,
|
||||
writablePayload,
|
||||
}) {
|
||||
const { res: localRes } = await requestLocalBackendExport(backendPayload);
|
||||
if (localRes && localRes.ok && localRes.filePath) {
|
||||
const savedPath = String(localRes.filePath);
|
||||
const savedName = String(localRes.fileName || safeName);
|
||||
showUiToast({
|
||||
message: t('export.savedLocal', { file: savedName }),
|
||||
detail: savedPath,
|
||||
actionLabel: t('export.openFolder'),
|
||||
onAction: () => {
|
||||
void revealExportedFile(savedPath);
|
||||
},
|
||||
tone: 'ok',
|
||||
durationMs: 7000,
|
||||
});
|
||||
return { ok: true, mode: 'local', filePath: savedPath, fileName: savedName };
|
||||
}
|
||||
|
||||
// 在 Antigravity Sidecar / 双栖 Electron 宿主内,<a download> 会被静默吞掉,绝不误报“已下载到浏览器”
|
||||
if (isHostEmbeddedWebview()) {
|
||||
const { res: localRes } = await requestLocalBackendExport(backendPayload);
|
||||
if (localRes && localRes.ok && localRes.filePath) {
|
||||
const savedPath = String(localRes.filePath);
|
||||
const savedName = String(localRes.fileName || safeName);
|
||||
showUiToast({
|
||||
message: t('export.savedLocal', { file: savedName }),
|
||||
detail: savedPath,
|
||||
actionLabel: t('export.openFolder'),
|
||||
onAction: () => {
|
||||
void revealExportedFile(savedPath);
|
||||
},
|
||||
tone: 'ok',
|
||||
durationMs: 7000,
|
||||
});
|
||||
return { ok: true, mode: 'local', filePath: savedPath, fileName: savedName };
|
||||
}
|
||||
|
||||
// 在 Antigravity Sidecar / 双栖 Electron 宿主内,<a download> 会被静默吞掉,绝不误报“已下载到浏览器”
|
||||
showUiToast({
|
||||
message: t('export.failed'),
|
||||
detail: t('export.hostUnavailable'),
|
||||
|
||||
Reference in New Issue
Block a user