continuous-integration/drone/tag Build is passing
鸿蒙微信 ArkWeb 下 H5 window.open 常静默失败,仅出现「开始下载…」。 OA/市场附件在小程序 WebView 内改为跳转 pages/oa/file-preview, 用 uni.downloadFile + openDocument 打开,浏览器环境仍用预签名直链。 Refs: #74 Co-authored-by: Cursor <cursoragent@cursor.com>
26 lines
722 B
JavaScript
26 lines
722 B
JavaScript
import assert from 'node:assert/strict'
|
|
import {
|
|
openDocumentFileType,
|
|
parseFilePreviewQuery
|
|
} from './oa-file-preview.js'
|
|
|
|
assert.equal(openDocumentFileType('a.xlsx'), 'xlsx')
|
|
assert.equal(openDocumentFileType('a.zip'), '')
|
|
|
|
const parsed = parseFilePreviewQuery({
|
|
fileUrl: encodeURIComponent('oa-approval/202610/abc.xlsx'),
|
|
n: 'file.xlsx'
|
|
})
|
|
assert.equal(parsed.fileUrl, 'oa-approval/202610/abc.xlsx')
|
|
assert.equal(parsed.name, 'file.xlsx')
|
|
assert.equal(parsed.fileType, 'xlsx')
|
|
|
|
const fallback = parseFilePreviewQuery({
|
|
f: 'oa-approval/x.pdf'
|
|
})
|
|
assert.equal(fallback.fileUrl, 'oa-approval/x.pdf')
|
|
assert.equal(fallback.name, 'file.bin')
|
|
assert.equal(fallback.fileType, '')
|
|
|
|
console.log('oa-file-preview: ok')
|