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 #99 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 b509c34 + f5337bb commit 58652ce
Show file tree
Hide file tree
Showing 13 changed files with 73 additions and 224 deletions.
7 changes: 4 additions & 3 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@
</template>

<script lang="ts">
import { Component, Vue } from 'vue-property-decorator'
import { Component, Vue, Watch } from 'vue-property-decorator'
import ServiceWorkerUpdatePopup from './pwa/components/ServiceWorkerUpdatePopup.vue'
// import { GetUserAuthFlow } from './flows/getUserAuth'
import { runFlowByFile } from '@/arkfbp/index'
import OpenAPI from '@/config/openapi'
@Component({
name: 'App',
Expand All @@ -21,6 +22,8 @@ import { runFlowByFile } from '@/arkfbp/index'
}
})
export default class extends Vue {
private openAPIInited = false
getUserInfo() {
// runWorkflow(new GetUserAuthFlow(), { store: this.$store })
}
Expand All @@ -33,8 +36,6 @@ export default class extends Vue {
}
}
openAPIInited = false
async created() {
await this.setCurrentTenant()
this.openAPIInited = true
Expand Down
4 changes: 3 additions & 1 deletion src/admin/router/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import Layout from '@/layout/index.vue'
// 之后该方法需要进一步根据OpenAPI的字段信息进行补充和完善
// 通过补充和完善体现该方法的扩展性和适应性
export function initRouterFromOpenAPI(openAPI: any) {
if (!openAPI) return []
const originRouters = openAPI.info.routers
const routers: RouteConfig[] = generateAsyncRoutersByOpenApiInfo(originRouters)
return routers
Expand Down Expand Up @@ -50,7 +51,8 @@ function generateRouterItem(tempRouter: any): RouteConfig {
meta: {
title: tempRouter.name,
icon: tempRouter.icon || 'dashboard',
page: tempRouter.page
page: tempRouter.page,
role: tempRouter.role,
}
}
}
Expand Down
1 change: 1 addition & 0 deletions src/flows/tablePage/fetch/nodes/fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export class Fetch extends AuthApiNode {
const tempState = this.getState()
this.url = getUrl(this.inputs.params.fetchUrl)
this.method = this.inputs.params.fetchMethod || 'get'

this.params = {
page: tempState.pagination.currentPage || 1,
page_size: tempState.pagination.pageSize || 10
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { FunctionNode } from 'arkfbp/lib/functionNode'
import { StateNode } from '@/nodes/stateNode'
import DialogState from '@/admin/common/Others/Dialog/DialogState'

export class AddSwitchTenantButton extends FunctionNode {
export class AddSwitchTenantButton extends StateNode {
async run() {
const tempState = this.inputs.tempState
// button
Expand Down
2 changes: 1 addition & 1 deletion src/flows/tenant/openSwitchTenantDialog/nodes/open.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import OpenDialog from '@/nodes/openDialog'
export class OpenSwitchTenantDialog extends OpenDialog {

get dialog(): DialogState | null {
const tempState: TablePageState = this.inputs.com.$store.state.tenant.tenantState
const tempState: TablePageState = this.getState()
if (tempState && tempState.dialogs) {
return tempState.dialogs.switch
} else {
Expand Down
6 changes: 3 additions & 3 deletions src/flows/tenant/setCurrentTenant/nodes/setCurrentTenant.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { TokenAPINode } from '@/arkfbp/nodes/tokenAPINode'
import { AuthApiNode } from '@/nodes/authApiNode'
import { TenantModule } from '@/store/modules/tenant'
import LoginStore from '@/login/store/login'

export class SetCurrentTenant extends TokenAPINode {
export class SetCurrentTenant extends AuthApiNode {
async run() {
const tenantUUId = LoginStore.TenantUUID || TenantModule.currentTenant.uuid || this.inputs.route.query.tenant
const tenantUUId = LoginStore.TenantUUID || TenantModule.currentTenant.uuid || this.inputs.route.query.tenant || location.hash.split('=')[1]
this.url = '/api/v1/tenant/'
this.method = 'get'
const outputs = await super.run()
Expand Down
13 changes: 9 additions & 4 deletions src/flows/tenant/switchTenant/nodes/switchTenant.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
import { FunctionNode } from 'arkfbp/lib/functionNode'
import { StateNode } from '@/nodes/stateNode'
import { TenantModule } from '@/store/modules/tenant'
import TablePageState from '@/admin/TablePage/TablePageState'

export class SwitchTenant extends FunctionNode {
export class SwitchTenant extends StateNode {
async run() {
const tenantState: TablePageState = this.inputs.com.$store.state.tenant.tenantState
const tenantState: TablePageState = this.getState()
const data = tenantState.dialogs?.switch.data
TenantModule.changeCurrentTenant(data)
const router = this.inputs.params.router
if (tenantState && tenantState.dialogs) {
tenantState.dialogs.switch.visible = false
}
router.push('/')
router.push({
path: '/',
query: {
tenant: TenantModule.currentTenant.uuid
}
})
return this.inputs
}
}
3 changes: 0 additions & 3 deletions src/layout/components/Sidebar/SidebarItemLink.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@ export default class extends Vue {
}
private toTarget() {
if (this.to === '/desktop') {
return '/desktop'
}
if (this.to.includes('system')) {
return {
path: this.to
Expand Down
217 changes: 23 additions & 194 deletions src/login/Login.vue
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
<template>
<login-component
title="北京龙归科技有限公司"
icon="https://www.longguikeji.com/img/icons/favicon-32x32.png"
v-if="isRenderLoginPage"
:title="tenant ? tenant.name : ''"
:icon="tenant ? tenant.icon : ''"
:config="config"
/>
</template>
<script lang="ts">
import Vue from 'vue'
import { Component } from 'vue-property-decorator'
import LoginComponent from './components/LoginComponent.vue'
import { LoginPagesConfig, LoginPageConfig } from './interface'
import { LoginPagesConfig, LoginPageConfig, LoginTenant } from './interface'
import LoginStore from './store/login'
import { jsonp } from 'vue-jsonp'
@Component({
name: 'Login',
Expand All @@ -19,201 +21,28 @@ import LoginStore from './store/login'
}
})
export default class Login extends Vue {
get config():LoginPagesConfig {
private isRenderLoginPage = false
private config: LoginPagesConfig = {}
private tenant: LoginTenant = {}
async created() {
await this.getLoginPage()
}
private async getLoginPage() {
LoginStore.TenantUUID = this.$route.query.tenant
let host = ''
let url = '/api/v1/loginpage/'
if (LoginStore.TenantUUID) {
host = LoginStore.host + '/api/v1/tenant/' + LoginStore.TenantUUID
} else {
host = LoginStore.host + '/api/v1'
}
let extendLogin:Object|undefined
if (!LoginStore.ThirdUserID && !LoginStore.BindUrl) {
extendLogin = {
title: '第三方登录',
buttons: [
{
img: 'https://github.githubassets.com/favicons/favicon.png',
tooltip: 'Github',
redirect: {
url: host + '/github/login',
params: {
next: 'http://' + window.location.host + '/third_part_callback'
}
}
},
{
img: 'https://gitee.com/assets/favicon.ico',
tooltip: 'Gitee',
redirect: {
url: host + '/gitee/login',
params: {
next: 'http://' + window.location.host + '/third_part_callback'
}
}
}
]
}
}
const loginPage:LoginPageConfig = {
forms: [
{
label: '密码登录',
items: [
{
type: 'text',
placeholder: '请输入账号,手机号',
name: 'username'
},
{
type: 'password',
placeholder: '请输入密码',
name: 'password'
}
],
submit: {
label: '登录',
http: {
url: host + '/login/',
method: 'post',
params: {
username: 'username',
password: 'password'
}
}
}
},
{
label: '验证码登录',
items: [
{
type: 'text',
placeholder: '请输入手机号',
name: 'mobile'
},
{
type: 'text',
placeholder: '请输入验证码',
name: 'code',
append: {
label: '发送验证码',
delay: 60,
http: {
url: host + '/send_sms/',
method: 'post',
params: {
mobile: 'mobile'
}
}
}
}
],
submit: {
label: '登录',
http: {
url: host + '/mobile_login/',
method: 'post',
params: {
mobile: 'mobile',
code: 'code'
}
}
}
}
],
bottoms: [
{
prepend: '还没有账号,',
label: '立即注册',
gopage: 'register'
},
{
label: '忘记密码?'
}
],
extend: extendLogin
}
const registerPage:LoginPageConfig = {
forms: [
{
label: '用户名注册',
items: [
{
type: 'text',
placeholder: '用户名',
name: 'username'
},
{
type: 'password',
placeholder: '密码',
name: 'password'
},
{
type: 'password',
placeholder: '重新填写密码',
name: 'password'
}
],
submit: {
label: '注册'
// http: {
// url: ''
// }
}
},
{
label: '手机号注册',
items: [
{
type: 'text',
placeholder: '请输入手机号',
name: 'mobile'
},
{
type: 'password',
placeholder: '密码',
name: 'password'
},
{
type: 'password',
placeholder: '重新填写密码',
name: 'password'
},
{
type: 'text',
placeholder: '请输入验证码',
name: 'code',
append: {
label: '发送验证码',
delay: 60,
http: {
url: host + '/send_sms/',
method: 'post',
params: {
mobile: 'mobile'
}
}
}
}
],
submit: {
label: '注册'
}
}
],
bottoms: [
{
prepend: '已有账号,',
label: '立即登录',
gopage: 'login'
}
]
url = '/api/v1/loginpage/?tenant=' + LoginStore.TenantUUID
}
return {
login: loginPage,
register: registerPage
const params = {
url,
method: 'get'
}
const { data, tenant } = await jsonp('/api/v1/jsonp', params)
this.config = data
this.tenant = tenant
this.isRenderLoginPage = true
}
}
</script>
Expand Down
2 changes: 1 addition & 1 deletion src/login/flows/ButtonClick/nodes/Http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export class Http extends FunctionNode {
async run() {
const com = this.$state.fetch().com
const btn = this.$state.fetch().btn as ButtonConfig

if (btn.http) {
const url = btn.http.url
const method = btn.http.method
Expand Down
9 changes: 9 additions & 0 deletions src/login/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ export interface LoginPagesConfig {
}

export interface LoginPageConfig {
name?: string
forms?:Array<FormConfig>
bottoms?:Array<ButtonConfig>
extend?:{
Expand Down Expand Up @@ -42,3 +43,11 @@ export interface ButtonConfig {
}
delay?:Number
}

export interface LoginTenant {
uuid?: string
name?: string
slug?: string
icon?: string
created?: string
}
Loading

0 comments on commit 58652ce

Please sign in to comment.