mirror of
https://github.com/toeverything/AFFiNE.git
synced 2024-12-25 07:22:39 +03:00
fix: use cdn api when querying static CDN files (#4361)
Co-authored-by: DarkSky <25152247+darkskygit@users.noreply.github.com>
This commit is contained in:
parent
f79cd76cec
commit
e1a330a0a6
@ -8,13 +8,17 @@ import {
|
|||||||
import { fetcher } from '@affine/workspace/affine/gql';
|
import { fetcher } from '@affine/workspace/affine/gql';
|
||||||
import type { BlobStorage } from '@blocksuite/store';
|
import type { BlobStorage } from '@blocksuite/store';
|
||||||
|
|
||||||
|
import { predefinedStaticFiles } from './local-static-storage';
|
||||||
|
|
||||||
export const createCloudBlobStorage = (workspaceId: string): BlobStorage => {
|
export const createCloudBlobStorage = (workspaceId: string): BlobStorage => {
|
||||||
return {
|
return {
|
||||||
crud: {
|
crud: {
|
||||||
get: async key => {
|
get: async key => {
|
||||||
|
const suffix = predefinedStaticFiles.includes(key)
|
||||||
|
? `/static/${key}`
|
||||||
|
: `/api/workspaces/${workspaceId}/blobs/${key}`;
|
||||||
return fetchWithTraceReport(
|
return fetchWithTraceReport(
|
||||||
runtimeConfig.serverUrlPrefix +
|
runtimeConfig.serverUrlPrefix + suffix
|
||||||
`/api/workspaces/${workspaceId}/blobs/${key}`
|
|
||||||
).then(res => {
|
).then(res => {
|
||||||
if (!res.ok) {
|
if (!res.ok) {
|
||||||
// status not in the range 200-299
|
// status not in the range 200-299
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import type { BlobStorage } from '@blocksuite/store';
|
import type { BlobStorage } from '@blocksuite/store';
|
||||||
|
|
||||||
const predefinedStaticFiles = [
|
export const predefinedStaticFiles = [
|
||||||
'v2yF7lY2L5rtorTtTmYFsoMb9dBPKs5M1y9cUKxcI1M=',
|
'v2yF7lY2L5rtorTtTmYFsoMb9dBPKs5M1y9cUKxcI1M=',
|
||||||
'nSEEkYxrThpZfLoPNOzMp6HWekvutAIYmADElDe1J6I=',
|
'nSEEkYxrThpZfLoPNOzMp6HWekvutAIYmADElDe1J6I=',
|
||||||
'CBWoKrhSDndjBJzscQKENRqiXOOZnzIA5qyiCoy4-A0=',
|
'CBWoKrhSDndjBJzscQKENRqiXOOZnzIA5qyiCoy4-A0=',
|
||||||
@ -29,7 +29,7 @@ export const createStaticStorage = (): BlobStorage => {
|
|||||||
return response.blob();
|
return response.blob();
|
||||||
}
|
}
|
||||||
} else if (predefinedStaticFiles.includes(key)) {
|
} else if (predefinedStaticFiles.includes(key)) {
|
||||||
const response = await fetch(`/static/${key}.png`);
|
const response = await fetch(`/static/${key}`);
|
||||||
if (response.ok) {
|
if (response.ok) {
|
||||||
return response.blob();
|
return response.blob();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user