提交 e6464ca7 编写于 作者: View Design's avatar View Design

图表

上级 3d076287
...@@ -30,7 +30,7 @@ const errorTitle = computed(() => { ...@@ -30,7 +30,7 @@ const errorTitle = computed(() => {
if (!title) { if (!title) {
const code = props.code const code = props.code
if (code === 404) title = 'Not found' if (code === 404) title = 'Not found'
else if (code === 500) title = 'Error' else if (code === 500 || code === 502) title = 'Error'
else if (code === 403) title= 'Forbidden' else if (code === 403) title= 'Forbidden'
} }
return title return title
...@@ -40,7 +40,7 @@ const errorDescription = computed(() => { ...@@ -40,7 +40,7 @@ const errorDescription = computed(() => {
if (!description) { if (!description) {
const code = props.code const code = props.code
if (code === 404) description = '抱歉,当前访问的内容不存在或被删除' if (code === 404) description = '抱歉,当前访问的内容不存在或被删除'
else if (code === 500) description = '抱歉,当前内容出现错误' else if (code === 500 || code === 502) description = '抱歉,当前内容出现错误'
else if (code === 403) description= '抱歉,您没有权限访问当前内容' else if (code === 403) description= '抱歉,您没有权限访问当前内容'
} }
return description return description
......
...@@ -8,16 +8,17 @@ ...@@ -8,16 +8,17 @@
<template v-if="item.ready"> <template v-if="item.ready">
<template v-if="item.type === 'search_relate_repo'"> <template v-if="item.type === 'search_relate_repo'">
<template v-if="item.data.length"> <template v-if="item.data.length">
<UCard :ui="cardUI"> <template v-for="(chart, cIndex) in item.data" :key="cIndex">
<ProseChart <UCard :ui="cardUI">
type="line" <ProseChart
title="Star 数据" type="line"
:labels="item.labels" :labels="item.labels"
:data="item.data" :data="item.data"
:info="item.info" :info="item.info"
simple simple
/> />
</UCard> </UCard>
</template>
</template> </template>
<template v-else> <template v-else>
<UCard :ui="cardUI"> <UCard :ui="cardUI">
......
<template> <template>
<div class="w-full relative" style="aspect-ratio: 2/1"> <template v-if="info">
<canvas ref="refChart" :aria-label="title"></canvas>
</div>
<template v-if="info.length">
<div class="mt-2 flex flex-col gap-1"> <div class="mt-2 flex flex-col gap-1">
<template v-for="item in info" :key="item.name"> <div class="flex items-center gap-1 text-sm">
<div class="flex items-center gap-1 text-sm"> <UIcon class="flex-shrink-0" name="i-simple-icons-github" />
<UIcon class="flex-shrink-0" name="i-simple-icons-github" /> <ULink class="line-clamp-1 underline" :to="info.url" target="_blank" :title="info.description">{{ info.name }}</ULink>
<ULink class="line-clamp-1 underline" :to="item.url" target="_blank" :title="item.description">{{ item.name }}</ULink> <UIcon class="flex-shrink-0" name="i-heroicons-arrow-top-right-on-square" />
<UIcon class="flex-shrink-0" name="i-heroicons-arrow-top-right-on-square" /> </div>
</div>
</template>
</div> </div>
</template> </template>
<div class="w-full relative" style="aspect-ratio: 2/1">
<canvas ref="refChart" :aria-label="title"></canvas>
</div>
</template> </template>
<script setup> <script setup>
import { Chart } from 'chart.js/auto'; import { Chart } from 'chart.js/auto';
...@@ -40,8 +38,8 @@ const props = defineProps({ ...@@ -40,8 +38,8 @@ const props = defineProps({
default: false default: false
}, },
info: { info: {
type: Array, type: Object,
default: () => [] default: () => {}
} }
}) })
const refChart = ref(null) const refChart = ref(null)
...@@ -68,7 +66,7 @@ function init () { ...@@ -68,7 +66,7 @@ function init () {
maintainAspectRatio: false, maintainAspectRatio: false,
plugins: { plugins: {
title: { title: {
display: true, display: !props.simple,
text: props.title, text: props.title,
font: { font: {
size: 14, size: 14,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册