Commit 6c72db9f authored by xiaoye's avatar xiaoye

更好的匹配url方法

parent 02e6308a
......@@ -275,7 +275,7 @@
await (new Promise(resolve => setTimeout(resolve, 500)));
page.tournament = true;
const url = window.location.href.split('/?');
window.location.replace(`${url[0]}/tournament/${search.result.tournaments[v].id}/?${url[1] ?? ''}`)
window.location.replace(`${url[0].replace(/\/?$/, '')}/tournament/${search.result.tournaments[v].id}${url[1] ? `/?${url[1]}` : ''}`);
},
menu : async(): Promise<void> => {
page.tournament = false;
......@@ -535,12 +535,15 @@
// @ts-ignore
emitter.on(tournamentReload, tournament.init);
const url = window.location.href.match(/tournament\/(\d+)[^\/]*\/\?/);
const url = window.location.pathname.match(/\/tournament\/([^\/]+)(?=\/|$)/);
if (url && !isNaN(parseInt(url[1]))) {
page.menu = false;
page.tournament = true;
} else {
search.on();
if (window.location.pathname.length > 1)
window.location.replace(window.location.href.replace(window.location.pathname, ''))
else
search.on();
}
});
......
......@@ -329,12 +329,9 @@
height : 0,
loading : false,
clear : async () : Promise<void>=> {
const url = window.location.href.match(/(\/tournament\/[^\/]+)(?=\/\?)/);
if (url) {
tournament.this = undefined;
await (new Promise(resolve => setTimeout(resolve, 450)));
window.location.replace(window.location.href.replace(url[1], ''));
}
tournament.this = undefined;
await (new Promise(resolve => setTimeout(resolve, 450)));
window.location.replace(window.location.href.replace(window.location.pathname, ''))
},
get : async (id : number) : Promise<void> => {
const t = await Tabulator.Tournament.Find(Mycard.token, id);
......@@ -377,7 +374,7 @@
});
onBeforeMount(() => {
const url = window.location.href.match(/tournament\/(\d+)[^\/]*\/\?/);
const url = window.location.pathname.match(/\/tournament\/([^\/]+)(?=\/|$)/);
url && !isNaN(parseInt(url[1])) ? page.get(parseInt(url[1])) : page.clear();
// @ts-ignore
emitter.on(updateTournament, participant.update);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment