|
@@ -31,7 +31,7 @@
|
|
|
<n-alert :show-icon="false" title="预览地址:" type="success">
|
|
<n-alert :show-icon="false" title="预览地址:" type="success">
|
|
|
{{ previewPath() }}
|
|
{{ previewPath() }}
|
|
|
</n-alert>
|
|
</n-alert>
|
|
|
- <n-button tertiary type="primary" @click="copyPath()">
|
|
|
|
|
|
|
+ <n-button tertiary type="primary" @click="copyPreviewPath()">
|
|
|
复制地址
|
|
复制地址
|
|
|
</n-button>
|
|
</n-button>
|
|
|
</n-space>
|
|
</n-space>
|
|
@@ -52,6 +52,7 @@
|
|
|
<script setup lang="ts">
|
|
<script setup lang="ts">
|
|
|
import { ref, shallowReactive, watchEffect } from 'vue'
|
|
import { ref, shallowReactive, watchEffect } from 'vue'
|
|
|
import { useRoute } from 'vue-router'
|
|
import { useRoute } from 'vue-router'
|
|
|
|
|
+import { useClipboard } from '@vueuse/core'
|
|
|
import { PreviewEnum } from '@/enums/pageEnum'
|
|
import { PreviewEnum } from '@/enums/pageEnum'
|
|
|
import { StorageEnum } from '@/enums/storageEnum'
|
|
import { StorageEnum } from '@/enums/storageEnum'
|
|
|
import { ResultEnum } from '@/enums/httpEnum'
|
|
import { ResultEnum } from '@/enums/httpEnum'
|
|
@@ -59,7 +60,7 @@ import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore
|
|
|
import { ProjectInfoEnum } from '@/store/modules/chartEditStore/chartEditStore.d'
|
|
import { ProjectInfoEnum } from '@/store/modules/chartEditStore/chartEditStore.d'
|
|
|
import { updateProjectApi } from '@/api/path'
|
|
import { updateProjectApi } from '@/api/path'
|
|
|
import {
|
|
import {
|
|
|
- goDialog,
|
|
|
|
|
|
|
+ previewPath,
|
|
|
renderIcon,
|
|
renderIcon,
|
|
|
fetchPathByName,
|
|
fetchPathByName,
|
|
|
routerTurnByPath,
|
|
routerTurnByPath,
|
|
@@ -73,6 +74,9 @@ import { icon } from '@/plugins'
|
|
|
const { BrowsersOutlineIcon, SendIcon, CloseIcon } = icon.ionicons5
|
|
const { BrowsersOutlineIcon, SendIcon, CloseIcon } = icon.ionicons5
|
|
|
const chartEditStore = useChartEditStore()
|
|
const chartEditStore = useChartEditStore()
|
|
|
|
|
|
|
|
|
|
+const previewPathRef = ref(previewPath())
|
|
|
|
|
+const { copy, isSupported } = useClipboard({ source: previewPathRef })
|
|
|
|
|
+
|
|
|
const routerParamsInfo = useRoute()
|
|
const routerParamsInfo = useRoute()
|
|
|
|
|
|
|
|
const modelShow = ref<boolean>(false)
|
|
const modelShow = ref<boolean>(false)
|
|
@@ -87,14 +91,6 @@ const closeHandle = () => {
|
|
|
modelShow.value = false
|
|
modelShow.value = false
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-// 预览地址
|
|
|
|
|
-const previewPath = () => {
|
|
|
|
|
- const { origin, pathname } = document.location
|
|
|
|
|
- const path = fetchPathByName(PreviewEnum.CHART_PREVIEW_NAME, 'href')
|
|
|
|
|
- const previewPath = `${origin}${pathname}${path}/${fetchRouteParamsLocation()}`
|
|
|
|
|
- return previewPath
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
// 预览
|
|
// 预览
|
|
|
const previewHandle = () => {
|
|
const previewHandle = () => {
|
|
|
const path = fetchPathByName(PreviewEnum.CHART_PREVIEW_NAME, 'href')
|
|
const path = fetchPathByName(PreviewEnum.CHART_PREVIEW_NAME, 'href')
|
|
@@ -139,15 +135,13 @@ const modelShowHandle = () => {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 复制预览地址
|
|
// 复制预览地址
|
|
|
-const copyPath = (successText?: string, failure?: string) => {
|
|
|
|
|
- navigator.clipboard
|
|
|
|
|
- .writeText(previewPath())
|
|
|
|
|
- .then(() => {
|
|
|
|
|
- window['$message'].success(successText || '复制成功!')
|
|
|
|
|
- })
|
|
|
|
|
- .catch(() => {
|
|
|
|
|
- window['$message'].success(failure || '复制失败!')
|
|
|
|
|
- })
|
|
|
|
|
|
|
+const copyPreviewPath = (successText?: string, failureText?: string) => {
|
|
|
|
|
+ if(isSupported) {
|
|
|
|
|
+ copy()
|
|
|
|
|
+ window['$message'].success(successText || '复制成功!')
|
|
|
|
|
+ } else {
|
|
|
|
|
+ window['$message'].success(failureText || '复制失败!')
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 发布
|
|
// 发布
|
|
@@ -161,7 +155,7 @@ const sendHandle = async () => {
|
|
|
if (res.code === ResultEnum.SUCCESS) {
|
|
if (res.code === ResultEnum.SUCCESS) {
|
|
|
modelShowHandle()
|
|
modelShowHandle()
|
|
|
if (!release.value) {
|
|
if (!release.value) {
|
|
|
- copyPath('发布成功!已复制地址到剪贴板~')
|
|
|
|
|
|
|
+ copyPreviewPath('发布成功!已复制地址到剪贴板~', '发布成功!')
|
|
|
} else {
|
|
} else {
|
|
|
window['$message'].success(`已取消发布`)
|
|
window['$message'].success(`已取消发布`)
|
|
|
}
|
|
}
|