From 41ec908f37519210cae360dcf13d14caa55c7695 Mon Sep 17 00:00:00 2001 From: ibuler Date: Fri, 9 May 2025 17:19:51 +0800 Subject: [PATCH] perf: update auth intergration --- src/store/modules/settings.js | 30 ++++ src/views/settings/Auth/Basic.vue | 47 ++++-- .../AuthMethod.vue} | 20 +-- src/views/settings/Auth/const.js | 115 +++++-------- src/views/settings/Auth/index.vue | 151 +++--------------- 5 files changed, 135 insertions(+), 228 deletions(-) rename src/views/settings/Auth/{AuthItem.vue => components/AuthMethod.vue} (79%) diff --git a/src/store/modules/settings.js b/src/store/modules/settings.js index 275c5d9a8..08c70f898 100644 --- a/src/store/modules/settings.js +++ b/src/store/modules/settings.js @@ -2,6 +2,7 @@ import defaultSettings from '@/settings' import { getPublicSettings } from '@/api/settings' import { changeElementColor, changeThemeColors } from '@/utils/theme/index' import { changeMenuColor } from '@/utils/theme/color' +import request from '@/utils/request' const { showSettings, fixedHeader, sidebarLogo, tagsView } = defaultSettings @@ -12,6 +13,7 @@ const state = { tagsView: tagsView, publicSettings: {}, hasValidLicense: false, + authMethods: {}, themeColors: JSON.parse(localStorage.getItem('themeColors')) || {} } @@ -78,6 +80,34 @@ const actions = { changeMenuColor(themeColors) changeElementColor(themeColors) commit('setTheme', themeColors) + }, + updateAuthItemStatus({ commit }, payload) { + const [key, value] = payload + return new Promise((resolve, reject) => { + const url = '/api/v1/settings/setting/?category=auth' + const data = { [key]: value } + request.patch(url, data).then(res => { + state.authMethods[key] = value + resolve(res) + }).catch(error => { + reject(error) + }) + }) + }, + getAuthMethods({ commit, state }) { + return new Promise((resolve, reject) => { + if (state.authMethods && Object.keys(state.authMethods).length > 0) { + resolve(state.authMethods) + } else { + const url = '/api/v1/settings/setting/?category=auth' + request.get(url).then(res => { + state.authMethods = res + resolve(res) + }).catch(error => { + reject(error) + }) + } + }) } } diff --git a/src/views/settings/Auth/Basic.vue b/src/views/settings/Auth/Basic.vue index 8e5b5e435..0561c84c2 100644 --- a/src/views/settings/Auth/Basic.vue +++ b/src/views/settings/Auth/Basic.vue @@ -1,33 +1,32 @@ -