Commit 5f4534fc330add7aaa9c8d33927ae967273fdea3
Merge branch 'fix/DEFECT-2122' into 'main_dev'
fix: 修改保存缩略图时先调用删除图片接口 See merge request yunteng/thingskit-view!274
Showing
3 changed files
with
25 additions
and
7 deletions
1 | 1 | import { defHttp } from '@/utils/external/http/axios' |
2 | -import {CameraRecord, ConfigurationItemType, DictItem, OrganizationListItem, UploadResponse} from './model' | |
2 | +import { CameraRecord, ConfigurationItemType, DictItem, OrganizationListItem, UploadResponse } from './model' | |
3 | 3 | import { PaginationResult } from '/#/external/axios' |
4 | 4 | import { isShareMode } from '@/views/share/hook' |
5 | 5 | |
... | ... | @@ -22,6 +22,7 @@ enum Api { |
22 | 22 | GET_DEVICE_LATEST = '/plugins/telemetry/DEVICE/', |
23 | 23 | DEVICE_ATTR = '/device/attributes', |
24 | 24 | ALARM_LIST = '/alarm', |
25 | + BASE_DELETE_URL = '/oss', | |
25 | 26 | } |
26 | 27 | |
27 | 28 | export const getDictItemByCode = (value: string) => { |
... | ... | @@ -89,7 +90,7 @@ export const getOrganizationList = (params?: OrganizationListItem) => |
89 | 90 | |
90 | 91 | //获取视频列表 |
91 | 92 | export const getVideoList = (params?: object) => |
92 | - defHttp.get<{data: CameraRecord[]}>({ | |
93 | + defHttp.get<{ data: CameraRecord[] }>({ | |
93 | 94 | url: Api.VIDEO, |
94 | 95 | params |
95 | 96 | }) |
... | ... | @@ -160,6 +161,17 @@ export const getAlarmList = (params?: object) => |
160 | 161 | url: Api.ALARM_LIST, |
161 | 162 | params |
162 | 163 | }, |
163 | - { | |
164 | - withShareToken: true | |
165 | - }) | |
164 | + { | |
165 | + withShareToken: true | |
166 | + }) | |
167 | + | |
168 | + | |
169 | +/** | |
170 | + * 删除上传的图片 | |
171 | + * @description deleteFilePath图片url | |
172 | + */ | |
173 | +export const deleteFilePath = (deleteFilePath?: string) => { | |
174 | + return defHttp.delete({ | |
175 | + url: `${Api.BASE_DELETE_URL}?deleteFilePath=${deleteFilePath}`, | |
176 | + }); | |
177 | +}; | ... | ... |
... | ... | @@ -11,6 +11,7 @@ import { useSync } from '../useSync.hook' |
11 | 11 | import { BaseUpdateContentParams, DateViewConfigurationInfoType } from '@/api/external/contentSave/model/contentModel' |
12 | 12 | import { useRole } from './business/useRole' |
13 | 13 | import { ChartEditStoreType, PageChartEditStoreType } from '@/store/modules/chartEditStore/chartEditStore.d' |
14 | +import { deleteFilePath } from '@/api/external/common' | |
14 | 15 | |
15 | 16 | /** |
16 | 17 | * * base64转file |
... | ... | @@ -180,7 +181,8 @@ export const useSyncRemote = () => { |
180 | 181 | |
181 | 182 | //thumbnailSyncUpdate 缩略图保存 |
182 | 183 | const thumbnailSyncUpdate = throttle(async (updateImg = true) => { |
183 | - const { state, organizationId, dataViewName } = projectInfoStore.getProjectInfo | |
184 | + console.log(projectInfoStore.getProjectInfo, 'projectInfoStore.getProjectInfo') | |
185 | + const { state, organizationId, dataViewName, thumbnail } = projectInfoStore.getProjectInfo | |
184 | 186 | if (updateImg) { |
185 | 187 | // 获取缩略图片 |
186 | 188 | const range = document.querySelector('.go-edit-range') as HTMLElement |
... | ... | @@ -198,6 +200,9 @@ export const useSyncRemote = () => { |
198 | 200 | base64toFile(canvasImage.toDataURL(), `${fetchRouteParamsLocation()}_index_preview.png`) |
199 | 201 | ) |
200 | 202 | const uploadRes = await uploadFile(uploadParams) |
203 | + if (thumbnail) { | |
204 | + await deleteFilePath(thumbnail) | |
205 | + } | |
201 | 206 | // 保存预览图 |
202 | 207 | if (uploadRes) { |
203 | 208 | await saveDataViewList({ | ... | ... |