mirror of
https://github.com/blossom-editor/blossom
synced 2024-11-17 14:39:21 +08:00
1.完成上传图片/替换图片自动刷新
2.完成todoList改变统计信息改变
This commit is contained in:
parent
91a9b20356
commit
2f775287e8
@ -164,3 +164,45 @@ export const useConfigStore = defineStore('configStore', {
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
// 上传文件后通知刷新List
|
||||
export const onUploadAfter = defineStore('onUploadAfter', {
|
||||
state: () => ({
|
||||
response: {
|
||||
isSuccess: false,
|
||||
msg: ''
|
||||
}
|
||||
}),
|
||||
actions: {
|
||||
setResponse(response: { isSuccess: boolean; msg: string }): void {
|
||||
this.response = response;
|
||||
}
|
||||
},
|
||||
getters: {
|
||||
getResponse(state) {
|
||||
return state.response;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// 修改todo状态后 通知刷新统计
|
||||
export const onTodoChange = defineStore('onTodoChange', {
|
||||
state: () => ({
|
||||
response: {
|
||||
isSuccess: false,
|
||||
msg: ''
|
||||
}
|
||||
}),
|
||||
actions: {
|
||||
setResponse(response: { isSuccess: boolean; msg: string }): void {
|
||||
this.response = response;
|
||||
}
|
||||
},
|
||||
getters: {
|
||||
getResponse(state) {
|
||||
return state.response;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -199,7 +199,7 @@ import PictureBatchDel from './PictureBatchDel.vue'
|
||||
import PictureTransfer from './PictureTransfer.vue'
|
||||
import errorImg from '@renderer/assets/imgs/img_error.png'
|
||||
import Notify from '@renderer/scripts/notify'
|
||||
|
||||
import {onUploadAfter} from '@renderer/stores/config'
|
||||
const userStore = useUserStore()
|
||||
|
||||
useLifecycle(
|
||||
@ -278,6 +278,16 @@ const clickCurFolder = (tree: DocTree) => {
|
||||
getPictureStat(curFolder.value.id)
|
||||
}
|
||||
|
||||
/**
|
||||
* 订阅文件上传通知
|
||||
*/
|
||||
const uploadResult = onUploadAfter()
|
||||
uploadResult.$subscribe((mutation, state)=>{
|
||||
if(state.response.isSuccess){
|
||||
refresh()
|
||||
}
|
||||
})
|
||||
|
||||
/**
|
||||
* 刷新
|
||||
*/
|
||||
@ -423,11 +433,14 @@ const deletePicture = (pic: Picture) => {
|
||||
pic.delTime = 2
|
||||
getPictureStat(curFolder.value?.id)
|
||||
getPictureStat()
|
||||
// 删除后刷新list
|
||||
refresh()
|
||||
})
|
||||
.catch((_) => {
|
||||
pic.delTime = 0
|
||||
pic.url = urlBak
|
||||
})
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
@ -524,6 +537,8 @@ const delBatchIgnoreCheck = () => {
|
||||
}
|
||||
delIgnoreCheck.value = true
|
||||
isShowBatchDelDialog.value = true
|
||||
// 删除后刷新
|
||||
refresh()
|
||||
}
|
||||
|
||||
const deleted = (ids: Array<string>) => {
|
||||
|
@ -8,17 +8,18 @@
|
||||
multiple
|
||||
:disabled="!curFolder || !curFolder?.id"
|
||||
:action="serverStore.serverUrl + uploadFileApiUrl"
|
||||
:data="(f: UploadRawFile) => uploadDate(f, curFolder!.id, porps.repeatUpload)"
|
||||
:data="(f: UploadRawFile) => uploadDate(f, curFolder!.id, prop.repeatUpload)"
|
||||
:headers="{ Authorization: 'Bearer ' + userStore.auth.token }"
|
||||
:show-file-list="true"
|
||||
:before-upload="beforeUpload"
|
||||
:on-success="onUploadSeccess"
|
||||
:on-success="onUploadSuccess"
|
||||
:on-error="onError">
|
||||
<bl-row v-if="!curFolder || !curFolder?.id" just="center" align="center" height="100%" style="font-size: 12px"
|
||||
>请先选择文件夹,再上传文件</bl-row
|
||||
>请先选择文件夹,再上传文件
|
||||
</bl-row
|
||||
>
|
||||
<bl-row v-else just="center" align="center" height="100%" style="font-size: 12px">
|
||||
点击或拖拽上传至<br />
|
||||
点击或拖拽上传至<br/>
|
||||
《{{ curFolder?.name }}》
|
||||
</bl-row>
|
||||
</el-upload>
|
||||
@ -26,15 +27,16 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { inject } from 'vue'
|
||||
import { UploadRawFile } from 'element-plus'
|
||||
import { uploadFileApiUrl } from '@renderer/api/blossom'
|
||||
import { useUserStore } from '@renderer/stores/user'
|
||||
import { useServerStore } from '@renderer/stores/server'
|
||||
import { provideKeyDocInfo } from '@renderer/views/doc/doc'
|
||||
import { beforeUpload, onUploadSeccess, onError, uploadDate } from '@renderer/views/picture/scripts/picture'
|
||||
import {inject} from 'vue'
|
||||
import {UploadRawFile} from 'element-plus'
|
||||
import {uploadFileApiUrl} from '@renderer/api/blossom'
|
||||
import {useUserStore} from '@renderer/stores/user'
|
||||
import {useServerStore} from '@renderer/stores/server'
|
||||
import {provideKeyDocInfo} from '@renderer/views/doc/doc'
|
||||
import {beforeUpload, onUploadSeccess, onError, uploadDate} from '@renderer/views/picture/scripts/picture'
|
||||
import {onUploadAfter} from '@renderer/stores/config'
|
||||
|
||||
const porps = defineProps({
|
||||
const prop = defineProps({
|
||||
repeatUpload: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
@ -48,6 +50,21 @@ const curFolder = inject(provideKeyDocInfo)
|
||||
const userStore = useUserStore()
|
||||
const serverStore = useServerStore()
|
||||
//#endregion
|
||||
|
||||
|
||||
/**
|
||||
* 上传成功后通知组件刷新
|
||||
* @param data
|
||||
*/
|
||||
const uploadResult = onUploadAfter()
|
||||
const onUploadSuccess = (resp: any, file: any, fileList: any) => {
|
||||
uploadResult.setResponse({
|
||||
isSuccess: true,
|
||||
msg: "upload success"
|
||||
})
|
||||
onUploadSeccess(resp, file, fileList)
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
|
@ -81,6 +81,7 @@ import { isNotNull } from '@renderer/assets/utils/obj'
|
||||
import { isEmpty } from 'lodash'
|
||||
import { download, writeText } from '@renderer/assets/utils/electron'
|
||||
import Notify from '@renderer/scripts/notify'
|
||||
import {onUploadAfter} from '@renderer/stores/config'
|
||||
|
||||
const userStore = useUserStore()
|
||||
const serverStore = useServerStore()
|
||||
@ -127,7 +128,8 @@ const deletePicture = () => {
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// 上传成功消息
|
||||
const uploadResult = onUploadAfter()
|
||||
/**
|
||||
* 替换上传成功
|
||||
*/
|
||||
@ -137,6 +139,12 @@ const onUploadSeccess: UploadProps['onSuccess'] = (resp, _file?) => {
|
||||
emits('saved')
|
||||
closePicInfo()
|
||||
picCacheRefresh()
|
||||
// 发布消息 刷新图片列表
|
||||
uploadResult.setResponse({
|
||||
isSuccess: true,
|
||||
msg: "upload success"
|
||||
})
|
||||
|
||||
return true
|
||||
} else {
|
||||
Notify.error(resp.msg, '图片替换失败')
|
||||
|
@ -301,6 +301,7 @@ import { isEmpty } from 'lodash'
|
||||
import Notify from '@renderer/scripts/notify'
|
||||
import TaskInfoComponent from './TaskInfo.vue'
|
||||
import { dayjs, ElMessageBox } from 'element-plus'
|
||||
import {onTodoChange} from '@renderer/stores/config'
|
||||
|
||||
onMounted(() => {
|
||||
document.addEventListener('dragover', preventDefaultDragover, false)
|
||||
@ -324,7 +325,19 @@ const countProc = computed<number>(() => taskProcComputed.value.filter((t) => t.
|
||||
const countComp = computed<number>(() => taskCompComputed.value.filter((t) => t.todoType != 99).length)
|
||||
const countTotal = computed(() => countWait.value + countProc.value + countComp.value)
|
||||
|
||||
// 修改todo status 成功消息
|
||||
const onTodoResult = onTodoChange()
|
||||
|
||||
// 发布消息
|
||||
const publicTodoChangeMsg = () => {
|
||||
onTodoResult.setResponse({
|
||||
isSuccess: true,
|
||||
msg: curTodo.value.todoName
|
||||
})
|
||||
}
|
||||
|
||||
const taskWaitComputed = computed<TaskInfo[]>(() => {
|
||||
publicTodoChangeMsg()
|
||||
if (queryTags.value.length == 0) {
|
||||
return taskWait.value
|
||||
}
|
||||
@ -332,6 +345,7 @@ const taskWaitComputed = computed<TaskInfo[]>(() => {
|
||||
})
|
||||
|
||||
const taskProcComputed = computed<TaskInfo[]>(() => {
|
||||
publicTodoChangeMsg()
|
||||
if (queryTags.value.length == 0) {
|
||||
return taskProc.value
|
||||
}
|
||||
@ -339,6 +353,7 @@ const taskProcComputed = computed<TaskInfo[]>(() => {
|
||||
})
|
||||
|
||||
const taskCompComputed = computed<TaskInfo[]>(() => {
|
||||
publicTodoChangeMsg()
|
||||
if (queryTags.value.length == 0) {
|
||||
return taskComp.value
|
||||
}
|
||||
@ -686,7 +701,7 @@ const dragStart = (doms: any, e: DragEvent) => {
|
||||
|
||||
ele.addEventListener('drag', onDrag)
|
||||
ele.addEventListener('dragend', onDragend)
|
||||
|
||||
|
||||
ele.classList.add('moving') // 原始元素隐藏
|
||||
|
||||
for (let i = 0; i < doms.length; i++) {
|
||||
|
@ -16,6 +16,8 @@ import { UniversalTransition } from 'echarts/features'
|
||||
import { LabelLayout } from 'echarts/features'
|
||||
import { CanvasRenderer } from 'echarts/renderers'
|
||||
import { getPrimaryColor } from '@renderer/scripts/global-theme'
|
||||
import {onTodoChange} from '@renderer/stores/config'
|
||||
|
||||
echarts.use([
|
||||
TitleComponent,
|
||||
TooltipComponent,
|
||||
@ -171,6 +173,22 @@ const reload = (dates: any, rates: any) => {
|
||||
const windowResize = () => {
|
||||
chartLineLog.resize()
|
||||
}
|
||||
|
||||
/**
|
||||
* todoList改变后刷新统计信息
|
||||
* @param data
|
||||
*/
|
||||
const todoChangeResult = onTodoChange()
|
||||
|
||||
/**
|
||||
* 订阅todoList改变
|
||||
*/
|
||||
todoChangeResult.$subscribe((mutation, state)=>{
|
||||
if(state.response.isSuccess){
|
||||
chartLineLog = echarts.init(ChartLineLogRef.value)
|
||||
}
|
||||
})
|
||||
|
||||
defineExpose({ reload, windowResize })
|
||||
</script>
|
||||
|
||||
|
@ -53,16 +53,38 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref } from 'vue'
|
||||
import { todoStatApi, taskStatApi, completedTodoApi, openTodoApi } from '@renderer/api/todo'
|
||||
import {ref} from 'vue'
|
||||
import {todoStatApi, taskStatApi, completedTodoApi, openTodoApi} from '@renderer/api/todo'
|
||||
import TodoChartCompleted from './TodoChartCompleted.vue'
|
||||
import { useLifecycle } from '@renderer/scripts/lifecycle'
|
||||
import {useLifecycle} from '@renderer/scripts/lifecycle'
|
||||
import {onTodoChange} from '@renderer/stores/config'
|
||||
import {getDateFormat} from '@renderer/assets/utils/util'
|
||||
|
||||
useLifecycle(
|
||||
() => getTaskStat(),
|
||||
() => getTaskStat()
|
||||
)
|
||||
|
||||
/**
|
||||
* todoList改变后刷新统计信息
|
||||
* @param data
|
||||
*/
|
||||
const todoChangeResult = onTodoChange()
|
||||
|
||||
/**
|
||||
* 订阅todoList改变
|
||||
*/
|
||||
todoChangeResult.$subscribe((mutation, state) => {
|
||||
if (state.response.isSuccess) {
|
||||
getTaskStat()
|
||||
// todo 有待优化: 拿到当前日期能否更合理
|
||||
todoStatApi({todoId:state.response.msg}).then((resp) => {
|
||||
todoStat.value = resp.data
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
// 获取任务状态统计
|
||||
const getTaskStat = () => {
|
||||
taskStatApi().then((resp) => {
|
||||
taskStat.value = {
|
||||
@ -72,6 +94,7 @@ const getTaskStat = () => {
|
||||
total: resp.data.total
|
||||
}
|
||||
TodoChartCompletedRef.value.reload(resp.data.dates, resp.data.rates)
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
@ -84,13 +107,13 @@ const taskStat = ref({
|
||||
})
|
||||
|
||||
const openTodo = () => {
|
||||
openTodoApi({ todoId: todoStat.value.todoId }).then((_resp) => {
|
||||
openTodoApi({todoId: todoStat.value.todoId}).then((_resp) => {
|
||||
emits('refreshTodo')
|
||||
})
|
||||
}
|
||||
|
||||
const completedTodo = () => {
|
||||
completedTodoApi({ todoId: todoStat.value.todoId }).then((_resp) => {
|
||||
completedTodoApi({todoId: todoStat.value.todoId}).then((_resp) => {
|
||||
emits('refreshTodo')
|
||||
})
|
||||
}
|
||||
@ -106,12 +129,12 @@ const todoStat = ref({
|
||||
})
|
||||
|
||||
const reload = (todoId: string) => {
|
||||
todoStatApi({ todoId: todoId }).then((resp) => {
|
||||
todoStatApi({todoId: todoId}).then((resp) => {
|
||||
todoStat.value = resp.data
|
||||
})
|
||||
}
|
||||
|
||||
defineExpose({ reload })
|
||||
defineExpose({reload})
|
||||
const emits = defineEmits(['refreshTodo'])
|
||||
</script>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user