mirror of
https://gitee.com/dromara/go-view.git
synced 2025-04-06 03:58:04 +08:00
feat: 处理请求展示的位置
This commit is contained in:
parent
d1de5f0c4c
commit
740f471ff4
@ -37,8 +37,15 @@ export const useChartDataFetch = (
|
|||||||
} = toRefs(targetComponent.request)
|
} = toRefs(targetComponent.request)
|
||||||
|
|
||||||
// 非请求类型
|
// 非请求类型
|
||||||
if (requestDataType.value !== RequestDataTypeEnum.AJAX || !requestInterval) return
|
if (
|
||||||
|
requestDataType.value !== RequestDataTypeEnum.AJAX ||
|
||||||
|
!requestInterval ||
|
||||||
|
!requestInterval.value ||
|
||||||
|
!targetInterval ||
|
||||||
|
!targetInterval.value
|
||||||
|
)
|
||||||
|
return
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// 处理地址
|
// 处理地址
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
|
@ -54,7 +54,8 @@ import {
|
|||||||
Planet as PawIcon,
|
Planet as PawIcon,
|
||||||
Search as SearchIcon,
|
Search as SearchIcon,
|
||||||
ChevronUpOutline as ChevronUpOutlineIcon,
|
ChevronUpOutline as ChevronUpOutlineIcon,
|
||||||
ChevronDownOutline as ChevronDownOutlineIcon
|
ChevronDownOutline as ChevronDownOutlineIcon,
|
||||||
|
Pulse as PulseIcon
|
||||||
} from '@vicons/ionicons5'
|
} from '@vicons/ionicons5'
|
||||||
|
|
||||||
import {
|
import {
|
||||||
@ -200,7 +201,9 @@ const ionicons5 = {
|
|||||||
// 向上
|
// 向上
|
||||||
ChevronUpOutlineIcon,
|
ChevronUpOutlineIcon,
|
||||||
// 向下
|
// 向下
|
||||||
ChevronDownOutlineIcon
|
ChevronDownOutlineIcon,
|
||||||
|
// 脉搏
|
||||||
|
PulseIcon
|
||||||
}
|
}
|
||||||
|
|
||||||
const carbon = {
|
const carbon = {
|
||||||
|
@ -1,45 +1,42 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="go-chart-configurations-data-ajax">
|
<div class="go-chart-configurations-data-ajax">
|
||||||
<n-button type="primary" @click="requestModelHandle">配置请求</n-button>
|
<n-card class="n-card-shallow">
|
||||||
<setting-item-box name="配置">
|
<setting-item-box name="基础配置">
|
||||||
<setting-item name="类型">
|
<setting-item name="请求方式">
|
||||||
<n-select v-model:value="targetData.request.requestHttpType" :options="selectOptions" />
|
<n-input size="small" :placeholder="requestHttpType || '暂无'" :disabled="true"></n-input>
|
||||||
</setting-item>
|
</setting-item>
|
||||||
<setting-item name="默认使用全局间隔">
|
|
||||||
<n-input-number
|
|
||||||
v-model:value.trim="targetData.request.requestInterval"
|
|
||||||
min="5"
|
|
||||||
:show-button="false"
|
|
||||||
placeholder="可以为空"
|
|
||||||
>
|
|
||||||
<template #suffix> 秒 </template>
|
|
||||||
</n-input-number>
|
|
||||||
</setting-item>
|
|
||||||
</setting-item-box>
|
|
||||||
|
|
||||||
<setting-item-box name="源地址:" :alone="true">
|
<setting-item name="请求间隔">
|
||||||
<n-text type="info">{{ requestOriginUrl || '暂无' }}</n-text>
|
<n-input size="small" :placeholder="requestInterval || '暂无'" :disabled="true">
|
||||||
</setting-item-box>
|
<template #suffix> {{ SelectHttpTimeNameObj[requestIntervalUnit] }} </template>
|
||||||
|
</n-input>
|
||||||
|
</setting-item>
|
||||||
|
</setting-item-box>
|
||||||
|
|
||||||
<setting-item-box :alone="true">
|
<setting-item-box name="源地址" :alone="true">
|
||||||
<template #name>
|
<n-input size="small" :placeholder="requestOriginUrl || '暂无'" :disabled="true">
|
||||||
地址
|
<template #prefix>
|
||||||
<n-tooltip trigger="hover" v-if="isDev()">
|
<n-icon :component="PulseIcon" />
|
||||||
<template #trigger>
|
|
||||||
<n-icon size="21" :depth="3">
|
|
||||||
<help-outline-icon></help-outline-icon>
|
|
||||||
</n-icon>
|
|
||||||
</template>
|
</template>
|
||||||
<ul class="go-pl-0">
|
</n-input>
|
||||||
开发环境使用 mock 数据,请输入
|
</setting-item-box>
|
||||||
<li v-for="item in apiList" :key="item.value">
|
|
||||||
<n-text type="info"> {{ item.value }} </n-text>
|
<setting-item-box name="组件地址" :alone="true">
|
||||||
</li>
|
<n-input size="small" :placeholder="requestUrl || '暂无'" :disabled="true">
|
||||||
</ul>
|
<template #prefix>
|
||||||
</n-tooltip>
|
<n-icon :component="FlashIcon" />
|
||||||
</template>
|
</template>
|
||||||
<n-input v-model:value.trim="targetData.request.requestUrl" :min="1" placeholder="请输入地址(去除源)" />
|
</n-input>
|
||||||
</setting-item-box>
|
</setting-item-box>
|
||||||
|
|
||||||
|
<n-text depth="3">更新内容请点击配置</n-text>
|
||||||
|
|
||||||
|
<div class="edit-text" @click="requestModelHandle">
|
||||||
|
<div class="go-absolute-center">
|
||||||
|
<n-button type="primary" secondary>点击配置</n-button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</n-card>
|
||||||
|
|
||||||
<setting-item-box :alone="true">
|
<setting-item-box :alone="true">
|
||||||
<template #name>
|
<template #name>
|
||||||
@ -53,16 +50,14 @@
|
|||||||
默认赋值给 dataset 字段
|
默认赋值给 dataset 字段
|
||||||
</n-tooltip>
|
</n-tooltip>
|
||||||
</template>
|
</template>
|
||||||
<n-space>
|
<n-button type="primary" ghost @click="sendHandle">
|
||||||
<n-button @click="sendHandle">
|
<template #icon>
|
||||||
<template #icon>
|
<n-icon>
|
||||||
<n-icon>
|
<flash-icon />
|
||||||
<flash-icon />
|
</n-icon>
|
||||||
</n-icon>
|
</template>
|
||||||
</template>
|
发送请求
|
||||||
发送请求
|
</n-button>
|
||||||
</n-button>
|
|
||||||
</n-space>
|
|
||||||
</setting-item-box>
|
</setting-item-box>
|
||||||
|
|
||||||
<!-- 底部数据展示 -->
|
<!-- 底部数据展示 -->
|
||||||
@ -77,9 +72,10 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, toRefs, onBeforeUnmount, watchEffect } from 'vue'
|
import { ref, toRefs, onBeforeUnmount, watchEffect } from 'vue'
|
||||||
import { icon } from '@/plugins'
|
import { icon } from '@/plugins'
|
||||||
|
import { useDesignStore } from '@/store/modules/designStore/designStore'
|
||||||
import { SettingItemBox, SettingItem } from '@/components/Pages/ChartItemSetting'
|
import { SettingItemBox, SettingItem } from '@/components/Pages/ChartItemSetting'
|
||||||
import { ChartDataRequest } from '../ChartDataRequest/index'
|
import { ChartDataRequest } from '../ChartDataRequest/index'
|
||||||
import { RequestHttpEnum, ResultEnum } from '@/enums/httpEnum'
|
import { RequestHttpEnum, ResultEnum, SelectHttpTimeNameObj } from '@/enums/httpEnum'
|
||||||
import { chartDataUrl, rankListUrl, scrollBoardUrl, numberFloatUrl, numberIntUrl, textUrl, imageUrl } from '@/api/mock'
|
import { chartDataUrl, rankListUrl, scrollBoardUrl, numberFloatUrl, numberIntUrl, textUrl, imageUrl } from '@/api/mock'
|
||||||
import { http } from '@/api/http'
|
import { http } from '@/api/http'
|
||||||
import { SelectHttpType } from '../../index.d'
|
import { SelectHttpType } from '../../index.d'
|
||||||
@ -87,51 +83,19 @@ import { ChartDataMatchingAndShow } from '../ChartDataMatchingAndShow'
|
|||||||
import { useTargetData } from '../../../hooks/useTargetData.hook'
|
import { useTargetData } from '../../../hooks/useTargetData.hook'
|
||||||
import { isDev, newFunctionHandle } from '@/utils'
|
import { isDev, newFunctionHandle } from '@/utils'
|
||||||
|
|
||||||
const { HelpOutlineIcon, FlashIcon } = icon.ionicons5
|
const { HelpOutlineIcon, FlashIcon, PulseIcon } = icon.ionicons5
|
||||||
const { targetData, chartEditStore } = useTargetData()
|
const { targetData, chartEditStore } = useTargetData()
|
||||||
|
const { requestUrl, requestHttpType, requestInterval, requestIntervalUnit } = toRefs(targetData.value.request)
|
||||||
const { requestOriginUrl } = toRefs(chartEditStore.getRequestGlobalConfig)
|
const { requestOriginUrl } = toRefs(chartEditStore.getRequestGlobalConfig)
|
||||||
|
const designStore = useDesignStore()
|
||||||
|
const themeColor = ref(designStore.getAppTheme)
|
||||||
|
|
||||||
// 是否展示数据分析
|
// 是否展示数据分析
|
||||||
const loading = ref(false)
|
const loading = ref(false)
|
||||||
const requestShow = ref(false)
|
const requestShow = ref(false)
|
||||||
const showMatching = ref(false)
|
const showMatching = ref(false)
|
||||||
let lastFilter: any = undefined
|
let lastFilter: any = undefined
|
||||||
|
|
||||||
const apiList = [
|
|
||||||
{
|
|
||||||
value: `【图表】${chartDataUrl}`
|
|
||||||
},
|
|
||||||
{
|
|
||||||
value: `【文本】${textUrl}`
|
|
||||||
},
|
|
||||||
{
|
|
||||||
value: `【0~100 整数】${numberIntUrl}`
|
|
||||||
},
|
|
||||||
{
|
|
||||||
value: `【0~1小数】${numberFloatUrl}`
|
|
||||||
},
|
|
||||||
{
|
|
||||||
value: `【图片地址】${imageUrl}`
|
|
||||||
},
|
|
||||||
{
|
|
||||||
value: `【排名列表】${rankListUrl}`
|
|
||||||
},
|
|
||||||
{
|
|
||||||
value: `【滚动表格】${scrollBoardUrl}`
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
// 选项
|
|
||||||
const selectOptions: SelectHttpType[] = [
|
|
||||||
{
|
|
||||||
label: RequestHttpEnum.GET,
|
|
||||||
value: RequestHttpEnum.GET
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: RequestHttpEnum.POST,
|
|
||||||
value: RequestHttpEnum.POST
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
// 请求配置 model
|
// 请求配置 model
|
||||||
const requestModelHandle = () => {
|
const requestModelHandle = () => {
|
||||||
requestShow.value = true
|
requestShow.value = true
|
||||||
@ -172,5 +136,28 @@ onBeforeUnmount(() => {
|
|||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
@include go('chart-configurations-data-ajax') {
|
@include go('chart-configurations-data-ajax') {
|
||||||
|
.n-card-shallow {
|
||||||
|
&.n-card {
|
||||||
|
@extend .go-background-filter;
|
||||||
|
}
|
||||||
|
.edit-text {
|
||||||
|
position: absolute;
|
||||||
|
top: 0px;
|
||||||
|
left: 0px;
|
||||||
|
width: 325px;
|
||||||
|
height: 254px;
|
||||||
|
cursor: pointer;
|
||||||
|
opacity: 0;
|
||||||
|
transition: all 0.3s;
|
||||||
|
@extend .go-background-filter;
|
||||||
|
backdrop-filter: blur(2px) !important;
|
||||||
|
}
|
||||||
|
&:hover {
|
||||||
|
border-color: v-bind('themeColor');
|
||||||
|
.edit-text {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
</n-card>
|
</n-card>
|
||||||
</template>
|
</template>
|
||||||
<template v-else>
|
<template v-else>
|
||||||
<n-button @click="addFilter">
|
<n-button class="go-ml-3" @click="addFilter">
|
||||||
<template #icon>
|
<template #icon>
|
||||||
<n-icon>
|
<n-icon>
|
||||||
<filter-icon />
|
<filter-icon />
|
||||||
@ -88,7 +88,7 @@
|
|||||||
|
|
||||||
<n-space>
|
<n-space>
|
||||||
<n-button size="medium" @click="closeFilter">取消</n-button>
|
<n-button size="medium" @click="closeFilter">取消</n-button>
|
||||||
<n-button size="medium" type="primary" ghost @click="saveFilter">保存</n-button>
|
<n-button size="medium" type="primary" @click="saveFilter">保存</n-button>
|
||||||
</n-space>
|
</n-space>
|
||||||
</n-space>
|
</n-space>
|
||||||
</template>
|
</template>
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
>
|
>
|
||||||
<!-- 源地址 -->
|
<!-- 源地址 -->
|
||||||
<setting-item name="前置 URL">
|
<setting-item name="前置 URL">
|
||||||
<n-input v-model:value.trim="requestOriginUrl" :disabled="editDisabled" placeholder="http://127.0.0.1/"></n-input>
|
<n-input v-model:value.trim="requestOriginUrl" :disabled="editDisabled" placeholder="例:http://127.0.0.1/"></n-input>
|
||||||
</setting-item>
|
</setting-item>
|
||||||
<setting-item name="更新间隔(为 0 表示不更新)">
|
<setting-item name="更新间隔(为 0 表示不更新)">
|
||||||
<n-input-group>
|
<n-input-group>
|
||||||
@ -32,7 +32,7 @@
|
|||||||
/>
|
/>
|
||||||
</n-input-group>
|
</n-input-group>
|
||||||
</setting-item>
|
</setting-item>
|
||||||
<n-button v-show="editDisabled" type="primary" secondary @click="editDisabled = false">
|
<n-button v-show="editDisabled" type="primary" ghost @click="editDisabled = false">
|
||||||
<template #icon>
|
<template #icon>
|
||||||
<n-icon>
|
<n-icon>
|
||||||
<pencil-icon />
|
<pencil-icon />
|
||||||
|
@ -2,11 +2,26 @@
|
|||||||
<!-- 组件配置 -->
|
<!-- 组件配置 -->
|
||||||
<n-divider class="go-my-3" title-placement="left"></n-divider>
|
<n-divider class="go-my-3" title-placement="left"></n-divider>
|
||||||
<setting-item-box
|
<setting-item-box
|
||||||
name="组件"
|
|
||||||
:itemRightStyle="{
|
:itemRightStyle="{
|
||||||
gridTemplateColumns: '5fr 2fr 1fr'
|
gridTemplateColumns: '5fr 2fr 1fr'
|
||||||
}"
|
}"
|
||||||
>
|
>
|
||||||
|
<template #name>
|
||||||
|
地址
|
||||||
|
<n-tooltip trigger="hover" v-if="isDev()">
|
||||||
|
<template #trigger>
|
||||||
|
<n-icon size="21" :depth="3">
|
||||||
|
<help-outline-icon></help-outline-icon>
|
||||||
|
</n-icon>
|
||||||
|
</template>
|
||||||
|
<ul class="go-pl-0">
|
||||||
|
开发环境使用 mock 数据,请输入
|
||||||
|
<li v-for="item in apiList" :key="item.value">
|
||||||
|
<n-text type="info"> {{ item.value }} </n-text>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</n-tooltip>
|
||||||
|
</template>
|
||||||
<setting-item name="请求方式 & URL 地址">
|
<setting-item name="请求方式 & URL 地址">
|
||||||
<n-input-group>
|
<n-input-group>
|
||||||
<n-select class="select-type-options" v-model:value="requestHttpType" :options="selectTypeOptions" />
|
<n-select class="select-type-options" v-model:value="requestHttpType" :options="selectTypeOptions" />
|
||||||
@ -19,21 +34,21 @@
|
|||||||
</n-input-group>
|
</n-input-group>
|
||||||
<!-- 组件url -->
|
<!-- 组件url -->
|
||||||
</setting-item>
|
</setting-item>
|
||||||
<setting-item name="默认使用全局间隔">
|
<setting-item name="更新间隔,为 0 则不请求">
|
||||||
<n-input-group>
|
<n-input-group>
|
||||||
<n-input-number
|
<n-input-number
|
||||||
v-model:value.trim="requestInterval"
|
v-model:value.trim="requestInterval"
|
||||||
class="select-time-number"
|
class="select-time-number"
|
||||||
min="1"
|
min="0"
|
||||||
:show-button="false"
|
:show-button="false"
|
||||||
placeholder="可以为空"
|
placeholder="默认使用全局数据"
|
||||||
>
|
>
|
||||||
</n-input-number>
|
</n-input-number>
|
||||||
<!-- 单位 -->
|
<!-- 单位 -->
|
||||||
<n-select class="select-time-options" v-model:value="requestIntervalUnit" :options="selectTimeOptions" />
|
<n-select class="select-time-options" v-model:value="requestIntervalUnit" :options="selectTimeOptions" />
|
||||||
</n-input-group>
|
</n-input-group>
|
||||||
</setting-item>
|
</setting-item>
|
||||||
<n-button secondary type="primary">
|
<n-button ghost type="primary">
|
||||||
<template #icon>
|
<template #icon>
|
||||||
<n-icon>
|
<n-icon>
|
||||||
<flash-icon />
|
<flash-icon />
|
||||||
@ -43,7 +58,7 @@
|
|||||||
</n-button>
|
</n-button>
|
||||||
</setting-item-box>
|
</setting-item-box>
|
||||||
<setting-item-box name="选择方式" class="go-mt-0">
|
<setting-item-box name="选择方式" class="go-mt-0">
|
||||||
<request-header></request-header>
|
<request-header></request-header>
|
||||||
</setting-item-box>
|
</setting-item-box>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@ -53,12 +68,38 @@ import { SettingItemBox, SettingItem } from '@/components/Pages/ChartItemSetting
|
|||||||
import { useTargetData } from '@/views/chart/ContentConfigurations/components/hooks/useTargetData.hook'
|
import { useTargetData } from '@/views/chart/ContentConfigurations/components/hooks/useTargetData.hook'
|
||||||
import { selectTypeOptions, selectTimeOptions } from '@/views/chart/ContentConfigurations/components/ChartData/index.d'
|
import { selectTypeOptions, selectTimeOptions } from '@/views/chart/ContentConfigurations/components/ChartData/index.d'
|
||||||
import { RequestHeader } from '../RequestHeader'
|
import { RequestHeader } from '../RequestHeader'
|
||||||
|
import { isDev } from '@/utils'
|
||||||
import { icon } from '@/plugins'
|
import { icon } from '@/plugins'
|
||||||
|
import { chartDataUrl, rankListUrl, scrollBoardUrl, numberFloatUrl, numberIntUrl, textUrl, imageUrl } from '@/api/mock'
|
||||||
|
|
||||||
const { FlashIcon } = icon.ionicons5
|
const { HelpOutlineIcon, FlashIcon } = icon.ionicons5
|
||||||
const { targetData, chartEditStore } = useTargetData()
|
const { targetData, chartEditStore } = useTargetData()
|
||||||
const { requestOriginUrl } = toRefs(chartEditStore.getRequestGlobalConfig)
|
const { requestOriginUrl } = toRefs(chartEditStore.getRequestGlobalConfig)
|
||||||
const { requestInterval, requestIntervalUnit, requestHttpType, requestUrl } = toRefs(targetData.value.request)
|
const { requestInterval, requestIntervalUnit, requestHttpType, requestUrl } = toRefs(targetData.value.request)
|
||||||
|
|
||||||
|
const apiList = [
|
||||||
|
{
|
||||||
|
value: `【图表】${chartDataUrl}`
|
||||||
|
},
|
||||||
|
{
|
||||||
|
value: `【文本】${textUrl}`
|
||||||
|
},
|
||||||
|
{
|
||||||
|
value: `【0~100 整数】${numberIntUrl}`
|
||||||
|
},
|
||||||
|
{
|
||||||
|
value: `【0~1小数】${numberFloatUrl}`
|
||||||
|
},
|
||||||
|
{
|
||||||
|
value: `【图片地址】${imageUrl}`
|
||||||
|
},
|
||||||
|
{
|
||||||
|
value: `【排名列表】${rankListUrl}`
|
||||||
|
},
|
||||||
|
{
|
||||||
|
value: `【滚动表格】${scrollBoardUrl}`
|
||||||
|
}
|
||||||
|
]
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
<n-text>—— </n-text>
|
<n-text>—— </n-text>
|
||||||
<n-tag type="primary" :bordered="false"> {{ requestContentTypeObj[requestContentType] }} </n-tag>
|
<n-tag type="primary" :bordered="false"> {{ requestContentTypeObj[requestContentType] }} </n-tag>
|
||||||
</div>
|
</div>
|
||||||
<n-button type="primary" ghost @click="closeHandle">确认</n-button>
|
<n-button type="primary" @click="closeHandle">确认</n-button>
|
||||||
</n-space>
|
</n-space>
|
||||||
</template>
|
</template>
|
||||||
</n-card>
|
</n-card>
|
||||||
@ -67,6 +67,9 @@ const closeHandle = () => {
|
|||||||
& > .n-card__content {
|
& > .n-card__content {
|
||||||
padding-right: 0;
|
padding-right: 0;
|
||||||
}
|
}
|
||||||
|
.n-card__content {
|
||||||
|
padding-bottom: 5px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
@ -7,8 +7,6 @@
|
|||||||
/>
|
/>
|
||||||
</setting-item-box>
|
</setting-item-box>
|
||||||
|
|
||||||
<n-divider style="margin: 10px 0;"></n-divider>
|
|
||||||
|
|
||||||
<!-- 静态 -->
|
<!-- 静态 -->
|
||||||
<chart-data-static
|
<chart-data-static
|
||||||
v-if="targetData.request.requestDataType === RequestDataTypeEnum.STATIC"
|
v-if="targetData.request.requestDataType === RequestDataTypeEnum.STATIC"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user