mirror of
https://gitee.com/dromara/go-view.git
synced 2025-06-30 08:39:15 +08:00
feat: 修复图片地址错误
This commit is contained in:
parent
10b6106a9f
commit
d2d4e94f10
52
proxyConfig.ts
Normal file
52
proxyConfig.ts
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
import { loadEnv } from 'vite'
|
||||||
|
// 这里是开发环境的代理配置
|
||||||
|
const devProxy = (mode:any) => {
|
||||||
|
return {
|
||||||
|
// 开发
|
||||||
|
'/dcim': {
|
||||||
|
// @ts-ignore
|
||||||
|
target: loadEnv(mode, process.cwd()).VITE_DEV_PATH,
|
||||||
|
changeOrigin: true,
|
||||||
|
ws: true,
|
||||||
|
secure: true,
|
||||||
|
},
|
||||||
|
// 开发首页缩略图
|
||||||
|
'/data/file': {
|
||||||
|
// @ts-ignore
|
||||||
|
target: loadEnv(mode, process.cwd()).VITE_DEV_PATH,
|
||||||
|
changeOrigin: true,
|
||||||
|
ws: true,
|
||||||
|
secure: true,
|
||||||
|
},
|
||||||
|
// 开发 图片
|
||||||
|
'/svgConfig/customLargeScreen': {
|
||||||
|
// @ts-ignore
|
||||||
|
target: loadEnv(mode, process.cwd()).VITE_DEV_PATH,
|
||||||
|
changeOrigin: true,
|
||||||
|
// rewrite: (path) => path.replace(new RegExp(`^/svgConfig/customLargeScreen`), ''),
|
||||||
|
ws: true,
|
||||||
|
secure: true,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
// 这里是生产环境的代理配置
|
||||||
|
const prodProxy = (mode:any) => {
|
||||||
|
return {
|
||||||
|
// 生产list页缩略图 开发时注释掉
|
||||||
|
'/svgConfig/customLargeScreen/data/file': {
|
||||||
|
// @ts-ignore
|
||||||
|
target: loadEnv(mode, process.cwd()).VITE_DEV_PATH,
|
||||||
|
changeOrigin: true,
|
||||||
|
rewrite: (path:any) => {
|
||||||
|
console.log(path.replace(new RegExp(`^/svgConfig/customLargeScreen/data/file`), '/data/file'))
|
||||||
|
return path.replace(new RegExp(`^/svgConfig/customLargeScreen/data/file`), '/data/file')
|
||||||
|
},
|
||||||
|
ws: true,
|
||||||
|
secure: true,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 根据环境变量导出相应的配置
|
||||||
|
export const proxyConfig = process.env.NODE_ENV === 'production' ? prodProxy : devProxy;
|
21
src/App.vue
21
src/App.vue
@ -19,6 +19,27 @@ import { GoAppProvider } from '@/components/GoAppProvider'
|
|||||||
import { I18n } from '@/components/I18n'
|
import { I18n } from '@/components/I18n'
|
||||||
import { useSystemInit, useDarkThemeHook, useThemeOverridesHook, useCode, useLang } from '@/hooks'
|
import { useSystemInit, useDarkThemeHook, useThemeOverridesHook, useCode, useLang } from '@/hooks'
|
||||||
import { getToken } from '@/api/path'
|
import { getToken } from '@/api/path'
|
||||||
|
import { onMounted, onUnmounted } from 'vue'
|
||||||
|
import { useRouterStore } from '@/store/modules/routerStore/routerStore'
|
||||||
|
|
||||||
|
const routerStore = useRouterStore()
|
||||||
|
let handleMessage = function(event:{data:string}) {
|
||||||
|
const {data}:{data:any} = event
|
||||||
|
if(data.page === 'customLargeScreen' && data.type === 'setCallByParent') {
|
||||||
|
routerStore.setCallByParent(data.callByParent)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
onMounted(() => {
|
||||||
|
window.addEventListener('message', handleMessage);
|
||||||
|
let obj = {
|
||||||
|
page: 'customLargeScreen',
|
||||||
|
type: 'bindPostMessageEvent'
|
||||||
|
}
|
||||||
|
window.parent.postMessage(JSON.stringify(obj), '*');
|
||||||
|
})
|
||||||
|
onUnmounted(() => {
|
||||||
|
window.removeEventListener('message', handleMessage);
|
||||||
|
})
|
||||||
|
|
||||||
getToken()
|
getToken()
|
||||||
|
|
||||||
|
@ -219,7 +219,7 @@ const presetImageList = ref([] as presetImageData[])
|
|||||||
for (let i = 1; i <= 12; i++) {
|
for (let i = 1; i <= 12; i++) {
|
||||||
presetImageList.value.push({
|
presetImageList.value.push({
|
||||||
index: i,
|
index: i,
|
||||||
// src: logoImg,
|
src: '',
|
||||||
hueRotate: i * 30
|
hueRotate: i * 30
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -2,11 +2,11 @@ import { PublicConfigClass } from '@/packages/public'
|
|||||||
import { CreateComponentType } from '@/packages/index.d'
|
import { CreateComponentType } from '@/packages/index.d'
|
||||||
import { ComprehensivePUEConfig } from './index'
|
import { ComprehensivePUEConfig } from './index'
|
||||||
import cloneDeep from 'lodash/cloneDeep'
|
import cloneDeep from 'lodash/cloneDeep'
|
||||||
import logo from '@/assets/logo.png'
|
// import logo from '@/assets/logo.png'
|
||||||
|
|
||||||
export const option = {
|
export const option = {
|
||||||
// 图片路径
|
// 图片路径
|
||||||
dataset: logo,
|
dataset: '',
|
||||||
// 适应方式
|
// 适应方式
|
||||||
fit: 'contain',
|
fit: 'contain',
|
||||||
// 圆角
|
// 圆角
|
||||||
|
@ -2,11 +2,11 @@ import { PublicConfigClass } from '@/packages/public'
|
|||||||
import { CreateComponentType } from '@/packages/index.d'
|
import { CreateComponentType } from '@/packages/index.d'
|
||||||
import { DeviceAlarmOverviewConfig } from './index'
|
import { DeviceAlarmOverviewConfig } from './index'
|
||||||
import cloneDeep from 'lodash/cloneDeep'
|
import cloneDeep from 'lodash/cloneDeep'
|
||||||
import logo from '@/assets/logo.png'
|
// import logo from '@/assets/logo.png'
|
||||||
|
|
||||||
export const option = {
|
export const option = {
|
||||||
// 图片路径
|
// 图片路径
|
||||||
dataset: logo,
|
dataset: '',
|
||||||
// 适应方式
|
// 适应方式
|
||||||
fit: 'contain',
|
fit: 'contain',
|
||||||
// 圆角
|
// 圆角
|
||||||
|
@ -2,11 +2,11 @@ import { PublicConfigClass } from '@/packages/public'
|
|||||||
import { CreateComponentType } from '@/packages/index.d'
|
import { CreateComponentType } from '@/packages/index.d'
|
||||||
import { RealTimeTrafficConfig } from './index'
|
import { RealTimeTrafficConfig } from './index'
|
||||||
import cloneDeep from 'lodash/cloneDeep'
|
import cloneDeep from 'lodash/cloneDeep'
|
||||||
import logo from '@/assets/logo.png'
|
// import logo from '@/assets/logo.png'
|
||||||
|
|
||||||
export const option = {
|
export const option = {
|
||||||
// 图片路径
|
// 图片路径
|
||||||
dataset: logo,
|
dataset: '',
|
||||||
// 适应方式
|
// 适应方式
|
||||||
fit: 'contain',
|
fit: 'contain',
|
||||||
// 圆角
|
// 圆角
|
||||||
|
@ -2,11 +2,11 @@ import { PublicConfigClass } from '@/packages/public'
|
|||||||
import { CreateComponentType } from '@/packages/index.d'
|
import { CreateComponentType } from '@/packages/index.d'
|
||||||
import { Theme1Config } from './index'
|
import { Theme1Config } from './index'
|
||||||
import cloneDeep from 'lodash/cloneDeep'
|
import cloneDeep from 'lodash/cloneDeep'
|
||||||
import bakground from '@/assets/customComponents/theme1/backgrond.jpg'
|
import background from '@/assets/customComponents/theme1/backgrond.jpg'
|
||||||
|
|
||||||
export const option = {
|
export const option = {
|
||||||
// 图片路径
|
// 图片路径
|
||||||
dataset: bakground,
|
dataset: background,
|
||||||
// 适应方式
|
// 适应方式
|
||||||
fit: 'contain',
|
fit: 'contain',
|
||||||
// 圆角
|
// 圆角
|
||||||
|
@ -120,13 +120,12 @@ const props = defineProps({
|
|||||||
props.chartConfig.attr.w = 1920
|
props.chartConfig.attr.w = 1920
|
||||||
props.chartConfig.attr.h = 1080
|
props.chartConfig.attr.h = 1080
|
||||||
Object.assign(props.chartConfig.attr, {w: 1920, h: 1080, x: 0, y: 0})
|
Object.assign(props.chartConfig.attr, {w: 1920, h: 1080, x: 0, y: 0})
|
||||||
console.log(props.chartConfig)
|
|
||||||
|
|
||||||
const { w, h } = toRefs(props.chartConfig.attr)
|
const { w, h } = toRefs(props.chartConfig.attr)
|
||||||
const { dataset, fit, borderRadius } = toRefs(props.chartConfig.option)
|
const { dataset, fit, borderRadius } = toRefs(props.chartConfig.option)
|
||||||
|
|
||||||
let date = ref(moment().format('yyyy-MM-DD'))
|
let date = ref(moment().format('yyyy-MM-DD'))
|
||||||
const weeks = ['周一', '周二', '周三', '周四', '周五', '周六', '周天']
|
const weeks = ['周一', '周二', '周三', '周四', '周五', '周六', '周日']
|
||||||
let time = ref(moment().format('HH:mm:ss ') + weeks[Number(moment().format('e'))])
|
let time = ref(moment().format('HH:mm:ss ') + weeks[Number(moment().format('e'))])
|
||||||
let timer: unknown
|
let timer: unknown
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
@ -169,8 +168,13 @@ const getStyle = (radius: number) => {
|
|||||||
// 编辑更新
|
// 编辑更新
|
||||||
watch(
|
watch(
|
||||||
() => props.chartConfig.option.dataset,
|
() => props.chartConfig.option.dataset,
|
||||||
(newData: any) => {
|
async (newData: any) => {
|
||||||
option.dataset = newData
|
try {
|
||||||
|
const img = await import(newData);
|
||||||
|
option.dataset = img.default
|
||||||
|
} catch(e) {
|
||||||
|
console.log(e)
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
immediate: true
|
immediate: true
|
||||||
@ -178,8 +182,13 @@ watch(
|
|||||||
)
|
)
|
||||||
|
|
||||||
// 预览更新
|
// 预览更新
|
||||||
useChartDataFetch(props.chartConfig, useChartEditStore, (newData: any) => {
|
useChartDataFetch(props.chartConfig, useChartEditStore, async (newData: any) => {
|
||||||
option.dataset = newData
|
try {
|
||||||
|
const img = await import(newData);
|
||||||
|
option.dataset = img.default
|
||||||
|
} catch(e) {
|
||||||
|
console.log(e)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -2,11 +2,11 @@ import { PublicConfigClass } from '@/packages/public'
|
|||||||
import { CreateComponentType } from '@/packages/index.d'
|
import { CreateComponentType } from '@/packages/index.d'
|
||||||
import { ImageConfig } from './index'
|
import { ImageConfig } from './index'
|
||||||
import cloneDeep from 'lodash/cloneDeep'
|
import cloneDeep from 'lodash/cloneDeep'
|
||||||
import logo from '@/assets/logo.png'
|
// import logo from '@/assets/logo.png'
|
||||||
|
|
||||||
export const option = {
|
export const option = {
|
||||||
// 图片路径
|
// 图片路径
|
||||||
dataset: logo,
|
dataset: '',
|
||||||
// 适应方式
|
// 适应方式
|
||||||
fit: 'contain',
|
fit: 'contain',
|
||||||
// 圆角
|
// 圆角
|
||||||
|
@ -18,15 +18,15 @@ export const usePackagesStore = defineStore({
|
|||||||
},
|
},
|
||||||
actions: {
|
actions: {
|
||||||
addPhotos(newPhoto: ConfigType, index: number) {
|
addPhotos(newPhoto: ConfigType, index: number) {
|
||||||
this.newPhoto = newPhoto
|
// this.newPhoto = newPhoto
|
||||||
this.packagesList.Photos.splice(index, 0, newPhoto)
|
// this.packagesList.Photos.splice(index, 0, newPhoto)
|
||||||
},
|
},
|
||||||
deletePhotos(photoInfo: ConfigType, index: number) {
|
deletePhotos(photoInfo: ConfigType, index: number) {
|
||||||
this.packagesList.Photos.splice(index, 1)
|
// this.packagesList.Photos.splice(index, 1)
|
||||||
const StoreKey = StorageEnum.GO_USER_MEDIA_PHOTOS
|
// const StoreKey = StorageEnum.GO_USER_MEDIA_PHOTOS
|
||||||
const userPhotosList = getLocalStorage(StoreKey)
|
// const userPhotosList = getLocalStorage(StoreKey)
|
||||||
userPhotosList.splice(index - 1, 1)
|
// userPhotosList.splice(index - 1, 1)
|
||||||
setLocalStorage(StoreKey, userPhotosList)
|
// setLocalStorage(StoreKey, userPhotosList)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
19
src/store/modules/routerStore/routerStore.ts
Normal file
19
src/store/modules/routerStore/routerStore.ts
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
import { defineStore } from 'pinia'
|
||||||
|
|
||||||
|
export const useRouterStore = defineStore({
|
||||||
|
id: 'useRouterStore',
|
||||||
|
state: () => ({
|
||||||
|
// 为true是router交给parent调用自身不跳转 为false使用自身路由
|
||||||
|
callByParent: false,
|
||||||
|
}),
|
||||||
|
getters: {
|
||||||
|
getCallByParent():boolean {
|
||||||
|
return this.callByParent
|
||||||
|
}
|
||||||
|
},
|
||||||
|
actions: {
|
||||||
|
setCallByParent(callByParent: boolean) {
|
||||||
|
this.callByParent = callByParent
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
@ -7,6 +7,8 @@ import { StorageEnum } from '@/enums/storageEnum'
|
|||||||
import { clearLocalStorage, getLocalStorage, clearCookie } from './storage'
|
import { clearLocalStorage, getLocalStorage, clearCookie } from './storage'
|
||||||
import router from '@/router'
|
import router from '@/router'
|
||||||
import { logoutApi } from '@/api/path'
|
import { logoutApi } from '@/api/path'
|
||||||
|
import { useRouterStore } from '@/store/modules/routerStore/routerStore'
|
||||||
|
import { onMounted } from 'vue'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* * 根据名字跳转路由
|
* * 根据名字跳转路由
|
||||||
@ -69,7 +71,8 @@ export const routerTurnByPath = (
|
|||||||
if (query?.length) {
|
if (query?.length) {
|
||||||
fullPath = `${path}/${query.join('/')}`
|
fullPath = `${path}/${query.join('/')}`
|
||||||
}
|
}
|
||||||
if (isCallByParent) {
|
const routerStore:any = useRouterStore()
|
||||||
|
if (routerStore && routerStore.getCallByParent) {
|
||||||
// 获取父页面的 window 对象
|
// 获取父页面的 window 对象
|
||||||
var parentWindow = window.parent;
|
var parentWindow = window.parent;
|
||||||
const message = {
|
const message = {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<!-- 事件配置 -->
|
<!-- 事件配置 -->
|
||||||
<n-collapse v-if="isReady" class="go-mt-3" arrow-placement="right" :default-expanded-names="['1', '2']">
|
<n-collapse class="go-mt-3" arrow-placement="right" :default-expanded-names="['1', '2']">
|
||||||
<n-text depth="3">
|
<n-text depth="3">
|
||||||
组件 id:
|
组件 id:
|
||||||
<n-text>{{ targetData.id }}</n-text>
|
<n-text>{{ targetData.id }}</n-text>
|
||||||
@ -38,7 +38,7 @@ const { chartEditStore } = useTargetData()
|
|||||||
const targetIndex = computed(() => chartEditStore.fetchTargetIndex())
|
const targetIndex = computed(() => chartEditStore.fetchTargetIndex())
|
||||||
const list = computed(() => chartEditStore.getComponentList)
|
const list = computed(() => chartEditStore.getComponentList)
|
||||||
let targetData:any = ref(list.value[targetIndex.value])
|
let targetData:any = ref(list.value[targetIndex.value])
|
||||||
const isReady = ref(false)
|
// const isReady = ref(false)
|
||||||
|
|
||||||
const init = () => {
|
const init = () => {
|
||||||
if(!targetData.value.customEvent) {
|
if(!targetData.value.customEvent) {
|
||||||
@ -52,11 +52,11 @@ const init = () => {
|
|||||||
}
|
}
|
||||||
init()
|
init()
|
||||||
watch(() => targetIndex.value, newIndex => {
|
watch(() => targetIndex.value, newIndex => {
|
||||||
isReady.value = false
|
// isReady.value = false
|
||||||
targetData.value = list.value[newIndex]
|
targetData.value = list.value[newIndex]
|
||||||
init()
|
init()
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
isReady.value = true
|
// isReady.value = true
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
watch(() => list.value.length, () => {
|
watch(() => list.value.length, () => {
|
||||||
|
@ -6,12 +6,13 @@ import viteCompression from 'vite-plugin-compression'
|
|||||||
import { axiosPre } from './src/settings/httpSetting'
|
import { axiosPre } from './src/settings/httpSetting'
|
||||||
import { viteMockServe } from 'vite-plugin-mock'
|
import { viteMockServe } from 'vite-plugin-mock'
|
||||||
import monacoEditorPlugin from 'vite-plugin-monaco-editor'
|
import monacoEditorPlugin from 'vite-plugin-monaco-editor'
|
||||||
|
import { proxyConfig } from './proxyConfig'
|
||||||
|
|
||||||
function pathResolve(dir: string) {
|
function pathResolve(dir: string) {
|
||||||
return resolve(process.cwd(), '.', dir)
|
return resolve(process.cwd(), '.', dir)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default ({ mode }) => defineConfig({
|
export default ({ mode } : { mode:any }) => defineConfig({
|
||||||
base: process.env.NODE_ENV === 'production' ? './' : '/',
|
base: process.env.NODE_ENV === 'production' ? './' : '/',
|
||||||
// 路径重定向
|
// 路径重定向
|
||||||
resolve: {
|
resolve: {
|
||||||
@ -46,50 +47,7 @@ export default ({ mode }) => defineConfig({
|
|||||||
open: true,
|
open: true,
|
||||||
port: 3000,
|
port: 3000,
|
||||||
proxy: {
|
proxy: {
|
||||||
// 生产list页缩略图 开发时注释掉
|
...proxyConfig(mode)
|
||||||
'/svgConfig/customLargeScreen/data/file': {
|
|
||||||
// @ts-ignore
|
|
||||||
target: loadEnv(mode, process.cwd()).VITE_DEV_PATH,
|
|
||||||
changeOrigin: true,
|
|
||||||
rewrite: (path) => path.replace(new RegExp(`^/svgConfig/customLargeScreen`), ''),
|
|
||||||
ws: true,
|
|
||||||
secure: true,
|
|
||||||
},
|
|
||||||
// 生产打开 开发时注释掉
|
|
||||||
[axiosPre]: {
|
|
||||||
// @ts-ignore
|
|
||||||
target: loadEnv(mode, process.cwd()).VITE_DEV_PATH,
|
|
||||||
changeOrigin: true,
|
|
||||||
// rewrite: (path) => path.replace(new RegExp(`^${axiosPre}`), ''),
|
|
||||||
// rewrite: () => '',
|
|
||||||
ws: true,
|
|
||||||
secure: true,
|
|
||||||
},
|
|
||||||
// 开发
|
|
||||||
// '/dcim': {
|
|
||||||
// // @ts-ignore
|
|
||||||
// target: loadEnv(mode, process.cwd()).VITE_DEV_PATH,
|
|
||||||
// changeOrigin: true,
|
|
||||||
// ws: true,
|
|
||||||
// secure: true,
|
|
||||||
// },
|
|
||||||
// // 开发首页缩略图
|
|
||||||
// '/data/file': {
|
|
||||||
// // @ts-ignore
|
|
||||||
// target: loadEnv(mode, process.cwd()).VITE_DEV_PATH,
|
|
||||||
// changeOrigin: true,
|
|
||||||
// ws: true,
|
|
||||||
// secure: true,
|
|
||||||
// },
|
|
||||||
// // 开发 图片
|
|
||||||
// '/svgConfig/customLargeScreen': {
|
|
||||||
// // @ts-ignore
|
|
||||||
// target: loadEnv(mode, process.cwd()).VITE_DEV_PATH,
|
|
||||||
// changeOrigin: true,
|
|
||||||
// // rewrite: (path) => path.replace(new RegExp(`^/svgConfig/customLargeScreen`), ''),
|
|
||||||
// ws: true,
|
|
||||||
// secure: true,
|
|
||||||
// },
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
plugins: [
|
plugins: [
|
||||||
|
Loading…
x
Reference in New Issue
Block a user