Merge branch 'dev'

This commit is contained in:
奔跑的面条 2023-01-16 17:58:43 +08:00
commit 97ca3e8664
7 changed files with 26 additions and 10 deletions

View File

@ -0,0 +1,3 @@
import ChartGlobImage from './index.vue'
export { ChartGlobImage }

View File

@ -3,7 +3,7 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { ref, PropType } from 'vue' import { ref, PropType, watch } from 'vue'
import { fetchImages } from '@/packages' import { fetchImages } from '@/packages'
import { ConfigType } from '@/packages/index.d' import { ConfigType } from '@/packages/index.d'
@ -11,7 +11,7 @@ const props = defineProps({
chartConfig: { chartConfig: {
type: Object as PropType<ConfigType>, type: Object as PropType<ConfigType>,
required: true required: true
}, }
}) })
const imageInfo = ref('') const imageInfo = ref('')
@ -20,5 +20,12 @@ const imageInfo = ref('')
const fetchImageUrl = async () => { const fetchImageUrl = async () => {
imageInfo.value = await fetchImages(props.chartConfig) imageInfo.value = await fetchImages(props.chartConfig)
} }
fetchImageUrl()
watch(
() => props.chartConfig.key,
() => fetchImageUrl(),
{
immediate: true
}
)
</script> </script>

View File

@ -63,7 +63,8 @@ export const fetchConfigComponent = (dropData: ConfigType) => {
* * * *
* @param {ConfigType} targetData * @param {ConfigType} targetData
*/ */
export const fetchImages = async (targetData: ConfigType) => { export const fetchImages = async (targetData?: ConfigType) => {
if (!targetData) return ''
// 新数据动态处理 // 新数据动态处理
const { image, package: targetDataPackage } = targetData const { image, package: targetDataPackage } = targetData
// 兼容旧数据 // 兼容旧数据

View File

@ -321,6 +321,12 @@ export const JSONParse = (data: string) => {
return JSON.parse(data, (k, v) => { return JSON.parse(data, (k, v) => {
if (typeof v === 'string' && v.indexOf && (v.indexOf('function') > -1 || v.indexOf('=>') > -1)) { if (typeof v === 'string' && v.indexOf && (v.indexOf('function') > -1 || v.indexOf('=>') > -1)) {
return eval(`(function(){return ${v}})()`) return eval(`(function(){return ${v}})()`)
} else if (typeof v === 'string' && v.indexOf && (v.indexOf('return ') > -1)) {
const baseLeftIndex = v.indexOf('(')
if (baseLeftIndex > -1) {
const newFn = `function ${v.substring(baseLeftIndex)}`
return eval(`(function(){return ${newFn}})()`)
}
} }
return v return v
}) })

View File

@ -22,7 +22,7 @@
</n-text> </n-text>
</div> </div>
<div class="list-center go-flex-center go-transition"> <div class="list-center go-flex-center go-transition">
<charts-item-image class="list-img" :chartConfig="item"></charts-item-image> <chart-glob-image class="list-img" :chartConfig="item"></chart-glob-image>
</div> </div>
<div class="list-bottom"> <div class="list-bottom">
<n-text class="list-bottom-text" depth="3"> <n-text class="list-bottom-text" depth="3">
@ -37,7 +37,7 @@
<script setup lang="ts"> <script setup lang="ts">
import { PropType, watch, ref, Ref, computed, nextTick } from 'vue' import { PropType, watch, ref, Ref, computed, nextTick } from 'vue'
import { MacOsControlBtn } from '@/components/Tips/MacOsControlBtn/index' import { MacOsControlBtn } from '@/components/Tips/MacOsControlBtn/index'
import { ChartsItemImage } from '../ChartsItemImage' import { ChartGlobImage } from '@/components/Pages/ChartGlobImage'
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'
import { ChartModeEnum } from '@/store/modules/chartLayoutStore/chartLayoutStore.d' import { ChartModeEnum } from '@/store/modules/chartLayoutStore/chartLayoutStore.d'
@ -47,6 +47,7 @@ import { DragKeyEnum } from '@/enums/editPageEnum'
import { createComponent } from '@/packages' import { createComponent } from '@/packages'
import { ConfigType, CreateComponentType } from '@/packages/index.d' import { ConfigType, CreateComponentType } from '@/packages/index.d'
import { fetchConfigComponent, fetchChartComponent } from '@/packages/index' import { fetchConfigComponent, fetchChartComponent } from '@/packages/index'
import omit from 'lodash/omit' import omit from 'lodash/omit'
const chartEditStore = useChartEditStore() const chartEditStore = useChartEditStore()

View File

@ -1,3 +0,0 @@
import ChartsItemImage from './index.vue'
export { ChartsItemImage }

View File

@ -37,7 +37,7 @@
:title="item.title" :title="item.title"
@click="selectChartHandle(item)" @click="selectChartHandle(item)"
> >
<img class="list-item-img" v-lazy="item.image" alt="展示图" /> <chart-glob-image class="list-item-img" :chartConfig="item"></chart-glob-image>
<n-text class="list-item-fs" depth="2">{{ item.title }}</n-text> <n-text class="list-item-fs" depth="2">{{ item.title }}</n-text>
</div> </div>
</n-scrollbar> </n-scrollbar>
@ -77,6 +77,7 @@ import { useChartLayoutStore } from '@/store/modules/chartLayoutStore/chartLayou
import { isString, addEventListener, removeEventListener } from '@/utils' import { isString, addEventListener, removeEventListener } from '@/utils'
import { fetchConfigComponent, fetchChartComponent } from '@/packages/index' import { fetchConfigComponent, fetchChartComponent } from '@/packages/index'
import { componentInstall, loadingStart, loadingFinish, loadingError } from '@/utils' import { componentInstall, loadingStart, loadingFinish, loadingError } from '@/utils'
import { ChartGlobImage } from '@/components/Pages/ChartGlobImage'
const props = defineProps({ const props = defineProps({
menuOptions: { menuOptions: {