diff --git a/src/pages/oj/App.vue b/src/pages/oj/App.vue index 5ee7fe8ed..5ed88cc26 100644 --- a/src/pages/oj/App.vue +++ b/src/pages/oj/App.vue @@ -40,14 +40,17 @@ this.getWebsiteConfig() }, methods: { - ...mapActions(['getWebsiteConfig']) + ...mapActions(['getWebsiteConfig', 'changeDomTitle']) }, computed: { ...mapState(['website']) }, watch: { - 'website' (newVal) { - document.title = newVal.website_name + 'website' () { + this.changeDomTitle() + }, + '$route' () { + this.changeDomTitle() } } } diff --git a/src/pages/oj/router/routes.js b/src/pages/oj/router/routes.js index 18de84288..847094cc9 100644 --- a/src/pages/oj/router/routes.js +++ b/src/pages/oj/router/routes.js @@ -1,11 +1,20 @@ // all routes here. import { - Home, NotFound, Announcements, - UserHome, Logout, About, FAQ, - ProblemList, Problem, - SubmissionList, SubmissionDetails, - ACMRank, OIRank, - ApplyResetPassword, ResetPassword + About, + ACMRank, + Announcements, + ApplyResetPassword, + FAQ, + Home, + Logout, + NotFound, + OIRank, + Problem, + ProblemList, + ResetPassword, + SubmissionDetails, + SubmissionList, + UserHome } from '../views' import * as Contest from '@oj/views/contest' @@ -15,52 +24,62 @@ export default [ { name: 'home', path: '/', + meta: {title: 'Home'}, component: Home }, { name: 'logout', path: '/logout', + meta: {title: 'Logout'}, component: Logout }, { name: 'apply-reset-password', path: '/apply-reset-password', + meta: {title: 'Apply Reset Password'}, component: ApplyResetPassword }, { name: 'reset-password', path: '/reset-password/:token', + meta: {title: 'Reset Password'}, component: ResetPassword }, { name: 'problem-list', path: '/problems', + meta: {title: 'Problem List'}, component: ProblemList }, { name: 'problem-details', path: '/problem/:problemID', + meta: {title: 'Problem Details'}, component: Problem }, { name: 'submission-list', path: '/status', + meta: {title: 'Submission List'}, component: SubmissionList }, { name: 'submission-details', path: '/status/:id/', + meta: {title: 'Submission Details'}, component: SubmissionDetails }, { name: 'contest-list', path: '/contests', + meta: {title: 'Contest List'}, component: Contest.ContestList }, { name: 'contest-details', path: '/contest/:contestID/', component: Contest.ContestDetails, + meta: {title: 'Contest Details'}, children: [ { name: 'contest-submission-list', @@ -97,42 +116,47 @@ export default [ { name: 'acm-rank', path: '/acm-rank', + meta: {title: 'ACM Rankings'}, component: ACMRank }, { name: 'oi-rank', path: '/oi-rank', + meta: {title: 'OI Rankings'}, component: OIRank }, { name: 'user-home', path: '/user-home', component: UserHome, - meta: {requiresAuth: true} + meta: {requiresAuth: true, title: 'User Home'} }, { path: '/setting', component: Setting.Settings, - meta: {requiresAuth: true}, children: [ { name: 'default-setting', path: '', + meta: {requiresAuth: true, title: 'Default Settings'}, component: Setting.ProfileSetting }, { name: 'profile-setting', path: 'profile', + meta: {requiresAuth: true, title: 'Profile Settings'}, component: Setting.ProfileSetting }, { name: 'account-setting', path: 'account', + meta: {requiresAuth: true, title: 'Account Settings'}, component: Setting.AccountSetting }, { name: 'security-setting', path: 'security', + meta: {requiresAuth: true, title: 'Security Settings'}, component: Setting.SecuritySetting } ] @@ -140,15 +164,18 @@ export default [ { path: '/about', name: 'about', + meta: {title: 'About'}, component: About }, { path: '/faq', name: 'faq', + meta: {title: 'FAQ'}, component: FAQ }, { path: '*', + meta: {title: '404'}, component: NotFound } ] diff --git a/src/pages/oj/store/index.js b/src/pages/oj/store/index.js index 274057ff4..99b84685c 100644 --- a/src/pages/oj/store/index.js +++ b/src/pages/oj/store/index.js @@ -49,6 +49,13 @@ const rootActions = { }, changeModalStatus ({commit}, payload) { commit(types.CHANGE_MODAL_STATUS, payload) + }, + changeDomTitle ({commit, state}, payload) { + if (payload && payload.title) { + window.document.title = state.website.website_name_shortcut + ' | ' + payload.title + } else { + window.document.title = state.website.website_name_shortcut + ' | ' + state.route.meta.title + } } } diff --git a/src/pages/oj/views/contest/ContestDetail.vue b/src/pages/oj/views/contest/ContestDetail.vue index 90416be2c..3ac9c51cf 100644 --- a/src/pages/oj/views/contest/ContestDetail.vue +++ b/src/pages/oj/views/contest/ContestDetail.vue @@ -78,7 +78,7 @@