refactor: ui
This commit is contained in:
parent
263872d5a3
commit
ef8c555108
@ -1,14 +1,14 @@
|
|||||||
import { Result } from '@/request/Result'
|
import {Result} from '@/request/Result'
|
||||||
import { get, post, postStream, del, put, request, download, exportFile } from '@/request/index'
|
import {get, post, postStream, del, put, request, download, exportFile} from '@/request/index'
|
||||||
import type { pageRequest } from '@/api/type/common'
|
import type {pageRequest} from '@/api/type/common'
|
||||||
import type { ApplicationFormType } from '@/api/type/application'
|
import type {ApplicationFormType} from '@/api/type/application'
|
||||||
import { type Ref } from 'vue'
|
import {type Ref} from 'vue'
|
||||||
import useStore from '@/stores'
|
import useStore from '@/stores'
|
||||||
|
|
||||||
const prefix: any = { _value: '/workspace/' }
|
const prefix: any = {_value: '/workspace/'}
|
||||||
Object.defineProperty(prefix, 'value', {
|
Object.defineProperty(prefix, 'value', {
|
||||||
get: function () {
|
get: function () {
|
||||||
const { user } = useStore()
|
const {user} = useStore()
|
||||||
return this._value + user.getWorkspaceId() + '/application'
|
return this._value + user.getWorkspaceId() + '/application'
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
@ -212,6 +212,17 @@ const getPlatformConfig: (application_id: string, type: string) => Promise<Resul
|
|||||||
) => {
|
) => {
|
||||||
return get(`${prefix.value}/${application_id}/platform/${type}`)
|
return get(`${prefix.value}/${application_id}/platform/${type}`)
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* 更新平台配置
|
||||||
|
*/
|
||||||
|
const updatePlatformConfig: (
|
||||||
|
application_id: string,
|
||||||
|
type: string,
|
||||||
|
data: any,
|
||||||
|
loading?: Ref<boolean>
|
||||||
|
) => Promise<Result<any>> = (application_id, type, data, loading) => {
|
||||||
|
return post(`${prefix.value}/${application_id}/platform/${type}`, data, undefined, loading)
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* 应用发布
|
* 应用发布
|
||||||
* @param application_id
|
* @param application_id
|
||||||
@ -245,4 +256,5 @@ export default {
|
|||||||
updatePlatformStatus,
|
updatePlatformStatus,
|
||||||
getPlatformConfig,
|
getPlatformConfig,
|
||||||
publish,
|
publish,
|
||||||
|
updatePlatformConfig
|
||||||
}
|
}
|
||||||
|
|||||||
@ -79,7 +79,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div v-if="showQrCodeTab">
|
<div v-if="showQrCodeTab">
|
||||||
<QrCodeTab :tabs="orgOptions" />
|
<QrCodeTab :tabs="orgOptions"/>
|
||||||
</div>
|
</div>
|
||||||
<div class="login-gradient-divider lighter mt-24" v-if="modeList.length > 1">
|
<div class="login-gradient-divider lighter mt-24" v-if="modeList.length > 1">
|
||||||
<span>{{ $t('views.login.moreMethod') }}</span>
|
<span>{{ $t('views.login.moreMethod') }}</span>
|
||||||
@ -108,7 +108,7 @@
|
|||||||
class="login-button-circle color-secondary"
|
class="login-button-circle color-secondary"
|
||||||
@click="changeMode('QR_CODE')"
|
@click="changeMode('QR_CODE')"
|
||||||
>
|
>
|
||||||
<img src="@/assets/scan/icon_qr_outlined.svg" width="25px" />
|
<img src="@/assets/scan/icon_qr_outlined.svg" width="25px"/>
|
||||||
</el-button>
|
</el-button>
|
||||||
<el-button
|
<el-button
|
||||||
v-if="item === '' && loginMode !== ''"
|
v-if="item === '' && loginMode !== ''"
|
||||||
@ -125,27 +125,27 @@
|
|||||||
</login-layout>
|
</login-layout>
|
||||||
</template>
|
</template>
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { onMounted, ref, onBeforeMount } from 'vue'
|
import {onMounted, ref, onBeforeMount} from 'vue'
|
||||||
import { useRoute, useRouter } from 'vue-router'
|
import {useRoute, useRouter} from 'vue-router'
|
||||||
import type { FormInstance, FormRules } from 'element-plus'
|
import type {FormInstance, FormRules} from 'element-plus'
|
||||||
import type { LoginRequest } from '@/api/type/login'
|
import type {LoginRequest} from '@/api/type/login'
|
||||||
import LoginContainer from '@/layout/login-layout/LoginContainer.vue'
|
import LoginContainer from '@/layout/login-layout/LoginContainer.vue'
|
||||||
import LoginLayout from '@/layout/login-layout/LoginLayout.vue'
|
import LoginLayout from '@/layout/login-layout/LoginLayout.vue'
|
||||||
import loginApi from '@/api/user/login'
|
import loginApi from '@/api/user/login'
|
||||||
import authApi from '@/api/system-settings/auth-setting'
|
import authApi from '@/api/system-settings/auth-setting'
|
||||||
import { t, getBrowserLang } from '@/locales'
|
import {t, getBrowserLang} from '@/locales'
|
||||||
import useStore from '@/stores'
|
import useStore from '@/stores'
|
||||||
import { useI18n } from 'vue-i18n'
|
import {useI18n} from 'vue-i18n'
|
||||||
import QrCodeTab from '@/views/login/scanCompinents/QrCodeTab.vue'
|
import QrCodeTab from '@/views/login/scanCompinents/QrCodeTab.vue'
|
||||||
import { MsgConfirm, MsgError } from '@/utils/message.ts'
|
import {MsgConfirm, MsgError} from '@/utils/message.ts'
|
||||||
import * as dd from 'dingtalk-jsapi'
|
import * as dd from 'dingtalk-jsapi'
|
||||||
import { loadScript } from '@/utils/utils'
|
import {loadScript} from '@/utils/utils'
|
||||||
import { EditionConst } from '@/utils/permission/data'
|
import {EditionConst} from '@/utils/permission/data'
|
||||||
import { hasPermission } from '@/utils/permission/index'
|
import {hasPermission} from '@/utils/permission/index'
|
||||||
|
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const { login, user, theme } = useStore()
|
const {login, user, theme} = useStore()
|
||||||
const { locale } = useI18n({ useScope: 'global' })
|
const {locale} = useI18n({useScope: 'global'})
|
||||||
const loading = ref<boolean>(false)
|
const loading = ref<boolean>(false)
|
||||||
|
|
||||||
const identifyCode = ref<string>('')
|
const identifyCode = ref<string>('')
|
||||||
@ -186,13 +186,13 @@ const loginHandle = () => {
|
|||||||
if (loginMode.value === 'LDAP') {
|
if (loginMode.value === 'LDAP') {
|
||||||
login.asyncLdapLogin(loginForm.value, loading).then(() => {
|
login.asyncLdapLogin(loginForm.value, loading).then(() => {
|
||||||
locale.value = localStorage.getItem('MaxKB-locale') || getBrowserLang() || 'en-US'
|
locale.value = localStorage.getItem('MaxKB-locale') || getBrowserLang() || 'en-US'
|
||||||
router.push({ name: 'home' })
|
router.push({name: 'home'})
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
login.asyncLogin(loginForm.value, loading).then(() => {
|
login.asyncLogin(loginForm.value, loading).then(() => {
|
||||||
locale.value = localStorage.getItem('MaxKB-locale') || getBrowserLang() || 'en-US'
|
locale.value = localStorage.getItem('MaxKB-locale') || getBrowserLang() || 'en-US'
|
||||||
localStorage.setItem('workspace_id', 'default')
|
localStorage.setItem('workspace_id', 'default')
|
||||||
router.push({ name: 'home' })
|
router.push({name: 'home'})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -275,7 +275,8 @@ function redirectAuth(authType: string) {
|
|||||||
window.location.href = url
|
window.location.href = url
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(() => {})
|
.catch(() => {
|
||||||
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -300,7 +301,7 @@ onBeforeMount(() => {
|
|||||||
loading.value = true
|
loading.value = true
|
||||||
user.asyncGetProfile().then((res) => {
|
user.asyncGetProfile().then((res) => {
|
||||||
// 企业版和专业版:第三方登录
|
// 企业版和专业版:第三方登录
|
||||||
if (hasPermission([EditionConst.IS_EE, EditionConst.IS_PE], 'OR')) {
|
if (user.isPE() || user.isEE()) {
|
||||||
login
|
login
|
||||||
.getAuthType()
|
.getAuthType()
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
@ -350,10 +351,10 @@ onMounted(() => {
|
|||||||
const handleDingTalk = () => {
|
const handleDingTalk = () => {
|
||||||
const code = params.get('corpId')
|
const code = params.get('corpId')
|
||||||
if (code) {
|
if (code) {
|
||||||
dd.runtime.permission.requestAuthCode({ corpId: code }).then((res) => {
|
dd.runtime.permission.requestAuthCode({corpId: code}).then((res) => {
|
||||||
console.log('DingTalk client request success:', res)
|
console.log('DingTalk client request success:', res)
|
||||||
login.dingOauth2Callback(res.code).then(() => {
|
login.dingOauth2Callback(res.code).then(() => {
|
||||||
router.push({ name: 'home' })
|
router.push({name: 'home'})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -366,7 +367,7 @@ onMounted(() => {
|
|||||||
appId: appId,
|
appId: appId,
|
||||||
success: (res: any) => {
|
success: (res: any) => {
|
||||||
login.larkCallback(res.code).then(() => {
|
login.larkCallback(res.code).then(() => {
|
||||||
router.push({ name: 'home' })
|
router.push({name: 'home'})
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
fail: (error: any) => {
|
fail: (error: any) => {
|
||||||
@ -386,11 +387,11 @@ onMounted(() => {
|
|||||||
scopeList: [],
|
scopeList: [],
|
||||||
success: (res: any) => {
|
success: (res: any) => {
|
||||||
login.larkCallback(res.code).then(() => {
|
login.larkCallback(res.code).then(() => {
|
||||||
router.push({ name: 'home' })
|
router.push({name: 'home'})
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
fail: (error: any) => {
|
fail: (error: any) => {
|
||||||
const { errno } = error
|
const {errno} = error
|
||||||
if (errno === 103) {
|
if (errno === 103) {
|
||||||
callRequestAuthCode()
|
callRequestAuthCode()
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,19 +1,18 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="flex-center mb-16">
|
<div class="flex-center mb-16">
|
||||||
<img src="@/assets/scan/logo_lark.svg " alt="" width="24px" class="mr-4" />
|
<img src="@/assets/scan/logo_lark.svg " alt="" width="24px" class="mr-4"/>
|
||||||
<h2>{{ $t('views.system.authentication.scanTheQRCode.larkQrCode') }}</h2>
|
<h2>{{ $t('views.system.authentication.scanTheQRCode.larkQrCode') }}</h2>
|
||||||
</div>
|
</div>
|
||||||
<div id="lark-qr" class="lark-qrName"></div>
|
<div id="lark-qr" class="lark-qrName"></div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { useScriptTag } from '@vueuse/core'
|
import {useScriptTag} from '@vueuse/core'
|
||||||
import { onMounted } from 'vue'
|
import {onMounted} from 'vue'
|
||||||
|
|
||||||
const { load } = useScriptTag(
|
const {load} = useScriptTag(
|
||||||
'https://lf-package-cn.feishucdn.com/obj/feishu-static/lark/passport/qrcode/LarkSSOSDKWebQRCode-1.0.3.js'
|
'https://lf-package-cn.feishucdn.com/obj/feishu-static/lark/passport/qrcode/LarkSSOSDKWebQRCode-1.0.3.js'
|
||||||
)
|
)
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
config: {
|
config: {
|
||||||
app_secret: string
|
app_secret: string
|
||||||
@ -27,15 +26,13 @@ const initActive = async () => {
|
|||||||
console.error('飞书二维码 SDK 加载失败')
|
console.error('飞书二维码 SDK 加载失败')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const data = {
|
const data = {
|
||||||
agentId: props.config.app_key,
|
agentId: props.config.app_key,
|
||||||
appSecret: props.config.app_secret
|
appSecret: props.config.app_secret
|
||||||
}
|
}
|
||||||
|
|
||||||
const redirectUrl = encodeURIComponent(`${window.location.origin}/api/feishu`)
|
const redirectUrl = encodeURIComponent(`${window.location.origin}/api/lark`)
|
||||||
const url = `https://passport.feishu.cn/suite/passport/oauth/authorize?client_id=${data.agentId}&redirect_uri=${redirectUrl}&response_type=code&state=fit2cloud-lark-qr`
|
const url = `https://passport.feishu.cn/suite/passport/oauth/authorize?client_id=${data.agentId}&redirect_uri=${redirectUrl}&response_type=code&state=fit2cloud-lark-qr`
|
||||||
|
|
||||||
const QRLoginObj = window.QRLogin({
|
const QRLoginObj = window.QRLogin({
|
||||||
id: 'lark-qr',
|
id: 'lark-qr',
|
||||||
goto: url,
|
goto: url,
|
||||||
|
|||||||
@ -30,7 +30,7 @@
|
|||||||
<el-form-item :label="$t('views.system.password')" prop="config.password">
|
<el-form-item :label="$t('views.system.password')" prop="config.password">
|
||||||
<el-input
|
<el-input
|
||||||
v-model="form.config.password"
|
v-model="form.config.password"
|
||||||
:placeholder="$t('views.userManage.form.password.placeholder')"
|
:placeholder="$t('views.login.loginForm.password.placeholder')"
|
||||||
show-password
|
show-password
|
||||||
/>
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
@ -120,7 +120,7 @@ const rules = reactive<FormRules<any>>({
|
|||||||
'config.password': [
|
'config.password': [
|
||||||
{
|
{
|
||||||
required: true,
|
required: true,
|
||||||
message: t('views.userManage.form.password.requiredMessage'),
|
message: t('views.login.loginForm.password.placeholder'),
|
||||||
trigger: 'blur'
|
trigger: 'blur'
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|||||||
@ -177,7 +177,7 @@ const open = async (platform: Platform) => {
|
|||||||
currentPlatform.config.callback_url = `${defaultCallbackUrl}/api/dingtalk`
|
currentPlatform.config.callback_url = `${defaultCallbackUrl}/api/dingtalk`
|
||||||
break
|
break
|
||||||
case 'lark':
|
case 'lark':
|
||||||
currentPlatform.config.callback_url = `${defaultCallbackUrl}/api/feishu`
|
currentPlatform.config.callback_url = `${defaultCallbackUrl}/api/lark`
|
||||||
break
|
break
|
||||||
default:
|
default:
|
||||||
break
|
break
|
||||||
|
|||||||
@ -30,7 +30,7 @@
|
|||||||
<el-form-item :label="$t('views.system.password')" prop="config.password">
|
<el-form-item :label="$t('views.system.password')" prop="config.password">
|
||||||
<el-input
|
<el-input
|
||||||
v-model="form.config.password"
|
v-model="form.config.password"
|
||||||
:placeholder="$t('views.userManage.form.password.placeholder')"
|
:placeholder="$t('views.login.loginForm.password.placeholder')"
|
||||||
show-password
|
show-password
|
||||||
/>
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
@ -120,7 +120,7 @@ const rules = reactive<FormRules<any>>({
|
|||||||
'config.password': [
|
'config.password': [
|
||||||
{
|
{
|
||||||
required: true,
|
required: true,
|
||||||
message: t('views.userManage.form.password.requiredMessage'),
|
message: t('views.login.loginForm.password.placeholder'),
|
||||||
trigger: 'blur'
|
trigger: 'blur'
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|||||||
@ -148,7 +148,7 @@ function createPlatform(key: string, name: string): Platform {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
key,
|
key,
|
||||||
logoSrc: new URL(`../../../assets/scan/logo_${logo}.svg`, import.meta.url).href,
|
logoSrc: new URL(`../../../../assets/scan/logo_${logo}.svg`, import.meta.url).href,
|
||||||
name,
|
name,
|
||||||
isActive: false,
|
isActive: false,
|
||||||
isValid: false,
|
isValid: false,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user