diff --git a/src/assets/scss/_common.scss b/src/assets/scss/_common.scss index 50eef195..b253f11f 100644 --- a/src/assets/scss/_common.scss +++ b/src/assets/scss/_common.scss @@ -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; + } } diff --git a/src/assets/scss/_element.scss b/src/assets/scss/_element.scss index 6f8a5da9..edae1c35 100644 --- a/src/assets/scss/_element.scss +++ b/src/assets/scss/_element.scss @@ -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'; diff --git a/src/i18n/zh/course/button.ts b/src/i18n/zh/course/button.ts new file mode 100644 index 00000000..0cff6dcc --- /dev/null +++ b/src/i18n/zh/course/button.ts @@ -0,0 +1,3 @@ +export default { + startStudy: '开始学习' +}; diff --git a/src/i18n/zh/course/index.ts b/src/i18n/zh/course/index.ts new file mode 100644 index 00000000..c7950171 --- /dev/null +++ b/src/i18n/zh/course/index.ts @@ -0,0 +1,5 @@ +import button from './button'; + +export default { + button +}; diff --git a/src/i18n/zh/index.ts b/src/i18n/zh/index.ts index 300d3f6e..53414c78 100644 --- a/src/i18n/zh/index.ts +++ b/src/i18n/zh/index.ts @@ -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 }; diff --git a/src/layouts/Course.vue b/src/layouts/Course.vue index eb841b25..8ad97258 100644 --- a/src/layouts/Course.vue +++ b/src/layouts/Course.vue @@ -4,7 +4,6 @@ - side diff --git a/src/pages/course/Detail.vue b/src/pages/course/Detail.vue new file mode 100644 index 00000000..d1ab74a4 --- /dev/null +++ b/src/pages/course/Detail.vue @@ -0,0 +1,107 @@ + + + + + + + + + + + + + {{ course.title }} + + + {{ course.introduction }} + + + + + + + + + + + + + + + + + + diff --git a/src/pages/course/List.vue b/src/pages/course/List.vue index 7afbd4aa..b74bbb70 100644 --- a/src/pages/course/List.vue +++ b/src/pages/course/List.vue @@ -1,5 +1,117 @@ - - Course List - + + + + + + + {{ tag }} + + + {{ course.title }} + + + {{ course.introduction }} + + + + + {{ $t('course.button.startStudy') }} + + + + + + + + + + + + + + + diff --git a/src/router/course.ts b/src/router/course.ts index 89268f8e..8a0f1b8a 100644 --- a/src/router/course.ts +++ b/src/router/course.ts @@ -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') } ] }; diff --git a/src/router/index.ts b/src/router/index.ts index ba4c9c9b..3e8ff087 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -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(), diff --git a/src/services/course/service.ts b/src/services/course/service.ts new file mode 100644 index 00000000..91193c1b --- /dev/null +++ b/src/services/course/service.ts @@ -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> { + return await httpClient.get(`/${this.key}/`); + } + + async get(id: number): Promise> { + return await httpClient.get(`/${this.key}/${id}`); + } + + async create(data: ICourse): Promise> { + return await httpClient.post(`/${this.key}/`, data); + } + + async update(id: number, data: ICourse): Promise> { + return await httpClient.put(`/${this.key}/${id}`, data); + } + + async delete(id: number): Promise> { + return await httpClient.delete(`/${this.key}/${id}`); + } + + async createForTeacher(teacherId: number, data: ICourse): Promise> { + return await httpClient.post(`/teachers/${teacherId}/${this.key}/`, data); + } + + async getAllForTeacher(teacherId: number): Promise> { + return await httpClient.get(`/teachers/${teacherId}/${this.key}/`); + } +} + +export const courseService = new CourseService(); diff --git a/src/services/course/types.ts b/src/services/course/types.ts new file mode 100644 index 00000000..f420b8b6 --- /dev/null +++ b/src/services/course/types.ts @@ -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; diff --git a/src/store/index.ts b/src/store/index.ts index d29be88f..baf7e260 100644 --- a/src/store/index.ts +++ b/src/store/index.ts @@ -11,7 +11,8 @@ export interface IState { const store = createStore({ state(): IState { return { - accessToken: undefined, + accessToken: + 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ0b2tlbl90eXBlIjoiYWNjZXNzIiwiZXhwIjoxNjQ0MTk0ODIwLCJqdGkiOiIwMmVjMjRkMDQ0ZDU0NGI0OTcwNzdiMTM3MWNjYTM2OCIsInVzZXJfaWQiOjMsInBlcm1pc3Npb25zIjpbInZpZXdfYWNhZGVteV9jb3Vyc2UiXSwiaXNfc3VwZXJ1c2VyIjpmYWxzZX0.4dqI9QGplnPn2LqPDpJcKzlDlX6wzUibA1GHi8rNXts', refreshToken: undefined, user: undefined };
{{ course.title }}
{{ course.introduction }}