Skip to content

Commit

Permalink
fix: 修复若干错误单词,删除执行表达式中的无用语句
Browse files Browse the repository at this point in the history
  • Loading branch information
ilxqx committed Sep 12, 2024
1 parent ff60a96 commit 4c86990
Show file tree
Hide file tree
Showing 10 changed files with 71 additions and 72 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ import FormAction from './FormAction';
// 弹框
import OpenModalAction from './OpenModalAction';
import MessageAction from './MessageAction';
import NotifacationAction from './NotifacationAction';
import NotificationAction from './NotificationAction';
import ShowConfirmAction from './ShowConfirmAction';
import RequestAction from './RequestAction';
// 组件
import VisibleAction from './VisibleAction';
import DisableAction from './DisableAction';
import ComponentMethods from './ComponentMethods';
import VariableAssigment from './VariableAssigment';
import VariableAssignment from './VariableAssignment';
// 飞书
import SendMessageAction from './SendMessageAction';
import CreateNodeAction from './CreateNodeAction';
Expand Down Expand Up @@ -128,7 +128,7 @@ const ActionModal = (props: any, ref: any) => {
label: '消息通知',
key: 'notifacation',
render: () => {
return <NotifacationAction />;
return <NotificationAction />;
},
},
],
Expand Down Expand Up @@ -176,7 +176,7 @@ const ActionModal = (props: any, ref: any) => {
label: '变量赋值',
key: 'variable',
render: () => {
return <VariableAssigment form={form} />;
return <VariableAssignment form={form} />;
},
},
],
Expand Down Expand Up @@ -313,7 +313,7 @@ const ActionModal = (props: any, ref: any) => {
form.setFieldsValue({
scripts: `/**
* 触发动作后,会执行该函数
* 上下文: context
* 上下文: context
* 变量: variable
* 事件流参数: eventParams
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import styles from './index.module.less';
import { useEffect, useState } from 'react';
import VsEditor from '@/components/VsEditor';
import VariableBind from '@/components/VariableBind/VariableBind';
const VariableAssigment = ({ form }: { form: FormInstance }) => {
const VariableAssignment = ({ form }: { form: FormInstance; }) => {
const variables = usePageStore((state) => state.page.variables);
const [dataType, setDataType] = useState('string');

Expand All @@ -26,9 +26,9 @@ const VariableAssigment = ({ form }: { form: FormInstance }) => {
<p className={styles.descInfo}>给页面全局变量动态赋值。页面中支持绑定动态变量的地方都可以使用此功能来添加动态值。</p>
<Divider />
</div>
<Form.Item label="赋值类型" name="assigmentType">
<Form.Item label="赋值类型" name="assignmentType">
<Radio.Group buttonStyle="solid">
<Radio.Button value="assigment">变量赋值</Radio.Button>
<Radio.Button value="assignment">变量赋值</Radio.Button>
<Radio.Button value="reset">变量重置</Radio.Button>
</Radio.Group>
</Form.Item>
Expand All @@ -46,12 +46,12 @@ const VariableAssigment = ({ form }: { form: FormInstance }) => {
</Form.Item>
<Form.Item noStyle shouldUpdate>
{(form: FormInstance) => {
const assigmentType = form.getFieldValue('assigmentType');
if (assigmentType === 'assigment')
const assignmentType = form.getFieldValue('assignmentType');
if (assignmentType === 'assignment')
return (
<Form.Item
label="赋值方式"
name="assigmentWay"
name="assignmentWay"
wrapperCol={{ span: 16 }}
tooltip="动态赋值会默认接收上一个行为的数据作为变量值,比如上一个行为是接口请求"
rules={[{ required: true, message: '请选择赋值方式' }]}
Expand All @@ -66,8 +66,8 @@ const VariableAssigment = ({ form }: { form: FormInstance }) => {
</Form.Item>
<Form.Item noStyle shouldUpdate>
{(form: FormInstance) => {
const { assigmentType, assigmentWay } = form.getFieldsValue();
if (assigmentType === 'assigment' && assigmentWay === 'static')
const { assignmentType, assignmentWay } = form.getFieldsValue();
if (assignmentType === 'assignment' && assignmentWay === 'static')
return (
<Form.Item label="变量值" name="value" wrapperCol={{ span: 16 }} rules={[{ required: true, message: '请输入变量值' }]}>
{/* {dataType === 'string' && <Input placeholder="请输入变量值" />} */}
Expand All @@ -82,4 +82,4 @@ const VariableAssigment = ({ form }: { form: FormInstance }) => {
</>
);
};
export default VariableAssigment;
export default VariableAssignment;
20 changes: 10 additions & 10 deletions packages/editor/src/packages/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ export interface ComponentType<T = any> {
parentId?: string;
config: ConfigType<T>;
// 属性中用于展示的事件,跟配置中的事件不同
events?: Array<{ name: string; value: string }>;
events?: Array<{ name: string; value: string; }>;
// 属性中用于展示的方法,跟配置中的方法不同
methods: ComponentMethodType[];
apis: { [key: string]: ApiType };
apis: { [key: string]: ApiType; };
elements: ComponentType<T>[];
[key: string]: any; // 自定义属性,比如事件函数挂载
}
Expand All @@ -83,11 +83,11 @@ export interface ApiConfig {
id: string;
source: any;
sourceField:
| string
| {
type: 'static' | 'variable';
value: string;
};
| string
| {
type: 'static' | 'variable';
value: string;
};
name?: {
type: 'variable' | 'static';
value: string;
Expand All @@ -108,7 +108,7 @@ export interface EventType<T = any> {
*/
export interface ActionNode<T> {
action: T;
next: (ActionNode<T> & { success: ActionNode<T>; fail: ActionNode<T> }) | null;
next: (ActionNode<T> & { success: ActionNode<T>; fail: ActionNode<T>; }) | null;
}

/**
Expand All @@ -118,7 +118,7 @@ export interface MethodsAction {
name: string;
target: string;
method: string;
data: Array<{ key: string; value: string }>;
data: Array<{ key: string; value: string; }>;
}

/**
Expand All @@ -145,7 +145,7 @@ export interface MessageAction {
/**
* 通知行为
*/
export interface NotifacationAction {
export interface NotificationAction {
type: 'info' | 'success' | 'error' | 'warning'; // 行为类型
message: string;
description: string;
Expand Down
16 changes: 8 additions & 8 deletions packages/editor/src/packages/utils/action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
JumpLinkAction,
MessageAction,
MethodsAction,
NotifacationAction,
NotificationAction,
VariableAction,
} from '../types';
import { getComponentRef } from './useComponentRefs';
Expand Down Expand Up @@ -327,7 +327,7 @@ const handleMessage = ({ action, next }: ActionNode<MessageAction>, data: any) =
/**
* 消息通知
*/
const handleNotifacation = ({ action, next }: ActionNode<NotifacationAction>, data: any) => {
const handleNotifacation = ({ action, next }: ActionNode<NotificationAction>, data: any) => {
notification.open({
type: action.type,
message: action.message,
Expand Down Expand Up @@ -415,7 +415,7 @@ const handleCopy = async ({ action, next }: ActionNode<CopyAction>, data: any) =
/**
* 定时器
*/
const handleSetTimeout = async ({ action, next }: ActionNode<{ duration: number }>, data: any) => {
const handleSetTimeout = async ({ action, next }: ActionNode<{ duration: number; }>, data: any) => {
setTimeout(() => {
execAction(next, data);
}, action.duration * 1000);
Expand All @@ -424,7 +424,7 @@ const handleSetTimeout = async ({ action, next }: ActionNode<{ duration: number
/**
* 组件显示和隐藏
*/
const handleVisible = async ({ action, next }: ActionNode<{ target: string; showType: string; showResult: string; expression: any }>, data: any) => {
const handleVisible = async ({ action, next }: ActionNode<{ target: string; showType: string; showResult: string; expression: any; }>, data: any) => {
const ref = getComponentRef(action.target);
if (action.showType === 'static') {
if (action.showResult === 'show') {
Expand All @@ -447,7 +447,7 @@ const handleVisible = async ({ action, next }: ActionNode<{ target: string; show
* 组件禁用
*/
const handleDisable = async (
{ action, next }: ActionNode<{ target: string; disableType: string; disableResult: string; expression: any }>,
{ action, next }: ActionNode<{ target: string; disableType: string; disableResult: string; expression: any; }>,
data: any,
) => {
const ref = getComponentRef(action.target);
Expand All @@ -474,7 +474,7 @@ const handleDisable = async (
* 发送飞书消息
*/
const handleSendMessage = async (
{ action, next }: ActionNode<{ msg_type: string; content: string; template_id: string; receive_id: number }>,
{ action, next }: ActionNode<{ msg_type: string; content: string; template_id: string; receive_id: number; }>,
data: any,
) => {
const res = await request.post('https://mars-api.marsview.cc/api/robot/sendMessage', { ...action, variables: data });
Expand All @@ -488,7 +488,7 @@ const handleSendMessage = async (
/**
* 创建知识库副本
*/
const handleCreateNode = async ({ action, next }: ActionNode<{ space_id: number; node_token: string; title: string }>, data: any) => {
const handleCreateNode = async ({ action, next }: ActionNode<{ space_id: number; node_token: string; title: string; }>, data: any) => {
const res = await request.post('https://mars-api.marsview.cc/api/robot/createNode', { ...action, variables: data });
if (res.data.code === 0) {
execAction(next?.success || next, res.data.data);
Expand All @@ -500,7 +500,7 @@ const handleCreateNode = async ({ action, next }: ActionNode<{ space_id: number;
/**
* 运行脚本
*/
const handleRunScripts = async ({ action, next }: ActionNode<{ scripts: string }>, data: any) => {
const handleRunScripts = async ({ action, next }: ActionNode<{ scripts: string; }>, data: any) => {
const result = renderFormula(action.scripts, data);
if (typeof result === 'boolean') {
if (result) {
Expand Down
14 changes: 7 additions & 7 deletions packages/materials/stores/pageStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,16 @@ export interface PageState {
source: any;
};
};
events: Array<{ name: string; value: string }>;
events: Array<{ name: string; value: string; }>;
// 页面全局接口
apis: { [key: string]: ApiType };
apis: { [key: string]: ApiType; };
elements: ComItemType[];
elementsMap: { [key: string]: ComponentType };
elementsMap: { [key: string]: ComponentType; };
// 页面变量
variables: PageVariable[];
variableData: { [key: string]: any };
variableData: { [key: string]: any; };
// 表单数据
formData: { [key: string]: any };
formData: { [key: string]: any; };
// 全局拦截器
interceptor: {
headers?: {
Expand All @@ -54,8 +54,8 @@ export interface PageState {
}[];
timeout: number;
timeoutErrorMessage: string;
requestIntercetpor?: string;
responseIntercetpor?: string;
requestInterceptor?: string;
responseInterceptor?: string;
};
};
}
Expand Down
24 changes: 12 additions & 12 deletions packages/materials/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ export interface ComponentType<T = any> {
parentId?: string;
config: ConfigType<T>;
// 属性中用于展示的事件,跟配置中的事件不同
events?: Array<{ name: string; value: string }>;
events?: Array<{ name: string; value: string; }>;
// 属性中用于展示的方法,跟配置中的方法不同
methods: ComponentMethodType[];
apis: { [key: string]: ApiType };
apis: { [key: string]: ApiType; };
elements: ComponentType<T>[];
[key: string]: any; // 自定义属性,比如事件函数挂载
}
Expand All @@ -83,11 +83,11 @@ export interface ApiConfig {
id: string;
source: any;
sourceField:
| string
| {
type: 'variable' | 'static';
value: string;
};
| string
| {
type: 'variable' | 'static';
value: string;
};
name?: {
type: 'variable' | 'static';
value: string;
Expand All @@ -108,7 +108,7 @@ export interface EventType<T = any> {
*/
export interface ActionNode<T> {
action: T;
next: (ActionNode<T> & { success: ActionNode<T>; fail: ActionNode<T> }) | null;
next: (ActionNode<T> & { success: ActionNode<T>; fail: ActionNode<T>; }) | null;
}

/**
Expand All @@ -118,7 +118,7 @@ export interface MethodsAction {
name: string;
target: string;
method: string;
data: Array<{ key: string; value: string }>;
data: Array<{ key: string; value: string; }>;
}

/**
Expand All @@ -145,7 +145,7 @@ export interface MessageAction {
/**
* 通知行为
*/
export interface NotifacationAction {
export interface NotificationAction {
type: 'info' | 'success' | 'error' | 'warning'; // 行为类型
message: string;
description: string;
Expand Down Expand Up @@ -175,8 +175,8 @@ export interface JumpLinkAction {
*/

export interface VariableAction {
assigmentType: 'assigment' | 'reset';
assigmentWay: 'static' | 'dynamic';
assignmentType: 'assigment' | 'reset';
assignmentWay: 'static' | 'dynamic';
name: string;
value: any;
}
Expand Down
Loading

0 comments on commit 4c86990

Please sign in to comment.