fix: radial bar chart style broken in 1.3k-1.7k px window

This commit is contained in:
Jacky 2024-06-24 23:37:59 +08:00
parent 6f349aa12a
commit 7d5104e550
No known key found for this signature in database
GPG key ID: 215C21B10DF38B4D
4 changed files with 31 additions and 24 deletions

View file

@ -4,6 +4,7 @@ import (
"github.com/0xJacky/Nginx-UI/api" "github.com/0xJacky/Nginx-UI/api"
"github.com/0xJacky/Nginx-UI/model" "github.com/0xJacky/Nginx-UI/model"
"net/http" "net/http"
"time"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"golang.org/x/crypto/bcrypt" "golang.org/x/crypto/bcrypt"
@ -29,6 +30,7 @@ func Login(c *gin.Context) {
u, _ := model.GetUser(user.Name) u, _ := model.GetUser(user.Name)
if err := bcrypt.CompareHashAndPassword([]byte(u.Password), []byte(user.Password)); err != nil { if err := bcrypt.CompareHashAndPassword([]byte(u.Password), []byte(user.Password)); err != nil {
time.Sleep(5 * time.Second)
c.JSON(http.StatusForbidden, gin.H{ c.JSON(http.StatusForbidden, gin.H{
"message": "The username or password is incorrect", "message": "The username or password is incorrect",
}) })

View file

@ -1,25 +1,28 @@
<script setup lang="ts"> <script setup lang="ts">
import VueApexCharts from 'vue3-apexcharts' import VueApexCharts from 'vue3-apexcharts'
import { reactive } from 'vue'
import { storeToRefs } from 'pinia' import { storeToRefs } from 'pinia'
import { useSettingsStore } from '@/pinia' import { useSettingsStore } from '@/pinia'
import type { Series } from '@/components/Chart/types' import type { Series } from '@/components/Chart/types'
const { series, centerText, colors, name, bottomText } const props = defineProps<{
= defineProps<{ series: Series[] | number[]
series: Series[] | number[] centerText?: string
centerText?: string colors?: string
colors?: string name?: string
name?: string bottomText?: string
bottomText?: string }>()
}>()
const settings = useSettingsStore() const settings = useSettingsStore()
const { theme } = storeToRefs(settings) const { theme } = storeToRefs(settings)
const chartOptions = reactive({ const fontColor = () => {
series, return theme.value === 'dark' ? '#fcfcfc' : undefined
}
const chartOptions = computed(() => ({
series: props.series,
chart: { chart: {
type: 'radialBar', type: 'radialBar',
offsetY: 0, offsetY: 0,
@ -31,24 +34,24 @@ const chartOptions = reactive({
dataLabels: { dataLabels: {
name: { name: {
fontSize: '14px', fontSize: '14px',
color: colors, color: props.colors,
offsetY: 36, offsetY: 36,
}, },
value: { value: {
offsetY: 50, offsetY: -12,
fontSize: '14px', fontSize: '14px',
color: undefined, color: fontColor(),
formatter: () => { formatter: () => {
return '' return props.centerText
}, },
}, },
}, },
}, },
}, },
fill: { fill: {
colors, colors: props.colors,
}, },
labels: [name], labels: [props.name],
states: { states: {
hover: { hover: {
filter: { filter: {
@ -61,7 +64,7 @@ const chartOptions = reactive({
}, },
}, },
}, },
}) }))
</script> </script>
<template> <template>
@ -70,9 +73,6 @@ const chartOptions = reactive({
:key="theme" :key="theme"
class="radial-bar-container" class="radial-bar-container"
> >
<p class="text">
{{ centerText }}
</p>
<p class="bottom_text"> <p class="bottom_text">
{{ bottomText }} {{ bottomText }}
</p> </p>
@ -96,6 +96,9 @@ const chartOptions = reactive({
.radialBar { .radialBar {
position: absolute; position: absolute;
top: -30px; top: -30px;
@media (max-width: 1700px) and (min-width: 1200px) {
top: -10px;
}
@media (max-width: 768px) and (min-width: 290px) { @media (max-width: 768px) and (min-width: 290px) {
left: 50%; left: 50%;
transform: translateX(-50%); transform: translateX(-50%);
@ -104,7 +107,6 @@ const chartOptions = reactive({
.text { .text {
position: absolute; position: absolute;
top: calc(50% - 5px);
width: 100%; width: 100%;
text-align: center; text-align: center;
} }
@ -112,6 +114,9 @@ const chartOptions = reactive({
.bottom_text { .bottom_text {
position: absolute; position: absolute;
top: calc(106px); top: calc(106px);
@media (max-width: 1300px) and (min-width: 1200px) {
top: calc(96px);
}
font-weight: 600; font-weight: 600;
width: 100%; width: 100%;
text-align: center; text-align: center;

View file

@ -1 +1 @@
{"version":"2.0.0-beta.25","build_id":137,"total_build":341} {"version":"2.0.0-beta.25","build_id":138,"total_build":342}

View file

@ -1 +1 @@
{"version":"2.0.0-beta.25","build_id":137,"total_build":341} {"version":"2.0.0-beta.25","build_id":138,"total_build":342}