修复类型匹配导致的run build的失败的问题

This commit is contained in:
EarlySummer
2024-11-04 16:29:53 +08:00
parent 0ba33befad
commit 18b8d60f6b
10 changed files with 119 additions and 112 deletions

View File

@@ -25,7 +25,7 @@
"@visactor/vchart": "^1.12.3",
"@visactor/vchart-theme": "^1.12.1",
"animate.css": "^4.1.1",
"axios": "^1.4.0",
"axios": "^1.6.8",
"cesium": "1.99",
"color": "^4.2.3",
"crypto-js": "^4.1.1",

View File

@@ -1,9 +1,9 @@
import axios, { AxiosResponse, AxiosRequestConfig, Axios } from 'axios'
import axios, { AxiosResponse, AxiosRequestConfig, Axios,AxiosRequestHeaders,InternalAxiosRequestConfig } from 'axios'
import { ResultEnum, ModuleTypeEnum } from "@/enums/httpEnum"
import {PageEnum, ErrorPageNameMap, PreviewEnum} from "@/enums/pageEnum"
import { StorageEnum } from '@/enums/storageEnum'
import { axiosPre } from '@/settings/httpSetting'
import { SystemStoreEnum, SystemStoreUserInfoEnum } from '@/store/modules/systemStore/systemStore.d'
import { SystemStoreEnum, SystemStoreUserInfoEnum,UserInfoType } from '@/store/modules/systemStore/systemStore.d'
import {
redirectErrorPage,
getLocalStorage,
@@ -28,7 +28,9 @@ let base_url=`${import.meta.env.PROD ? import.meta.env.VITE_PRO_PATH : ''}${axio
const dialog = useDialog()
export interface MyResponseType<T> {
export interface MyResponseType<T> extends AxiosResponse<T, any>{
code: ResultEnum
data: T
message: string
@@ -44,17 +46,14 @@ const axiosInstance = axios.create({
}) as unknown as MyRequestInstance
axiosInstance.interceptors.request.use(
(config: AxiosRequestConfig) => {
(config:InternalAxiosRequestConfig) => {
// 获取 tenantId
const info = getLocalStorage(StorageEnum.GO_SYSTEM_STORE)
// console.log(window.location)
const tenantId = info ? info[SystemStoreEnum.TENANT_INFO]['tenantId'] : undefined
if (tenantId) {
config.headers = {
...config.headers,
'tenant-id': tenantId
}
}
if (tenantId) (config as Recordable).headers['tenant-id'] = tenantId
// 白名单校验
if (includes(fetchAllowList, config.url)) return config
@@ -64,11 +63,13 @@ axiosInstance.interceptors.request.use(
routerTurnByName(PageEnum.BASE_LOGIN_NAME)
return config
}
const userInfo = info[SystemStoreEnum.USER_INFO]
config.headers = {
...config.headers,
[userInfo[SystemStoreUserInfoEnum.TOKEN_NAME] || 'token']: 'Bearer ' + userInfo[SystemStoreUserInfoEnum.USER_TOKEN] || ''
}
const userInfo:UserInfoType = info[SystemStoreEnum.USER_INFO] as UserInfoType
(config as Recordable).headers.Authorization = 'Bearer ' + userInfo[SystemStoreUserInfoEnum.USER_TOKEN] || ''
// config.headers = {
// ...config.headers,
// [userInfo[SystemStoreUserInfoEnum.TOKEN_NAME] || 'token']: 'Bearer ' + userInfo[SystemStoreUserInfoEnum.USER_TOKEN] || ''
// }
return config
},
(err: AxiosRequestConfig) => {
@@ -123,12 +124,12 @@ axiosInstance.interceptors.response.use(
})
//修改当前访问令牌
// config.headers!.Authorization = 'Bearer ' + (await refreshTokenRes).data.data.accessToken
const userInfo = info[SystemStoreEnum.USER_INFO]
config.headers = {
...config.headers,
[userInfo[SystemStoreUserInfoEnum.TOKEN_NAME] || 'token']: 'Bearer ' + userInfo[SystemStoreUserInfoEnum.USER_TOKEN] || ''
}
const userInfo:UserInfoType = info[SystemStoreEnum.USER_INFO] as UserInfoType
// config.headers = {
// ...config.headers,
// [userInfo[SystemStoreUserInfoEnum.TOKEN_NAME] || 'token']: 'Bearer ' + userInfo[SystemStoreUserInfoEnum.USER_TOKEN] || ''
// }
(config as Recordable).headers.Authorization = 'Bearer ' + userInfo[SystemStoreUserInfoEnum.USER_TOKEN] || ''
requestList.forEach((cb: any) => {
cb()
})

View File

@@ -182,7 +182,7 @@ const props = defineProps({
default: false
},
chartStyles: {
type: Object as PropType<Omit<PickCreateComponentType<'styles'>, 'animations'>>,
type: Object as PropType<Omit<PickCreateComponentType<'styles'>, 'animations' | 'animationsOpen' | 'animationsCirculate' | 'animationsCurve' | 'animationsDirection' | 'circulatePlayTime' | 'circulateDelayTime'>>,
required: true
}
})

View File

@@ -6,6 +6,7 @@
<script setup lang="ts">
import { reactive, watch, PropType } from 'vue'
import VChart from 'vue-echarts'
import { useCanvasInitOptions } from '@/hooks/useCanvasInitOptions.hook'
import { use, graphic } from 'echarts/core'
import { CanvasRenderer } from 'echarts/renderers'
import { LineChart } from 'echarts/charts'
@@ -15,7 +16,7 @@ import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore
import { chartColorsSearch, defaultTheme } from '@/settings/chartThemes/index'
import { DatasetComponent, GridComponent, TooltipComponent, LegendComponent } from 'echarts/components'
import { useChartDataFetch } from '@/hooks'
import { isPreview } from '@/utils'
import { isPreview, colorGradientCustomMerge} from '@/utils'
const props = defineProps({
themeSetting: {
@@ -32,6 +33,8 @@ const props = defineProps({
}
})
const initOptions = useCanvasInitOptions(props.chartConfig.option, props.themeSetting)
use([DatasetComponent, CanvasRenderer, LineChart, GridComponent, TooltipComponent, LegendComponent])
const chartEditStore = useChartEditStore()
@@ -41,41 +44,45 @@ const option = reactive({
// 渐变色处理
watch(
() => chartEditStore.getEditCanvasConfig.chartThemeColor,
(newColor: keyof typeof chartColorsSearch) => {
try {
if (!isPreview()) {
const themeColor = chartColorsSearch[newColor] || chartColorsSearch[defaultTheme]
props.chartConfig.option.series.forEach((value: any, index: number) => {
value.areaStyle.color = new graphic.LinearGradient(0, 0, 0, 1, [
{
offset: 0,
color: themeColor[3]
},
{
offset: 1,
color: 'rgba(0,0,0, 0)'
}
])
})
() => chartEditStore.getEditCanvasConfig.chartThemeColor,
(newColor: keyof typeof chartColorsSearch) => {
try {
if (!isPreview()) {
const themeColor =
colorGradientCustomMerge(chartEditStore.getEditCanvasConfig.chartCustomThemeColorInfo)[newColor] ||
colorGradientCustomMerge(chartEditStore.getEditCanvasConfig.chartCustomThemeColorInfo)[defaultTheme]
props.chartConfig.option.series.forEach((value: any, index: number) => {
value.areaStyle.color = new graphic.LinearGradient(0, 0, 0, 1, [
{
offset: 0,
color: themeColor[3]
},
{
offset: 1,
color: 'rgba(0,0,0, 0)'
}
])
})
}
option.value = mergeTheme(props.chartConfig.option, props.themeSetting, includes)
props.chartConfig.option = option.value
} catch (error) {
console.log(error)
}
option.value = mergeTheme(props.chartConfig.option, props.themeSetting, includes)
props.chartConfig.option = option.value
} catch (error) {
console.log(error)
},
{
immediate: true
}
},
{
immediate: true
}
)
watch(
() => props.chartConfig.option.dataset,
() => {
option.value = props.chartConfig.option
}
() => props.chartConfig.option.dataset,
() => {
option.value = props.chartConfig.option
}
)
const { vChartRef } = useChartDataFetch(props.chartConfig, useChartEditStore)
const { vChartRef } = useChartDataFetch(props.chartConfig, useChartEditStore, (newData: any) => {
props.chartConfig.option.dataset = newData
})
</script>

View File

@@ -1,18 +1,18 @@
<template>
<n-space class="go-decorates-flipper-number" :size="flipperGap" align="center" justify="center">
<flipper
:count="item"
:width="flipperWidth"
:height="flipperHeight"
:front-color="flipperTextColor"
:back-color="flipperBgColor"
:radius="flipperRadius"
:flip-type="flipperType"
:duration="flipperSpeed"
:border-width="flipperBorderWidth"
v-for="(item, index) in flipperData"
:key="index"
class="go-d-block"
:count="item"
:width="flipperWidth"
:height="flipperHeight"
:front-color="flipperTextColor"
:back-color="flipperBgColor"
:radius="flipperRadius"
:flip-type="flipperType"
:duration="flipperSpeed"
:border-width="flipperBorderWidth"
v-for="(item, index) in flipperData"
:key="index"
class="go-d-block"
/>
</n-space>
</template>
@@ -43,34 +43,35 @@ const {
flipperRadius,
flipperGap,
flipperType,
flipperSpeed
flipperSpeed,
flipperBorderWidth
} = toRefs(props.chartConfig.option as OptionType)
const flipperData = ref<string[] | number[]>([])
const getFlipperData = (val: string | number) => {
return val
.toString()
.padStart(flipperLength.value, '0') // 左侧填充|右对齐
.split('') // 转数组
.slice(flipperLength.value * -1) // 从后面取指定长度
.toString()
.padStart(flipperLength.value, '0') // 左侧填充|右对齐
.split('') // 转数组
.slice(flipperLength.value * -1) // 从后面取指定长度
}
const updateDatasetHandler = (newVal: string | number) => {
flipperData.value = getFlipperData(newVal)
}
watch(
() => props.chartConfig.option,
newVal => {
try {
updateDatasetHandler((newVal as OptionType).dataset)
} catch (error) {
console.log(error)
() => props.chartConfig.option,
newVal => {
try {
updateDatasetHandler((newVal as any as OptionType).dataset)
} catch (error) {
console.log(error)
}
},
{
immediate: true,
deep: true
}
},
{
immediate: true,
deep: true
}
)
useChartDataFetch(props.chartConfig, useChartEditStore, (newVal: string | number) => {

View File

@@ -51,7 +51,7 @@
</div>
</template>
<script setup lang="ts">
import {Component ,PropType, toRefs, shallowReactive, watch, computed, ref, onMounted,onMethods, nextTick} from 'vue'
import {Component ,PropType, toRefs, shallowReactive, watch, computed, ref, onMounted, nextTick} from 'vue'
import { CreateComponentType } from '@/packages/index.d'
import { useChartDataFetch } from '@/hooks'
import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore'

View File

@@ -1,6 +1,5 @@
import type { App } from 'vue'
import { createRouter, createWebHashHistory, RouteRecordRaw } from 'vue-router'
import { RedirectRoute } from '@/router/base'
import { createRouterGuards } from './router-guards'
import { PageEnum } from '@/enums/pageEnum'
import { HttpErrorPage, LoginRoute, ReloadRoute, RedirectRoute } from '@/router/base'

View File

@@ -667,7 +667,7 @@ export const useChartEditStore = defineStore({
} else {
const group = historyData[0] as CreateComponentGroupType
group.groupList.forEach(item => {
ids.push(item.id)
ids.unshift(item.id)
})
}
this.setGroup(ids, false)

View File

@@ -117,25 +117,25 @@ export const isMac = () => {
/**
* * file转url
*/
export const fileToUrl = (file: File): string => {
const Url = URL || window.URL || window.webkitURL
const ImageUrl = Url.createObjectURL(file)
return ImageUrl
}
// export const fileToUrl = (file: File): string => {
// const Url = URL || window.URL || window.webkitURL
// const ImageUrl = Url.createObjectURL(file)
// return ImageUrl
// }
/**
* * file转base64
*/
export const fileTobase64 = (file: File, callback: Function) => {
let reader = new FileReader()
reader.readAsDataURL(file)
reader.onload = function (e: ProgressEvent<FileReader>) {
if (e.target) {
let base64 = e.target.result
callback(base64)
}
}
}
// export const fileTobase64 = (file: File, callback: Function) => {
// let reader = new FileReader()
// reader.readAsDataURL(file)
// reader.onload = function (e: ProgressEvent<FileReader>) {
// if (e.target) {
// let base64 = e.target.result
// callback(base64)
// }
// }
// }
/**
* * 挂载监听

View File

@@ -29,9 +29,9 @@
</n-layout-header>
<n-layout-content>
<monaco-editor
v-model:modelValue="content"
language="json"
:editorOptions="{
v-model:modelValue="content"
language="json"
:editorOptions="{
lineNumbers: 'on',
minimap: { enabled: true }
}"
@@ -42,22 +42,21 @@
</template>
<script setup lang="ts">
import { computed, ref, watch } from 'vue'
import { ref } from 'vue'
import { MonacoEditor } from '@/components/Pages/MonacoEditor'
import { SavePageEnum } from '@/enums/editPageEnum'
import { getSessionStorageInfo } from '../preview/utils'
import type { ChartEditStorageType } from '../preview/index.d'
import { setSessionStorage, fetchRouteParamsLocation, JSONStringify, JSONParse, setTitle } from '@/utils'
import { setSessionStorage, JSONStringify, JSONParse, setTitle, goDialog } from '@/utils'
import { StorageEnum } from '@/enums/storageEnum'
import { icon } from '@/plugins'
import { useSync } from '@/views/chart/hooks/useSync.hook'
import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore'
import { ProjectInfoEnum } from '@/store/modules/chartEditStore/chartEditStore.d'
const chartEditStore = useChartEditStore()
const { dataSyncUpdate } = useSync()
const { ChevronBackOutlineIcon, DownloadIcon } = icon.ionicons5
import type { ChartEditStorageType } from '../preview/index.d'
const { ChevronBackOutlineIcon, DownloadIcon, AnalyticsIcon } = icon.ionicons5
const showOpenFilePicker: Function = (window as any).showOpenFilePicker
const content = ref('')
window['$message'].warning('请不要刷新此窗口!')
// 从sessionStorage 获取数据
async function getDataBySession() {
const localStorageInfo: ChartEditStorageType = (await getSessionStorageInfo()) as unknown as ChartEditStorageType