mirror of
https://github.com/cupcakearmy/cryptgeon.git
synced 2026-09-26 20:41:45 +00:00
first v3
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
<script lang="ts" module>
|
||||
export type DecryptedNote = Omit<NotePublic, 'contents'> & { contents: any }
|
||||
export type DecryptedNote = {
|
||||
meta: { type: 'text' | 'file' }
|
||||
contents: any
|
||||
}
|
||||
|
||||
function saveAs(file: File) {
|
||||
const url = window.URL.createObjectURL(file)
|
||||
@@ -20,7 +23,7 @@
|
||||
|
||||
import Button from '$lib/ui/Button.svelte'
|
||||
import { copy } from '$lib/utils'
|
||||
import type { FileDTO, NotePublic } from 'cryptgeon/shared'
|
||||
import type { FileDTO } from '@cryptgeon/shared'
|
||||
|
||||
interface Props {
|
||||
note: DecryptedNote
|
||||
@@ -31,10 +34,9 @@
|
||||
const RE_URL = /[A-Za-z]+:\/\/([A-Z a-z0-9\-._~:\/?#\[\]@!$&'()*+,;%=])+/g
|
||||
let files: FileDTO[] = $state([])
|
||||
|
||||
async function downloadFile(file: FileDTO) {
|
||||
// @ts-ignore
|
||||
const f = new File([file.contents], file.name, {
|
||||
type: file.type,
|
||||
async function downloadFile(file: FileDTO) {
|
||||
const f = new File([file.data.slice(0)], file.name, {
|
||||
type: file.mime,
|
||||
})
|
||||
saveAs(f)
|
||||
}
|
||||
@@ -78,12 +80,12 @@
|
||||
<button onclick={() => downloadFile(file)}>
|
||||
<b>↓ {file.name}</b>
|
||||
</button>
|
||||
<small> {file.type} - {prettyBytes(file.size)}</small>
|
||||
<small> {file.mime} - {prettyBytes(file.size ?? file.data.length)}</small>
|
||||
</div>
|
||||
{#if file.type.startsWith('image/')}
|
||||
{#if file.mime.startsWith('image/')}
|
||||
{#key file.name}
|
||||
<img
|
||||
src={URL.createObjectURL(new File([file.contents], file.name, { type: file.type }))}
|
||||
src={URL.createObjectURL(new File([file.data.slice(0)], file.name, { type: file.mime }))}
|
||||
alt={file.name}
|
||||
class="preview"
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user