mirror of
https://github.com/m1ngsama/FUJI.git
synced 2025-12-25 02:56:38 +00:00
organize files
This commit is contained in:
parent
a420b0b2bc
commit
9ceccd9bed
4 changed files with 29 additions and 6 deletions
|
|
@ -2,6 +2,7 @@
|
||||||
import QRCode from "qrcode"
|
import QRCode from "qrcode"
|
||||||
import { v4 as uuid } from "uuid"
|
import { v4 as uuid } from "uuid"
|
||||||
import { ref, onMounted, watch } from "vue"
|
import { ref, onMounted, watch } from "vue"
|
||||||
|
import { useGraduationIdURL } from "./graduation"
|
||||||
|
|
||||||
const id = ref<string>()
|
const id = ref<string>()
|
||||||
const idStoreKey = "graduationId"
|
const idStoreKey = "graduationId"
|
||||||
|
|
@ -10,11 +11,12 @@ const setId = () => {
|
||||||
localStorage.setItem(idStoreKey, id.value)
|
localStorage.setItem(idStoreKey, id.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
const url = ref<string>()
|
|
||||||
const svg = ref()
|
const svg = ref()
|
||||||
watch(id, async () => {
|
watch(id, async () => {
|
||||||
svg.value = await QRCode.toString(`https://nbtca.space/graduation/download/${id.value}`, { type: "svg" })
|
if (!id.value) {
|
||||||
url.value = await QRCode.toDataURL(`https://nbtca.space/graduation/download/${id.value}`)
|
return
|
||||||
|
}
|
||||||
|
svg.value = await QRCode.toString(useGraduationIdURL().constructURL(id.value))
|
||||||
})
|
})
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { onMounted, ref } from "vue"
|
import { onMounted, ref } from "vue"
|
||||||
|
import { useGraduationIdURL } from "./graduation"
|
||||||
|
|
||||||
const id = ref<string>()
|
const id = ref<string>()
|
||||||
|
|
||||||
|
|
@ -22,7 +23,7 @@ const setStatus = async () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
id.value = new URLSearchParams(window.location.search).get("id")
|
id.value = useGraduationIdURL().getId()
|
||||||
setStatus()
|
setStatus()
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
---
|
---
|
||||||
import BaseLayout from "../../layouts/BaseLayout.astro"
|
import BaseLayout from "../../layouts/BaseLayout.astro"
|
||||||
import GraduationView from "../../components/GraduationView.vue"
|
import GraduationDownloadView from "./GraduationDownloadView.vue"
|
||||||
|
|
||||||
---
|
---
|
||||||
<BaseLayout>
|
<BaseLayout>
|
||||||
<GraduationView client:load></GraduationView>
|
<GraduationDownloadView client:load></GraduationDownloadView>
|
||||||
</BaseLayout>
|
</BaseLayout>
|
||||||
|
|
|
||||||
20
src/pages/graduation/graduation.ts
Normal file
20
src/pages/graduation/graduation.ts
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
import { SITE_URL } from "../../consts"
|
||||||
|
|
||||||
|
export const useGraduationIdURL = () => {
|
||||||
|
const idKey = "id"
|
||||||
|
|
||||||
|
const getId = () => {
|
||||||
|
return new URLSearchParams(window.location.search).get(idKey) as string | undefined
|
||||||
|
}
|
||||||
|
|
||||||
|
const constructURL = (id: string) => {
|
||||||
|
const url = new URL(`/graduation/download`, SITE_URL)
|
||||||
|
url.searchParams.append(idKey, id)
|
||||||
|
return url.toString()
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
getId,
|
||||||
|
constructURL,
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in a new issue