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

Commit

Permalink
Merge pull request #98 from longguikeji/dev/plpl
Browse files Browse the repository at this point in the history
Dev/plpl
  • Loading branch information
welylongguikeji authored Apr 7, 2021
2 parents 60114c1 + 908683a commit b509c34
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 24 deletions.
7 changes: 3 additions & 4 deletions src/flows/hookFlow/beforeDestroy/nodes/beforeDestroy.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { isTenantState } from '@/utils/get-page-state'
import { FunctionNode } from 'arkfbp/lib/functionNode'
import { StateNode } from '@/nodes/stateNode'

export class BeforeDestroy extends FunctionNode {
export class BeforeDestroy extends StateNode {
async run() {
// beforeDestory one page
const tempState = isTenantState() ? this.inputs.com.$store.state.tenant.tenantState : this.inputs.com.$store.state.admin.adminState
const tempState = this.getFirstState()
if (tempState) {
const path = this.inputs.com.path
tempState.pages.splice(tempState.pages.indexOf(path), 1)
Expand Down
7 changes: 3 additions & 4 deletions src/flows/hookFlow/created/nodes/created.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { isTenantState } from '@/utils/get-page-state'
import { FunctionNode } from 'arkfbp/lib/functionNode'
import { StateNode } from '@/nodes/stateNode'

export class Created extends FunctionNode {
export class Created extends StateNode {
async run() {
// add current page
const tempState = isTenantState() ? this.inputs.com.$store.state.tenant.tenantState : this.inputs.com.$store.state.admin.adminState
const tempState = this.getFirstState()
if (tempState) {
const path = this.inputs.com.path
tempState.pages.push(path)
Expand Down
3 changes: 1 addition & 2 deletions src/flows/tablePage/openCreateDialog/nodes/open.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
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 = isTenantState() ? this.inputs.com.$store.state.tenant.tenantState : this.inputs.com.$store.state.admin.adminState
const tempState: TablePageState = this.getState()
if (tempState && tempState.dialogs) {
return tempState.dialogs.create
} else {
Expand Down
3 changes: 1 addition & 2 deletions src/flows/tablePage/openUpdateDialog/nodes/open.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
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 = isTenantState() ? this.inputs.com.$store.state.tenant.tenantState : this.inputs.com.$store.state.admin.adminState
const tempState: TablePageState = this.getState()
if (tempState && tempState.dialogs) {
return tempState.dialogs.update
} else {
Expand Down
7 changes: 2 additions & 5 deletions src/flows/treePage/fetchTableList/nodes/fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,9 @@ export class Fetch extends AuthApiNode {
async run() {
const tempState = this.getState()

this.url = getUrl(this.inputs.params.tableUrl)
this.url = getUrl(this.inputs.params.tableUrl, this.inputs.params.data)
this.method = this.inputs.params.tableMethod || 'get'
this.params = {
group: this.inputs.params.data.uuid,
}


this.$state.commit((state: any) => {
state.client = tempState
})
Expand Down
2 changes: 1 addition & 1 deletion src/flows/treePage/init/nodes/initTableList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export class InitTableList extends FunctionNode {

// 对table表格机进行初始化操作
if (initContent.tableList) {
const tableListNodeOperationPath = initContent.tableList.path
const tableListNodeOperationPath = initContent.tableList.path.split('?')[0]
const tableListNodeOperationMethod = initContent.tableList.method
const tableListNodeOperation = OpenAPI.instance.getOperation(tableListNodeOperationPath, tableListNodeOperationMethod)
if (tableListNodeOperation) {
Expand Down
6 changes: 5 additions & 1 deletion src/nodes/authApiNode.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { APINode } from "arkfbp/lib/apiNode";
import { getToken } from '@/utils/auth'
import getPageState, { getPreviousPageState } from '@/utils/get-page-state'
import getPageState, { getPreviousPageState, getFirstPageState } from '@/utils/get-page-state'

export class AuthApiNode extends APINode {
async run() {
Expand All @@ -20,4 +20,8 @@ export class AuthApiNode extends APINode {
getPreviousState() {
return getPreviousPageState()
}

getFirstState() {
return getFirstPageState()
}
}
6 changes: 5 additions & 1 deletion src/nodes/stateNode.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { FunctionNode } from 'arkfbp/lib/functionNode'
import getPageState, { getPreviousPageState } from '@/utils/get-page-state'
import getPageState, { getPreviousPageState, getFirstPageState } from '@/utils/get-page-state'

export class StateNode extends FunctionNode {

Expand All @@ -11,4 +11,8 @@ export class StateNode extends FunctionNode {
return getPreviousPageState()
}

getFirstState() {
return getFirstPageState()
}

}
18 changes: 14 additions & 4 deletions src/utils/get-page-state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,29 @@ function getStateByPath(tempState: any, path: string) {
}

export default function getPageState(specifiedPath = '') {
const tempState = isTenantState() ? TenantModule.tenantState : AdminModule.adminState
if (!tempState) return
const tempState = getCurrentRequiredState()
const path = specifiedPath === '' ? tempState.pages[tempState.pages.length - 1] : specifiedPath
return getStateByPath(tempState, path)
}

export function getPreviousPageState() {
const tempState = isTenantState() ? TenantModule.tenantState : AdminModule.adminState
if (!tempState) return
const tempState = getCurrentRequiredState()
const path = tempState.pages.length === 1 ? tempState.pages[tempState.pages.length - 1] : tempState.pages[tempState.pages.length - 2]
return getStateByPath(tempState, path)
}

export function getFirstPageState() {
const tempState = getCurrentRequiredState()
const path = tempState.pages[0]
return getStateByPath(tempState, path)
}

export function getCurrentRequiredState() {
const tempState = isTenantState() ? TenantModule.tenantState : AdminModule.adminState
if (!tempState) return
return tempState
}

export function isTenantState() {
return (location.hash === '#/tenant' || location.pathname === '/tenant')
}

0 comments on commit b509c34

Please sign in to comment.