18 lines
1.2 KiB
Vue
18 lines
1.2 KiB
Vue
|
|
<script setup lang="ts">
|
||
|
|
import {ref} from 'vue'
|
||
|
|
import {ElMessage,ElMessageBox} from 'element-plus'
|
||
|
|
import {Share} from '@element-plus/icons-vue'
|
||
|
|
import {useAssetsStore} from '../stores/assets'
|
||
|
|
import {useSharedAssetsStore} from '../stores/sharedAssets'
|
||
|
|
import {errorMessage} from '../api'
|
||
|
|
const props=defineProps<{assetId:string}>(),busy=ref(false),assets=useAssetsStore(),shared=useSharedAssetsStore()
|
||
|
|
async function publish(){
|
||
|
|
const id=props.assetId,session=assets.sessionId()
|
||
|
|
try{await ElMessageBox.confirm('将此素材的独立副本发布到共享库,所有已登录用户均可查看、下载和导入使用。撤回发布后,其他用户已经导入的副本仍会保留。是否发布?','发布到共享库',{confirmButtonText:'发布副本',cancelButtonText:'暂不发布',type:'warning'})}catch{return}
|
||
|
|
if(session!==assets.sessionId()||assets.deleted[id])return
|
||
|
|
busy.value=true
|
||
|
|
try{if(await shared.publish(id))ElMessage.success('独立副本已发布到共享库')}catch(error){ElMessage.error(errorMessage(error))}finally{busy.value=false}
|
||
|
|
}
|
||
|
|
</script>
|
||
|
|
<template><el-button text :icon="Share" :loading="busy" @click="publish">发布到共享库</el-button></template>
|