change.diff 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. diff --git a/viewer.ts b/viewer.ts
  2. index 1111111..3333333 100644
  3. --- a/viewer.ts
  4. +++ b/viewer.ts
  5. @@ -1,8 +1,24 @@
  6. -const renderer = 'text'
  7. +const renderer = 'highlight.js'
  8. +
  9. +type PreviewMode = 'url' | 'file'
  10. +
  11. export default renderer
  12. -export function open(url: string) {
  13. - return fetch(url)
  14. +export async function open(url: string, mode: PreviewMode = 'url') {
  15. + const response = await fetch(url, { credentials: 'include' })
  16. + if (!response.ok) {
  17. + throw new Error(`Preview download failed: ${response.status}`)
  18. + }
  19. +
  20. + const blob = await response.blob()
  21. + if (mode === 'file') {
  22. + const filename = decodeURIComponent(url.split('/').pop() || 'preview.bin')
  23. + return new File([blob], filename, { type: blob.type })
  24. + }
  25. +
  26. + return blob
  27. }
  28. diff --git a/styles.css b/styles.css
  29. index aaaaaaa..bbbbbbb 100644
  30. --- a/styles.css
  31. +++ b/styles.css
  32. @@ -4,6 +4,9 @@
  33. .preview-shell {
  34. min-height: 100vh;
  35. overflow: hidden;
  36. + display: grid;
  37. + grid-template-columns: minmax(260px, 320px) minmax(0, 1fr);
  38. + background: #f6f8fb;
  39. }