Skip to content

Commit 1184d48

Browse files
committed
update charts
1 parent 62129af commit 1184d48

File tree

6 files changed

+244
-10
lines changed

6 files changed

+244
-10
lines changed

package-lock.json

Lines changed: 45 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"@vueuse/core": "^10.3.0",
1717
"axios": "^1.4.0",
1818
"crypto-js": "^4.1.1",
19+
"echarts": "^5.4.3",
1920
"nprogress": "^0.2.0",
2021
"vue": "^3.3.4",
2122
"vue-router": "^4.2.4"

src/components/AngelPowerChart.vue

Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
<script lang="ts" setup>
2+
import { useStorage } from "@vueuse/core"
3+
import * as echarts from "echarts"
4+
import {
5+
computed,
6+
nextTick,
7+
onMounted,
8+
onUnmounted,
9+
ref,
10+
toRefs,
11+
watch,
12+
} from "vue"
13+
14+
import { useDarkMode } from "../composables/useDarkMode"
15+
16+
import type { ECharts } from "echarts"
17+
import type { AngelDataObject } from "../share"
18+
19+
const $props = defineProps<{
20+
angel: AngelDataObject
21+
}>()
22+
const { angel } = toRefs($props)
23+
24+
const chart = ref<ECharts | null>(null)
25+
const chartBody = ref<HTMLDivElement>()
26+
const isMini = useStorage("rocox-mini", true)
27+
const { isDarkMode } = useDarkMode()
28+
29+
const init = () => {
30+
chart.value = echarts.init(chartBody.value, "", {
31+
renderer: "svg",
32+
...bounding.value,
33+
})
34+
chart.value.setOption(opt.value)
35+
}
36+
37+
const bounding = computed(() => ({
38+
width: isMini.value ? 160 : 256,
39+
height: isMini.value ? 160 : 256,
40+
}))
41+
const chartValues = computed(() => [
42+
angel.value.wg,
43+
angel.value.mg,
44+
angel.value.fy,
45+
angel.value.mk,
46+
angel.value.sm,
47+
angel.value.sd,
48+
])
49+
const optTitleColor = computed(() => (isDarkMode.value ? "#ccc" : "#333"))
50+
const optTextColor = computed(() => (isDarkMode.value ? "#aaa" : "#555"))
51+
const optBlurBg = computed(() =>
52+
isDarkMode.value ? "rgba(32, 32, 32, 0.5)" : "rgba(255, 255, 255, 0.5)"
53+
)
54+
const opt = computed(() => ({
55+
title: {
56+
text: isMini.value ? angel.value.add : "种族值",
57+
subtext: isMini.value ? undefined : angel.value.add,
58+
textStyle: {
59+
color: optTitleColor.value,
60+
},
61+
},
62+
tooltip: {
63+
show: true,
64+
position: isMini.value ? ["-70%", "-5%"] : undefined,
65+
hideDelay: 500,
66+
confine: !isMini.value,
67+
className: "tooltip",
68+
backgroundColor: optBlurBg.value,
69+
textStyle: {
70+
color: optTextColor.value,
71+
fontSize: isMini.value ? 12 : 14,
72+
},
73+
},
74+
animationDuration: 300,
75+
radar: {
76+
center: ["50%", "50%"],
77+
nameGap: 5,
78+
slient: true,
79+
indicator: [
80+
{ name: `物攻`, min: 0, max: 200, color: optTextColor.value },
81+
{ name: `魔攻`, min: 0, max: 200, color: optTextColor.value },
82+
{ name: `物抗`, min: 0, max: 200, color: optTextColor.value },
83+
{ name: `魔抗`, min: 0, max: 200, color: optTextColor.value },
84+
{ name: `精力`, min: 0, max: 200, color: optTextColor.value },
85+
{ name: `速度`, min: 0, max: 200, color: optTextColor.value },
86+
],
87+
axisLine: {
88+
show: false,
89+
},
90+
splitLine: {
91+
show: true,
92+
lineStyle: {
93+
color: optTextColor.value,
94+
width: 2,
95+
},
96+
},
97+
},
98+
series: [
99+
{
100+
name: "种族值",
101+
type: "radar",
102+
select: {
103+
disabled: true,
104+
selectedMode: "single",
105+
},
106+
data: [
107+
{
108+
value: chartValues.value,
109+
tooltip: chartValues.value,
110+
},
111+
],
112+
},
113+
],
114+
}))
115+
116+
onMounted(() => {
117+
watch(
118+
opt,
119+
() => {
120+
if (!chart.value) {
121+
} else chart.value?.dispose()
122+
123+
nextTick(() => {
124+
init()
125+
chart.value?.on("mouseover", (data) => {
126+
console.log(data)
127+
})
128+
})
129+
},
130+
{
131+
immediate: true,
132+
deep: true,
133+
}
134+
)
135+
})
136+
onUnmounted(() => {
137+
if (chart.value !== null) chart.value.dispose()
138+
})
139+
</script>
140+
141+
<template>
142+
<div class="chart-container">
143+
<div id="power-chart" ref="chartBody"></div>
144+
</div>
145+
</template>
146+
147+
<style lang="postcss" scoped>
148+
.chart-container {
149+
@apply flex items-center justify-center w-48 h-48
150+
rounded-md dark:bg-slate-800
151+
transition-all ease-in-out duration-300;
152+
153+
@apply sm:w-72 sm:h-72;
154+
}
155+
#power-chart {
156+
@apply w-40 h-40;
157+
@apply sm:w-64 sm:h-64;
158+
}
159+
#power-chart div {
160+
@apply overflow-auto;
161+
}
162+
</style>
163+
<style lang="postcss">
164+
.tooltip {
165+
@apply backdrop-blur;
166+
}
167+
</style>

src/components/native/TitleBar.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ const throttleToggleIspinned = useThrottleFn(() => {
9393
toggleIspinned()
9494
}, 800)
9595
const throttleToggleMini = useThrottleFn(async () => {
96-
toggleMiniWindow()
96+
await toggleMiniWindow(!isMini.value)
9797
}, 800)
9898
9999
function minimize() {
@@ -218,6 +218,8 @@ onMounted(async () => {
218218
bg-slate-100 dark:bg-slate-900 text-slate-600 dark:text-slate-200
219219
transition-all
220220
select-none;
221+
222+
z-index: 99999999;
221223
}
222224
223225
.title {

src/composables/useWindow.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export const toggleMiniWindow = async (symbol?: boolean) => {
5959
const isMini = useStorage("rocox-mini", true)
6060
let size =
6161
symbol !== undefined
62-
? boundings[symbol ? 1 : 0]
62+
? boundings[symbol ? 0 : 1]
6363
: boundings[isMini.value ? 0 : 1]
6464

6565
await appWindow.setSize(new LogicalSize(size.width, size.height))

0 commit comments

Comments
 (0)