feat(roundtable): 业务链条配置增加管理员权限,管理员可配所有链条
- 后端 store/路由:scope=all(仅管理员)列全量;get/update/delete 加 is_admin 旁路,管理员可操作任意 owner 链条且不转移归属;非管理员请求 all 退化为 mine - 前端列表页/会商弹窗:管理员多「全部链条」筛选 tab,canManage=isAdmin||isMine 放开发布/设置/删除 - 编辑器:管理员可见发布按钮;按 chainId 找不到本地列表时直接 getChain 拉取(修复管理员从「全部链条」进编辑器空白),并修掉自身无链条时加载卡死的边界 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
48744441ba
commit
f13a1bb7fe
6 files changed
+113
-45
No files matched your search
@@ -78,6 +78,7 @@ import { useDesensitizeSubtree } from "@/roundtable-planning/lib/use-desensitize
|
||||
import { TagSearchBar } from "@/components/workspace/tags/tag-search-bar";
|
||||
import { ModelNameSelect } from "@/components/workspace/model-name-select";
|
||||
import { listAgents } from "@/core/agents";
|
||||
import { getStoredAuth } from "@/core/auth";
|
||||
|
||||
import {
|
||||
filterRecommendCandidates,
|
||||
@@ -86,6 +87,7 @@ import {
|
||||
import {
|
||||
createChain,
|
||||
deleteChain,
|
||||
getChain,
|
||||
listChains,
|
||||
optimizeChainPrompt,
|
||||
setChainPublic,
|
||||
@@ -171,6 +173,8 @@ export default function BusinessChainEditorPage() {
|
||||
// 当前编辑链条的发布状态 / 是否本人所有(发布按钮 + 只读保护用)。
|
||||
const [currentChainPublic, setCurrentChainPublic] = useState(false);
|
||||
const [currentChainMine, setCurrentChainMine] = useState(true);
|
||||
// 管理员:可编辑 / 发布 / 删除任意账号的链条(与「全部链条」筛选配套)。
|
||||
const isAdmin = getStoredAuth()?.system_role === "admin";
|
||||
const [publishing, setPublishing] = useState(false);
|
||||
const [title, setTitle] = useState("");
|
||||
const [description, setDescription] = useState("");
|
||||
@@ -330,10 +334,23 @@ export default function BusinessChainEditorPage() {
|
||||
if (appliedChainParamRef.current) return;
|
||||
const chainId = searchParams.get("chainId");
|
||||
if (!chainId) return;
|
||||
if (chains.length === 0) return; // 等 refreshChains 拉回列表
|
||||
const chain = chains.find((c) => c.id === chainId);
|
||||
if (chain) loadChain(chain);
|
||||
appliedChainParamRef.current = true; // 命中或链条已不存在,都不再重试
|
||||
appliedChainParamRef.current = true; // 只应用一次,之后不覆盖用户手动切换
|
||||
// 优先用「我的链条」列表里已拉到的对象(省一次请求);不在列表里(管理员从「全部链条」
|
||||
// 点设置 / 公共链条 / 自己没有任何链条)则直接按 id 拉取。后端对管理员放开任意链条、
|
||||
// 对所有人放开已发布公共链条;拉不到则静默保持空白新建态。
|
||||
const local = chains.find((c) => c.id === chainId);
|
||||
if (local) {
|
||||
loadChain(local);
|
||||
return;
|
||||
}
|
||||
void (async () => {
|
||||
try {
|
||||
const chain = await getChain(chainId);
|
||||
if (chain) loadChain(chain);
|
||||
} catch {
|
||||
// 静默:取不到就保持当前(空白)状态。
|
||||
}
|
||||
})();
|
||||
}, [chains, searchParams, loadChain]);
|
||||
|
||||
// ─── 席位增删改(全部委托给 lib/chain-stages 纯函数)────────────────────
|
||||
@@ -987,8 +1004,8 @@ export default function BusinessChainEditorPage() {
|
||||
|
||||
{/* 右侧操作 */}
|
||||
<div className="ml-auto flex items-center gap-2">
|
||||
{/* 发布 / 取消发布:仅已保存且本人所有的链条。发布后所有账号可在「公共」筛选查看 / 选用。 */}
|
||||
{currentChainId && currentChainMine && (
|
||||
{/* 发布 / 取消发布:已保存且本人所有(或管理员)的链条。发布后所有账号可在「公共」筛选查看 / 选用。 */}
|
||||
{currentChainId && (currentChainMine || isAdmin) && (
|
||||
<button
|
||||
type="button"
|
||||
onClick={handleTogglePublish}
|
||||
|
||||
Reference in new issue
Block a user