feat(notebook): lock material source to notebook when studioToken is provided
- Auto-switch materialSource to 'notebook' on mount when initialNotebookId is set - Replace material source dropdown with static label when studioToken is present Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
1 parent
0e7149eec3
commit
d57bcd9aa2
1 file changed
+32
-17
@@ -97,6 +97,14 @@ export function AIWritingForm({
|
|||||||
[models, modelName],
|
[models, modelName],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// initialNotebookId 存在时自动切换素材来源为「我的笔记」
|
||||||
|
useEffect(() => {
|
||||||
|
if (initialNotebookId != null) {
|
||||||
|
setMaterialSource('notebook');
|
||||||
|
}
|
||||||
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
|
}, []);
|
||||||
|
|
||||||
// 初始化时加载文章类型
|
// 初始化时加载文章类型
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
refreshTypes();
|
refreshTypes();
|
||||||
@@ -276,23 +284,30 @@ export function AIWritingForm({
|
|||||||
|
|
||||||
<div className="mt-4 space-y-2">
|
<div className="mt-4 space-y-2">
|
||||||
<label className={FIELD_LABEL_CLASS}>素材来源</label>
|
<label className={FIELD_LABEL_CLASS}>素材来源</label>
|
||||||
<Select
|
{/* studioToken 模式:素材来源已锁定为「我的笔记」,不可切换 */}
|
||||||
value={materialSource}
|
{studioToken ? (
|
||||||
onValueChange={(v) => handleMaterialSourceChange(v as MaterialSource)}
|
<div className={`${FIELD_TRIGGER_CLASS} flex items-center px-3 border rounded-xl bg-white text-sm text-muted-foreground`}>
|
||||||
disabled={disabled}
|
我的笔记
|
||||||
>
|
</div>
|
||||||
<SelectTrigger className={FIELD_TRIGGER_CLASS}>
|
) : (
|
||||||
<SelectValue placeholder="选择素材来源" />
|
<Select
|
||||||
</SelectTrigger>
|
value={materialSource}
|
||||||
<SelectContent>
|
onValueChange={(v) => handleMaterialSourceChange(v as MaterialSource)}
|
||||||
{MATERIAL_SOURCE_OPTIONS.map((opt) => (
|
disabled={disabled}
|
||||||
<SelectItem key={opt.value} value={opt.value} className="text-sm">
|
>
|
||||||
{opt.label}
|
<SelectTrigger className={FIELD_TRIGGER_CLASS}>
|
||||||
<span className="ml-1 text-xs text-muted-foreground">— {opt.desc}</span>
|
<SelectValue placeholder="选择素材来源" />
|
||||||
</SelectItem>
|
</SelectTrigger>
|
||||||
))}
|
<SelectContent>
|
||||||
</SelectContent>
|
{MATERIAL_SOURCE_OPTIONS.map((opt) => (
|
||||||
</Select>
|
<SelectItem key={opt.value} value={opt.value} className="text-sm">
|
||||||
|
{opt.label}
|
||||||
|
<span className="ml-1 text-xs text-muted-foreground">— {opt.desc}</span>
|
||||||
|
</SelectItem>
|
||||||
|
))}
|
||||||
|
</SelectContent>
|
||||||
|
</Select>
|
||||||
|
)}
|
||||||
|
|
||||||
{/* 选了"我的笔记"才展示笔记本 / 文档选择器 */}
|
{/* 选了"我的笔记"才展示笔记本 / 文档选择器 */}
|
||||||
{materialSource === 'notebook' && (
|
{materialSource === 'notebook' && (
|
||||||
|
|||||||
Reference in new issue
Block a user