Initial import of weiyuan frontend

This commit is contained in:
qiubaishen
2026-10-15 16:33:46 +08:00
commit d8f3aee261
774 changed files with 374914 additions and 0 deletions
+169
View File
@@ -0,0 +1,169 @@
/*
Copyright (C) 2025 QuantumNous
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import React, { useEffect, useMemo, useState } from 'react';
import { Button, Empty, Tag } from '@douyinfe/semi-ui';
import { Cable, LockKeyhole } from 'lucide-react';
import { useTranslation } from 'react-i18next';
import { API } from '../../helpers/api';
import {
usePageGuide,
PageGuideDrawer,
PageGuideTrigger,
} from '../../components/common/PageGuide';
import './org-connectors.css';
const OrgMyConnectors = ({ orgId }) => {
const { t } = useTranslation();
const headers = useMemo(() => ({ 'X-Org-Id': String(orgId) }), [orgId]);
const [items, setItems] = useState([]);
const [loadError, setLoadError] = useState('');
useEffect(() => {
let active = true;
API.get('/api/org/connectors/mine', { headers, skipErrorHandler: true })
.then((response) => {
if (!active) return;
if (response.data?.success) {
setItems(response.data.data || []);
setLoadError('');
} else {
// A failed load must not masquerade as "no authorizations".
setLoadError(response.data?.message || t('授权列表加载失败'));
}
})
.catch((error) => {
if (active)
setLoadError(
error?.response?.data?.message ||
error?.message ||
t('授权列表加载失败'),
);
});
return () => {
active = false;
};
}, [headers, t]);
// 使用指引:成员视角的阅读式说明(无上手流程,不出进度胶囊)。
const guide = usePageGuide({
guideKey: 'org-my-connectors',
title: t('我的业务系统授权 · 使用指引'),
intro: t('这里列出专家在任务中可以代表你调用的业务系统与边界'),
steps: [
{
title: t('看懂授权卡片'),
detail: t('一张卡片对应一个已授权的业务系统连接器'),
points: [
t('右上角标签是访问级别:read 只读,write 可执行写操作'),
t('卡片中的标签列出专家可调用的具体方法'),
],
},
{
title: t('理解确认策略'),
detail: t('确认策略决定哪些调用执行前需要你亲自确认'),
points: [
t('never 无需确认;write 写操作前确认;always 每次调用都确认'),
],
},
{
title: t('任务中的确认操作'),
detail: t('确认动作发生在云端大脑的任务详情页'),
points: [
t('专家发起调用时任务会停在「等待操作确认」'),
t('展开「查看冻结参数」核对操作内容,填写原因后确认或拒绝'),
t('长时间不处理会确认超时,任务按已发生用量结算'),
],
},
{
title: t('需要调整授权'),
detail: t('授权由企业管理员统一发布与撤销'),
points: [t('缺少某个系统的授权或范围不足时,请联系企业管理员')],
},
],
faq: [
{
q: t('列表是空的?'),
a: t('管理员发布授权并覆盖到你之后才会显示,请联系企业管理员'),
},
{
q: t('「企业服务账号由管理员管理」是什么意思?'),
a: t('该连接器以企业级凭据运行,个人无法自行撤销'),
},
],
});
return (
<main className='org-connector-page'>
<header className='org-connector-hero'>
<div>
<h1>{t('我的业务系统授权')}</h1>
<p>{t('查看专家在任务中可代表你调用的业务系统、方法和确认策略。')}</p>
</div>
<div className='org-connector-actions'>
<PageGuideTrigger guide={guide} />
</div>
</header>
<PageGuideDrawer guide={guide} />
{loadError ? (
<Empty title={t('授权列表加载失败')} description={loadError} />
) : items.length === 0 ? (
<Empty
title={t('当前没有 Connector 授权')}
description={t('管理员发布授权并覆盖到你后会显示在这里。')}
/>
) : (
<section className='org-connector-grid'>
{items.map((item) => (
<article className='org-connector-card' key={item.grant.id}>
<div className='org-connector-card-top'>
<span className='org-connector-icon'>
<Cable size={20} />
</span>
<Tag
color={
item.grant.access_level === 'write' ? 'orange' : 'green'
}
>
{item.grant.access_level}
</Tag>
</div>
<h3>{item.connector_name}</h3>
<p>{item.definition_name}</p>
<div className='org-connector-tags'>
{item.methods.map((method) => (
<Tag key={method}>{method}</Tag>
))}
</div>
<p>
<LockKeyhole size={14} /> {t('确认策略')}:{' '}
{item.grant.confirmation_policy}
</p>
<Button disabled={!item.revocable}>
{item.revocable
? t('撤销个人委托')
: t('企业服务账号由管理员管理')}
</Button>
</article>
))}
</section>
)}
</main>
);
};
export default OrgMyConnectors;