Commit 2f165371fbb8479c02faff8f82488b89014f0978
1 parent
df9f5749
perf(src/views/chart): 优化背景图片选择,应用类型自动选择应用背景
Showing
2 changed files
with
21 additions
and
3 deletions
... | ... | @@ -2,9 +2,10 @@ |
2 | 2 | import { EditCanvasConfigEnum } from '@/store/modules/chartEditStore/chartEditStore.d'; |
3 | 3 | import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore'; |
4 | 4 | import { NEllipsis, NImage, NSelect, NSpace, NText, SelectOption } from 'naive-ui'; |
5 | -import { computed, h, unref } from 'vue'; | |
5 | +import { h } from 'vue'; | |
6 | 6 | import { useBackgroundSelect } from '@/utils/external/useBackgroundImageSelect'; |
7 | 7 | |
8 | +const emit = defineEmits(['bgChange']) | |
8 | 9 | const chartEditStore = useChartEditStore() |
9 | 10 | const canvasConfig = chartEditStore.getEditCanvasConfig |
10 | 11 | |
... | ... | @@ -17,10 +18,15 @@ const renderOption = (option: SelectOption) => { |
17 | 18 | ]) |
18 | 19 | } |
19 | 20 | |
20 | -const handleUpdateValue = (value: string, _option: SelectOption) => { | |
21 | +const handleUpdateValue = (value: string) => { | |
21 | 22 | chartEditStore.setEditCanvasConfig(EditCanvasConfigEnum.BACKGROUND_IMAGE, value) |
23 | + emit('bgChange',value) | |
22 | 24 | } |
23 | 25 | |
26 | +const removeBg = ()=> canvasConfig.backgroundImage = null | |
27 | +defineExpose({ | |
28 | + removeBg | |
29 | +}) | |
24 | 30 | </script> |
25 | 31 | |
26 | 32 | ... | ... |
... | ... | @@ -43,7 +43,7 @@ |
43 | 43 | <n-space vertical :size="12"> |
44 | 44 | <n-space> |
45 | 45 | <!-- THINGS_KIT 新增预置背景选择 --> |
46 | - <SelectBackgroundImage /> | |
46 | + <SelectBackgroundImage ref="selectBackgroundImageRef" @bgChange="handleBgChange" /> | |
47 | 47 | <n-text>背景颜色</n-text> |
48 | 48 | <div class="picker-height"> |
49 | 49 | <n-color-picker |
... | ... | @@ -248,10 +248,15 @@ const selectColorValueHandle = (value: number) => { |
248 | 248 | canvasConfig.selectColor = value == 0 |
249 | 249 | } |
250 | 250 | |
251 | +// THINGS_KIT 优化清除背景,背景选择下拉框值还存在 | |
252 | +const selectBackgroundImageRef=ref<typeof SelectBackgroundImage|null>() | |
253 | + | |
251 | 254 | // 清除背景 |
252 | 255 | const clearImage = () => { |
253 | 256 | chartEditStore.setEditCanvasConfig(EditCanvasConfigEnum.BACKGROUND_IMAGE, undefined) |
254 | 257 | chartEditStore.setEditCanvasConfig(EditCanvasConfigEnum.SELECT_COLOR, true) |
258 | + // THINGS_KIT 优化清除背景,背景选择下拉框值还存在 | |
259 | + selectBackgroundImageRef.value?.removeBg() | |
255 | 260 | } |
256 | 261 | |
257 | 262 | // 启用/关闭 颜色(强制更新) |
... | ... | @@ -291,6 +296,13 @@ const customRequest = (options: UploadCustomRequestOptions) => { |
291 | 296 | const selectPreviewType = (key: PreviewScaleEnum) => { |
292 | 297 | chartEditStore.setEditCanvasConfig(EditCanvasConfigEnum.PREVIEW_SCALE_TYPE, key) |
293 | 298 | } |
299 | + | |
300 | +// THINGS_KIT 优化背景图片选择,应用类型自动选择应用背景 | |
301 | +const handleBgChange=(value:string)=>{ | |
302 | + if(!value) return | |
303 | + selectColorValue.value = 1,selectColorValueHandle(1),chartEditStore.setEditCanvasConfig(EditCanvasConfigEnum.BACKGROUND_IMAGE, value) | |
304 | +} | |
305 | + | |
294 | 306 | </script> |
295 | 307 | |
296 | 308 | <style lang="scss" scoped> | ... | ... |