mirror of
https://github.com/1Panel-dev/MaxKB.git
synced 2025-12-30 09:42:48 +00:00
refactor: ui
This commit is contained in:
parent
263872d5a3
commit
ef8c555108
|
|
@ -1,14 +1,14 @@
|
|||
import { Result } from '@/request/Result'
|
||||
import { get, post, postStream, del, put, request, download, exportFile } from '@/request/index'
|
||||
import type { pageRequest } from '@/api/type/common'
|
||||
import type { ApplicationFormType } from '@/api/type/application'
|
||||
import { type Ref } from 'vue'
|
||||
import {Result} from '@/request/Result'
|
||||
import {get, post, postStream, del, put, request, download, exportFile} from '@/request/index'
|
||||
import type {pageRequest} from '@/api/type/common'
|
||||
import type {ApplicationFormType} from '@/api/type/application'
|
||||
import {type Ref} from 'vue'
|
||||
import useStore from '@/stores'
|
||||
|
||||
const prefix: any = { _value: '/workspace/' }
|
||||
const prefix: any = {_value: '/workspace/'}
|
||||
Object.defineProperty(prefix, 'value', {
|
||||
get: function () {
|
||||
const { user } = useStore()
|
||||
const {user} = useStore()
|
||||
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}`)
|
||||
}
|
||||
/**
|
||||
* 更新平台配置
|
||||
*/
|
||||
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
|
||||
|
|
@ -245,4 +256,5 @@ export default {
|
|||
updatePlatformStatus,
|
||||
getPlatformConfig,
|
||||
publish,
|
||||
updatePlatformConfig
|
||||
}
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@
|
|||
</div>
|
||||
</div>
|
||||
<div v-if="showQrCodeTab">
|
||||
<QrCodeTab :tabs="orgOptions" />
|
||||
<QrCodeTab :tabs="orgOptions"/>
|
||||
</div>
|
||||
<div class="login-gradient-divider lighter mt-24" v-if="modeList.length > 1">
|
||||
<span>{{ $t('views.login.moreMethod') }}</span>
|
||||
|
|
@ -98,7 +98,7 @@
|
|||
'font-size': item === 'OAUTH2' ? '8px' : '10px',
|
||||
color: theme.themeInfo?.theme,
|
||||
}"
|
||||
>{{ item }}</span
|
||||
>{{ item }}</span
|
||||
>
|
||||
</el-button>
|
||||
<el-button
|
||||
|
|
@ -108,7 +108,7 @@
|
|||
class="login-button-circle color-secondary"
|
||||
@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
|
||||
v-if="item === '' && loginMode !== ''"
|
||||
|
|
@ -125,27 +125,27 @@
|
|||
</login-layout>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { onMounted, ref, onBeforeMount } from 'vue'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
import type { FormInstance, FormRules } from 'element-plus'
|
||||
import type { LoginRequest } from '@/api/type/login'
|
||||
import {onMounted, ref, onBeforeMount} from 'vue'
|
||||
import {useRoute, useRouter} from 'vue-router'
|
||||
import type {FormInstance, FormRules} from 'element-plus'
|
||||
import type {LoginRequest} from '@/api/type/login'
|
||||
import LoginContainer from '@/layout/login-layout/LoginContainer.vue'
|
||||
import LoginLayout from '@/layout/login-layout/LoginLayout.vue'
|
||||
import loginApi from '@/api/user/login'
|
||||
import authApi from '@/api/system-settings/auth-setting'
|
||||
import { t, getBrowserLang } from '@/locales'
|
||||
import {t, getBrowserLang} from '@/locales'
|
||||
import useStore from '@/stores'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import {useI18n} from 'vue-i18n'
|
||||
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 { loadScript } from '@/utils/utils'
|
||||
import { EditionConst } from '@/utils/permission/data'
|
||||
import { hasPermission } from '@/utils/permission/index'
|
||||
import {loadScript} from '@/utils/utils'
|
||||
import {EditionConst} from '@/utils/permission/data'
|
||||
import {hasPermission} from '@/utils/permission/index'
|
||||
|
||||
const router = useRouter()
|
||||
const { login, user, theme } = useStore()
|
||||
const { locale } = useI18n({ useScope: 'global' })
|
||||
const {login, user, theme} = useStore()
|
||||
const {locale} = useI18n({useScope: 'global'})
|
||||
const loading = ref<boolean>(false)
|
||||
|
||||
const identifyCode = ref<string>('')
|
||||
|
|
@ -186,13 +186,13 @@ const loginHandle = () => {
|
|||
if (loginMode.value === 'LDAP') {
|
||||
login.asyncLdapLogin(loginForm.value, loading).then(() => {
|
||||
locale.value = localStorage.getItem('MaxKB-locale') || getBrowserLang() || 'en-US'
|
||||
router.push({ name: 'home' })
|
||||
router.push({name: 'home'})
|
||||
})
|
||||
} else {
|
||||
login.asyncLogin(loginForm.value, loading).then(() => {
|
||||
locale.value = localStorage.getItem('MaxKB-locale') || getBrowserLang() || 'en-US'
|
||||
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
|
||||
}
|
||||
})
|
||||
.catch(() => {})
|
||||
.catch(() => {
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
|
|
@ -300,7 +301,7 @@ onBeforeMount(() => {
|
|||
loading.value = true
|
||||
user.asyncGetProfile().then((res) => {
|
||||
// 企业版和专业版:第三方登录
|
||||
if (hasPermission([EditionConst.IS_EE, EditionConst.IS_PE], 'OR')) {
|
||||
if (user.isPE() || user.isEE()) {
|
||||
login
|
||||
.getAuthType()
|
||||
.then((res) => {
|
||||
|
|
@ -350,10 +351,10 @@ onMounted(() => {
|
|||
const handleDingTalk = () => {
|
||||
const code = params.get('corpId')
|
||||
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)
|
||||
login.dingOauth2Callback(res.code).then(() => {
|
||||
router.push({ name: 'home' })
|
||||
router.push({name: 'home'})
|
||||
})
|
||||
})
|
||||
}
|
||||
|
|
@ -366,7 +367,7 @@ onMounted(() => {
|
|||
appId: appId,
|
||||
success: (res: any) => {
|
||||
login.larkCallback(res.code).then(() => {
|
||||
router.push({ name: 'home' })
|
||||
router.push({name: 'home'})
|
||||
})
|
||||
},
|
||||
fail: (error: any) => {
|
||||
|
|
@ -386,11 +387,11 @@ onMounted(() => {
|
|||
scopeList: [],
|
||||
success: (res: any) => {
|
||||
login.larkCallback(res.code).then(() => {
|
||||
router.push({ name: 'home' })
|
||||
router.push({name: 'home'})
|
||||
})
|
||||
},
|
||||
fail: (error: any) => {
|
||||
const { errno } = error
|
||||
const {errno} = error
|
||||
if (errno === 103) {
|
||||
callRequestAuthCode()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,19 +1,18 @@
|
|||
<template>
|
||||
<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>
|
||||
</div>
|
||||
<div id="lark-qr" class="lark-qrName"></div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { useScriptTag } from '@vueuse/core'
|
||||
import { onMounted } from 'vue'
|
||||
import {useScriptTag} from '@vueuse/core'
|
||||
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'
|
||||
)
|
||||
|
||||
const props = defineProps<{
|
||||
config: {
|
||||
app_secret: string
|
||||
|
|
@ -27,15 +26,13 @@ const initActive = async () => {
|
|||
console.error('飞书二维码 SDK 加载失败')
|
||||
return
|
||||
}
|
||||
|
||||
const data = {
|
||||
agentId: props.config.app_key,
|
||||
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 QRLoginObj = window.QRLogin({
|
||||
id: 'lark-qr',
|
||||
goto: url,
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@
|
|||
<el-form-item :label="$t('views.system.password')" prop="config.password">
|
||||
<el-input
|
||||
v-model="form.config.password"
|
||||
:placeholder="$t('views.userManage.form.password.placeholder')"
|
||||
:placeholder="$t('views.login.loginForm.password.placeholder')"
|
||||
show-password
|
||||
/>
|
||||
</el-form-item>
|
||||
|
|
@ -120,7 +120,7 @@ const rules = reactive<FormRules<any>>({
|
|||
'config.password': [
|
||||
{
|
||||
required: true,
|
||||
message: t('views.userManage.form.password.requiredMessage'),
|
||||
message: t('views.login.loginForm.password.placeholder'),
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
|
|
|
|||
|
|
@ -177,7 +177,7 @@ const open = async (platform: Platform) => {
|
|||
currentPlatform.config.callback_url = `${defaultCallbackUrl}/api/dingtalk`
|
||||
break
|
||||
case 'lark':
|
||||
currentPlatform.config.callback_url = `${defaultCallbackUrl}/api/feishu`
|
||||
currentPlatform.config.callback_url = `${defaultCallbackUrl}/api/lark`
|
||||
break
|
||||
default:
|
||||
break
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@
|
|||
<el-form-item :label="$t('views.system.password')" prop="config.password">
|
||||
<el-input
|
||||
v-model="form.config.password"
|
||||
:placeholder="$t('views.userManage.form.password.placeholder')"
|
||||
:placeholder="$t('views.login.loginForm.password.placeholder')"
|
||||
show-password
|
||||
/>
|
||||
</el-form-item>
|
||||
|
|
@ -120,7 +120,7 @@ const rules = reactive<FormRules<any>>({
|
|||
'config.password': [
|
||||
{
|
||||
required: true,
|
||||
message: t('views.userManage.form.password.requiredMessage'),
|
||||
message: t('views.login.loginForm.password.placeholder'),
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
|
|
|
|||
|
|
@ -148,7 +148,7 @@ function createPlatform(key: string, name: string): Platform {
|
|||
|
||||
return {
|
||||
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,
|
||||
isActive: false,
|
||||
isValid: false,
|
||||
|
|
|
|||
Loading…
Reference in New Issue