mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-14 05:07:22 +01:00
Compare commits
3 Commits
v5.41.7
...
fiz/profil
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4250fbc53f | ||
|
|
0c0dc20dcc | ||
|
|
c0508a2f22 |
@@ -117,7 +117,7 @@ export default {
|
|||||||
closeWithAction () {
|
closeWithAction () {
|
||||||
this.close();
|
this.close();
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.$router.push({ name: 'achievements' });
|
this.$router.push(`/profile/${this.$store.state.user.data._id}#achievements`);
|
||||||
}, 200);
|
}, 200);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ export default {
|
|||||||
props: ['notification', 'canRemove'],
|
props: ['notification', 'canRemove'],
|
||||||
methods: {
|
methods: {
|
||||||
action () {
|
action () {
|
||||||
this.$router.push({ name: 'achievements' });
|
this.$router.push(`/profile/${this.$store.state.user.data._id}#achievements`);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
action () {
|
action () {
|
||||||
this.$router.push({ name: 'stats' });
|
this.$router.push(`/profile/${this.$store.state.user.data._id}#stats`);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -176,7 +176,12 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
showProfile (startingPage) {
|
showProfile (startingPage) {
|
||||||
this.$router.push({ name: startingPage });
|
const userId = this.$store.state.user.data._id;
|
||||||
|
let path = `/profile/${userId}`;
|
||||||
|
if (startingPage !== 'profile') {
|
||||||
|
path += `#${startingPage}`;
|
||||||
|
}
|
||||||
|
this.$router.push(path);
|
||||||
},
|
},
|
||||||
toLearnMore () {
|
toLearnMore () {
|
||||||
this.$router.push({ name: 'subscription' });
|
this.$router.push({ name: 'subscription' });
|
||||||
|
|||||||
@@ -1126,7 +1126,12 @@ export default {
|
|||||||
this.loadUser();
|
this.loadUser();
|
||||||
this.oldTitle = this.$store.state.title;
|
this.oldTitle = this.$store.state.title;
|
||||||
this.handleExternalLinks();
|
this.handleExternalLinks();
|
||||||
this.selectPage(this.startingPage);
|
// Check if there's a hash in the URL to determine the starting page
|
||||||
|
let pageToSelect = this.startingPage;
|
||||||
|
if (window.location.hash && (window.location.hash === '#stats' || window.location.hash === '#achievements')) {
|
||||||
|
pageToSelect = window.location.hash.substring(1);
|
||||||
|
}
|
||||||
|
this.selectPage(pageToSelect);
|
||||||
this.$root.$on('habitica:report-profile-result', () => {
|
this.$root.$on('habitica:report-profile-result', () => {
|
||||||
this.loadUser();
|
this.loadUser();
|
||||||
});
|
});
|
||||||
@@ -1211,10 +1216,15 @@ export default {
|
|||||||
},
|
},
|
||||||
selectPage (page) {
|
selectPage (page) {
|
||||||
this.selectedPage = page || 'profile';
|
this.selectedPage = page || 'profile';
|
||||||
window.history.replaceState(null, null, '');
|
const profileUserId = this.userId || this.userLoggedIn._id;
|
||||||
|
let newPath = `/profile/${profileUserId}`;
|
||||||
|
if (page !== 'profile') {
|
||||||
|
newPath += `#${page}`;
|
||||||
|
}
|
||||||
|
window.history.replaceState(null, null, newPath);
|
||||||
this.$store.dispatch('common:setTitle', {
|
this.$store.dispatch('common:setTitle', {
|
||||||
section: this.$t('user'),
|
section: this.$t('user'),
|
||||||
subSection: this.$t(this.startingPage),
|
subSection: this.$t(page),
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
getNextIncentive () {
|
getNextIncentive () {
|
||||||
|
|||||||
@@ -98,6 +98,9 @@ const router = new VueRouter({
|
|||||||
path: '/profile/:userId',
|
path: '/profile/:userId',
|
||||||
props: true,
|
props: true,
|
||||||
},
|
},
|
||||||
|
{ name: 'profile', path: '/user/profile' },
|
||||||
|
{ name: 'stats', path: '/user/stats' },
|
||||||
|
{ name: 'achievements', path: '/user/achievements' },
|
||||||
{
|
{
|
||||||
path: '/inventory',
|
path: '/inventory',
|
||||||
component: InventoryContainer,
|
component: InventoryContainer,
|
||||||
@@ -332,6 +335,10 @@ router.beforeEach(async (to, from, next) => {
|
|||||||
if (to.params.startingPage !== undefined) {
|
if (to.params.startingPage !== undefined) {
|
||||||
startingPage = to.params.startingPage;
|
startingPage = to.params.startingPage;
|
||||||
}
|
}
|
||||||
|
// Check if there's a hash in the URL for stats or achievements
|
||||||
|
if (to.hash === '#stats' || to.hash === '#achievements') {
|
||||||
|
startingPage = to.hash.substring(1);
|
||||||
|
}
|
||||||
if (from.name === null) {
|
if (from.name === null) {
|
||||||
store.state.postLoadModal = `profile/${to.params.userId}`;
|
store.state.postLoadModal = `profile/${to.params.userId}`;
|
||||||
return next({ name: 'tasks' });
|
return next({ name: 'tasks' });
|
||||||
@@ -352,10 +359,18 @@ router.beforeEach(async (to, from, next) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ((to.name === 'stats' || to.name === 'achievements' || to.name === 'profile') && from.name !== null) {
|
if ((to.name === 'stats' || to.name === 'achievements' || to.name === 'profile') && from.name !== null) {
|
||||||
|
const userId = store.state.user.data._id;
|
||||||
|
let redirectPath = `/profile/${userId}`;
|
||||||
|
if (to.name === 'stats') {
|
||||||
|
redirectPath += '#stats';
|
||||||
|
} else if (to.name === 'achievements') {
|
||||||
|
redirectPath += '#achievements';
|
||||||
|
}
|
||||||
router.app.$emit('habitica:show-profile', {
|
router.app.$emit('habitica:show-profile', {
|
||||||
|
userId,
|
||||||
startingPage: to.name,
|
startingPage: to.name,
|
||||||
fromPath: from.path,
|
fromPath: from.path,
|
||||||
toPath: to.path,
|
toPath: redirectPath,
|
||||||
});
|
});
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user