fix: modules

This commit is contained in:
archer
2023-07-18 20:02:51 +08:00
parent a993eba7f0
commit ba73762285
5 changed files with 27 additions and 13 deletions

View File

@@ -57,7 +57,7 @@ const MermaidBlock = ({ code }: { code: string }) => {
const { svg } = await mermaid.render(`mermaid-${Date.now()}`, formatCode);
setSvg(svg);
} catch (e: any) {
console.log('[Mermaid] ', e?.message);
// console.log('[Mermaid] ', e?.message);
}
})();
}, [code]);

View File

@@ -615,6 +615,8 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
await authUser({ req, authRoot: true });
await connectToDatabase();
const { limit = 1000 } = req.body as { limit: number };
// 遍历所有的 app
const apps = await App.find(
{
@@ -623,7 +625,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
// userId: '63f9a14228d2a688d8dc9e1b'
},
'_id chat'
);
).limit(limit);
await Promise.all(
apps.map(async (app) => {

View File

@@ -264,7 +264,7 @@ const AppEdit = ({ app, fullScreen, onFullScreen }: Props) => {
setLoaded(true);
onFixView();
},
[onDelConnect, setEdges, setNodes, onChangeNode, onDelNode]
[onDelConnect, setEdges, setNodes, onFixView, onChangeNode, onDelNode]
);
useEffect(() => {

View File

@@ -2,6 +2,7 @@ import { connectToDatabase, Bill, User, ShareChat } from '../mongo';
import { BillSourceEnum } from '@/constants/user';
import { getModel } from '../utils/data';
import type { BillListItemType } from '@/types/mongoSchema';
import { formatPrice } from '@/utils/user';
export const createTaskBill = async ({
appName,
@@ -62,7 +63,7 @@ export const finishTaskBill = async ({ billId }: { billId: string }) => {
if (!res) return;
const total = res.list.reduce((sum, item) => sum + item.amount, 0) || 0;
console.log('finish bill:', total);
console.log('finish bill:', formatPrice(total));
// 账号扣费
await User.findByIdAndUpdate(res.userId, {

View File

@@ -104,15 +104,26 @@ export const appModule2FlowNode = ({
intro: template.intro,
type: template.type,
url: template.url,
inputs: template.inputs.map((templateInput) => ({
...templateInput,
value:
item.inputs.find((item) => item.key === templateInput.key)?.value || templateInput.value
})),
outputs: template.outputs.map((templateOutput) => ({
...templateOutput,
targets: item.outputs.find((item) => item.key === templateOutput.key)?.targets || []
}))
inputs: template.inputs.map((templateInput) => {
// use latest inputs
const itemInput = item.inputs.find((item) => item.key === templateInput.key) || templateInput;
return {
...templateInput,
key: itemInput.key,
value: itemInput.value
};
}),
outputs: item.outputs.map((itemOutput) => {
// unChange outputs
const templateOutput =
template.outputs.find((item) => item.key === itemOutput.key) || itemOutput;
return {
...templateOutput,
key: itemOutput.key,
targets: itemOutput.targets || []
};
})
};
return {