diff --git a/src/router/index.ts b/src/router/index.ts index cf31b3a..fbf1afc 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -20,6 +20,30 @@ const routes: RouteRecordRaw[] = [ { path: '/apps/:id(\\d+)', component: () => import('@/views/apps/ApplicationFrame.vue'), + props: route => ({ + id: Number(route.params.id), + lecturer: route.query.lecturer_id, + relativePath: route.query.relativePath || '', + }), + beforeEnter: route => { + console.log(route.params, route.query); + }, + }, + + { + path: '/apps/44/lecturer', + redirect: to => { + const query = to.query; + const relativePath = to.path.slice(to.path.lastIndexOf('/') + 1); + + return { + path: '/apps/44', + query: { + lecturer_id: query.lecturer_id, + relativePath: relativePath, + }, + }; + }, }, { path: '/timetable', diff --git a/src/views/apps/ApplicationFrame.vue b/src/views/apps/ApplicationFrame.vue index 3d16051..ae3229a 100644 --- a/src/views/apps/ApplicationFrame.vue +++ b/src/views/apps/ApplicationFrame.vue @@ -16,6 +16,18 @@ const router = useRouter(); const profileStore = useProfileStore(); const appStore = useAppsStore(); +router.replace({ query: undefined }); + +const props = defineProps({ + lecturer: { type: String, required: false, default: null }, + relativePath: { type: String, required: false, default: null }, +}); + +const relPath = props.relativePath; +const lect_id = props.lecturer; + +console.log('props: ', props.lecturer, props.relativePath); + enum AppState { WaitLoad = 1, Show = 2, @@ -29,13 +41,18 @@ const appState = ref(AppState.WaitLoad); const scopes: Ref = ref([]); const scopeNamesToRequest: Ref = ref([]); -// const userScopeApproved: Ref = ref(); toolbar.setup({ backUrl: '/apps', }); const composeUrl = async (url: URL, token: string | null, scopes: string[]) => { + if (relPath) { + url = new URL(relPath, url); + } + if (lect_id) { + url = new URL(`?lecturer_id=${lect_id}`, url); + } if (token !== null) { url.searchParams.set('token', token); } @@ -125,6 +142,7 @@ const openApp = async (data: ServiceData) => { appState.value = AppState.Error; return; } + url.value = new URL(data.link); toolbar.title = data.name ?? 'Ошибка';