perf: refs #7308 call 1 time useSession
gitea/salix-front/pipeline/pr-dev This commit looks good
Details
gitea/salix-front/pipeline/pr-dev This commit looks good
Details
This commit is contained in:
parent
70000e3eca
commit
7f281b8630
|
@ -15,6 +15,7 @@ import { useAcl } from 'src/composables/useAcl';
|
||||||
import { isLoggedIn } from 'src/utils/session';
|
import { isLoggedIn } from 'src/utils/session';
|
||||||
import { useSession } from 'src/composables/useSession';
|
import { useSession } from 'src/composables/useSession';
|
||||||
|
|
||||||
|
let session = null;
|
||||||
const { t, te } = i18n.global;
|
const { t, te } = i18n.global;
|
||||||
|
|
||||||
const createHistory = process.env.SERVER
|
const createHistory = process.env.SERVER
|
||||||
|
@ -45,7 +46,8 @@ export { Router };
|
||||||
export default defineRouter(function (/* { store, ssrContext } */) {
|
export default defineRouter(function (/* { store, ssrContext } */) {
|
||||||
const state = useState();
|
const state = useState();
|
||||||
Router.beforeEach(async (to, from, next) => {
|
Router.beforeEach(async (to, from, next) => {
|
||||||
const session = useSession();
|
console.error('beforeEach', session);
|
||||||
|
if (!session) session = useSession();
|
||||||
const outLayout = Router.options.routes[0].children.map((r) => r.name);
|
const outLayout = Router.options.routes[0].children.map((r) => r.name);
|
||||||
if (!session.isLoggedIn() && !outLayout.includes(to.name)) {
|
if (!session.isLoggedIn() && !outLayout.includes(to.name)) {
|
||||||
return next({ name: 'Login', query: { redirect: to.fullPath } });
|
return next({ name: 'Login', query: { redirect: to.fullPath } });
|
||||||
|
|
Loading…
Reference in New Issue