|
| 1 | +<template> |
| 2 | + <div class="base64-tool-container"> |
| 3 | + <div v-if="imgList.length" class="base64-tool-left"> |
| 4 | + <img-process-state-card |
| 5 | + card-type="base64" |
| 6 | + v-for="img in imgList" |
| 7 | + :img-obj="img" |
| 8 | + :key="img.uuid" |
| 9 | + @remove="remove" |
| 10 | + /> |
| 11 | + </div> |
| 12 | + <div class="base64-tool-right" :class="{ 'no-img': !imgList.length }"> |
| 13 | + <getting-images ref="gettingImagesRef" @getImgList="getImgList"></getting-images> |
| 14 | + |
| 15 | + <div class="user-operate"> |
| 16 | + <el-button v-if="imgList.length" plain type="warning" @click="reset"> 重置 </el-button> |
| 17 | + </div> |
| 18 | + </div> |
| 19 | + </div> |
| 20 | +</template> |
| 21 | + |
| 22 | +<script setup lang="ts"> |
| 23 | +import { ref, watch } from 'vue' |
| 24 | +import { ImageHandleResult, ImgProcessStateModel } from '@/common/model' |
| 25 | +import { useStore } from '@/store' |
| 26 | +
|
| 27 | +const store = useStore() |
| 28 | +
|
| 29 | +const gettingImagesRef = ref<any>(null) |
| 30 | +
|
| 31 | +const imgList = ref<ImgProcessStateModel[]>([]) |
| 32 | +
|
| 33 | +const getImgList = (imgs: ImageHandleResult[]) => { |
| 34 | + imgs.forEach((x) => { |
| 35 | + store.dispatch('TOOLBOX_IMG_LIST_ADD', { |
| 36 | + uuid: x.uuid, |
| 37 | + originalName: x.file.name, |
| 38 | + originalSize: x.file.size, |
| 39 | + originalBase64: x.base64 |
| 40 | + }) |
| 41 | + }) |
| 42 | +} |
| 43 | +
|
| 44 | +// 重置 |
| 45 | +const reset = () => { |
| 46 | + store.dispatch('TOOLBOX_IMG_LIST_RESET') |
| 47 | + gettingImagesRef.value?.reset() |
| 48 | +} |
| 49 | +
|
| 50 | +// 删除 |
| 51 | +const remove = (uuid: string) => { |
| 52 | + store.dispatch('TOOLBOX_IMG_LIST_REMOVE', uuid) |
| 53 | + gettingImagesRef.value?.remove(uuid) |
| 54 | +} |
| 55 | +
|
| 56 | +watch( |
| 57 | + () => store.state.toolboxImageListModule.toolboxImageList, |
| 58 | + (newValue) => { |
| 59 | + imgList.value = newValue |
| 60 | + }, |
| 61 | + { |
| 62 | + immediate: true, |
| 63 | + deep: true |
| 64 | + } |
| 65 | +) |
| 66 | +</script> |
| 67 | + |
| 68 | +<style scoped lang="stylus"> |
| 69 | +@import "base64-tool.styl" |
| 70 | +</style> |
0 commit comments