fix: 解决动态变更颜色,部分组件不会更新的问题

This commit is contained in:
奔跑的面条 2022-08-19 10:02:09 +08:00
parent 8ddc85738a
commit a6d1baec3e
10 changed files with 59 additions and 20 deletions

View File

@ -28,7 +28,7 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { ref, computed } from 'vue' import { computed } from 'vue'
import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore' import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore'
import { EditCanvasConfigEnum } from '@/store/modules/chartEditStore/chartEditStore.d' import { EditCanvasConfigEnum } from '@/store/modules/chartEditStore/chartEditStore.d'
import { import {
@ -46,8 +46,13 @@ const chartEditStore = useChartEditStore()
// //
const designStore = useDesignStore() const designStore = useDesignStore()
const themeColor = ref(designStore.getAppTheme)
//
const themeColor = computed(() => {
return designStore.getAppTheme
})
//
const selectName = computed(() => { const selectName = computed(() => {
return chartEditStore.getEditCanvasConfig.chartThemeColor return chartEditStore.getEditCanvasConfig.chartThemeColor
}) })

View File

@ -34,7 +34,7 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { ref } from 'vue' import { ref, computed } from 'vue'
import { animations } from '@/settings/animations/index' import { animations } from '@/settings/animations/index'
import { CollapseItem } from '@/components/Pages/ChartItemSetting' import { CollapseItem } from '@/components/Pages/ChartItemSetting'
import { useDesignStore } from '@/store/modules/designStore/designStore' import { useDesignStore } from '@/store/modules/designStore/designStore'
@ -42,12 +42,16 @@ import { useTargetData } from '../hooks/useTargetData.hook'
// //
const designStore = useDesignStore() const designStore = useDesignStore()
const themeColor = ref(designStore.getAppTheme)
const hoverPreviewAnimate = ref('') const hoverPreviewAnimate = ref('')
const { targetData } = useTargetData() const { targetData } = useTargetData()
//
const themeColor = computed(() => {
return designStore.getAppTheme
})
// * // *
const activeIndex = (value: string) => { const activeIndex = (value: string) => {
const selectValue = targetData.value.styles.animations const selectValue = targetData.value.styles.animations

View File

@ -84,7 +84,7 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { ref, toRefs, onBeforeUnmount, watchEffect, toRaw } from 'vue' import { ref, toRefs, computed, onBeforeUnmount, watchEffect, toRaw } from 'vue'
import { icon } from '@/plugins' import { icon } from '@/plugins'
import { useDesignStore } from '@/store/modules/designStore/designStore' import { useDesignStore } from '@/store/modules/designStore/designStore'
import { SettingItemBox, SettingItem } from '@/components/Pages/ChartItemSetting' import { SettingItemBox, SettingItem } from '@/components/Pages/ChartItemSetting'
@ -108,7 +108,6 @@ const {
requestIntervalUnit: GlobalRequestIntervalUnit requestIntervalUnit: GlobalRequestIntervalUnit
} = toRefs(chartEditStore.getRequestGlobalConfig) } = toRefs(chartEditStore.getRequestGlobalConfig)
const designStore = useDesignStore() const designStore = useDesignStore()
const themeColor = ref(designStore.getAppTheme)
// //
const loading = ref(false) const loading = ref(false)
@ -142,6 +141,11 @@ const sendHandle = async () => {
} }
} }
//
const themeColor = computed(() => {
return designStore.getAppTheme
})
watchEffect(() => { watchEffect(() => {
const filter = targetData.value?.filter const filter = targetData.value?.filter
if (lastFilter !== filter && firstFocus) { if (lastFilter !== filter && firstFocus) {

View File

@ -65,7 +65,7 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { ref, toRefs } from 'vue' import { ref, toRefs, computed } from 'vue'
import { useDesignStore } from '@/store/modules/designStore/designStore' import { useDesignStore } from '@/store/modules/designStore/designStore'
import { SettingItemBox, SettingItem } from '@/components/Pages/ChartItemSetting' import { SettingItemBox, SettingItem } from '@/components/Pages/ChartItemSetting'
import { useTargetData } from '@/views/chart/ContentConfigurations/components/hooks/useTargetData.hook' import { useTargetData } from '@/views/chart/ContentConfigurations/components/hooks/useTargetData.hook'
@ -79,9 +79,12 @@ const { requestOriginUrl, requestInterval, requestIntervalUnit } = toRefs(chartE
const editDisabled = ref(true) const editDisabled = ref(true)
const designStore = useDesignStore() const designStore = useDesignStore()
const themeColor = ref(designStore.getAppTheme)
const showTable = ref(false) const showTable = ref(false)
//
const themeColor = computed(() => {
return designStore.getAppTheme
})
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>

View File

@ -11,7 +11,7 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { ref, reactive, computed, watch } from 'vue' import { reactive, computed, watch } from 'vue'
import { useDesignStore } from '@/store/modules/designStore/designStore' import { useDesignStore } from '@/store/modules/designStore/designStore'
import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore' import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore'
import { EditCanvasTypeEnum } from '@/store/modules/chartEditStore/chartEditStore.d' import { EditCanvasTypeEnum } from '@/store/modules/chartEditStore/chartEditStore.d'
@ -21,7 +21,6 @@ import throttle from 'lodash/throttle'
import cloneDeep from 'lodash/cloneDeep' import cloneDeep from 'lodash/cloneDeep'
// //
const designStore = useDesignStore() const designStore = useDesignStore()
const themeColor = ref(designStore.getAppTheme)
const chartEditStore = useChartEditStore() const chartEditStore = useChartEditStore()
const settingStore = useSettingStore() const settingStore = useSettingStore()
@ -49,6 +48,11 @@ const useComponentStyle = (attr?: Partial<{ x: number; y: number }>) => {
return componentStyle return componentStyle
} }
//
const themeColor = computed(() => {
return designStore.getAppTheme
})
// * // *
const minDistance = computed(() => { const minDistance = computed(() => {
return settingStore.getChartAlignRange return settingStore.getChartAlignRange

View File

@ -11,13 +11,12 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { ref, toRefs } from 'vue' import { toRefs, computed } from 'vue'
import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore' import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore'
import { useDesignStore } from '@/store/modules/designStore/designStore' import { useDesignStore } from '@/store/modules/designStore/designStore'
const chartEditStore = useChartEditStore() const chartEditStore = useChartEditStore()
const designStore = useDesignStore() const designStore = useDesignStore()
const themeColor = ref(designStore.getAppTheme)
const { width, height } = toRefs(chartEditStore.getEditCanvasConfig) const { width, height } = toRefs(chartEditStore.getEditCanvasConfig)
@ -34,6 +33,12 @@ const lines = {
h: [], h: [],
v: [] v: []
} }
//
const themeColor = computed(() => {
return designStore.getAppTheme
})
</script> </script>
<style> <style>

View File

@ -6,7 +6,7 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { ref, toRefs, watch } from 'vue' import { ref, toRefs, watch, computed } from 'vue'
import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore' import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore'
import { useDesignStore } from '@/store/modules/designStore/designStore' import { useDesignStore } from '@/store/modules/designStore/designStore'
import { useSizeStyle, useComponentStyle } from '../../hooks/useStyle.hook' import { useSizeStyle, useComponentStyle } from '../../hooks/useStyle.hook'
@ -14,10 +14,13 @@ import { selectBoxIndex } from '@/settings/designSetting'
// //
const designStore = useDesignStore() const designStore = useDesignStore()
const themeColor = ref(designStore.getAppTheme)
const chartEditStore = useChartEditStore() const chartEditStore = useChartEditStore()
const { isSelect, scale } = toRefs(chartEditStore.getEditCanvas) const { isSelect, scale } = toRefs(chartEditStore.getEditCanvas)
const themeColor = computed(() => {
return designStore.getAppTheme
})
// //
const positionStyle = ref() const positionStyle = ref()

View File

@ -21,7 +21,7 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { ref, computed, PropType } from 'vue' import { computed, PropType } from 'vue'
import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore' import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore'
import { useDesignStore } from '@/store/modules/designStore/designStore' import { useDesignStore } from '@/store/modules/designStore/designStore'
import { CreateComponentType, CreateComponentGroupType } from '@/packages/index.d' import { CreateComponentType, CreateComponentGroupType } from '@/packages/index.d'
@ -39,9 +39,7 @@ const props = defineProps({
} }
}) })
//
const designStore = useDesignStore() const designStore = useDesignStore()
const themeColor = ref(designStore.getAppTheme)
const chartEditStore = useChartEditStore() const chartEditStore = useChartEditStore()
// //
@ -50,6 +48,11 @@ const pointList = ['t', 'r', 'b', 'l', 'lt', 'rt', 'lb', 'rb']
// //
const cursorResize = ['n', 'e', 's', 'w', 'nw', 'ne', 'sw', 'se'] const cursorResize = ['n', 'e', 's', 'w', 'nw', 'ne', 'sw', 'se']
//
const themeColor = computed(() => {
return designStore.getAppTheme
})
// //
const hover = computed(() => { const hover = computed(() => {
return props.item.id === chartEditStore.getTargetChart.hoverId return props.item.id === chartEditStore.getTargetChart.hoverId

View File

@ -70,9 +70,13 @@ const { FolderIcon, FolderOpenIcon } = icon.ionicons5
const chartEditStore = useChartEditStore() const chartEditStore = useChartEditStore()
const { handleContextMenu, onClickOutSide } = useContextMenu() const { handleContextMenu, onClickOutSide } = useContextMenu()
const themeColor = ref(designStore.getAppTheme)
const expend = ref(false) const expend = ref(false)
//
const themeColor = computed(() => {
return designStore.getAppTheme
})
// //
const optionsHandle = ( const optionsHandle = (
targetList: MenuOptionsItemType[], targetList: MenuOptionsItemType[],

View File

@ -22,16 +22,20 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { ref, toRefs, computed } from 'vue' import { toRefs, computed } from 'vue'
import { requireErrorImg } from '@/utils' import { requireErrorImg } from '@/utils'
import { useDesignStore } from '@/store/modules/designStore/designStore' import { useDesignStore } from '@/store/modules/designStore/designStore'
import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore' import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore'
// //
const designStore = useDesignStore() const designStore = useDesignStore()
const themeColor = ref(designStore.getAppTheme)
const chartEditStore = useChartEditStore() const chartEditStore = useChartEditStore()
//
const themeColor = computed(() => {
return designStore.getAppTheme
})
const props = defineProps({ const props = defineProps({
componentData: { componentData: {
type: Object, type: Object,