update pagination

This commit is contained in:
AceDataCloud committed 2023-01-02 02:51:47 +08:00
1 parent 89461c8b1a
commit f3fb5ba6fd
12 files changed
+155 -30

No files matched your search

+13 -1
View File
@@ -1,11 +1,23 @@
<template>
<router-view />
<el-config-provider :locale="locale">
<router-view />
</el-config-provider>
</template>
<script lang="ts">
import { defineComponent } from 'vue';
import { ElConfigProvider } from 'element-plus';
import zhCn from 'element-plus/dist/locale/zh-cn.mjs';
export default defineComponent({
components: {
ElConfigProvider
},
data() {
return {
locale: zhCn
};
},
mounted() {
this.$store.dispatch('getMe');
}
+1 -1
View File
@@ -2,7 +2,7 @@
<el-card v-if="application && service" shadow="hover" class="card">
<div class="item">
<div class="icon">
<font-awesome-icon :icon="'fa-regular fa-' + service.icon" />
<font-awesome-icon v-if="service.icon" :icon="service.icon" />
</div>
<div class="main">
<div class="title">
+2 -2
View File
@@ -6,8 +6,8 @@
<el-col :span="12" :offset="6" class="p-t text-center">
<p>
<span
><a href="https://academy.zhishuyun.com">{{ $t('common.entity.website') }}</a> ©
{{ new Date().getFullYear() }} {{ $t('common.entity.copyright') }}
><a href="https://zhishuyun.com">{{ $t('common.entity.website') }}</a> © {{ new Date().getFullYear() }}
{{ $t('common.entity.copyright') }}
</span>
<span class="ml-2">
<a href="https://beian.miit.gov.cn/">京ICP备18021371号-2 </a>
+7 -1
View File
@@ -7,7 +7,7 @@
<el-row>
<el-col :span="20">
<el-menu :default-active="active" class="el-menu-demo" mode="horizontal" @select="onSelect">
<el-menu-item v-t="'common.nav.course'" index="/courses"></el-menu-item>
<el-menu-item v-t="'common.nav.service'" index="/services"></el-menu-item>
<!-- <el-menu-item v-t="'common.nav.category'" index="/categories"></el-menu-item> -->
</el-menu>
</el-col>
@@ -22,6 +22,7 @@
<img :src="user?.avatar || defaultAvatar" class="avatar" />
<template #dropdown>
<el-dropdown-menu>
<el-dropdown-item @click="onConsole">{{ $t('common.button.console') }}</el-dropdown-item>
<el-dropdown-item @click="onProfile">{{ $t('common.button.profile') }}</el-dropdown-item>
<el-dropdown-item @click="onVerify">{{ $t('common.button.verify') }}</el-dropdown-item>
<el-dropdown-item @click="onLogout">{{ $t('common.button.logout') }}</el-dropdown-item>
@@ -74,6 +75,11 @@ export default defineComponent({
onVerify() {
window.location.href = 'https://auth.test.zhishuyun.com/user/verify';
},
onConsole() {
this.$router.push({
name: 'console-application-list'
});
},
onLogout() {
this.$store.dispatch('resetAuth');
this.$router.push('/');
+3
View File
@@ -1,5 +1,8 @@
/// <reference types="vite/client" />
declare module 'element-ui/*';
declare module '*.mjs';
declare module '*.vue' {
import { DefineComponent } from 'vue';
const component: DefineComponent<{}, {}, {}>;
+1
View File
@@ -13,6 +13,7 @@ export default {
watch: '观看',
verify: '实名认证',
profile: '个人信息',
console: '控制台',
learn: '学习',
buy: '购买'
};
+2 -1
View File
@@ -6,5 +6,6 @@ export default {
article: '文章',
publication: '发布',
course: '课程',
category: '分类'
category: '分类',
service: '服务'
};
+10 -7
View File
@@ -1,10 +1,10 @@
<template>
<el-container>
<el-header>
<el-container class="wrapper">
<el-header class="header">
<top-header />
</el-header>
<el-main> <router-view /> </el-main>
<el-footer>
<el-main class="main"> <router-view /> </el-main>
<el-footer class="footer">
<bottom-footer />
</el-footer>
</el-container>
@@ -22,9 +22,12 @@ export default {
};
</script>
<style lang="scss">
.el-header,
.el-footer {
<style lang="scss" scoped>
.wrapper {
min-height: 100vh;
}
.header {
padding: 0;
}
</style>
+10 -2
View File
@@ -1,12 +1,20 @@
import { AxiosResponse } from 'axios';
import { decamelizeKeys } from 'humps';
import { httpClient } from '../instance';
import { IService, IServiceDetailResponse, IServiceListResponse } from './models';
export interface IServiceQuery {
limit: number;
offset: number;
}
class ServiceOperator {
key = 'services';
async getAll(): Promise<AxiosResponse<IServiceListResponse>> {
return await httpClient.get(`/${this.key}/`);
async getAll(query: IServiceQuery): Promise<AxiosResponse<IServiceListResponse>> {
return await httpClient.get(`/${this.key}/`, {
params: decamelizeKeys(query)
});
}
async get(id: string): Promise<AxiosResponse<IServiceDetailResponse>> {
+5
View File
@@ -124,6 +124,11 @@ export default defineComponent({
.catch((error) => {
if (error?.response?.data?.code === ERROR_CODE_DUPLICATION) {
ElMessage.error(this.$t('application.message.alreadyApplied'));
setTimeout(() => {
this.$router.push({
name: 'console-application-list'
});
}, 2000);
}
});
}
+91 -12
View File
@@ -1,11 +1,24 @@
<template>
<el-row>
<el-col :span="20" :offset="2">
<el-row :gutter="15" class="services">
<el-col v-for="(service, serviceIndex) in services" :key="serviceIndex" :md="6" :xs="24">
<el-row v-if="loading" :gutter="15" class="services">
<el-col v-for="_ in 8" :key="_" :lg="6" :md="8" :sm="12" :xs="24">
<el-card shadow="hover" class="service">
<el-skeleton>
<template #template>
<el-skeleton-item variant="image" class="icon-placeholder" />
<el-skeleton-item variant="p" class="title-placeholder" />
<el-skeleton-item variant="p" class="price-placeholder" />
</template>
</el-skeleton>
</el-card>
</el-col>
</el-row>
<el-row v-else :gutter="15" class="services">
<el-col v-for="(service, serviceIndex) in services" :key="serviceIndex" :lg="6" :md="8" :sm="12" :xs="24">
<el-card shadow="hover" class="service">
<div class="icon">
<font-awesome-icon :icon="'fa-regular fa-' + service.icon" />
<font-awesome-icon v-if="service.icon" :icon="service.icon" />
</div>
<div class="title">{{ service.title }}</div>
<div class="price">
@@ -38,6 +51,21 @@
</el-card>
</el-col>
</el-row>
<el-row>
<el-col :span="10" :offset="14">
<div class="pagination m-v-lg">
<el-pagination
v-model:current-page="page"
background
:page-size="limit"
layout="total, prev, pager, next"
:total="total"
@current-change="onPageChange"
>
</el-pagination>
</div>
</el-col>
</el-row>
</el-col>
</el-row>
</template>
@@ -46,11 +74,13 @@
import { serviceOperator, IService, IServiceListResponse } from '@/operators';
import { defineComponent } from 'vue';
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
import { ElForm, ElMessage } from 'element-plus';
interface IData {
services: IService[];
loading: boolean;
total: number | undefined;
limit: number;
page: number;
}
export default defineComponent({
name: 'ServiceList',
@@ -60,16 +90,39 @@ export default defineComponent({
data(): IData {
return {
services: [],
loading: false
loading: true,
total: undefined,
limit: 8,
page: parseInt(this.$route.query.page?.toString() || '1')
};
},
async mounted() {
this.loading = true;
console.debug('start to load all services');
serviceOperator.getAll().then(({ data: data }: { data: IServiceListResponse }) => {
this.services = data.items;
this.loading = false;
});
this.onFetchData();
},
methods: {
onPageChange(page: number) {
this.$router.push({
name: this.$route.name?.toString(),
query: {
page: page
}
});
this.onFetchData();
},
onFetchData() {
this.loading = true;
console.debug('start to load all services');
serviceOperator
.getAll({
limit: this.limit,
offset: (this.page - 1) * this.limit
})
.then(({ data: data }: { data: IServiceListResponse }) => {
this.services = data.items;
this.total = data.count;
this.loading = false;
});
}
}
});
</script>
@@ -77,7 +130,7 @@ export default defineComponent({
<style lang="scss" scoped>
$transition-duration: 0.5s;
.services {
padding: 50px;
padding: 50px 0;
.service {
width: 100%;
height: 280px;
@@ -87,6 +140,28 @@ $transition-duration: 0.5s;
position: relative;
transition: all $transition-duration;
.icon-placeholder {
display: flex;
width: 80px;
height: 80px;
margin: 0 auto 15px auto;
text-align: center;
}
.title-placeholder {
display: block;
width: 80px;
height: 20px;
margin: 0 auto 10px auto;
}
.price-placeholder {
display: block;
width: 100px;
height: 16px;
margin: 0 auto 10px auto;
}
.icon {
font-size: 60px;
text-align: center;
@@ -154,4 +229,8 @@ $transition-duration: 0.5s;
}
}
}
.pagination {
padding-bottom: 50px;
float: right;
}
</style>
+10 -3
View File
@@ -1,9 +1,16 @@
import { library } from '@fortawesome/fontawesome-svg-core';
import * as icons from '@fortawesome/free-regular-svg-icons';
import * as iconsRegular from '@fortawesome/free-regular-svg-icons';
import * as iconsSolid from '@fortawesome/free-solid-svg-icons';
// register all icons from font awesome
for (const key in icons) {
for (const key in iconsRegular) {
//@ts-ignore
const icon = icons[key];
const icon = iconsRegular[key];
if (icon?.iconName) library.add(icon);
}
for (const key in iconsSolid) {
//@ts-ignore
const icon = iconsSolid[key];
if (icon?.iconName) library.add(icon);
}