feat: 一些优化,以及token消耗展示

This commit is contained in:
2025-06-29 01:25:42 +08:00
parent 2da3fe3b47
commit dfc817e3e3
8 changed files with 146 additions and 64 deletions

View File

@@ -7,37 +7,55 @@ export const matchMedia = (
if (type === "sm") {
if (window.matchMedia("(max-width: 767.98px)").matches) {
/* 窗口小于或等于 */
matchFunc?.()
matchFunc?.();
}
else {
mismatchFunc?.()
mismatchFunc?.();
}
}
else if (type === "md") {
if (window.matchMedia("(max-width: 992px)").matches) {
/* 窗口小于或等于 */
matchFunc?.()
matchFunc?.();
}
else {
mismatchFunc?.()
mismatchFunc?.();
}
}
else if (type === "lg") {
if (window.matchMedia("(max-width: 1200px)").matches) {
/* 窗口小于或等于 */
matchFunc?.()
matchFunc?.();
}
else {
mismatchFunc?.()
mismatchFunc?.();
}
}
else {
if (window.matchMedia(`(max-width: ${type}px)`).matches) {
/* 窗口小于或等于 */
matchFunc?.()
matchFunc?.();
}
else {
mismatchFunc?.()
mismatchFunc?.();
}
}
}
};
export const useWindowWidth = () => {
const width = ref(window.innerWidth);
const updateWidth = () => {
width.value = window.innerWidth;
};
onMounted(() => {
window.addEventListener("resize", updateWidth);
});
onUnmounted(() => {
window.removeEventListener("resize", updateWidth);
});
return width;
};