|
@@ -6,18 +6,30 @@
|
|
<ui-icon type="close" class="icon" />
|
|
<ui-icon type="close" class="icon" />
|
|
</ButtonPane>
|
|
</ButtonPane>
|
|
|
|
|
|
- <img src="/static/t.png" class="cover">
|
|
|
|
|
|
+ <img
|
|
|
|
+ :src="showCoverUrl"
|
|
|
|
+ class="cover"
|
|
|
|
+ :style="{opacity: showCoverUrl ? '1' : 0}"
|
|
|
|
+ @click="router.replace(writeRouteName.photos)"
|
|
|
|
+ >
|
|
</div>
|
|
</div>
|
|
</template>
|
|
</template>
|
|
|
|
|
|
<script setup lang="ts">
|
|
<script setup lang="ts">
|
|
import UiIcon from "@/components/base/components/icon/index.vue";
|
|
import UiIcon from "@/components/base/components/icon/index.vue";
|
|
import ButtonPane from "@/components/button-pane/index.vue";
|
|
import ButtonPane from "@/components/button-pane/index.vue";
|
|
|
|
+import {photos} from '@/store/photos'
|
|
import { useSDK } from '@/hook/useLaser'
|
|
import { useSDK } from '@/hook/useLaser'
|
|
import {genUseLoading} from "@/hook";
|
|
import {genUseLoading} from "@/hook";
|
|
-import {base64ToBlob} from "@/utils";
|
|
|
|
|
|
+import {base64ToBlob, getId} from "@/utils";
|
|
import {nextTick, ref} from "vue";
|
|
import {nextTick, ref} from "vue";
|
|
|
|
+import {getStaticFile} from '@/dbo/main'
|
|
|
|
+import {uploadImage} from "@/store/sync";
|
|
|
|
+import {router, writeRouteName} from "@/router";
|
|
|
|
|
|
|
|
+const showCoverUrl = ref<string>(
|
|
|
|
+ photos.value[photos.value.length - 1]?.url && getStaticFile(photos.value[photos.value.length - 1]?.url)
|
|
|
|
+)
|
|
const tempPhoto = ref<string>();
|
|
const tempPhoto = ref<string>();
|
|
const coverRef = ref<HTMLImageElement>()
|
|
const coverRef = ref<HTMLImageElement>()
|
|
const photo = genUseLoading(async () => {
|
|
const photo = genUseLoading(async () => {
|
|
@@ -26,11 +38,21 @@ const photo = genUseLoading(async () => {
|
|
const {dataUrl: base64} = await sdk.scene.screenshot(dom.offsetWidth, dom.offsetHeight)
|
|
const {dataUrl: base64} = await sdk.scene.screenshot(dom.offsetWidth, dom.offsetHeight)
|
|
const blob = base64ToBlob(base64)
|
|
const blob = base64ToBlob(base64)
|
|
tempPhoto.value = URL.createObjectURL(blob)
|
|
tempPhoto.value = URL.createObjectURL(blob)
|
|
|
|
+
|
|
|
|
+ const upload = uploadImage(blob)
|
|
await nextTick();
|
|
await nextTick();
|
|
const handler = () => {
|
|
const handler = () => {
|
|
coverRef.value.removeEventListener("animationend", handler)
|
|
coverRef.value.removeEventListener("animationend", handler)
|
|
-
|
|
|
|
|
|
+ showCoverUrl.value = tempPhoto.value
|
|
tempPhoto.value = null
|
|
tempPhoto.value = null
|
|
|
|
+ upload.then(url => {
|
|
|
|
+ photos.value.push({
|
|
|
|
+ id: getId(),
|
|
|
|
+ url: url,
|
|
|
|
+ time: new Date().getTime()
|
|
|
|
+ })
|
|
|
|
+ showCoverUrl.value = getStaticFile(url)
|
|
|
|
+ })
|
|
}
|
|
}
|
|
coverRef.value.addEventListener("animationend", handler)
|
|
coverRef.value.addEventListener("animationend", handler)
|
|
})
|
|
})
|