Merge branch 'dev' into master-fetch-dev

This commit is contained in:
奔跑的面条
2023-03-04 14:42:56 +08:00
11 changed files with 194 additions and 101 deletions
@@ -1,12 +1,6 @@
<template>
<n-space>
<n-button
v-for="item in btnList"
:key="item.key"
:type="item.type()"
ghost
@click="item.event"
>
<n-space class="go-mt-0">
<n-button v-for="item in comBtnList" :key="item.key" :type="item.type()" ghost @click="item.event">
<template #icon>
<component :is="item.icon"></component>
</template>
@@ -32,9 +26,7 @@
{{ previewPath() }}
</n-alert>
<n-space vertical>
<n-button tertiary type="primary" @click="copyPreviewPath()">
复制地址
</n-button>
<n-button tertiary type="primary" @click="copyPreviewPath()"> 复制地址 </n-button>
<n-button :type="release ? 'warning' : 'primary'" @click="sendHandle">
{{ release ? '取消发布' : '发布大屏' }}
</n-button>
@@ -52,13 +44,14 @@
</template>
<script setup lang="ts">
import { ref, shallowReactive, watchEffect } from 'vue'
import { ref, computed, watchEffect } from 'vue'
import { useRoute } from 'vue-router'
import { useClipboard } from '@vueuse/core'
import { PreviewEnum } from '@/enums/pageEnum'
import { StorageEnum } from '@/enums/storageEnum'
import { ResultEnum } from '@/enums/httpEnum'
import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore'
import { syncData } from '../../ContentEdit/components/EditTools/hooks/useSyncUpdate.hook'
import { ProjectInfoEnum } from '@/store/modules/chartEditStore/chartEditStore.d'
import { changeProjectReleaseApi } from '@/api/path'
import {
@@ -69,11 +62,12 @@ import {
setSessionStorage,
getLocalStorage,
httpErrorHandle,
fetchRouteParamsLocation,
fetchRouteParamsLocation
} from '@/utils'
import { icon } from '@/plugins'
import { cloneDeep } from 'lodash'
const { BrowsersOutlineIcon, SendIcon, CloseIcon } = icon.ionicons5
const { BrowsersOutlineIcon, SendIcon, AnalyticsIcon, CloseIcon } = icon.ionicons5
const chartEditStore = useChartEditStore()
const previewPathRef = ref(previewPath())
@@ -101,31 +95,26 @@ const previewHandle = () => {
// id 标识
const previewId = typeof id === 'string' ? id : id[0]
const storageInfo = chartEditStore.getStorageInfo
const sessionStorageInfo =
getLocalStorage(StorageEnum.GO_CHART_STORAGE_LIST) || []
const sessionStorageInfo = getLocalStorage(StorageEnum.GO_CHART_STORAGE_LIST) || []
if (sessionStorageInfo?.length) {
const repeateIndex = sessionStorageInfo.findIndex(
(e: { id: string }) => e.id === previewId
)
const repeateIndex = sessionStorageInfo.findIndex((e: { id: string }) => e.id === previewId)
// 重复替换
if (repeateIndex !== -1) {
sessionStorageInfo.splice(repeateIndex, 1, {
id: previewId,
...storageInfo,
...storageInfo
})
setSessionStorage(StorageEnum.GO_CHART_STORAGE_LIST, sessionStorageInfo)
} else {
sessionStorageInfo.push({
id: previewId,
...storageInfo,
...storageInfo
})
setSessionStorage(StorageEnum.GO_CHART_STORAGE_LIST, sessionStorageInfo)
}
} else {
setSessionStorage(StorageEnum.GO_CHART_STORAGE_LIST, [
{ id: previewId, ...storageInfo },
])
setSessionStorage(StorageEnum.GO_CHART_STORAGE_LIST, [{ id: previewId, ...storageInfo }])
}
// 跳转
routerTurnByPath(path, [previewId], undefined, true)
@@ -148,11 +137,11 @@ const copyPreviewPath = (successText?: string, failureText?: string) => {
// 发布
const sendHandle = async () => {
const res = (await changeProjectReleaseApi({
const res = await changeProjectReleaseApi({
id: fetchRouteParamsLocation(),
// 反过来
state: release.value ? -1 : 1,
}))
state: release.value ? -1 : 1
})
if (res && res.code === ResultEnum.SUCCESS) {
modelShowHandle()
@@ -167,22 +156,38 @@ const sendHandle = async () => {
}
}
const btnList = shallowReactive([
const btnList = [
{
select: true,
title: () => '同步内容',
type: () => 'primary',
icon: renderIcon(AnalyticsIcon),
event: syncData
},
{
key: 'preview',
title: () => '预览',
type: () => 'default',
icon: renderIcon(BrowsersOutlineIcon),
event: previewHandle,
event: previewHandle
},
{
key: 'release',
title: () => (release.value ? '已发布' : '发布'),
icon: renderIcon(SendIcon),
type: () => (release.value ? 'primary' : 'default'),
event: modelShowHandle,
},
])
event: modelShowHandle
}
]
const comBtnList = computed(() => {
if (chartEditStore.getEditCanvas.isCodeEdit) {
return btnList
}
const cloneList = cloneDeep(btnList)
cloneList.shift()
return cloneList
})
</script>
<style lang="scss" scoped>