mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-05-07 14:56:06 +02:00
refactor: use router handle login redirect
This commit is contained in:
@@ -148,8 +148,9 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { onBeforeMount, onBeforeUnmount, ref, watch } from 'vue';
|
||||
import { Connection, Delete, Download } from '@element-plus/icons-vue';
|
||||
import { onBeforeMount, onBeforeUnmount, ref } from 'vue';
|
||||
import { useRoute, useRouter } from 'vue-router';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
|
||||
@@ -159,6 +160,8 @@
|
||||
import { watchState } from '../../service/watchState';
|
||||
|
||||
const { showVRCXUpdateDialog } = useVRCXUpdaterStore();
|
||||
const router = useRouter();
|
||||
const route = useRoute();
|
||||
const { loginForm, enableCustomEndpoint } = storeToRefs(useAuthStore());
|
||||
const { toggleCustomEndpoint, relogin, deleteSavedLogin, login, getAllSavedCredentials } = useAuthStore();
|
||||
const { promptProxySettings } = useGeneralSettingsStore();
|
||||
@@ -196,6 +199,23 @@
|
||||
savedCredentials.value = await getAllSavedCredentials();
|
||||
}
|
||||
|
||||
function postLoginRedirect() {
|
||||
const redirect = route.query.redirect;
|
||||
if (typeof redirect === 'string' && redirect.startsWith('/') && redirect !== '/login') {
|
||||
return redirect;
|
||||
}
|
||||
return '/feed';
|
||||
}
|
||||
|
||||
watch(
|
||||
() => watchState.isLoggedIn,
|
||||
(isLoggedIn) => {
|
||||
if (isLoggedIn) {
|
||||
router.replace(postLoginRedirect());
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
onBeforeMount(async () => {
|
||||
updateSavedCredentials();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user