refactor: 优化首页移动端显示效果

This commit is contained in:
xlsea 2024-04-11 17:16:48 +08:00
parent b81e2a89ec
commit 15780d1894
3 changed files with 28 additions and 6 deletions

View File

@ -7,7 +7,6 @@ export {}
declare module 'vue' { declare module 'vue' {
export interface GlobalComponents { export interface GlobalComponents {
ACheckableTag: typeof import('ant-design-vue/es')['CheckableTag']
AppProvider: typeof import('./../components/common/app-provider.vue')['default'] AppProvider: typeof import('./../components/common/app-provider.vue')['default']
BetterScroll: typeof import('./../components/custom/better-scroll.vue')['default'] BetterScroll: typeof import('./../components/custom/better-scroll.vue')['default']
ButtonIcon: typeof import('./../components/custom/button-icon.vue')['default'] ButtonIcon: typeof import('./../components/custom/button-icon.vue')['default']
@ -34,7 +33,6 @@ declare module 'vue' {
IconMdiKeyboardEsc: typeof import('~icons/mdi/keyboard-esc')['default'] IconMdiKeyboardEsc: typeof import('~icons/mdi/keyboard-esc')['default']
IconMdiKeyboardReturn: typeof import('~icons/mdi/keyboard-return')['default'] IconMdiKeyboardReturn: typeof import('~icons/mdi/keyboard-return')['default']
IconMdiRefresh: typeof import('~icons/mdi/refresh')['default'] IconMdiRefresh: typeof import('~icons/mdi/refresh')['default']
'IconOui:appSpaces': typeof import('~icons/oui/app-spaces')['default']
IconUilSearch: typeof import('~icons/uil/search')['default'] IconUilSearch: typeof import('~icons/uil/search')['default']
LangSwitch: typeof import('./../components/common/lang-switch.vue')['default'] LangSwitch: typeof import('./../components/common/lang-switch.vue')['default']
LookForward: typeof import('./../components/custom/look-forward.vue')['default'] LookForward: typeof import('./../components/custom/look-forward.vue')['default']

View File

@ -58,7 +58,7 @@ const onUpdateType = (value: string) => {
<NSpace vertical :size="16"> <NSpace vertical :size="16">
<HeaderBanner /> <HeaderBanner />
<CardData :model-value="cardCount!" /> <CardData :model-value="cardCount!" />
<NCard :bordered="false" class="card-wrapper"> <NCard :bordered="false" class="card-wrapper p-t-136px xl:p-t-0">
<div class="relative"> <div class="relative">
<NTabs type="line" animated> <NTabs type="line" animated>
<NTabPane name="retryTask" :tab="$t('page.home.retryTask')"> <NTabPane name="retryTask" :tab="$t('page.home.retryTask')">
@ -68,7 +68,7 @@ const onUpdateType = (value: string) => {
<RetryTab :type="1" :line-params="tabParams" /> <RetryTab :type="1" :line-params="tabParams" />
</NTabPane> </NTabPane>
</NTabs> </NTabs>
<div class="absolute right-40px top-0 flex gap-16px"> <div class="absolute top--136px flex flex-wrap gap-16px xl:right-40px xl:top-0 xl:flex-nowrap">
<NRadioGroup v-model:value="tabParams.type" @update:value="onUpdateType"> <NRadioGroup v-model:value="tabParams.type" @update:value="onUpdateType">
<NRadioButton value="DAY" label="今日" /> <NRadioButton value="DAY" label="今日" />
<NRadioButton value="WEEK" label="最近一周" /> <NRadioButton value="WEEK" label="最近一周" />

View File

@ -1,5 +1,5 @@
<script setup lang="ts"> <script setup lang="ts">
import { computed } from 'vue'; import { computed, nextTick, onUnmounted, reactive } from 'vue';
import { createReusableTemplate } from '@vueuse/core'; import { createReusableTemplate } from '@vueuse/core';
import { useRouter } from 'vue-router'; import { useRouter } from 'vue-router';
import { $t } from '@/locales'; import { $t } from '@/locales';
@ -15,6 +15,30 @@ interface Props {
modelValue?: Api.Dashboard.CardCount; modelValue?: Api.Dashboard.CardCount;
} }
const state = reactive({ width: 0 });
const gridCol = computed(() => {
if (state.width >= 1600) {
return 4;
} else if (state.width >= 1024) {
return 2;
}
return 1;
});
const getState = () => {
state.width = document.documentElement.clientWidth;
};
nextTick(() => {
getState();
window.addEventListener('resize', getState);
});
onUnmounted(() => {
//
window.removeEventListener('resize', getState);
});
const props = withDefaults(defineProps<Props>(), { const props = withDefaults(defineProps<Props>(), {
modelValue: () => ({ modelValue: () => ({
jobTask: { jobTask: {
@ -189,7 +213,7 @@ function getGradientColor(color: CardData['color']) {
</DefineGradientBg> </DefineGradientBg>
<!-- define component end: GradientBg --> <!-- define component end: GradientBg -->
<NGrid cols="s:1 m:2 l:4" responsive="screen" :x-gap="16" :y-gap="16"> <NGrid :cols="gridCol" responsive="screen" :x-gap="16" :y-gap="16">
<NGi v-for="item in cardData" :key="item.key"> <NGi v-for="item in cardData" :key="item.key">
<NSpin :show="false"> <NSpin :show="false">
<GradientBg <GradientBg