mirror of
https://gitee.com/bootx/dax-pay-ui
synced 2026-08-11 23:25:33 +08:00
refactor(social): 管理端登录配置 SocialConfig 迁移为 SocialLoginConfig
配合后端重命名同步管理端: - SocialConfigApi -> SocialLoginConfigApi, URL /social/config -> /social/login-config - 视图 social-config.vue -> social-login-config.vue, SocialConfigDrawer.vue -> SocialLoginConfigDrawer.vue - 权限码 perm-codes 更新为 iam:social:login-config:view|manage
This commit is contained in:
@@ -72,34 +72,34 @@ export const SocialApi = {
|
||||
/**
|
||||
* 第三方平台登录配置管理 API
|
||||
*/
|
||||
export const SocialConfigApi = {
|
||||
export const SocialLoginConfigApi = {
|
||||
/**
|
||||
* 全量查询平台配置(枚举驱动, 首次访问读时初始化缺失平台)
|
||||
* 未配置平台返回 configured=false 的占位记录(已落库, 含 id)
|
||||
*/
|
||||
findAll(): Promise<Result<SocialConfigResult[]>> {
|
||||
return defHttp.get({ url: '/social/config/find-all' });
|
||||
findAll(): Promise<Result<SocialLoginConfigResult[]>> {
|
||||
return defHttp.get({ url: '/social/login-config/find-all' });
|
||||
},
|
||||
|
||||
/**
|
||||
* 根据平台编码查询(不存在则初始化占位记录, 返回含 id 的记录)
|
||||
*/
|
||||
findBySource(source: string): Promise<Result<SocialConfigResult>> {
|
||||
return defHttp.get({ url: '/social/config/get-by-source', params: { source } });
|
||||
findBySource(source: string): Promise<Result<SocialLoginConfigResult>> {
|
||||
return defHttp.get({ url: '/social/login-config/get-by-source', params: { source } });
|
||||
},
|
||||
|
||||
/**
|
||||
* 修改平台配置(保存即标记为已配置)
|
||||
*/
|
||||
update(data: SocialConfigParam): Promise<Result<void>> {
|
||||
return defHttp.post({ url: '/social/config/update', data });
|
||||
update(data: SocialLoginConfigParam): Promise<Result<void>> {
|
||||
return defHttp.post({ url: '/social/login-config/update', data });
|
||||
},
|
||||
|
||||
/**
|
||||
* 切换平台启用状态(仅已配置平台可启停)
|
||||
*/
|
||||
updateEnabled(source: string, enabled: boolean): Promise<Result<void>> {
|
||||
return defHttp.post({ url: '/social/config/update-enabled', params: { source, enabled } });
|
||||
return defHttp.post({ url: '/social/login-config/update-enabled', params: { source, enabled } });
|
||||
},
|
||||
};
|
||||
|
||||
@@ -128,7 +128,7 @@ export interface SocialBindResult {
|
||||
/**
|
||||
* 第三方平台登录配置
|
||||
*/
|
||||
export interface SocialConfigResult {
|
||||
export interface SocialLoginConfigResult {
|
||||
/** 主键 */
|
||||
id?: string;
|
||||
/** 平台编码 */
|
||||
@@ -148,7 +148,7 @@ export interface SocialConfigResult {
|
||||
/**
|
||||
* 第三方平台登录配置表单参数
|
||||
*/
|
||||
export interface SocialConfigParam extends Partial<SocialConfigResult> {}
|
||||
export interface SocialLoginConfigParam extends Partial<SocialLoginConfigResult> {}
|
||||
|
||||
/**
|
||||
* 社交登录授权码兑换结果
|
||||
|
||||
@@ -37,8 +37,8 @@ export const PermCodes = {
|
||||
KICKOUT: 'iam:online:user:kickout',
|
||||
},
|
||||
Social: {
|
||||
VIEW: 'iam:social:config:view',
|
||||
MANAGE: 'iam:social:config:manage',
|
||||
VIEW: 'iam:social:login-config:view',
|
||||
MANAGE: 'iam:social:login-config:manage',
|
||||
},
|
||||
},
|
||||
|
||||
@@ -250,6 +250,16 @@ export const PermCodes = {
|
||||
MANAGE: 'system:notify:notice:manage',
|
||||
PUBLISH: 'system:notify:notice:publish',
|
||||
},
|
||||
/** 公众号配置 menuCode=system:notify:wechat-config */
|
||||
WechatConfig: {
|
||||
MANAGE: 'system:notify:wechat-config:manage',
|
||||
},
|
||||
/** 微信通知记录 menuCode=system:notify:wechat-message */
|
||||
WechatMessage: {
|
||||
VIEW: 'system:notify:wechat-message:view',
|
||||
RESEND: 'system:notify:wechat-message:resend',
|
||||
TEST: 'system:notify:wechat-message:test',
|
||||
},
|
||||
/** 存储文件 menuCode=system:file:platform */
|
||||
FilePlatform: {
|
||||
VIEW: 'system:file:platform:view',
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script lang="ts" setup>
|
||||
import type { SocialConfigParam, SocialConfigResult } from '#/api/iam/social.api';
|
||||
import type { SocialLoginConfigParam, SocialLoginConfigResult } from '#/api/iam/social.api';
|
||||
|
||||
import { computed, reactive, ref, watch } from 'vue';
|
||||
|
||||
@@ -7,15 +7,15 @@
|
||||
import { useClipboard } from '@vueuse/core';
|
||||
import { IconifyIcon } from '@vben-core/icons';
|
||||
|
||||
import { SocialConfigApi } from '#/api/iam/social.api';
|
||||
import { SocialLoginConfigApi } from '#/api/iam/social.api';
|
||||
import { UrlConfigApi } from '#/api/system/url-config.api';
|
||||
import { useFormEdit } from '#/hooks/useFormEdit';
|
||||
import { useMessage } from '#/hooks/useMessage';
|
||||
|
||||
defineOptions({ name: 'SocialConfigDrawer' });
|
||||
defineOptions({ name: 'SocialLoginConfigDrawer' });
|
||||
|
||||
const props = defineProps<{
|
||||
configItem: null | SocialConfigResult;
|
||||
configItem: null | SocialLoginConfigResult;
|
||||
visible: boolean;
|
||||
}>();
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
const formRef = ref();
|
||||
// 当前操作的平台(新增/编辑时锁定, 决定是否显示 agentId 字段)
|
||||
const currentSource = ref<string>('');
|
||||
const formData = reactive<SocialConfigParam>({
|
||||
const formData = reactive<SocialLoginConfigParam>({
|
||||
id: undefined,
|
||||
source: '',
|
||||
clientId: '',
|
||||
@@ -55,7 +55,7 @@
|
||||
}));
|
||||
|
||||
// 原始脱敏数据(来自后端), 用于 diffForm 比对敏感字段是否被修改
|
||||
const originalForm = ref<SocialConfigResult>({});
|
||||
const originalForm = ref<SocialLoginConfigResult>({});
|
||||
|
||||
/**
|
||||
* 是否显示企业微信 agentId 字段
|
||||
@@ -131,7 +131,7 @@
|
||||
});
|
||||
} else {
|
||||
// 配置模式(未配置平台), 先调 findBySource 初始化占位记录
|
||||
const record = (await SocialConfigApi.findBySource(item.source!)).data;
|
||||
const record = (await SocialLoginConfigApi.findBySource(item.source!)).data;
|
||||
currentSource.value = record.source || '';
|
||||
const configSourceName = $t(`iam.social.platform.${currentSource.value}`);
|
||||
modalTitle.value = `${configSourceName}${$t('iam.social.action.config')}`;
|
||||
@@ -160,11 +160,11 @@
|
||||
// 未修改返回 undefined(JSON 序列化时字段被忽略, 后端 NOT_NULL 策略下不参与 UPDATE),
|
||||
// 修改则返回新值
|
||||
const sensitiveData = diffForm(originalForm.value, formData, 'clientSecret');
|
||||
const submitData: SocialConfigParam = {
|
||||
const submitData: SocialLoginConfigParam = {
|
||||
...formData,
|
||||
...sensitiveData,
|
||||
};
|
||||
await SocialConfigApi.update(submitData);
|
||||
await SocialLoginConfigApi.update(submitData);
|
||||
message.success($t(isFirstConfig.value ? 'iam.social.tip.configSuccess' : 'iam.social.tip.editSuccess'));
|
||||
emit('update:visible', false);
|
||||
emit('saved');
|
||||
@@ -1,5 +1,5 @@
|
||||
<script lang="ts" setup>
|
||||
import type { SocialConfigResult } from '#/api/iam/social.api';
|
||||
import type { SocialLoginConfigResult } from '#/api/iam/social.api';
|
||||
|
||||
import { computed, onMounted, ref } from 'vue';
|
||||
|
||||
@@ -7,17 +7,17 @@
|
||||
|
||||
import { IconifyIcon } from '@vben-core/icons';
|
||||
|
||||
import { SocialConfigApi } from '#/api/iam/social.api';
|
||||
import { SocialLoginConfigApi } from '#/api/iam/social.api';
|
||||
import SocialLogo from '#/components/social/SocialLogo.vue';
|
||||
import { socialColorMap } from '#/enums/social';
|
||||
|
||||
import SocialConfigDrawer from './components/SocialConfigDrawer.vue';
|
||||
import SocialLoginConfigDrawer from './components/SocialLoginConfigDrawer.vue';
|
||||
|
||||
defineOptions({ name: 'SocialConfigList' });
|
||||
defineOptions({ name: 'SocialLoginConfigList' });
|
||||
|
||||
const loading = ref(false);
|
||||
// 平台配置列表(来自后端 枚举+库表内存合并, 已含未配置平台的缺省展示项)
|
||||
const configList = ref<SocialConfigResult[]>([]);
|
||||
const configList = ref<SocialLoginConfigResult[]>([]);
|
||||
|
||||
/**
|
||||
* 卡片列表: 在后端返回基础上补充展示用的 label(国际化名称) 与 color(品牌色)
|
||||
@@ -36,7 +36,7 @@
|
||||
*/
|
||||
function loadConfig() {
|
||||
loading.value = true;
|
||||
SocialConfigApi.findAll()
|
||||
SocialLoginConfigApi.findAll()
|
||||
.then((res) => {
|
||||
configList.value = res.data || [];
|
||||
})
|
||||
@@ -47,12 +47,12 @@
|
||||
|
||||
// ===== 配置抽屉 =====
|
||||
const modalVisible = ref(false);
|
||||
const selectedItem = ref<SocialConfigResult | null>(null);
|
||||
const selectedItem = ref<SocialLoginConfigResult | null>(null);
|
||||
|
||||
/**
|
||||
* 打开配置弹窗
|
||||
*/
|
||||
function handleConfig(item: SocialConfigResult & { label: string }) {
|
||||
function handleConfig(item: SocialLoginConfigResult & { label: string }) {
|
||||
selectedItem.value = item;
|
||||
modalVisible.value = true;
|
||||
}
|
||||
@@ -121,7 +121,7 @@
|
||||
</a-card>
|
||||
|
||||
<!-- 配置抽屉 -->
|
||||
<SocialConfigDrawer
|
||||
<SocialLoginConfigDrawer
|
||||
v-model:visible="modalVisible"
|
||||
:config-item="selectedItem"
|
||||
@saved="loadConfig"
|
||||
Reference in New Issue
Block a user