feat(消息管理&界面配置): 消息管理模版支持换行&界面配置图片固定比例

This commit is contained in:
baiqi 2023-10-18 13:41:13 +08:00 committed by 刘瑞斌
parent 7cfc18a007
commit b7cc4fb45e
8 changed files with 25 additions and 16 deletions

View File

@ -34,7 +34,7 @@
import useContainerShadow from '@/hooks/useContainerShadow'; import useContainerShadow from '@/hooks/useContainerShadow';
import type { CommonList, TableQueryParams } from '@/models/common'; import type { CommonList } from '@/models/common';
const props = withDefaults( const props = withDefaults(
defineProps<{ defineProps<{
@ -43,10 +43,10 @@
cardMinWidth: number; // px cardMinWidth: number; // px
shadowLimit: number; // shadowLimit: number; //
remoteParams?: Record<string, any>; // remoteParams?: Record<string, any>; //
remoteFunc?: (v: TableQueryParams) => Promise<CommonList<any>>; //
gap?: number; // gap?: number; //
isProportional?: boolean; // isProportional?: boolean; //
paddingBottomSpace?: string; // paddingBottomSpace?: string; //
remoteFunc?: (v: any) => Promise<CommonList<any>>; //
}>(), }>(),
{ {
mode: 'static', mode: 'static',

View File

@ -1,6 +1,7 @@
<template> <template>
<div ref="treeContainerRef" :class="['ms-tree-container', containerStatusClass]"> <div ref="treeContainerRef" :class="['ms-tree-container', containerStatusClass]">
<a-tree <a-tree
v-show="treeData.length > 0"
v-bind="props" v-bind="props"
ref="treeRef" ref="treeRef"
v-model:expanded-keys="expandedKeys" v-model:expanded-keys="expandedKeys"
@ -16,6 +17,7 @@
</template> </template>
<template v-if="$slots['extra']" #extra="_props"> <template v-if="$slots['extra']" #extra="_props">
<div <div
v-if="_props.hideMoreAction !== true"
:class="[ :class="[
'ms-tree-node-extra', 'ms-tree-node-extra',
innerFocusNodeKey === _props[props.fieldNames.key] ? 'ms-tree-node-extra--focus' : '', innerFocusNodeKey === _props[props.fieldNames.key] ? 'ms-tree-node-extra--focus' : '',

View File

@ -9,6 +9,7 @@ export interface MsTreeFieldNames extends TreeFieldNames {
} }
export type MsTreeNodeData = { export type MsTreeNodeData = {
hideMoreAction?: boolean; // 隐藏更多操作
[key: string]: any; [key: string]: any;
} & TreeNodeData; } & TreeNodeData;

View File

@ -24,7 +24,7 @@
width: 55%; width: 55%;
.img { .img {
width: 100%; width: 100%;
object-fit: cover; object-fit: fill;
} }
} }
</style> </style>

View File

@ -8,6 +8,7 @@
v-model:model-value="robotFilters" v-model:model-value="robotFilters"
:options="robotOptions" :options="robotOptions"
:allow-search="false" :allow-search="false"
allow-clear
class="mr-[8px] w-[240px]" class="mr-[8px] w-[240px]"
:prefix="t('project.messageManagement.robot')" :prefix="t('project.messageManagement.robot')"
value-key="id" value-key="id"
@ -62,6 +63,7 @@
:options="defaultReceivers" :options="defaultReceivers"
:search-keys="['label']" :search-keys="['label']"
allow-search allow-search
allow-clear
value-key="id" value-key="id"
label-key="name" label-key="name"
:multiple="true" :multiple="true"
@ -365,7 +367,7 @@
enable: val, // enable: val, //
}); });
Message.success( Message.success(
t('project.messageManagement.enableRobotSuccess', { t(val ? 'project.messageManagement.enableRobotSuccess' : 'project.messageManagement.disableRobotSuccess', {
name: `${record.functionName}-${record.eventName}-${record.projectRobotConfigMap?.[dataIndex].robotName}`, name: `${record.functionName}-${record.eventName}-${record.projectRobotConfigMap?.[dataIndex].robotName}`,
}) })
); );

View File

@ -194,22 +194,24 @@
// 使 ${variableName} // 使 ${variableName}
function replaceVariableStr(str: string, fields: Field[], isSubject = false) { function replaceVariableStr(str: string, fields: Field[], isSubject = false) {
const regex = /\$\{([^}]+)\}/g; const regex = /\$\{([^}]+)\}/g;
return str.replace(regex, (match, variableName) => { return str
// variableName name .replace(regex, (match, variableName) => {
const variable = fields.find((v) => v.id === variableName); // variableName name
if (variableName === 'name' && !isSubject) { const variable = fields.find((v) => v.id === variableName);
return variable ? `<span style='color: rgb(var(--primary-6))'><${variable.name}></span>` : match; if (variableName === 'name' && !isSubject) {
} return variable ? `<span style='color: rgb(var(--primary-6))'><${variable.name}></span>` : match;
if (isSubject) { }
return variable ? variable.name : match; if (isSubject) {
} return variable ? variable.name : match;
return variable ? `<${variable.name}>` : match; }
}); return variable ? `<${variable.name}>` : match;
})
.replace(/\n/g, '<br>');
} }
// 使 {{name}} // 使 {{name}}
function replacePreviewName(str: string) { function replacePreviewName(str: string) {
return str.replace(/{{(.*?)}}/g, `<span style='color: rgb(var(--primary-6))'><$1></span>`); return str.replace(/{{(.*?)}}/g, `<span style='color: rgb(var(--primary-6))'><$1></span>`).replace(/\n/g, '<br>');
} }
const subject = computed(() => { const subject = computed(() => {

View File

@ -94,6 +94,7 @@ export default {
'project.messageManagement.desc': 'Description', 'project.messageManagement.desc': 'Description',
'project.messageManagement.saveSuccess': 'Template saved successfully', 'project.messageManagement.saveSuccess': 'Template saved successfully',
'project.messageManagement.enableRobotSuccess': '{name} is enabled', 'project.messageManagement.enableRobotSuccess': '{name} is enabled',
'project.messageManagement.disableRobotSuccess': '{name} is disabled',
'project.messageManagement.saveReceiverSuccess': 'Recipient modified successfully', 'project.messageManagement.saveReceiverSuccess': 'Recipient modified successfully',
'project.messageManagement.unsetReceiverTip': 'Please set up message recipients before enabling the robot', 'project.messageManagement.unsetReceiverTip': 'Please set up message recipients before enabling the robot',
'project.messageManagement.receiverNotNull': 'Please set at least one message recipient', 'project.messageManagement.receiverNotNull': 'Please set at least one message recipient',

View File

@ -86,6 +86,7 @@ export default {
'project.messageManagement.desc': '描述', 'project.messageManagement.desc': '描述',
'project.messageManagement.saveSuccess': '模版保存成功', 'project.messageManagement.saveSuccess': '模版保存成功',
'project.messageManagement.enableRobotSuccess': '{name} 已启用', 'project.messageManagement.enableRobotSuccess': '{name} 已启用',
'project.messageManagement.disableRobotSuccess': '{name} 已禁用',
'project.messageManagement.saveReceiverSuccess': '接收人修改成功', 'project.messageManagement.saveReceiverSuccess': '接收人修改成功',
'project.messageManagement.unsetReceiverTip': '启用机器人前请先设置消息接收人', 'project.messageManagement.unsetReceiverTip': '启用机器人前请先设置消息接收人',
'project.messageManagement.receiverNotNull': '请最少设置一位消息接收人', 'project.messageManagement.receiverNotNull': '请最少设置一位消息接收人',