Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: update download progress text effect and replace homepage component #55

Merged
merged 1 commit into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 23 additions & 9 deletions frontend/src/components/appcard/InstallButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
@mouseover="updateHover(true)"
@mouseleave="updateHover(false)"
dense
:percentage="item.progress ? Number(item.progress) : 0"
flat
no-caps
>
Expand All @@ -40,14 +39,14 @@
>
{{ status }}
</div>
<div
style="width: 100%; height: 100%"
class="row justify-center items-center"
<progress-button
ref="progressBar"
v-if="showDownloadProgress(item)"
>
<!-- <q-spinner-hourglass size="12px" style="margin-right: 4px"/>-->
{{ item.progress ? Number(item.progress) + '%' : '0%' }}
</div>
:progress="item.progress"
:covered-text-color="white"
:default-text-color="blueDefault"
:progress-bar-color="blueDefault"
/>
<div
v-if="
item.status === APP_STATUS.pending ||
Expand Down Expand Up @@ -154,6 +153,7 @@ import {
canSuspend
} from 'src/constants/config';
import { bus, BUS_EVENT } from 'src/utils/bus';
import ProgressButton from 'src/components/base/ProgressButton.vue';

const props = defineProps({
item: {
Expand Down Expand Up @@ -499,7 +499,6 @@ function updateUI() {
}
break;
case APP_STATUS.installing:
case APP_STATUS.downloading:
if (hoverRef.value && canInstallingCancel(props.item?.cfgType)) {
isLoading.value = false;
status.value = t('app.cancel');
Expand All @@ -514,6 +513,21 @@ function updateUI() {
border.value = '1px solid transparent';
}
break;
case APP_STATUS.downloading:
if (hoverRef.value && canInstallingCancel(props.item?.cfgType)) {
isLoading.value = false;
status.value = t('app.cancel');
textColor.value = blueDefault.value;
backgroundColor.value = background1.value;
border.value = `1px solid ${blueDefault.value}`;
} else {
isLoading.value = true;
status.value = t('app.installing');
textColor.value = white.value;
backgroundColor.value = blueAlpha.value;
border.value = '1px solid transparent';
}
break;
case APP_STATUS.initializing:
if (hoverRef.value && canInstallingCancel(props.item?.cfgType)) {
isLoading.value = false;
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/components/appcard/MyAppCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,8 @@ function goAppDetails() {

.my-application-title {
max-width: 70%;
overflow: hidden;
text-overflow: ellipsis;
}

.my-application-version {
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/components/base/AppStoreSwiper.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
:style="{ '--NavigationOffsite': `${navigationOffsite}px` }"
class="row justify-center items-center"
>
<!-- 自定义后退按钮 -->
<!-- custom back button -->
<div
class="button-left"
@click="customPrev"
Expand Down Expand Up @@ -43,7 +43,7 @@
</swiper-slide>
</swiper>

<!-- 自定义前进按钮 -->
<!-- custom forward button -->
<div
class="button-right"
@click="customNext"
Expand Down
250 changes: 186 additions & 64 deletions frontend/src/components/base/BtBanner.vue
Original file line number Diff line number Diff line change
@@ -1,93 +1,215 @@
<template>
<div class="banner-background justify-start items-center">
<q-carousel
class="banner-carousel"
animated
v-model="slide"
:autoplay="10000"
swipeable
infinite
keep-alive
transition-prev="slide-right"
transition-next="slide-left"
<div class="banner-root">
<!-- @autoplayTimeLeft="onAutoplayTimeLeft"-->
<swiper
:spaceBetween="30"
:centeredSlides="true"
:autoplay="{
delay: 2500,
disableOnInteraction: false
}"
:style="{ width: swiperSize + 'px' }"
:navigation="false"
:modules="modules"
class="banner-swiper"
@swiper="setSwiperRef"
@slideChange="onSlideChange"
>
<template v-for="item in size" :key="item">
<q-carousel-slide style="padding: 0" :name="item">
<slot name="slide" :index="item" />
</q-carousel-slide>
</template>
</q-carousel>

<div
v-if="size > 1"
class="cursor-pointer banner-navigation row justify-start items-center"
>
<template v-for="item in size" :key="item">
<div
:class="item === slide ? 'navigation-active' : 'navigation-normal'"
@click="changeActive(item)"
/>
</template>
</div>
<swiper-slide
class="banner-swiper-slide"
v-for="(item, index) in size"
:key="index"
>
<slot name="swiper" :index="index" />
</swiper-slide>
<div
v-if="size > 1"
class="cursor-pointer banner-navigation row justify-start items-center"
>
<template v-for="item in size" :key="item">
<div
:class="
item - 1 === currentSlide
? 'navigation-active'
: 'navigation-normal'
"
@click="changeActive(item)"
/>
</template>
</div>
<!-- <template #container-end>-->

<!-- <template v-for="(item, index) in size" :key="item">-->
<!-- -->
<!-- </template>-->

<!-- <div class="autoplay-progress">-->
<!-- <svg viewBox="0 0 48 48" ref="progressCircle">-->
<!-- <circle cx="24" cy="24" r="20" />-->
<!-- </svg>-->
<!-- <span ref="progressContent"></span>-->
<!-- </div>-->
<!-- </template>-->
</swiper>
</div>
</template>

<script lang="ts" setup>
import { ref } from 'vue';
import { onBeforeUnmount, onMounted, ref } from 'vue';
// Import Swiper Vue.js components
import { Swiper, SwiperSlide } from 'swiper/vue';

// Import Swiper styles
import 'swiper/css';
import 'swiper/css/navigation';
import 'swiper/css/autoplay';
import { Navigation, Autoplay } from 'swiper/modules';
import { useQuasar } from 'quasar';

const props = defineProps({
defineProps({
size: {
type: Number,
require: true
},
start: {
type: Number,
default: 1
}
});
// import required modules
const modules = [Navigation, Autoplay];
const $q = useQuasar();
// const progressCircle = ref<string | null>(null);
// const progressContent = ref<string | null>(null);
const swiperSize = ref();
let swiperRef: any = null;
let resizeTimer: NodeJS.Timeout | null = null;
const currentSlide = ref(0);
// const onAutoplayTimeLeft = (s, time, progress) => {
// progressCircle.value.style.setProperty('--progress', 1 - progress);
// progressContent.value.textContent = `${Math.ceil(time / 1000)}s`;
// };

const slide = ref(props.start);
const setSwiperRef = (swiper: any) => {
swiperRef = swiper;
};

const changeActive = (index: number) => {
slide.value = index;
swiperRef.slideTo(index);
};

function onSlideChange(swiper) {
currentSlide.value = swiper.activeIndex;
}

const resize = () => {
if (resizeTimer) {
clearTimeout(resizeTimer);
}
resizeTimer = setTimeout(function () {
updateSwiper();
}, 200);
};

const updateSwiper = () => {
if ($q.screen.width < 864) {
swiperSize.value = 800;
} else if ($q.screen.width < 1024) {
swiperSize.value = $q.screen.width - 88;
} else {
swiperSize.value = $q.screen.width - 208 - 88;
}
};

onMounted(async () => {
updateSwiper();
window.addEventListener('resize', resize);
});

onBeforeUnmount(() => {
window.removeEventListener('resize', resize);
});
</script>

<style scoped lang="scss">
.banner-background {
<style lang="scss" scoped>
.banner-root {
width: 100%;
height: 100%;
position: relative;
max-width: 100%;
height: auto;

.banner-carousel {
width: 100%;
.banner-swiper {
position: relative;
max-width: 100%;
height: 100%;
}

.banner-navigation {
width: auto;
height: 20px;
right: 64px;
bottom: 32px;
position: absolute;

.navigation-base {
height: 8px;
border-radius: 20px;
margin-right: 8px;
.banner-swiper-slide {
max-width: 100%;
text-align: center;
font-size: 18px;
background: #fff;
display: flex;
justify-content: center;
align-items: center;
}

.navigation-active {
@extend .navigation-base;
width: 32px;
background-color: #ffffff;
.banner-swiper-slide img {
display: block;
width: 100%;
height: 100%;
object-fit: cover;
}

.navigation-normal {
@extend .navigation-base;
width: 8px;
background: rgba(255, 255, 255, 0.4);
.banner-navigation {
width: auto;
height: 20px;
right: 44px;
bottom: 32px;
position: absolute;
z-index: 1000;

.navigation-base {
height: 8px;
border-radius: 20px;
margin-right: 8px;
}

.navigation-active {
@extend .navigation-base;
width: 32px;
background-color: #ffffff;
}

.navigation-normal {
@extend .navigation-base;
width: 8px;
background: rgba(255, 255, 255, 0.4);
}
}
}
}

//.autoplay-progress {
// position: absolute;
// right: 16px;
// bottom: 16px;
// z-index: 10;
// width: 48px;
// height: 48px;
// display: flex;
// align-items: center;
// justify-content: center;
// font-weight: bold;
// color: var(--swiper-theme-color);
//}
//
//.autoplay-progress svg {
// --progress: 0;
// position: absolute;
// left: 0;
// top: 0px;
// z-index: 10;
// width: 100%;
// height: 100%;
// stroke-width: 4px;
// stroke: var(--swiper-theme-color);
// fill: none;
// stroke-dashoffset: calc(125.6px * (1 - var(--progress)));
// stroke-dasharray: 125.6;
// transform: rotate(-90deg);
//}
</style>
Loading
Loading