-
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: file hash calc and components list
- Loading branch information
Showing
8 changed files
with
61 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
export * from "./useCrypto"; | ||
export * from "./useCert"; | ||
export * from "./useCrypto" | ||
export * from "./useCert" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<script setup> | ||
import { reactive } from 'vue' | ||
import { hashText } from '../crypto/useCrypto'; | ||
const files = reactive({}) | ||
function calculateHash(ev) { | ||
const uploads = ev?.target?.files | ||
for (const file of uploads) { | ||
console.log(file) | ||
const reader = new FileReader(); | ||
reader.readAsDataURL(file); | ||
reader.onloadend = async () => { | ||
// Use a regex to remove data url part | ||
const base64String = reader.result | ||
const hash = await hashText(base64String) | ||
files[hash] = { name: file.name } | ||
}; | ||
} | ||
} | ||
</script> | ||
<template lang='pug'> | ||
.flex.flex-col.gap-2.p-2 | ||
label.p-2.flex.flex-wrap.gap-2.bg-light-100.dark-bg-dark-400.rounded.cursor-pointer.max-w-90.overflow-scroll | ||
.font-bold Check file hash | ||
.flex-1 | ||
input( | ||
type="file" | ||
@change="calculateHash($event)" | ||
) | ||
.p-2.flex.flex-col.break-all.bg-light-100.dark-bg-dark-400.shadow(v-for="(file,hash) in files" :key="hash") | ||
.p-0.text-xs.bg-light-400.dark-bg-dark-800.select-none.opacity-80 {{ file.name }} | ||
.font-mono.p-0.text-lg {{ hash }} | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<script setup> | ||
import { components } from '#components' | ||
const emit = defineEmits(['component']) | ||
</script> | ||
|
||
<template lang='pug'> | ||
.flex.flex-wrap | ||
.cursor-pointer.p-1.opacity-60.hover-opacity-100( | ||
v-for="(component, name ) in components" | ||
@click="$emit('component', name)" | ||
) {{ name }} | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters