Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/chat/template/embed.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const chatButtonHtml=

const getChatContainerHtml=(protocol,host,token,query,prefix)=>{
return `<div id="maxkb-chat-container">
<iframe id="maxkb-chat" allow="microphone" src=${protocol}://${host}${prefix}/${token}?mode=embed${query}></iframe>
<iframe id="maxkb-chat" allow="microphone; fullscreen" src=${protocol}://${host}${prefix}/${token}?mode=embed${query}></iframe>
<div class="maxkb-operate"><div class="maxkb-closeviewport maxkb-viewportnone"><svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 1024 1024" fill="none"><path d="M384.341333 597.205333a42.538667 42.538667 0 0 1 42.666667 42.666667v220.16a21.333333 21.333333 0 0 1-21.333333 21.333333h-42.666667a21.333333 21.333333 0 0 1-21.333333-21.333333v-113.493333l-167.04 167.04a21.333333 21.333333 0 0 1-30.165334 0l-30.165333-30.208a21.333333 21.333333 0 0 1 0-30.165334l170.709333-170.666666H163.669333a21.333333 21.333333 0 0 1-21.333333-21.333334v-42.666666a21.333333 21.333333 0 0 1 21.333333-21.333334h220.672zM849.92 110.506667a21.333333 21.333333 0 0 1 30.165333 0l30.165334 30.165333a21.333333 21.333333 0 0 1 0 30.165333l-170.709334 170.666667h121.344a21.333333 21.333333 0 0 1 21.333334 21.333333v42.666667a21.333333 21.333333 0 0 1-21.333334 21.333333h-220.672a42.538667 42.538667 0 0 1-42.666666-42.666666v-220.16a21.333333 21.333333 0 0 1 21.333333-21.333334h42.666667a21.333333 21.333333 0 0 1 21.333333 21.333334v113.493333l167.04-166.997333z" fill="{{header_font_color}}"/></svg></div>
<div class="maxkb-openviewport">
<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 1024 1024" fill="none"><path d="M366.165333 593.749333a21.333333 21.333333 0 0 1 30.208 0l30.165334 30.165334a21.333333 21.333333 0 0 1 0 30.208l-170.752 170.666666H377.173333a21.333333 21.333333 0 0 1 21.333334 21.333334v42.666666a21.333333 21.333333 0 0 1-21.333334 21.333334H156.458667a42.538667 42.538667 0 0 1-42.666667-42.666667v-220.16a21.333333 21.333333 0 0 1 21.333333-21.333333h42.666667a21.333333 21.333333 0 0 1 21.333333 21.333333v113.493333l167.04-167.04z m500.992-480a42.538667 42.538667 0 0 1 42.666667 42.666667v220.16a21.333333 21.333333 0 0 1-21.333333 21.333333h-42.666667a21.333333 21.333333 0 0 1-21.333333-21.333333v-113.493333l-167.04 167.04a21.333333 21.333333 0 0 1-30.165334 0l-30.165333-30.165334a21.333333 21.333333 0 0 1 0-30.165333l170.709333-170.666667h-121.344a21.333333 21.333333 0 0 1-21.333333-21.333333v-42.666667a21.333333 21.333333 0 0 1 21.333333-21.333333h220.672z" fill="{{header_font_color}}"/></svg></div>
Expand Down
51 changes: 51 additions & 0 deletions apps/oss/tests/test_file_retrieval_auth.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
from unittest.mock import patch

from django.http import HttpResponse
from django.test import SimpleTestCase
from rest_framework.test import APIRequestFactory

from oss.views import FileRetrievalView
from oss.views.file import FILE_AUTH_COOKIE


class FileRetrievalAuthTestCase(SimpleTestCase):
"""文件读取接口的凭证来源:请求头优先,cookie 兜底。"""

def setUp(self):
self.factory = APIRequestFactory()

def retrieve(self, request):
with patch("oss.views.file.FileSerializer.Operate") as operate:
operate.return_value.get.return_value = HttpResponse()
FileRetrievalView.as_view()(request, file_id="file-id")
return operate.return_value.get.call_args.kwargs["mk_file_auth"]

def test_bearer_header_is_used_when_cookie_is_missing(self):
request = self.factory.get("/chat/oss/file/file-id", HTTP_AUTHORIZATION="Bearer header-token")

self.assertEqual(self.retrieve(request), "header-token")

def test_bearer_header_takes_precedence_over_cookie(self):
self.factory.cookies[FILE_AUTH_COOKIE] = "cookie-token"
request = self.factory.get("/chat/oss/file/file-id", HTTP_AUTHORIZATION="bearer header-token")

self.assertEqual(self.retrieve(request), "header-token")

def test_cookie_is_used_without_bearer_header(self):
self.factory.cookies[FILE_AUTH_COOKIE] = "cookie-token"
request = self.factory.get("/chat/oss/file/file-id")

self.assertEqual(self.retrieve(request), "cookie-token")

def test_other_authorization_schemes_fall_back_to_cookie(self):
self.factory.cookies[FILE_AUTH_COOKIE] = "cookie-token"
for authorization in ("Basic dXNlcjpwYXNz", "Bearer ", "Bearer"):
with self.subTest(authorization=authorization):
request = self.factory.get("/chat/oss/file/file-id", HTTP_AUTHORIZATION=authorization)

self.assertEqual(self.retrieve(request), "cookie-token")

def test_missing_credentials_pass_none(self):
request = self.factory.get("/chat/oss/file/file-id")

self.assertIsNone(self.retrieve(request))

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here are the issues and suggestions I found:

Potential issues

  1. Broken subTest argument (Bug)

    with self.subTest(authorization=[API_KEY]):

    [API_KEY] is undefined and authorization should be bound to the loop variable. This will raise NameError. It should be:

    with self.subTest(authorization=authorization):
  2. Shared cookies mutated across tests via self.factory
    self.factory.cookies[...] = ... mutates state on the factory instance. Since setUp creates a fresh APIRequestFactory per test this is currently safe, but it's fragile — reading via request.COOKIES semantics (factory.cookies vs request cookie passing) can be confusing. Consider using self.factory.get(..., cookies={...}) or DRF's client for clarity.

  3. patch target coupling
    The test asserts on operate.return_value.get.call_args.kwargs["mk_file_auth"]. If the view calls .get() multiple times or positional args change, call_args will be wrong (it captures only the last call). Prefer assert_called_once_with(...) on the expected call for robustness.

  4. Mock return type doesn't reflect HttpResponse usage
    Patching the whole Operate class and returning an HttpResponse from the mock means the view's response handling is bypassed/simulated. Fine for a focused unit test, but make sure this isn't hiding real behavior (e.g., if the view expects a FileResponse).

  5. No assertion that the view returns the mocked response / status
    The helper discards the view's response. Adding a check that .as_view()(...) returns the patched HttpResponse would catch regressions where the view errors before calling the serializer.

Test quality suggestions

  1. Coverage gap on whitespace / casing of header
    You test Bearer and bearer , but not values like "Bearer token" (multiple spaces) or a token containing spaces. Add explicit cases reflecting the actual parsing logic.

  2. Explicitly document/intend prefix matching
    If the code uses startswith("bearer ") (case-insensitive), test mixed case (bEaReR) explicitly for clarity and intent.

  3. Missing "empty Bearer falls back to cookie even without cookie → None" symmetry — minor, optional.

Style/nits

  1. retrieve helper name shadows Django's retrieve semantics — consider _extract_mk_file_auth for readability.
  2. Docstring in Chinese while answers/filenames are English — fine per project convention, just noting consistency.
  3. FILE_AUTH_COOKIE imported from oss.views.file but view imported via oss.views — mixing import paths; pick one for consistency.

Minimal fix for the blocking bug

def test_other_authorization_schemes_fall_back_to_cookie(self):
    self.factory.cookies[FILE_AUTH_COOKIE] = "cookie-token"
    for authorization in ("Basic dXNlcjpwYXNz", "Bearer ", "Bearer"):
        with self.subTest(authorization=authorization):
            request = self.factory.get("/chat/oss/file/file-id", HTTP_AUTHORIZATION=authorization)
            self.assertEqual(self.retrieve(request), "cookie-token")

The subTest(authorization=[API_KEY]) line is the only outright defect; the rest are robustness/maintainability improvements.

16 changes: 15 additions & 1 deletion apps/oss/views/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,20 @@
from oss.serializers.file import FileSerializer, get_url_content


FILE_AUTH_COOKIE = "mk_file_auth"


def get_file_auth(request: Request):
"""
读取文件凭证:优先使用 Authorization 请求头中的 Bearer token,没有时使用 cookie。
对话页以 iframe 嵌入第三方页面时,浏览器可能不发送跨站 cookie,前端改用请求头携带同一个 token。
"""
scheme, _separator, token = request.headers.get("Authorization", "").partition(" ")
if scheme.lower() == "bearer" and token.strip():
return token.strip()
return request.COOKIES.get(FILE_AUTH_COOKIE)


class FileRetrievalView(APIView):
@extend_schema(
methods=["GET"],
Expand All @@ -41,7 +55,7 @@ def get(self, request: Request, file_id: str):
"http_range": request.headers.get("Range", ""),
}
).get(
mk_file_auth=request.COOKIES.get("mk_file_auth"),
mk_file_auth=get_file_auth(request),
thumbnail=request.query_params.get("variant") == "thumbnail",
)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here's my review of the code:

Potential Issues

  1. request.COOKIES access via get_file_auth — In some Django/DRF contexts (e.g., when CSRF_COOKIE_HTTPONLY=False matters or with custom Request subclasses), request.COOKIES is fine, but be aware DRF's Request wraps the underlying HttpRequest. Ensure request.COOKIES resolves correctly (it does via DRF forwarding, but worth verifying your version).

  2. Bearer scheme parsing is loose — partition(" ") splits on the first space only. Headers like Bearer token (multiple spaces) will leave leading whitespace in token, which .strip() handles. However headers like Bearer with no token → _separator == "", token == "", falls through correctly. OK, but consider stricter validation.

  3. Case-insensitivity of scheme — Handled via .lower(). Good.

  4. Header precedence over cookie — Intentional per docstring. But note: if an attacker can set a malformed/empty Authorization header, it falls back to cookie. Acceptable, but document the security implications (header presence alone doesn't block cookie fallback unless token is non-empty).

  5. No logging/observability — Consider logging when falling back between auth methods for debugging cross-site iframe issues.

Optimization / Improvements

  1. Type hints — Return type should be Optional[str]:

    def get_file_auth(request: Request) -> Optional[str]:
  2. Centralize the cookie name constant — The old code used a string literal "mk_file_auth". If other modules reference it, import FILE_AUTH_COOKIE there too (grep the codebase).

  3. Stricter Bearer parsing — Optional:

    auth = request.headers.get("Authorization", "")
    if auth.lower().startswith("bearer "):
        return auth[7:].strip() or None
  4. Security consideration — Accepting bearer tokens from third-party iframe contexts increases exposure surface (tokens in URLs/logs/referer). Ensure the token TTL is short and scoped to file resources only. Also verify CORS/allowed origins.

  5. Test coverage — Add tests for: header-only, cookie-only, both present (header wins), empty bearer, malformed scheme.

  6. Docstring language consistency — Code comments are in Chinese while the project may standardize on English; confirm team convention.

Overall the change is reasonable and the logic is sound. Main action items: add return type hint, confirm constant is reused consistently, and add tests.

Expand Down
6 changes: 4 additions & 2 deletions ui/src/conversation-panel/components/content/items/file.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ import MkAudio from '@/components/global/mk-media-preview/MkAudio.vue'
import MkVideo from '@/components/global/mk-media-preview/MkVideo.vue'
import FileUploadCard from '@/components/mk-drag-upload/FileUploadCard.vue'
import { getFilePreviewType } from '../../../right-sidebar/file-preview/index'
import { downloadChatFile } from '../../../right-sidebar/file-preview/loader'
import { useRightSidebarStoreOptional } from '../../../right-sidebar/index'
import { downloadByURL } from '@/utils/common'
import { useFileRequestHeaders } from '../../../view/index'
import { getFileExtension, isAudio, isImage, isVideo } from '@/utils/icon'
import { formatFileSize } from '@/utils/number'

Expand All @@ -20,6 +21,7 @@ const props = defineProps<{
const { t } = useI18n({ useScope: 'global' })
// 对话视图内可在右侧预览,工作流执行详情等无右侧栏时直接下载
const rightSidebar = useRightSidebarStoreOptional()
const getFileRequestHeaders = useFileRequestHeaders()

type FileKind = 'image' | 'audio' | 'video' | 'file'

Expand Down Expand Up @@ -48,7 +50,7 @@ const imageSources = computed(() => imageFiles.value.map((file) => file.src))
function openFile(file: ChatFile) {
if (!file.url) return
if (rightSidebar && getFilePreviewType(file.name)) rightSidebar.showFilePreview({ name: file.name, url: file.url })
else downloadByURL(file.url, file.name)
else void downloadChatFile(file.url, file.name, getFileRequestHeaders())
}

function getFileDescription(file: ChatFile) {
Expand Down
11 changes: 6 additions & 5 deletions ui/src/conversation-panel/right-sidebar/file-preview/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { computed, onBeforeUnmount, onMounted, useTemplateRef } from 'vue'
import { useI18n } from 'vue-i18n'
import type { FilePreviewType } from './index'
import type { Component } from 'vue'
import { useViewType } from '@/conversation-panel/view/index'
import { useFileRequestHeaders, useViewType } from '@/conversation-panel/view/index'
import { useRightSidebarStore } from '../index'
import { createFullscreenToggle } from '../knowledge-source/document-preview/index'
import CsvItem from './items/csv/index.vue'
Expand All @@ -14,12 +14,13 @@ import PdfItem from './items/pdf/index.vue'
import PptItem from './items/ppt/index.vue'
import TextItem from './items/text/index.vue'
import WordItem from './items/word/index.vue'
import { downloadByURL } from '@/utils/common'
import { downloadChatFile } from './loader'

defineOptions({ name: 'FilePreview' })

const { t } = useI18n({ useScope: 'global' })
const viewType = useViewType()
const getFileRequestHeaders = useFileRequestHeaders()
const { filePreview, closeRightSide } = useRightSidebarStore()
const { previewFile, previewType } = filePreview
const fullscreen = createFullscreenToggle()
Expand All @@ -42,7 +43,7 @@ const previewRenderer = computed(() => (previewType.value ? previewRenderers[pre
// 下载当前预览的原文件
const downloadFile = () => {
const file = previewFile.value
if (file?.url) downloadByURL(file.url, file.name)
if (file?.url) void downloadChatFile(file.url, file.name, getFileRequestHeaders())
}

// 全屏只作用于预览区域
Expand All @@ -69,8 +70,8 @@ onBeforeUnmount(() => fullscreen.unbind())
<MkIcon name="icon_download_outlined" size="18" />
</el-button>
</MkTooltip>
<!-- 全屏预览 -->
<MkTooltip :content="t('common.actions.fullscreen')">
<!-- 全屏预览;浏览器不允许全屏时不显示 -->
<MkTooltip v-if="fullscreen.enabled" :content="t('common.actions.fullscreen')">
<el-button text class="ml-0!" @click="fullscreen.toggle()">
<MkIcon name="icon_window-new_outlined" size="18" />
</el-button>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script setup lang="ts">
import type { PreviewFile } from '../../index'
import SheetTable from '../../components/sheet-table/index.vue'
import { fetchPreviewFile, usePreviewLoader } from '../../loader'
import { usePreviewLoader } from '../../loader'
import FilePreviewStatus from '../../status.vue'
import { loadCsvSheet } from './csv'

Expand All @@ -13,7 +13,7 @@ const {
data: sheet,
loading,
error,
} = usePreviewLoader(async (signal) => loadCsvSheet(props.file.name, await (await fetchPreviewFile(props.file.url, signal)).arrayBuffer()))
} = usePreviewLoader(async (fetchFile) => loadCsvSheet(props.file.name, await (await fetchFile(props.file.url)).arrayBuffer()))
</script>

<template>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { ref, watch } from 'vue'
import type { PreviewFile } from '../../index'
import SheetTable from '../../components/sheet-table/index.vue'
import { fetchPreviewFile, usePreviewLoader } from '../../loader'
import { usePreviewLoader } from '../../loader'
import FilePreviewStatus from '../../status.vue'

defineOptions({ name: 'FilePreviewExcel' })
Expand All @@ -13,9 +13,9 @@ const {
data: sheets,
loading,
error,
} = usePreviewLoader(async (signal) => {
} = usePreviewLoader(async (fetchFile) => {
// xlsx 解析模块(exceljs、图表)首次预览时才加载
const [response, { loadXlsxSheets }] = await Promise.all([fetchPreviewFile(props.file.url, signal), import('./xlsx')])
const [response, { loadXlsxSheets }] = await Promise.all([fetchFile(props.file.url), import('./xlsx')])
return loadXlsxSheets(await response.arrayBuffer())
})
const activeSheet = ref('')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<script setup lang="ts">
import type { PreviewFile } from '../../index'
import { fetchPreviewFile, usePreviewLoader } from '../../loader'
import { usePreviewLoader } from '../../loader'
import FilePreviewStatus from '../../status.vue'

defineOptions({ name: 'FilePreviewHtml' })

const props = defineProps<{ file: PreviewFile }>()

const { data: html, loading, error } = usePreviewLoader(async (signal) => (await fetchPreviewFile(props.file.url, signal)).text())
const { data: html, loading, error } = usePreviewLoader(async (fetchFile) => (await fetchFile(props.file.url)).text())
</script>

<template>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<script setup lang="ts">
import type { PreviewFile } from '../../index'
import { fetchPreviewFile, usePreviewLoader } from '../../loader'
import { usePreviewLoader } from '../../loader'
import FilePreviewStatus from '../../status.vue'

defineOptions({ name: 'FilePreviewMarkdown' })

const props = defineProps<{ file: PreviewFile }>()

const { data: text, loading, error } = usePreviewLoader(async (signal) => (await fetchPreviewFile(props.file.url, signal)).text())
const { data: text, loading, error } = usePreviewLoader(async (fetchFile) => (await fetchFile(props.file.url)).text())
</script>

<template>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<script setup lang="ts">
import { onBeforeUnmount, onMounted, useTemplateRef } from 'vue'
import type { PreviewFile } from '../../index'
import { useFileRequestHeaders } from '../../../../view/index'
import { createPdfRenderer } from '../../../knowledge-source/document-preview/index'
import FilePreviewStatus from '../../status.vue'

Expand All @@ -9,13 +10,14 @@ defineOptions({ name: 'FilePreviewPdf' })
const props = defineProps<{ file: PreviewFile }>()

const pdfRenderer = createPdfRenderer()
const getFileRequestHeaders = useFileRequestHeaders()
const { loading, error } = pdfRenderer
const scrollRef = useTemplateRef<HTMLElement>('scrollRef')
const pagesRef = useTemplateRef<HTMLElement>('pagesRef')

// 挂载后逐页绘制;滚动容器用于按可见区域绘制及宽度变化时重绘
onMounted(() => {
if (pagesRef.value && scrollRef.value) void pdfRenderer.render(pagesRef.value, scrollRef.value, props.file.url)
if (pagesRef.value && scrollRef.value) void pdfRenderer.render(pagesRef.value, scrollRef.value, props.file.url, getFileRequestHeaders())
})
onBeforeUnmount(() => void pdfRenderer.destroy())
</script>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<script setup lang="ts">
import { onBeforeUnmount, onMounted, useTemplateRef } from 'vue'
import type { PreviewFile } from '../../index'
import { useFileRequestHeaders } from '../../../../view/index'
import FilePreviewStatus from '../../status.vue'
import { createPptRenderer } from './ppt'

Expand All @@ -9,13 +10,14 @@ defineOptions({ name: 'FilePreviewPpt' })
const props = defineProps<{ file: PreviewFile }>()

const pptRenderer = createPptRenderer()
const getFileRequestHeaders = useFileRequestHeaders()
const { loading, error } = pptRenderer
const scrollRef = useTemplateRef<HTMLElement>('scrollRef')
const slidesRef = useTemplateRef<HTMLElement>('slidesRef')

// 挂载后按幻灯片列表绘制;滚动容器用于按可见区域挂载幻灯片
onMounted(() => {
if (slidesRef.value && scrollRef.value) void pptRenderer.render(slidesRef.value, scrollRef.value, props.file.url)
if (slidesRef.value && scrollRef.value) void pptRenderer.render(slidesRef.value, scrollRef.value, props.file.url, getFileRequestHeaders())
})
onBeforeUnmount(() => pptRenderer.destroy())
</script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ export function createPptRenderer() {
viewer = null
}

/** target 为放置幻灯片的容器,scrollTarget 为其滚动容器,用于按可见区域挂载幻灯片。 */
async function render(target: HTMLElement, scrollTarget: HTMLElement, url: string) {
/** target 为放置幻灯片的容器,scrollTarget 为其滚动容器,用于按可见区域挂载幻灯片;headers 随文件请求发送。 */
async function render(target: HTMLElement, scrollTarget: HTMLElement, url: string, headers?: Record<string, string>) {
const current = ++token
release()
target.replaceChildren()
Expand All @@ -43,7 +43,7 @@ export function createPptRenderer() {
const controller = new AbortController()
abortController = controller
try {
const response = await fetch(url, { signal: controller.signal })
const response = await fetch(url, { headers, signal: controller.signal })
if (!response.ok) throw new Error(String(response.status))
const [data, { PptxViewer, RECOMMENDED_ZIP_LIMITS }] = await Promise.all([response.arrayBuffer(), loadPptxRenderer()])
if (current !== token) return
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<script setup lang="ts">
import type { PreviewFile } from '../../index'
import { fetchPreviewFile, usePreviewLoader } from '../../loader'
import { usePreviewLoader } from '../../loader'
import FilePreviewStatus from '../../status.vue'

defineOptions({ name: 'FilePreviewText' })

const props = defineProps<{ file: PreviewFile }>()

const { data: text, loading, error } = usePreviewLoader(async (signal) => (await fetchPreviewFile(props.file.url, signal)).text())
const { data: text, loading, error } = usePreviewLoader(async (fetchFile) => (await fetchFile(props.file.url)).text())
</script>

<template>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,15 @@
<script setup lang="ts">
import { onBeforeUnmount, ref } from 'vue'
import type { PreviewFile } from '../../index'
import { fetchPreviewFile, usePreviewLoader } from '../../loader'
import { usePreviewLoader } from '../../loader'
import FilePreviewStatus from '../../status.vue'
import { WORD_PREVIEW_SRCDOC, fitWordPages, renderWordDocument } from './word'

defineOptions({ name: 'FilePreviewWord' })

const props = defineProps<{ file: PreviewFile }>()

const {
data: wordDocument,
loading,
error,
fail,
signal,
} = usePreviewLoader(async (signal) => (await fetchPreviewFile(props.file.url, signal)).arrayBuffer())
const { data: wordDocument, loading, error, fail, signal } = usePreviewLoader(async (fetchFile) => (await fetchFile(props.file.url)).arrayBuffer())
// 下载完成后 iframe 加载并绘制,绘制期间保持加载状态
const rendering = ref(true)
// 页面随 iframe 宽度缩放(面板拖拽、全屏切换时重新计算)
Expand Down
Loading
Loading