tijiao
This commit is contained in:
53
src/main.js
53
src/main.js
@@ -12,6 +12,11 @@ import './components/common/directives';
|
||||
import 'babel-polyfill';
|
||||
import api from './api/index.js';
|
||||
import Common from './components/common/common'
|
||||
|
||||
|
||||
import store from './store' // 引入 store
|
||||
|
||||
|
||||
Vue.prototype.$validateString = function (str) {
|
||||
return /^[a-zA-Z\s\u00C0-\u00FF\u0100-\u017F-]+$/.test(str);
|
||||
}
|
||||
@@ -63,7 +68,6 @@ async function loadJournalType() {
|
||||
localStorage.setItem('journalTypeData', JSON.stringify(res.data.base)); // 将数据存储到 localStorage
|
||||
localStorage.setItem('journalTypeDataAll', JSON.stringify([...res.data.base, ...res.data.supplement])); // 将数据存储到 localStorage
|
||||
|
||||
|
||||
}
|
||||
})
|
||||
await api
|
||||
@@ -84,6 +88,20 @@ async function loadJournalType() {
|
||||
} else {
|
||||
console.log('Journal types loaded from localStorage:', JSON.parse(localData));
|
||||
}
|
||||
}
|
||||
async function loadJournalList() {
|
||||
|
||||
return await api
|
||||
.post('api/Article/getJournal', {})
|
||||
.then((res) => {
|
||||
store.commit('setJournalList', res); // 提交 mutation 更新 journalList
|
||||
console.log('journalList at line 100:, 提交 mutation 更新 journalList')
|
||||
|
||||
})
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
// 启动应用时调用一次函数来加载 journalType 数据
|
||||
@@ -182,29 +200,26 @@ const i18n = new VueI18n({
|
||||
messages
|
||||
});
|
||||
//使用钩子函数对路由进行权限跳转
|
||||
router.beforeEach((to, from, next) => {
|
||||
loadJournalType();
|
||||
router.beforeEach(async(to, from, next) => {
|
||||
try {
|
||||
// 尝试请求接口(即使失败也继续后续逻辑)
|
||||
await Promise.all([
|
||||
loadJournalList(),
|
||||
loadJournalType()
|
||||
]);
|
||||
} catch (err) {
|
||||
// 仅打印错误,不阻断路由
|
||||
console.error('接口请求失败,但继续路由跳转', err);
|
||||
}
|
||||
|
||||
// 无论接口成功/失败,都执行原有跳转逻辑
|
||||
document.title = `${to.meta.title} | Traditional Medicine Research`;
|
||||
const role = localStorage.getItem('U_name');
|
||||
const userrole = localStorage.getItem('U_status');
|
||||
|
||||
if (!role && to.path != '/register' && to.path !== '/submission' && to.path !== '/verification' && to.path !== '/orcidLink' && to.path !== '/img' && to.path !== '/reviewer' && to.path !== '/thanks' && to.path !== '/login' && to.path !== '/refuse' && to.path !== '/managing' && to.path.search(/retrieve/i) < 0) {
|
||||
next('/login');
|
||||
// } else if (to.meta.permission) {
|
||||
// // 如果是管理员权限则可进入,这里只是简单的模拟管理员权限而已
|
||||
// // role === 'admin' ? next() : next('/403');
|
||||
// if(userrole == to.meta.permission){
|
||||
// next();
|
||||
// }else{
|
||||
// next('/403');
|
||||
// }
|
||||
|
||||
} else {
|
||||
//审稿人导航
|
||||
// if(to.path=='/reviewerArticleList'&&userrole!='reviewer'){
|
||||
// next('/authorApplyReviewer');
|
||||
// }
|
||||
// 简单的判断IE10及以下不进入富文本编辑器,该组件不兼容
|
||||
if (navigator.userAgent.indexOf('MSIE') > -1 && to.path === '/editor') {
|
||||
Vue.prototype.$alert('vue-quill-editor组件不兼容IE10及以下浏览器,请使用更高版本的浏览器查看', '浏览器不兼容通知', {
|
||||
confirmButtonText: '确定'
|
||||
@@ -212,14 +227,16 @@ router.beforeEach((to, from, next) => {
|
||||
} else {
|
||||
next();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
new Vue({
|
||||
router,
|
||||
i18n,
|
||||
store,
|
||||
render: h => h(App),
|
||||
|
||||
mounted() {
|
||||
this.$renderMath(); // 页面加载后自动渲染
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user