update index and detail of course
This commit is contained in:
1 parent
bee5606474
commit
344fd73833
13 files changed
+325
-12
No files matched your search
@@ -9,13 +9,16 @@ body {
|
||||
}
|
||||
|
||||
#app {
|
||||
background-color: #f8f9fe;
|
||||
background-color: #f7f8fc;
|
||||
|
||||
.el-main {
|
||||
padding: 0 !important;
|
||||
}
|
||||
|
||||
.el-card {
|
||||
word-wrap: break-word;
|
||||
border-radius: 0.375rem;
|
||||
border: 1px solid rgba(0, 0, 0, 0.05);
|
||||
box-shadow: 0 0 2rem 0 rgba(136, 152, 170, 0.15) !important;
|
||||
border: none;
|
||||
}
|
||||
|
||||
.el-menu-item.is-active {
|
||||
@@ -26,4 +29,8 @@ body {
|
||||
.el-breadcrumb__inner.is-link {
|
||||
color: var(--el-text-color-regular);
|
||||
}
|
||||
|
||||
.el-button {
|
||||
border-radius: 9999px;
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,11 @@
|
||||
@forward 'element-plus/theme-chalk/src/common/var.scss' with (
|
||||
$colors: (
|
||||
'danger': (
|
||||
'base': #ec4450
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
$--font-path: 'element-plus/theme-chalk/src/fonts';
|
||||
|
||||
@import 'element-plus/theme-chalk/src/index.scss';
|
||||
@@ -0,0 +1,3 @@
|
||||
export default {
|
||||
startStudy: '开始学习'
|
||||
};
|
||||
@@ -0,0 +1,5 @@
|
||||
import button from './button';
|
||||
|
||||
export default {
|
||||
button
|
||||
};
|
||||
@@ -1,7 +1,9 @@
|
||||
import common from './common/index';
|
||||
import auth from './auth/index';
|
||||
import course from './course/index';
|
||||
|
||||
export default {
|
||||
common,
|
||||
auth
|
||||
auth,
|
||||
course
|
||||
};
|
||||
@@ -4,7 +4,6 @@
|
||||
<top-header />
|
||||
</el-header>
|
||||
<el-container>
|
||||
<el-aside width="200px"> side</el-aside>
|
||||
<el-main> <router-view /> </el-main>
|
||||
</el-container>
|
||||
</el-container>
|
||||
|
||||
@@ -0,0 +1,107 @@
|
||||
<template>
|
||||
<el-row>
|
||||
<el-col :span="24">
|
||||
<div class="wrapper">
|
||||
<div class="container">
|
||||
<el-row v-if="course">
|
||||
<el-col :span="6"
|
||||
><div class="thumbnail">
|
||||
<img :src="course.thumbnail" />
|
||||
</div>
|
||||
</el-col>
|
||||
<el-col :span="10">
|
||||
<div class="title mb-5">
|
||||
<p>{{ course.title }}</p>
|
||||
</div>
|
||||
<div class="introduction mb-5">
|
||||
<p>{{ course.introduction }}</p>
|
||||
</div>
|
||||
</el-col>
|
||||
<el-col :span="8"> </el-col>
|
||||
</el-row>
|
||||
</div>
|
||||
</div>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row>
|
||||
<el-col :span="24">
|
||||
<div class="banner"></div>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { courseService } from '@/services/course/service';
|
||||
import { ICourse, ICourseDetailResponse } from '@/services/course/types';
|
||||
import { defineComponent } from 'vue';
|
||||
interface IData {
|
||||
course: ICourse | undefined;
|
||||
loading: boolean;
|
||||
id: number;
|
||||
}
|
||||
export default defineComponent({
|
||||
name: 'CourseList',
|
||||
data(): IData {
|
||||
return {
|
||||
id: parseInt(this.$route.params.id.toString()),
|
||||
course: undefined,
|
||||
loading: false
|
||||
};
|
||||
},
|
||||
async mounted() {
|
||||
this.loading = true;
|
||||
courseService.get(this.id).then(({ data: data }: { data: ICourseDetailResponse }) => {
|
||||
this.loading = false;
|
||||
this.course = data;
|
||||
});
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.wrapper {
|
||||
width: 100%;
|
||||
height: 500px;
|
||||
background-image: radial-gradient(circle at 0 2%, #283e63, #172337 99%);
|
||||
.container {
|
||||
width: 1200px;
|
||||
margin: auto;
|
||||
padding-top: 50px;
|
||||
|
||||
.title {
|
||||
p {
|
||||
font-weight: bold;
|
||||
color: white;
|
||||
font-size: 2.4rem;
|
||||
}
|
||||
}
|
||||
.introduction {
|
||||
p {
|
||||
color: white;
|
||||
font-size: 1rem;
|
||||
}
|
||||
}
|
||||
.thumbnail {
|
||||
text-align: center;
|
||||
img {
|
||||
pointer-events: none;
|
||||
width: 200px;
|
||||
height: 200px;
|
||||
margin-top: 50px;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.banner {
|
||||
border-bottom-left-radius: 28px;
|
||||
border-bottom-right-radius: 28px;
|
||||
background: linear-gradient(270deg, #f44881, #ec454f);
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
width: 100%;
|
||||
height: 55px;
|
||||
}
|
||||
</style>
|
||||
+115
-3
@@ -1,5 +1,117 @@
|
||||
<template>
|
||||
<div>
|
||||
<h1>Course List</h1>
|
||||
</div>
|
||||
<el-row>
|
||||
<el-col :span="20" :offset="2">
|
||||
<div class="courses">
|
||||
<el-card shadow="hover" class="course" v-for="course in courses">
|
||||
<div class="content">
|
||||
<div class="tags mb-5">
|
||||
<el-button size="small" type="danger" class="tag" v-for="tag in course.tags">{{ tag }}</el-button>
|
||||
</div>
|
||||
<div class="title mb-5">
|
||||
<p>{{ course.title }}</p>
|
||||
</div>
|
||||
<div class="introduction mb-5">
|
||||
<p>{{ course.introduction }}</p>
|
||||
</div>
|
||||
<div class="study">
|
||||
<router-link
|
||||
:to="{
|
||||
name: 'course-detail',
|
||||
params: {
|
||||
id: course.id
|
||||
}
|
||||
}"
|
||||
>
|
||||
<el-button>
|
||||
{{ $t('course.button.startStudy') }}
|
||||
</el-button>
|
||||
</router-link>
|
||||
</div>
|
||||
</div>
|
||||
<div class="thumbnail">
|
||||
<img :src="course.thumbnail" />
|
||||
</div>
|
||||
</el-card>
|
||||
</div>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { courseService } from '@/services/course/service';
|
||||
import { ICourse, ICourseListResponse } from '@/services/course/types';
|
||||
import { defineComponent } from 'vue';
|
||||
interface IData {
|
||||
courses: ICourse[];
|
||||
loading: boolean;
|
||||
}
|
||||
export default defineComponent({
|
||||
name: 'CourseList',
|
||||
data(): IData {
|
||||
return {
|
||||
courses: [],
|
||||
loading: false
|
||||
};
|
||||
},
|
||||
async mounted() {
|
||||
this.loading = true;
|
||||
courseService.getAll().then(({ data: data }: { data: ICourseListResponse }) => {
|
||||
this.courses = data.items;
|
||||
this.loading = false;
|
||||
});
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.courses {
|
||||
.course {
|
||||
width: 1200px;
|
||||
height: 360px;
|
||||
border-radius: 0.9rem !important;
|
||||
margin: 2rem auto;
|
||||
padding: 2rem 3rem;
|
||||
position: relative;
|
||||
.content {
|
||||
max-width: 650px;
|
||||
}
|
||||
|
||||
.tags {
|
||||
.tag {
|
||||
padding-left: 20px;
|
||||
padding-right: 20px;
|
||||
}
|
||||
}
|
||||
|
||||
.title {
|
||||
p {
|
||||
font-size: 1.7rem;
|
||||
}
|
||||
}
|
||||
.introduction {
|
||||
p {
|
||||
font-size: 1rem;
|
||||
color: rgb(96 111 123);
|
||||
}
|
||||
}
|
||||
.thumbnail {
|
||||
img {
|
||||
position: absolute;
|
||||
right: -165px;
|
||||
margin-top: -50px;
|
||||
max-width: 80%;
|
||||
pointer-events: none;
|
||||
top: 0;
|
||||
width: 500px;
|
||||
height: 500px;
|
||||
}
|
||||
}
|
||||
.study {
|
||||
.el-button {
|
||||
padding-left: 30px;
|
||||
padding-right: 30px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -1,6 +1,6 @@
|
||||
export default {
|
||||
path: '/course',
|
||||
name: 'course',
|
||||
path: '/courses',
|
||||
name: 'courses',
|
||||
meta: {
|
||||
auth: true
|
||||
},
|
||||
@@ -10,6 +10,11 @@ export default {
|
||||
path: '',
|
||||
name: 'course-list',
|
||||
component: () => import('@/pages/course/List.vue')
|
||||
},
|
||||
{
|
||||
path: ':id',
|
||||
name: 'course-detail',
|
||||
component: () => import('@/pages/course/Detail.vue')
|
||||
}
|
||||
]
|
||||
};
|
||||
+9
-1
@@ -3,7 +3,15 @@ import auth from './auth';
|
||||
import course from './course';
|
||||
import store from '@/store';
|
||||
|
||||
const routes = [auth, course];
|
||||
const routes = [
|
||||
{
|
||||
path: '/',
|
||||
name: 'index',
|
||||
redirect: '/courses'
|
||||
},
|
||||
auth,
|
||||
course
|
||||
];
|
||||
|
||||
const router = createRouter({
|
||||
history: createWebHistory(),
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
import { AxiosResponse } from 'axios';
|
||||
import httpClient from '../instance';
|
||||
import { ICourse, ICourseDetailResponse, ICourseListResponse } from './types';
|
||||
|
||||
class CourseService {
|
||||
key = 'courses';
|
||||
|
||||
async getAll(): Promise<AxiosResponse<ICourseListResponse>> {
|
||||
return await httpClient.get(`/${this.key}/`);
|
||||
}
|
||||
|
||||
async get(id: number): Promise<AxiosResponse<ICourseDetailResponse>> {
|
||||
return await httpClient.get(`/${this.key}/${id}`);
|
||||
}
|
||||
|
||||
async create(data: ICourse): Promise<AxiosResponse<ICourseDetailResponse>> {
|
||||
return await httpClient.post(`/${this.key}/`, data);
|
||||
}
|
||||
|
||||
async update(id: number, data: ICourse): Promise<AxiosResponse<ICourseDetailResponse>> {
|
||||
return await httpClient.put(`/${this.key}/${id}`, data);
|
||||
}
|
||||
|
||||
async delete(id: number): Promise<AxiosResponse<null>> {
|
||||
return await httpClient.delete(`/${this.key}/${id}`);
|
||||
}
|
||||
|
||||
async createForTeacher(teacherId: number, data: ICourse): Promise<AxiosResponse<ICourseDetailResponse>> {
|
||||
return await httpClient.post(`/teachers/${teacherId}/${this.key}/`, data);
|
||||
}
|
||||
|
||||
async getAllForTeacher(teacherId: number): Promise<AxiosResponse<ICourseListResponse>> {
|
||||
return await httpClient.get(`/teachers/${teacherId}/${this.key}/`);
|
||||
}
|
||||
}
|
||||
|
||||
export const courseService = new CourseService();
|
||||
@@ -0,0 +1,19 @@
|
||||
export interface ICourse {
|
||||
id: number;
|
||||
tags?: string[];
|
||||
title?: string;
|
||||
cover?: string;
|
||||
thumbnail?: string;
|
||||
duration?: number;
|
||||
introduction?: string;
|
||||
createdAt?: string;
|
||||
updatedAt?: string;
|
||||
publisherId?: number;
|
||||
}
|
||||
|
||||
export interface ICourseListResponse {
|
||||
count: number;
|
||||
items: ICourse[];
|
||||
}
|
||||
|
||||
export type ICourseDetailResponse = ICourse;
|
||||
+2
-1
@@ -11,7 +11,8 @@ export interface IState {
|
||||
const store = createStore({
|
||||
state(): IState {
|
||||
return {
|
||||
accessToken: undefined,
|
||||
accessToken:
|
||||
'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ0b2tlbl90eXBlIjoiYWNjZXNzIiwiZXhwIjoxNjQ0MTk0ODIwLCJqdGkiOiIwMmVjMjRkMDQ0ZDU0NGI0OTcwNzdiMTM3MWNjYTM2OCIsInVzZXJfaWQiOjMsInBlcm1pc3Npb25zIjpbInZpZXdfYWNhZGVteV9jb3Vyc2UiXSwiaXNfc3VwZXJ1c2VyIjpmYWxzZX0.4dqI9QGplnPn2LqPDpJcKzlDlX6wzUibA1GHi8rNXts',
|
||||
refreshToken: undefined,
|
||||
user: undefined
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user