mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/vue/learning-system-portal.git
synced 2025-12-10 19:36:43 +08:00
修改个人主页的url规则
This commit is contained in:
@@ -104,7 +104,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.pageId = this.$route.query.id;
|
this.pageId = this.$xpage.getHomeId(this.$route);
|
||||||
this.sex = this.userInfo.sex;
|
this.sex = this.userInfo.sex;
|
||||||
// 判断路由是进入的学员默认页面就重置setCurIdentity
|
// 判断路由是进入的学员默认页面就重置setCurIdentity
|
||||||
if(this.$route.path == '/uc/study/task' || this.$route.path == '/study/index'){
|
if(this.$route.path == '/uc/study/task' || this.$route.path == '/study/index'){
|
||||||
|
|||||||
@@ -60,7 +60,7 @@
|
|||||||
methods:{
|
methods:{
|
||||||
toHome() {
|
toHome() {
|
||||||
// ,query:{id:item.objId || item.id}
|
// ,query:{id:item.objId || item.id}
|
||||||
this.$router.push({path:'/home/index?id='+this.aid})
|
this.$router.push({path:this.$xpage.getHomePath(this.aid)})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
watch:{
|
watch:{
|
||||||
|
|||||||
@@ -74,7 +74,7 @@
|
|||||||
toHome() {
|
toHome() {
|
||||||
// ,query:{id:item.objId || item.id}
|
// ,query:{id:item.objId || item.id}
|
||||||
if(this.aid){
|
if(this.aid){
|
||||||
this.$router.push({path:'/home/index?id='+this.aid})
|
this.$router.push({path:this.$xpage.getHomePath(this.aid)})
|
||||||
}else{
|
}else{
|
||||||
this.$message.error("参数错误");
|
this.$message.error("参数错误");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -108,7 +108,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<el-dropdown-menu slot="dropdown">
|
<el-dropdown-menu slot="dropdown">
|
||||||
<el-dropdown-item @click.native="setCurIdentity(1)"><a :href="`${webBaseUrl}${isTiao ? '/uc/study/task' : '/uc/study/courses'}`">个人中心</a></el-dropdown-item>
|
<el-dropdown-item @click.native="setCurIdentity(1)"><a :href="`${webBaseUrl}${isTiao ? '/uc/study/task' : '/uc/study/courses'}`">个人中心</a></el-dropdown-item>
|
||||||
<el-dropdown-item><router-link :to="'/home/index?id='+userInfo.aid">个人主页</router-link></el-dropdown-item>
|
<el-dropdown-item><router-link :to="'/home/index/'+userInfo.aid">个人主页</router-link></el-dropdown-item>
|
||||||
</el-dropdown-menu>
|
</el-dropdown-menu>
|
||||||
</el-dropdown>
|
</el-dropdown>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -67,7 +67,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<el-dropdown-menu slot="dropdown">
|
<el-dropdown-menu slot="dropdown">
|
||||||
<el-dropdown-item @click.native="setCurIdentity(1)"><a :href="`${webBaseUrl}${isTiao ? '/uc/study/task' : '/uc/study/courses'}`">个人中心</a></el-dropdown-item>
|
<el-dropdown-item @click.native="setCurIdentity(1)"><a :href="`${webBaseUrl}${isTiao ? '/uc/study/task' : '/uc/study/courses'}`">个人中心</a></el-dropdown-item>
|
||||||
<el-dropdown-item><router-link :to="'/home/index?id='+userInfo.aid">个人主页</router-link></el-dropdown-item>
|
<el-dropdown-item><router-link :to="'/home/'+userInfo.aid">个人主页</router-link></el-dropdown-item>
|
||||||
</el-dropdown-menu>
|
</el-dropdown-menu>
|
||||||
</el-dropdown>
|
</el-dropdown>
|
||||||
</div>
|
</div>
|
||||||
@@ -83,7 +83,7 @@
|
|||||||
</el-dropdown>
|
</el-dropdown>
|
||||||
</div> -->
|
</div> -->
|
||||||
<div class="person-action">
|
<div class="person-action">
|
||||||
<el-button @click="logout()" type="text"><svg-icon style="margin-right: 4px;font-size:22px;color: #000;" icon-class="white-out"></svg-icon>登出</el-button>
|
<el-button @click="logout()" type="text"><svg-icon style="margin-right: 4px;font-size:16px;" icon-class="white-out"></svg-icon>登出</el-button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import store from './store'
|
|||||||
|
|
||||||
//import './mock/index'
|
//import './mock/index'
|
||||||
|
|
||||||
import constants from '@/utils/constants'
|
import xpage from '@/utils/xpage'
|
||||||
import VueCookies from 'vue-cookies'
|
import VueCookies from 'vue-cookies'
|
||||||
Vue.use(VueCookies)
|
Vue.use(VueCookies)
|
||||||
import Element from 'element-ui'
|
import Element from 'element-ui'
|
||||||
@@ -29,7 +29,7 @@ Vue.prototype.$watermark = watermark
|
|||||||
|
|
||||||
Vue.config.productionTip = false
|
Vue.config.productionTip = false
|
||||||
|
|
||||||
Vue.prototype.$Constants = constants;
|
Vue.prototype.$xpage = xpage;
|
||||||
|
|
||||||
|
|
||||||
Vue.prototype.msgSuccess = function(msg) {
|
Vue.prototype.msgSuccess = function(msg) {
|
||||||
|
|||||||
@@ -154,17 +154,17 @@ export const constantRoutes = [{
|
|||||||
hidden: true,
|
hidden: true,
|
||||||
component: (resolve) => require(['@/views/homepage/Index'], resolve),
|
component: (resolve) => require(['@/views/homepage/Index'], resolve),
|
||||||
name: 'homePage',
|
name: 'homePage',
|
||||||
redirect: '/home/index',
|
redirect: '/home/:id',
|
||||||
meta: { title: '个人主页', icon: 'dashboard', noCache: true, affix: false },
|
meta: { title: '个人主页', icon: 'dashboard', noCache: true, affix: false },
|
||||||
children: [{
|
children: [{
|
||||||
path: 'index',
|
path: ':id',
|
||||||
hidden: true,
|
hidden: true,
|
||||||
component: (resolve) => require(['@/views/homepage/page'], resolve),
|
component: (resolve) => require(['@/views/homepage/page'], resolve),
|
||||||
name: 'page',
|
name: 'page',
|
||||||
meta: { title: '个人主页', icon: 'dashboard', noCache: true, affix: true }
|
meta: { title: '个人主页', icon: 'dashboard', noCache: true, affix: true }
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: 'leaving',
|
path: ':id/leaving',
|
||||||
hidden: true,
|
hidden: true,
|
||||||
component: (resolve) => require(['@/views/homepage/leavingMessage'], resolve),
|
component: (resolve) => require(['@/views/homepage/leavingMessage'], resolve),
|
||||||
name: 'leavingMessage',
|
name: 'leavingMessage',
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import 'nprogress/nprogress.css'
|
|||||||
import { getToken } from '@/utils/token'
|
import { getToken } from '@/utils/token'
|
||||||
import { routers } from "@/data/pages"
|
import { routers } from "@/data/pages"
|
||||||
import watermark from './utils/warterMark.js'
|
import watermark from './utils/warterMark.js'
|
||||||
import constants from '@/utils/constants'
|
import xpage from '@/utils/xpage'
|
||||||
|
|
||||||
NProgress.configure({ showSpinner: false })
|
NProgress.configure({ showSpinner: false })
|
||||||
|
|
||||||
@@ -17,9 +17,9 @@ router.beforeEach((to, from, next) => {
|
|||||||
//动态计算文件的路径
|
//动态计算文件的路径
|
||||||
let configPath=process.env.VUE_APP_FILE_RELATIVE_PATH;
|
let configPath=process.env.VUE_APP_FILE_RELATIVE_PATH;
|
||||||
if(configPath.startsWith('http')){
|
if(configPath.startsWith('http')){
|
||||||
constants.fileBaseUrl=configPath;
|
xpage.fileBaseUrl=configPath;
|
||||||
}else{
|
}else{
|
||||||
constants.fileBaseUrl = window.location.protocol+'//'+window.location.host+configPath;
|
xpage.fileBaseUrl = window.location.protocol+'//'+window.location.host+configPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +0,0 @@
|
|||||||
/**页面设置的一些常量*/
|
|
||||||
const constants={
|
|
||||||
fileBaseUrl:'http://192.168.0.10/pc/cdn/upload',
|
|
||||||
newLoginKey:'boe_new_login'
|
|
||||||
}
|
|
||||||
|
|
||||||
export default constants
|
|
||||||
20
src/utils/xpage.js
Normal file
20
src/utils/xpage.js
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
/**页面设置的一些常量,方便,用于一个处理只写一处,不要多处写*/
|
||||||
|
const constants={
|
||||||
|
fileBaseUrl:'http://192.168.0.10/pc/cdn/upload',
|
||||||
|
newLoginKey:'boe_new_login'
|
||||||
|
}
|
||||||
|
|
||||||
|
/**返回个人主页的id参数*/
|
||||||
|
const getHomeId=function(r){
|
||||||
|
return r.params.id;
|
||||||
|
}
|
||||||
|
|
||||||
|
const getHomePath=function(id){
|
||||||
|
return '/home/'+id;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default {
|
||||||
|
getHomeId,
|
||||||
|
getHomePath,
|
||||||
|
constants
|
||||||
|
}
|
||||||
@@ -73,8 +73,8 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
this.pageId = this.$route.query.id;
|
this.pageId = this.$xpage.getHomeId(this.$route);
|
||||||
if(!this.$route.query.id){
|
if(!this.pageId){
|
||||||
this.$router.push({path:'/404'})
|
this.$router.push({path:'/404'})
|
||||||
}else{
|
}else{
|
||||||
this.init();
|
this.init();
|
||||||
|
|||||||
@@ -95,13 +95,14 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
watch:{
|
created() {
|
||||||
|
this.pageId =this.$xpage.getHomeId(this.$route);
|
||||||
|
if(this.pageId){
|
||||||
},
|
|
||||||
mounted() {
|
|
||||||
this.pageId = this.$route.query.id;
|
|
||||||
this.getList();
|
this.getList();
|
||||||
|
}else{
|
||||||
|
this.$router.push({path:'/404'})
|
||||||
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
delReplySon(item,index) { //子级的删除手动删掉,调用保存接口
|
delReplySon(item,index) { //子级的删除手动删掉,调用保存接口
|
||||||
|
|||||||
@@ -118,16 +118,9 @@
|
|||||||
Profess:[]
|
Profess:[]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// watch:{
|
|
||||||
// '$route' (to, from) { //监听路由是否变化
|
|
||||||
// if(to.query.id != from.query.id && from.path == "/home/index"){
|
|
||||||
// this.id = to.query.id;
|
|
||||||
// this.init();//重新加载数据
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// },
|
|
||||||
created(){
|
created(){
|
||||||
if(this.$route.query.id && this.$route.query.id!=''){
|
this.pageId = this.$xpage.getHomeId(this.$route);
|
||||||
|
if(this.pageId && this.pageId!=''){
|
||||||
this.init();
|
this.init();
|
||||||
}else{
|
}else{
|
||||||
//this.$message.error("参数错误");
|
//this.$message.error("参数错误");
|
||||||
@@ -135,12 +128,22 @@
|
|||||||
this.$router.push({path:'/404'})
|
this.$router.push({path:'/404'})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
watch:{
|
||||||
|
'$route' (to, from) { //监听路由是否变化
|
||||||
|
console.log(from,'from')
|
||||||
|
if(to.params.id != from.params.id){
|
||||||
|
this.pageId = to.params.id;
|
||||||
|
console.log(this.pageId,'重新加载页面');
|
||||||
|
this.init();//重新加载数据
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
|
|
||||||
},
|
},
|
||||||
methods:{
|
methods:{
|
||||||
init(){
|
init(){
|
||||||
this.pageId = this.$route.query.id;
|
|
||||||
this.getList();
|
this.getList();
|
||||||
if(this.pageId == this.userInfo.aid) {
|
if(this.pageId == this.userInfo.aid) {
|
||||||
this.personal = true;
|
this.personal = true;
|
||||||
|
|||||||
Reference in New Issue
Block a user