新增404
This commit is contained in:
parent
11be3b5e3a
commit
67ed03635b
File diff suppressed because one or more lines are too long
2
dist/index.html
vendored
2
dist/index.html
vendored
@ -1 +1 @@
|
||||
<!doctype html><html lang="zh-CN"><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><link rel="icon" href="/favicon.ico"><title>NEU小站课程评分系统</title><script defer="defer" src="/js/chunk-vendors.3aa9144b.js"></script><script defer="defer" src="/js/app.2c83ed37.js"></script><link href="/css/chunk-vendors.f2db5e15.css" rel="stylesheet"><link href="/css/app.387e87f6.css" rel="stylesheet"></head><body><noscript><strong>本系统需要JavaScript支持,请启用JavaScript后继续。</strong></noscript><div id="app"></div></body></html>
|
||||
<!doctype html><html lang="zh-CN"><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><link rel="icon" href="/favicon.ico"><title>NEU小站课程评分系统</title><script defer="defer" src="/js/chunk-vendors.3aa9144b.js"></script><script defer="defer" src="/js/app.87b57846.js"></script><link href="/css/chunk-vendors.f2db5e15.css" rel="stylesheet"><link href="/css/app.6ab343bc.css" rel="stylesheet"></head><body><noscript><strong>本系统需要JavaScript支持,请启用JavaScript后继续。</strong></noscript><div id="app"></div></body></html>
|
||||
2
dist/js/app.2c83ed37.js
vendored
2
dist/js/app.2c83ed37.js
vendored
File diff suppressed because one or more lines are too long
2
dist/js/app.87b57846.js
vendored
Normal file
2
dist/js/app.87b57846.js
vendored
Normal file
File diff suppressed because one or more lines are too long
@ -6,6 +6,7 @@ import RatingPageforComp from '../views/RatingPageforComp.vue'
|
||||
import ChatList from '../views/ChatList.vue'
|
||||
import AboutPage from '../views/AboutPage.vue'
|
||||
import CourseDetail from '../views/CourseDetail.vue'
|
||||
import NotFound from '../views/404.vue'
|
||||
|
||||
const routes = [
|
||||
{
|
||||
@ -63,6 +64,18 @@ const routes = [
|
||||
title: '课程详情 - NEU小站课程评分系统',
|
||||
},
|
||||
component: CourseDetail
|
||||
},
|
||||
{
|
||||
path: '/404',
|
||||
name: 'NotFound',
|
||||
meta: {
|
||||
title: '404 - 未知页面 - NEU小站课程评分系统',
|
||||
},
|
||||
component: NotFound
|
||||
},
|
||||
{
|
||||
path: '/:pathMatch(.*)*',
|
||||
redirect: '/404'
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
82
src/views/404.vue
Normal file
82
src/views/404.vue
Normal file
File diff suppressed because it is too large
Load Diff
@ -270,10 +270,13 @@ export default {
|
||||
this.courseId = this.$route.params.course_id;
|
||||
if (this.courseId) {
|
||||
await this.loadCourseData();
|
||||
if (this.course && this.course.course_name) {
|
||||
document.title = this.course.course_name + " (" + this.course.teachers + ") " + " - NEU小站课程评分系统";
|
||||
}
|
||||
} else {
|
||||
this.loading = false;
|
||||
// 处理没有 ID 的情况,例如跳转回列表页
|
||||
this.$router.push('/rating');
|
||||
// 处理没有 ID 的情况,跳转到 404 页面
|
||||
this.$router.replace('/404');
|
||||
}
|
||||
},
|
||||
beforeUnmount() {
|
||||
@ -291,6 +294,12 @@ export default {
|
||||
try {
|
||||
// 1. 获取课程基础详情
|
||||
const response = await fetch(`https://coursesystem.xn--xhq44jb2fzpc.com/course-detail?course_id=${this.courseId}`);
|
||||
|
||||
if (response.status === 404) {
|
||||
this.$router.replace('/404');
|
||||
return;
|
||||
}
|
||||
|
||||
if (!response.ok) throw new Error('Failed to fetch course detail');
|
||||
|
||||
this.course = await response.json();
|
||||
|
||||
@ -318,7 +318,8 @@ export default {
|
||||
},
|
||||
|
||||
showCourseDetail(course) {
|
||||
this.$router.push(`/detail/${course.course_id}`);
|
||||
// 新标签页打开
|
||||
window.open(`/detail/${course.course_id}`, '_blank');
|
||||
},
|
||||
|
||||
formatTopComment(comment) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user