mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-07-19 19:06:07 +00:00
feat: update eslint & prettier rules
This commit is contained in:
@@ -1,39 +1,33 @@
|
||||
import {BotCardVO} from "@/app/home/bots/components/bot-card/BotCardVO";
|
||||
import styles from "./botCard.module.css";
|
||||
import { BotCardVO } from '@/app/home/bots/components/bot-card/BotCardVO';
|
||||
import styles from './botCard.module.css';
|
||||
|
||||
export default function BotCard({
|
||||
botCardVO
|
||||
}: {
|
||||
botCardVO: BotCardVO;
|
||||
}) {
|
||||
return (
|
||||
<div className={`${styles.cardContainer}`}>
|
||||
{/* icon和基本信息 */}
|
||||
<div className={`${styles.iconBasicInfoContainer}`}>
|
||||
{/* icon */}
|
||||
<div className={`${styles.icon}`}>
|
||||
ICO
|
||||
</div>
|
||||
{/* bot基本信息 */}
|
||||
<div className={`${styles.basicInfoContainer}`}>
|
||||
<div className={`${styles.basicInfoText} ${styles.bigText}`}>
|
||||
{botCardVO.name}
|
||||
</div>
|
||||
<div className={`${styles.basicInfoText}`}>
|
||||
平台:{botCardVO.adapter}
|
||||
</div>
|
||||
<div className={`${styles.basicInfoText}`}>
|
||||
绑定流水线:{botCardVO.pipelineName}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{/* 描述和创建时间 */}
|
||||
<div className={`${styles.urlAndUpdateText}`}>
|
||||
描述:{botCardVO.description}
|
||||
</div>
|
||||
{/* <div className={`${styles.urlAndUpdateText}`}>
|
||||
export default function BotCard({ botCardVO }: { botCardVO: BotCardVO }) {
|
||||
return (
|
||||
<div className={`${styles.cardContainer}`}>
|
||||
{/* icon和基本信息 */}
|
||||
<div className={`${styles.iconBasicInfoContainer}`}>
|
||||
{/* icon */}
|
||||
<div className={`${styles.icon}`}>ICO</div>
|
||||
{/* bot基本信息 */}
|
||||
<div className={`${styles.basicInfoContainer}`}>
|
||||
<div className={`${styles.basicInfoText} ${styles.bigText}`}>
|
||||
{botCardVO.name}
|
||||
</div>
|
||||
<div className={`${styles.basicInfoText}`}>
|
||||
平台:{botCardVO.adapter}
|
||||
</div>
|
||||
<div className={`${styles.basicInfoText}`}>
|
||||
绑定流水线:{botCardVO.pipelineName}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{/* 描述和创建时间 */}
|
||||
<div className={`${styles.urlAndUpdateText}`}>
|
||||
描述:{botCardVO.description}
|
||||
</div>
|
||||
{/* <div className={`${styles.urlAndUpdateText}`}>
|
||||
更新时间:{botCardVO.updateTime}
|
||||
</div> */}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,28 +1,26 @@
|
||||
export interface IBotCardVO {
|
||||
id: string;
|
||||
name: string;
|
||||
adapter: string;
|
||||
description: string;
|
||||
updateTime: string;
|
||||
pipelineName: string;
|
||||
id: string;
|
||||
name: string;
|
||||
adapter: string;
|
||||
description: string;
|
||||
updateTime: string;
|
||||
pipelineName: string;
|
||||
}
|
||||
|
||||
export class BotCardVO implements IBotCardVO {
|
||||
id: string;
|
||||
adapter: string;
|
||||
description: string;
|
||||
name: string;
|
||||
updateTime: string;
|
||||
pipelineName: string;
|
||||
id: string;
|
||||
adapter: string;
|
||||
description: string;
|
||||
name: string;
|
||||
updateTime: string;
|
||||
pipelineName: string;
|
||||
|
||||
|
||||
constructor(props: IBotCardVO) {
|
||||
this.id = props.id;
|
||||
this.name = props.name;
|
||||
this.adapter = props.adapter;
|
||||
this.description = props.description;
|
||||
this.updateTime = props.updateTime;
|
||||
this.pipelineName = props.pipelineName;
|
||||
}
|
||||
|
||||
}
|
||||
constructor(props: IBotCardVO) {
|
||||
this.id = props.id;
|
||||
this.name = props.name;
|
||||
this.adapter = props.adapter;
|
||||
this.description = props.description;
|
||||
this.updateTime = props.updateTime;
|
||||
this.pipelineName = props.pipelineName;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,24 +1,24 @@
|
||||
import {
|
||||
BotFormEntity,
|
||||
IBotFormEntity
|
||||
} from "@/app/home/bots/components/bot-form/BotFormEntity";
|
||||
import { Button, Form, Input, notification, Select, Space } from "antd";
|
||||
import { useEffect, useState } from "react";
|
||||
import { IChooseAdapterEntity } from "@/app/home/bots/components/bot-form/ChooseAdapterEntity";
|
||||
IBotFormEntity,
|
||||
} from '@/app/home/bots/components/bot-form/BotFormEntity';
|
||||
import { Button, Form, Input, notification, Select, Space } from 'antd';
|
||||
import { useEffect, useState } from 'react';
|
||||
import { IChooseAdapterEntity } from '@/app/home/bots/components/bot-form/ChooseAdapterEntity';
|
||||
import {
|
||||
DynamicFormItemConfig,
|
||||
IDynamicFormItemConfig,
|
||||
parseDynamicFormItemType
|
||||
} from "@/app/home/components/dynamic-form/DynamicFormItemConfig";
|
||||
import { UUID } from "uuidjs";
|
||||
import DynamicFormComponent from "@/app/home/components/dynamic-form/DynamicFormComponent";
|
||||
import { httpClient } from "@/app/infra/http/HttpClient";
|
||||
import { Bot } from "@/app/infra/api/api-types";
|
||||
parseDynamicFormItemType,
|
||||
} from '@/app/home/components/dynamic-form/DynamicFormItemConfig';
|
||||
import { UUID } from 'uuidjs';
|
||||
import DynamicFormComponent from '@/app/home/components/dynamic-form/DynamicFormComponent';
|
||||
import { httpClient } from '@/app/infra/http/HttpClient';
|
||||
import { Bot } from '@/app/infra/api/api-types';
|
||||
|
||||
export default function BotForm({
|
||||
initBotId,
|
||||
onFormSubmit,
|
||||
onFormCancel
|
||||
onFormCancel,
|
||||
}: {
|
||||
initBotId?: string;
|
||||
onFormSubmit: (value: IBotFormEntity) => void;
|
||||
@@ -55,9 +55,9 @@ export default function BotForm({
|
||||
rawAdapterList.adapters.map((item) => {
|
||||
return {
|
||||
label: item.label.zh_CN,
|
||||
value: item.name
|
||||
value: item.name,
|
||||
};
|
||||
})
|
||||
}),
|
||||
);
|
||||
// 初始化适配器表单map
|
||||
rawAdapterList.adapters.forEach((rawAdapter) => {
|
||||
@@ -71,9 +71,9 @@ export default function BotForm({
|
||||
label: item.label,
|
||||
name: item.name,
|
||||
required: item.required,
|
||||
type: parseDynamicFormItemType(item.type)
|
||||
})
|
||||
)
|
||||
type: parseDynamicFormItemType(item.type),
|
||||
}),
|
||||
),
|
||||
);
|
||||
});
|
||||
// 拉取初始化表单信息
|
||||
@@ -99,12 +99,12 @@ export default function BotForm({
|
||||
adapter: bot.adapter,
|
||||
description: bot.description,
|
||||
name: bot.name,
|
||||
adapter_config: bot.adapter_config
|
||||
adapter_config: bot.adapter_config,
|
||||
});
|
||||
}
|
||||
|
||||
function handleAdapterSelect(adapterName: string) {
|
||||
console.log("Select adapter: ", adapterName);
|
||||
console.log('Select adapter: ', adapterName);
|
||||
if (adapterName) {
|
||||
const dynamicFormConfigList =
|
||||
adapterNameToDynamicConfigMap.get(adapterName);
|
||||
@@ -129,33 +129,33 @@ export default function BotForm({
|
||||
// 只有通过外层固定表单验证才会走到这里,真正的提交逻辑在这里
|
||||
function onDynamicFormSubmit(value: object) {
|
||||
setIsLoading(true);
|
||||
console.log("set loading", true);
|
||||
console.log('set loading', true);
|
||||
if (initBotId) {
|
||||
// 编辑提交
|
||||
console.log("submit edit", form.getFieldsValue(), value);
|
||||
console.log('submit edit', form.getFieldsValue(), value);
|
||||
const updateBot: Bot = {
|
||||
uuid: initBotId,
|
||||
name: form.getFieldsValue().name,
|
||||
description: form.getFieldsValue().description,
|
||||
adapter: form.getFieldsValue().adapter,
|
||||
adapter_config: value
|
||||
adapter_config: value,
|
||||
};
|
||||
httpClient
|
||||
.updateBot(initBotId, updateBot)
|
||||
.then((res) => {
|
||||
// TODO success toast
|
||||
console.log("update bot success", res);
|
||||
console.log('update bot success', res);
|
||||
onFormSubmit(form.getFieldsValue());
|
||||
notification.success({
|
||||
message: "更新成功",
|
||||
description: "机器人更新成功"
|
||||
message: '更新成功',
|
||||
description: '机器人更新成功',
|
||||
});
|
||||
})
|
||||
.catch(() => {
|
||||
// TODO error toast
|
||||
notification.error({
|
||||
message: "更新失败",
|
||||
description: "机器人更新失败"
|
||||
message: '更新失败',
|
||||
description: '机器人更新失败',
|
||||
});
|
||||
})
|
||||
.finally(() => {
|
||||
@@ -165,20 +165,20 @@ export default function BotForm({
|
||||
});
|
||||
} else {
|
||||
// 创建提交
|
||||
console.log("submit create", form.getFieldsValue(), value);
|
||||
console.log('submit create', form.getFieldsValue(), value);
|
||||
const newBot: Bot = {
|
||||
name: form.getFieldsValue().name,
|
||||
description: form.getFieldsValue().description,
|
||||
adapter: form.getFieldsValue().adapter,
|
||||
adapter_config: value
|
||||
adapter_config: value,
|
||||
};
|
||||
httpClient
|
||||
.createBot(newBot)
|
||||
.then((res) => {
|
||||
// TODO success toast
|
||||
notification.success({
|
||||
message: "创建成功",
|
||||
description: "机器人创建成功"
|
||||
message: '创建成功',
|
||||
description: '机器人创建成功',
|
||||
});
|
||||
console.log(res);
|
||||
onFormSubmit(form.getFieldsValue());
|
||||
@@ -186,8 +186,8 @@ export default function BotForm({
|
||||
.catch(() => {
|
||||
// TODO error toast
|
||||
notification.error({
|
||||
message: "创建失败",
|
||||
description: "机器人创建失败"
|
||||
message: '创建失败',
|
||||
description: '机器人创建失败',
|
||||
});
|
||||
})
|
||||
.finally(() => {
|
||||
@@ -197,7 +197,7 @@ export default function BotForm({
|
||||
});
|
||||
}
|
||||
setShowDynamicForm(false);
|
||||
console.log("set loading", false);
|
||||
console.log('set loading', false);
|
||||
// TODO 刷新bot列表
|
||||
// TODO 关闭当前弹窗 Already closed @setShowDynamicForm(false)?
|
||||
}
|
||||
@@ -217,9 +217,9 @@ export default function BotForm({
|
||||
disabled={isLoading}
|
||||
>
|
||||
<Form.Item<IBotFormEntity>
|
||||
label={"机器人名称"}
|
||||
name={"name"}
|
||||
rules={[{ required: true, message: "该项为必填项哦~" }]}
|
||||
label={'机器人名称'}
|
||||
name={'name'}
|
||||
rules={[{ required: true, message: '该项为必填项哦~' }]}
|
||||
>
|
||||
<Input
|
||||
placeholder="为机器人取个好听的名字吧~"
|
||||
@@ -228,17 +228,17 @@ export default function BotForm({
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item<IBotFormEntity>
|
||||
label={"描述"}
|
||||
name={"description"}
|
||||
rules={[{ required: true, message: "该项为必填项哦~" }]}
|
||||
label={'描述'}
|
||||
name={'description'}
|
||||
rules={[{ required: true, message: '该项为必填项哦~' }]}
|
||||
>
|
||||
<Input placeholder="简单描述一下这个机器人"></Input>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item<IBotFormEntity>
|
||||
label={"平台/适配器选择"}
|
||||
name={"adapter"}
|
||||
rules={[{ required: true, message: "该项为必填项哦~" }]}
|
||||
label={'平台/适配器选择'}
|
||||
name={'adapter'}
|
||||
rules={[{ required: true, message: '该项为必填项哦~' }]}
|
||||
>
|
||||
<Select
|
||||
style={{ width: 220 }}
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
export interface IBotFormEntity {
|
||||
name: string,
|
||||
description: string,
|
||||
adapter: string,
|
||||
adapter_config: object;
|
||||
name: string;
|
||||
description: string;
|
||||
adapter: string;
|
||||
adapter_config: object;
|
||||
}
|
||||
|
||||
export class BotFormEntity implements IBotFormEntity {
|
||||
adapter: string;
|
||||
description: string;
|
||||
name: string;
|
||||
adapter_config: object;
|
||||
adapter: string;
|
||||
description: string;
|
||||
name: string;
|
||||
adapter_config: object;
|
||||
|
||||
constructor(props: IBotFormEntity) {
|
||||
this.adapter = props.adapter;
|
||||
this.description = props.description;
|
||||
this.name = props.name;
|
||||
this.adapter_config = props.adapter_config;
|
||||
}
|
||||
}
|
||||
constructor(props: IBotFormEntity) {
|
||||
this.adapter = props.adapter;
|
||||
this.description = props.description;
|
||||
this.name = props.name;
|
||||
this.adapter_config = props.adapter_config;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
export interface IChooseAdapterEntity {
|
||||
label: string
|
||||
value: string
|
||||
}
|
||||
label: string;
|
||||
value: string;
|
||||
}
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
"use client";
|
||||
'use client';
|
||||
|
||||
import { useEffect, useState } from "react";
|
||||
import styles from "./botConfig.module.css";
|
||||
import EmptyAndCreateComponent from "@/app/home/components/empty-and-create-component/EmptyAndCreateComponent";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { BotCardVO } from "@/app/home/bots/components/bot-card/BotCardVO";
|
||||
import { Modal, notification, Spin } from "antd";
|
||||
import BotForm from "@/app/home/bots/components/bot-form/BotForm";
|
||||
import BotCard from "@/app/home/bots/components/bot-card/BotCard";
|
||||
import CreateCardComponent from "@/app/infra/basic-component/create-card-component/CreateCardComponent";
|
||||
import { httpClient } from "@/app/infra/http/HttpClient";
|
||||
import { Bot } from "@/app/infra/api/api-types";
|
||||
import { useEffect, useState } from 'react';
|
||||
import styles from './botConfig.module.css';
|
||||
import EmptyAndCreateComponent from '@/app/home/components/empty-and-create-component/EmptyAndCreateComponent';
|
||||
import { useRouter } from 'next/navigation';
|
||||
import { BotCardVO } from '@/app/home/bots/components/bot-card/BotCardVO';
|
||||
import { Modal, notification, Spin } from 'antd';
|
||||
import BotForm from '@/app/home/bots/components/bot-form/BotForm';
|
||||
import BotCard from '@/app/home/bots/components/bot-card/BotCard';
|
||||
import CreateCardComponent from '@/app/infra/basic-component/create-card-component/CreateCardComponent';
|
||||
import { httpClient } from '@/app/infra/http/HttpClient';
|
||||
import { Bot } from '@/app/infra/api/api-types';
|
||||
|
||||
export default function BotConfigPage() {
|
||||
const router = useRouter();
|
||||
const [pageShowRule, setPageShowRule] = useState<BotConfigPageShowRule>(
|
||||
BotConfigPageShowRule.NO_BOT
|
||||
BotConfigPageShowRule.NO_BOT,
|
||||
);
|
||||
const [modalOpen, setModalOpen] = useState<boolean>(false);
|
||||
const [botList, setBotList] = useState<BotCardVO[]>([]);
|
||||
@@ -49,10 +49,10 @@ export default function BotConfigPage() {
|
||||
return new BotCardVO({
|
||||
adapter: bot.adapter,
|
||||
description: bot.description,
|
||||
id: bot.uuid || "",
|
||||
id: bot.uuid || '',
|
||||
name: bot.name,
|
||||
updateTime: bot.updated_at || "",
|
||||
pipelineName: bot.use_pipeline_name || ""
|
||||
updateTime: bot.updated_at || '',
|
||||
pipelineName: bot.use_pipeline_name || '',
|
||||
});
|
||||
});
|
||||
if (botList.length === 0) {
|
||||
@@ -63,12 +63,12 @@ export default function BotConfigPage() {
|
||||
setBotList(botList);
|
||||
})
|
||||
.catch((err) => {
|
||||
console.error("get bot list error", err);
|
||||
console.error('get bot list error', err);
|
||||
// TODO HACK: need refactor to hook mode Notification, but it's not working under render
|
||||
notification.error({
|
||||
message: "获取机器人列表失败",
|
||||
message: '获取机器人列表失败',
|
||||
description: err.message,
|
||||
placement: "bottomRight"
|
||||
placement: 'bottomRight',
|
||||
});
|
||||
})
|
||||
.finally(() => {
|
||||
@@ -89,7 +89,7 @@ export default function BotConfigPage() {
|
||||
function selectBot(cardVO: BotCardVO) {
|
||||
setIsEditForm(true);
|
||||
setNowSelectedCard(cardVO);
|
||||
console.log("set now vo", cardVO);
|
||||
console.log('set now vo', cardVO);
|
||||
setModalOpen(true);
|
||||
}
|
||||
|
||||
@@ -97,7 +97,7 @@ export default function BotConfigPage() {
|
||||
<div className={styles.configPageContainer}>
|
||||
<Spin spinning={isLoading} tip="加载中..." size="large">
|
||||
<Modal
|
||||
title={isEditForm ? "编辑机器人" : "创建机器人"}
|
||||
title={isEditForm ? '编辑机器人' : '创建机器人'}
|
||||
centered
|
||||
open={modalOpen}
|
||||
onOk={() => setModalOpen(false)}
|
||||
@@ -117,20 +117,20 @@ export default function BotConfigPage() {
|
||||
</Modal>
|
||||
{pageShowRule === BotConfigPageShowRule.NO_LLM && (
|
||||
<EmptyAndCreateComponent
|
||||
title={"需要先创建大模型才能配置机器人哦~"}
|
||||
subTitle={"快去创建一个吧!"}
|
||||
buttonText={"创建大模型 GO!"}
|
||||
title={'需要先创建大模型才能配置机器人哦~'}
|
||||
subTitle={'快去创建一个吧!'}
|
||||
buttonText={'创建大模型 GO!'}
|
||||
onButtonClick={() => {
|
||||
router.push("/home/models");
|
||||
router.push('/home/models');
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
|
||||
{pageShowRule === BotConfigPageShowRule.NO_BOT && (
|
||||
<EmptyAndCreateComponent
|
||||
title={"您还未配置机器人哦~"}
|
||||
subTitle={"快去创建一个吧!"}
|
||||
buttonText={"创建机器人 +"}
|
||||
title={'您还未配置机器人哦~'}
|
||||
subTitle={'快去创建一个吧!'}
|
||||
buttonText={'创建机器人 +'}
|
||||
onButtonClick={handleCreateBotClick}
|
||||
/>
|
||||
)}
|
||||
@@ -164,5 +164,5 @@ export default function BotConfigPage() {
|
||||
enum BotConfigPageShowRule {
|
||||
NO_LLM,
|
||||
NO_BOT,
|
||||
HAVE_BOT
|
||||
HAVE_BOT,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user