diff --git a/src/flows/hookFlow/beforeDestroy/nodes/beforeDestroy.ts b/src/flows/hookFlow/beforeDestroy/nodes/beforeDestroy.ts index a45ab312..75253fda 100644 --- a/src/flows/hookFlow/beforeDestroy/nodes/beforeDestroy.ts +++ b/src/flows/hookFlow/beforeDestroy/nodes/beforeDestroy.ts @@ -1,9 +1,10 @@ +import { isTenantState } from '@/utils/get-page-state' import { FunctionNode } from 'arkfbp/lib/functionNode' export class BeforeDestroy extends FunctionNode { async run() { // beforeDestory one page - const tempState = location.pathname === '/tenant' ? this.inputs.com.$store.state.tenant.tenantState : this.inputs.com.$store.state.admin.adminState + const tempState = isTenantState() ? this.inputs.com.$store.state.tenant.tenantState : this.inputs.com.$store.state.admin.adminState if (tempState) { const path = this.inputs.com.path tempState.pages.splice(tempState.pages.indexOf(path), 1) diff --git a/src/flows/hookFlow/created/nodes/created.ts b/src/flows/hookFlow/created/nodes/created.ts index 097d84fd..4fc52a74 100644 --- a/src/flows/hookFlow/created/nodes/created.ts +++ b/src/flows/hookFlow/created/nodes/created.ts @@ -1,9 +1,10 @@ +import { isTenantState } from '@/utils/get-page-state' import { FunctionNode } from 'arkfbp/lib/functionNode' export class Created extends FunctionNode { async run() { // add current page - const tempState = location.pathname === '/tenant' ? this.inputs.com.$store.state.tenant.tenantState : this.inputs.com.$store.state.admin.adminState + const tempState = isTenantState() ? this.inputs.com.$store.state.tenant.tenantState : this.inputs.com.$store.state.admin.adminState if (tempState) { const path = this.inputs.com.path tempState.pages.push(path) diff --git a/src/flows/tablePage/fetch/nodes/fetch.ts b/src/flows/tablePage/fetch/nodes/fetch.ts index 37e828fb..63367898 100644 --- a/src/flows/tablePage/fetch/nodes/fetch.ts +++ b/src/flows/tablePage/fetch/nodes/fetch.ts @@ -14,7 +14,6 @@ export class Fetch extends AuthApiNode { this.$state.commit((state: any) => { state.client = tempState }) - const outputs = await super.run() return outputs } diff --git a/src/flows/tablePage/openCreateDialog/nodes/open.ts b/src/flows/tablePage/openCreateDialog/nodes/open.ts index cf28221b..f3da53e2 100644 --- a/src/flows/tablePage/openCreateDialog/nodes/open.ts +++ b/src/flows/tablePage/openCreateDialog/nodes/open.ts @@ -1,10 +1,11 @@ import DialogState from '@/admin/common/Others/Dialog/DialogState' import TablePageState from '@/admin/TablePage/TablePageState' import OpenDialog from '@/nodes/openDialog' +import { isTenantState } from '@/utils/get-page-state' export class Open extends OpenDialog { get dialog():DialogState | null { - const tempState: TablePageState = location.pathname === '/tenant' ? this.inputs.com.$store.state.tenant.tenantState : this.inputs.com.$store.state.admin.adminState + const tempState: TablePageState = isTenantState() ? this.inputs.com.$store.state.tenant.tenantState : this.inputs.com.$store.state.admin.adminState if (tempState && tempState.dialogs) { return tempState.dialogs.create } else { diff --git a/src/flows/tablePage/openUpdateDialog/nodes/open.ts b/src/flows/tablePage/openUpdateDialog/nodes/open.ts index f3529da3..fb1c00ee 100644 --- a/src/flows/tablePage/openUpdateDialog/nodes/open.ts +++ b/src/flows/tablePage/openUpdateDialog/nodes/open.ts @@ -1,10 +1,11 @@ import TablePageState from '@/admin/TablePage/TablePageState' import OpenDialog from '@/nodes/openDialog' import DialogState from '@/admin/common/Others/Dialog/DialogState' +import { isTenantState } from '@/utils/get-page-state' export class Open extends OpenDialog { get dialog():DialogState | null { - const tempState: TablePageState = location.pathname === '/tenant' ? this.inputs.com.$store.state.tenant.tenantState : this.inputs.com.$store.state.admin.adminState + const tempState: TablePageState = isTenantState() ? this.inputs.com.$store.state.tenant.tenantState : this.inputs.com.$store.state.admin.adminState if (tempState && tempState.dialogs) { return tempState.dialogs.update } else { diff --git a/src/flows/tenant/setCurrentTenant/nodes/setCurrentTenant.ts b/src/flows/tenant/setCurrentTenant/nodes/setCurrentTenant.ts index fc57c172..e20d348b 100644 --- a/src/flows/tenant/setCurrentTenant/nodes/setCurrentTenant.ts +++ b/src/flows/tenant/setCurrentTenant/nodes/setCurrentTenant.ts @@ -15,8 +15,8 @@ export class SetCurrentTenant extends TokenAPINode { } }) } else { - const path = location.pathname - if (path === '/login') { + const path = location.hash + if (path === '#/login') { this.inputs.router.push('/login') } else { this.inputs.router.push('/tenant') diff --git a/src/nodes/authApiNode.ts b/src/nodes/authApiNode.ts index 7501bd45..e24449e9 100644 --- a/src/nodes/authApiNode.ts +++ b/src/nodes/authApiNode.ts @@ -13,7 +13,7 @@ export class AuthApiNode extends APINode { return super.run() } - getState(path: string = '') { + getState(path = '') { return getPageState(path) } diff --git a/src/utils/get-page-state.ts b/src/utils/get-page-state.ts index 7a04cf84..bc919fd0 100644 --- a/src/utils/get-page-state.ts +++ b/src/utils/get-page-state.ts @@ -21,23 +21,19 @@ function getStateByPath(tempState: any, path: string) { } export default function getPageState(specifiedPath = '') { - const tempState = getTempState() + const tempState = isTenantState() ? TenantModule.tenantState : AdminModule.adminState if (!tempState) return const path = specifiedPath === '' ? tempState.pages[tempState.pages.length - 1] : specifiedPath return getStateByPath(tempState, path) } export function getPreviousPageState() { - const tempState = getTempState() + const tempState = isTenantState() ? TenantModule.tenantState : AdminModule.adminState if (!tempState) return const path = tempState.pages.length === 1 ? tempState.pages[tempState.pages.length - 1] : tempState.pages[tempState.pages.length - 2] return getStateByPath(tempState, path) } -function getTempState() { - if (location.hash === '#/tenant' || location.pathname === '/tenant') { - return TenantModule.tenantState - } else { - return AdminModule.adminState - } +export function isTenantState() { + return (location.hash === '#/tenant' || location.pathname === '/tenant') }