From d55359567d603268934a722188b62da34bd02dbf Mon Sep 17 00:00:00 2001 From: Kinplemelon Date: Tue, 18 Nov 2025 17:29:18 +0800 Subject: [PATCH 1/6] refactor(authn): interaction of authentication page --- src/i18n/Auth.ts | 4 + src/router/index.ts | 12 +- src/views/Auth/AuthnCreate.vue | 6 +- src/views/Auth/AuthnDefault.vue | 355 +++++++++++++++++++++ src/views/Auth/AuthnDetails.vue | 7 +- src/views/Auth/AuthnExtended.vue | 144 +++++++++ src/views/Auth/components/AuthnMenuTab.vue | 43 +++ 7 files changed, 563 insertions(+), 8 deletions(-) create mode 100644 src/views/Auth/AuthnDefault.vue create mode 100644 src/views/Auth/AuthnExtended.vue create mode 100644 src/views/Auth/components/AuthnMenuTab.vue diff --git a/src/i18n/Auth.ts b/src/i18n/Auth.ts index f3793a09c..515b8761b 100644 --- a/src/i18n/Auth.ts +++ b/src/i18n/Auth.ts @@ -898,4 +898,8 @@ Find more information about Variform expressions in EMQX doc.`, zh: '存在重复的权限配置', en: 'Duplicated permission configuration', }, + extended: { + zh: '扩展', + en: 'Extended', + }, } diff --git a/src/router/index.ts b/src/router/index.ts index f9c2f89a5..3fc858cb0 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -233,15 +233,21 @@ export const routes: Array = [ { path: '/authentication', component: Layout, + redirect: { name: 'authentication-default' }, meta: { hideKey: 'authentication', authRequired: true, }, children: [ { - path: '', - name: 'authentication', - component: () => import('@/views/Auth/Authn.vue'), + path: 'default', + name: 'authentication-default', + component: () => import('@/views/Auth/AuthnDefault.vue'), + }, + { + path: 'extended', + name: 'authentication-extended', + component: () => import('@/views/Auth/AuthnExtended.vue'), }, { path: 'create', diff --git a/src/views/Auth/AuthnCreate.vue b/src/views/Auth/AuthnCreate.vue index c729afceb..c0e9e8021 100644 --- a/src/views/Auth/AuthnCreate.vue +++ b/src/views/Auth/AuthnCreate.vue @@ -1,7 +1,7 @@ + + + + diff --git a/src/views/Auth/AuthnDetails.vue b/src/views/Auth/AuthnDetails.vue index 4e117ce39..b0859aac6 100644 --- a/src/views/Auth/AuthnDetails.vue +++ b/src/views/Auth/AuthnDetails.vue @@ -3,7 +3,7 @@
+ + + + diff --git a/src/views/Auth/components/AuthnMenuTab.vue b/src/views/Auth/components/AuthnMenuTab.vue new file mode 100644 index 000000000..a4b12ea5b --- /dev/null +++ b/src/views/Auth/components/AuthnMenuTab.vue @@ -0,0 +1,43 @@ + + + + + From b793ce8796e944b8417fc737813ddea8509927ad Mon Sep 17 00:00:00 2001 From: Kinplemelon Date: Tue, 18 Nov 2025 17:48:17 +0800 Subject: [PATCH 2/6] refactor(authn): remove previous sorting --- src/api/auth.ts | 4 +- src/hooks/Auth/useAuthn.ts | 69 ++------------------- src/views/Auth/AuthnExtended.vue | 19 +----- src/views/Auth/components/TableDropdown.vue | 29 +-------- 4 files changed, 10 insertions(+), 111 deletions(-) diff --git a/src/api/auth.ts b/src/api/auth.ts index 5597967ef..99aeefc5c 100644 --- a/src/api/auth.ts +++ b/src/api/auth.ts @@ -1,8 +1,8 @@ /* eslint-disable @typescript-eslint/explicit-module-boundary-types */ import http from '@/common/http' -import { AuthzSetting, ImportResult, Metrics } from '@/types/auth' +import { AuthnItem, AuthzSetting, ImportResult, Metrics } from '@/types/auth' -export function listAuthn(params = {}) { +export function listAuthn(params = {}): Promise { return http.get('/authentication', { params }) } diff --git a/src/hooks/Auth/useAuthn.ts b/src/hooks/Auth/useAuthn.ts index 2446a6294..e83ad364d 100644 --- a/src/hooks/Auth/useAuthn.ts +++ b/src/hooks/Auth/useAuthn.ts @@ -1,7 +1,7 @@ import { listAuthn, queryAuthnItemMetrics } from '@/api/auth' -import { AuthnItem, Metrics } from '@/types/auth' -import { SortableEvent } from 'sortablejs' import jwtIcon from '@/assets/img/jwt.png' +import { AuthnItem, Metrics } from '@/types/auth' +import { AuthnMechanismType } from '@/types/enum' export type AuthnItemInTable = AuthnItem & { metrics?: Metrics @@ -10,14 +10,9 @@ export type AuthnItemInTable = AuthnItem & { export default (): { isListLoading: Ref authnList: Ref - tableCom: Ref getAuthnItemBackendForShow: (item: AuthnItemInTable) => string getAuthnList: (isInit?: boolean) => Promise updateAuthnItemMetrics: (authn: AuthnItem) => Promise - moveAuthnUp: (index: number) => Promise - moveAuthnDown: (index: number) => Promise - moveAuthnToTop: (authn: AuthnItem) => any - moveAuthnToBottom: (authn: AuthnItem) => any } => { const isListLoading = ref(false) const authnList: Ref> = ref([]) @@ -45,13 +40,13 @@ export default (): { const res: AuthnItem[] = await listAuthn() authnList.value = res.map((item) => { const ret: AuthnItemInTable = item - if (ret.mechanism !== 'jwt' && ret.mechanism !== 'cinfo') { + if (ret.mechanism !== 'jwt' && ret.mechanism !== AuthnMechanismType.CINFO) { try { ret.img = getImg(`img/${ret.backend}.png`) } catch { ret.img = '' } - } else if (ret.mechanism === 'cinfo') { + } else if (ret.mechanism === AuthnMechanismType.CINFO) { ret.img = getImg(`img/cinfo.png`) } else { ret.img = jwtIcon @@ -60,8 +55,6 @@ export default (): { return item }) setAddedAuthn() - await nextTick() - initSortable() } catch (error) { console.error(error) } finally { @@ -108,67 +101,13 @@ export default (): { } } - const { - moveAuthnBeforeAnotherAuthn, - moveAuthnAfterAnotherAuthn, - moveAuthnToTop: requestMoveAuthnToTop, - moveAuthnToBottom: requestMoveAuthnToBottom, - } = useHandleAuthnItem() - const moveAuthnUp = async (index: number) => handleDragEvent(index - 1, index, authnList.value) - const moveAuthnDown = async (index: number) => handleDragEvent(index + 1, index, authnList.value) - const moveAuthnToTop = async (row: AuthnItem) => { - try { - await requestMoveAuthnToTop(row) - } catch (error) { - // empty the array first when an error occurs, otherwise the view will not be updated - authnList.value = [] - } finally { - getAuthnList() - } - } - const moveAuthnToBottom = async (row: AuthnItem) => { - try { - await requestMoveAuthnToBottom(row) - } catch (error) { - // empty the array first when an error occurs, otherwise the view will not be updated - authnList.value = [] - } finally { - getAuthnList() - } - } - const { handleDragEvent } = useMove( - { - moveToBottom: moveAuthnToBottom, - moveToTop: moveAuthnToTop, - moveBeforeAnotherTarget: moveAuthnBeforeAnotherAuthn, - moveAfterAnotherTarget: moveAuthnAfterAnotherAuthn, - }, - undefined, - getAuthnList, - ) - - const handleOrderChanged = async (evt: SortableEvent) => { - const { newIndex, oldIndex } = evt - if (newIndex === undefined || oldIndex === undefined) { - return - } - handleDragEvent(newIndex, oldIndex, authnList.value) - } - - const { tableCom, initSortable } = useSortableTable(handleOrderChanged) - initTableData() return { isListLoading, authnList, - tableCom, getAuthnItemBackendForShow, getAuthnList, updateAuthnItemMetrics, - moveAuthnUp, - moveAuthnDown, - moveAuthnToTop, - moveAuthnToBottom, } } diff --git a/src/views/Auth/AuthnExtended.vue b/src/views/Auth/AuthnExtended.vue index 356a9b4b5..72fca511c 100644 --- a/src/views/Auth/AuthnExtended.vue +++ b/src/views/Auth/AuthnExtended.vue @@ -7,13 +7,7 @@
- + - + diff --git a/src/views/Auth/components/AuthnManager.vue b/src/views/Auth/components/AuthnManager.vue index b5f542518..1877a89a3 100644 --- a/src/views/Auth/components/AuthnManager.vue +++ b/src/views/Auth/components/AuthnManager.vue @@ -30,100 +30,37 @@ {{ t('Base.add') }} - - - - - - - - - - - - + - - - - - - - - - -
- -

- {{ $t('Auth.isSuperuserDesc') }} -

-
-
-
- -
+ :authn-id="id" + :field="field" + :user="currentItem" + :gateway="gateway" + @save="loadData" + /> + + diff --git a/src/views/Auth/components/AuthnUserTable.vue b/src/views/Auth/components/AuthnUserTable.vue new file mode 100644 index 000000000..70ecec217 --- /dev/null +++ b/src/views/Auth/components/AuthnUserTable.vue @@ -0,0 +1,59 @@ + + + + + From d568b56b317cc1e0a4b1e1c2e9d93e95942b85bc Mon Sep 17 00:00:00 2001 From: Kinplemelon Date: Wed, 19 Nov 2025 17:07:30 +0800 Subject: [PATCH 6/6] refactor(authn): unify style --- src/views/Auth/AuthnDefault.vue | 77 ++++++++++++++++++--------------- 1 file changed, 43 insertions(+), 34 deletions(-) diff --git a/src/views/Auth/AuthnDefault.vue b/src/views/Auth/AuthnDefault.vue index 0c27e2e48..75a53b848 100644 --- a/src/views/Auth/AuthnDefault.vue +++ b/src/views/Auth/AuthnDefault.vue @@ -1,31 +1,41 @@