Skip to content
This repository has been archived by the owner on Jan 19, 2023. It is now read-only.

Dev/plpl #97

Merged
merged 2 commits into from
Apr 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/flows/hookFlow/beforeDestroy/nodes/beforeDestroy.ts
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
3 changes: 2 additions & 1 deletion src/flows/hookFlow/created/nodes/created.ts
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
1 change: 0 additions & 1 deletion src/flows/tablePage/fetch/nodes/fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ export class Fetch extends AuthApiNode {
this.$state.commit((state: any) => {
state.client = tempState
})

const outputs = await super.run()
return outputs
}
Expand Down
3 changes: 2 additions & 1 deletion src/flows/tablePage/openCreateDialog/nodes/open.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
3 changes: 2 additions & 1 deletion src/flows/tablePage/openUpdateDialog/nodes/open.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions src/flows/tenant/setCurrentTenant/nodes/setCurrentTenant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
2 changes: 1 addition & 1 deletion src/nodes/authApiNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export class AuthApiNode extends APINode {
return super.run()
}

getState(path: string = '') {
getState(path = '') {
return getPageState(path)
}

Expand Down
12 changes: 4 additions & 8 deletions src/utils/get-page-state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')
}