mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-16 17:46:18 +08:00
fix: image proxy url (#14505)
#### PR Dependency Tree * **PR #14505** 👈 This tree was auto-generated by [Charcoal](https://github.com/danerwilliams/charcoal) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Improvements** * Better image-proxy detection to avoid double-proxying already proxied images. * Improved runtime image proxy configuration so images load consistently across deployments. * More robust image URL handling for optimized image loading and fewer redundant requests. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { SignalWatcher, WithDisposable } from '@blocksuite/affine/global/lit';
|
||||
import { unsafeCSSVarV2 } from '@blocksuite/affine/shared/theme';
|
||||
import { ShadowlessElement } from '@blocksuite/affine/std';
|
||||
import { DEFAULT_IMAGE_PROXY_ENDPOINT } from '@blocksuite/affine-shared/consts';
|
||||
import { isImageProxyURL } from '@blocksuite/affine-shared/adapters';
|
||||
import { ToggleDownIcon, ToolIcon } from '@blocksuite/icons/lit';
|
||||
import { type Signal } from '@preact/signals-core';
|
||||
import { css, html, nothing, type TemplateResult } from 'lit';
|
||||
@@ -250,7 +250,7 @@ export class ToolResultCard extends SignalWatcher(
|
||||
@state()
|
||||
private accessor isCollapsed = true;
|
||||
|
||||
private readonly imageProxyURL = DEFAULT_IMAGE_PROXY_ENDPOINT;
|
||||
private readonly imageProxyURL = BUILD_CONFIG.imageProxyUrl;
|
||||
|
||||
protected override render() {
|
||||
return html`
|
||||
@@ -323,7 +323,7 @@ export class ToolResultCard extends SignalWatcher(
|
||||
}
|
||||
|
||||
buildUrl(imageUrl: string) {
|
||||
if (imageUrl.startsWith(this.imageProxyURL)) {
|
||||
if (imageUrl.startsWith(this.imageProxyURL) || isImageProxyURL(imageUrl)) {
|
||||
return imageUrl;
|
||||
}
|
||||
return `${this.imageProxyURL}?url=${encodeURIComponent(imageUrl)}`;
|
||||
|
||||
Reference in New Issue
Block a user