| 12345678910111213141516171819202122232425262728293031323334353637383940 |
- diff --git a/viewer.ts b/viewer.ts
- index 1111111..3333333 100644
- --- a/viewer.ts
- +++ b/viewer.ts
- @@ -1,8 +1,24 @@
- -const renderer = 'text'
- +const renderer = 'highlight.js'
- +
- +type PreviewMode = 'url' | 'file'
- +
- export default renderer
- -export function open(url: string) {
- - return fetch(url)
- +export async function open(url: string, mode: PreviewMode = 'url') {
- + const response = await fetch(url, { credentials: 'include' })
- + if (!response.ok) {
- + throw new Error(`Preview download failed: ${response.status}`)
- + }
- +
- + const blob = await response.blob()
- + if (mode === 'file') {
- + const filename = decodeURIComponent(url.split('/').pop() || 'preview.bin')
- + return new File([blob], filename, { type: blob.type })
- + }
- +
- + return blob
- }
- diff --git a/styles.css b/styles.css
- index aaaaaaa..bbbbbbb 100644
- --- a/styles.css
- +++ b/styles.css
- @@ -4,6 +4,9 @@
- .preview-shell {
- min-height: 100vh;
- overflow: hidden;
- + display: grid;
- + grid-template-columns: minmax(260px, 320px) minmax(0, 1fr);
- + background: #f6f8fb;
- }
|