fix:上传文件点击编辑没反应
This commit is contained in:
@@ -420,6 +420,7 @@ function AuthenticatedModelPlatformApp() {
|
|||||||
// 选择脚本
|
// 选择脚本
|
||||||
const selectScript = (scriptId: string | null) => {
|
const selectScript = (scriptId: string | null) => {
|
||||||
setSelectedId(scriptId);
|
setSelectedId(scriptId);
|
||||||
|
selectedIdRef.current = scriptId;
|
||||||
};
|
};
|
||||||
|
|
||||||
// 打开标签
|
// 打开标签
|
||||||
@@ -440,23 +441,18 @@ function AuthenticatedModelPlatformApp() {
|
|||||||
|
|
||||||
// 关闭标签
|
// 关闭标签
|
||||||
const closeTab = async (scriptId: string, event?: ReactMouseEvent) => {
|
const closeTab = async (scriptId: string, event?: ReactMouseEvent) => {
|
||||||
console.log('[closeTab] 开始关闭:', scriptId, '当前 selectedId:', selectedId);
|
|
||||||
event?.stopPropagation();
|
event?.stopPropagation();
|
||||||
if (editSessionRef.current?.script_id === scriptId) {
|
if (editSessionRef.current?.script_id === scriptId) {
|
||||||
console.log('[closeTab] 需要结束编辑');
|
|
||||||
await endEditing(false, false);
|
await endEditing(false, false);
|
||||||
}
|
}
|
||||||
// 从缓存中删除
|
// 从缓存中删除
|
||||||
sessionCacheRef.current.delete(scriptId);
|
sessionCacheRef.current.delete(scriptId);
|
||||||
setOpenTabIds((current) => {
|
setOpenTabIds((current) => {
|
||||||
console.log('[closeTab] 当前标签栏:', current);
|
|
||||||
const index = current.indexOf(scriptId);
|
const index = current.indexOf(scriptId);
|
||||||
if (index === -1) return current;
|
if (index === -1) return current;
|
||||||
const newTabs = current.filter((id) => id !== scriptId);
|
const newTabs = current.filter((id) => id !== scriptId);
|
||||||
console.log('[closeTab] 关闭后的标签栏:', newTabs);
|
|
||||||
if (selectedId === scriptId) {
|
if (selectedId === scriptId) {
|
||||||
const nextId = newTabs[index] ?? newTabs[index - 1] ?? null;
|
const nextId = newTabs[index] ?? newTabs[index - 1] ?? null;
|
||||||
console.log('[closeTab] 选中下一个:', nextId);
|
|
||||||
setSelectedId(nextId);
|
setSelectedId(nextId);
|
||||||
selectedIdRef.current = nextId;
|
selectedIdRef.current = nextId;
|
||||||
}
|
}
|
||||||
@@ -485,6 +481,7 @@ function AuthenticatedModelPlatformApp() {
|
|||||||
|
|
||||||
// 打开脚本编辑器
|
// 打开脚本编辑器
|
||||||
const openScriptEditor = async (script: ScriptItem, showToast = true) => {
|
const openScriptEditor = async (script: ScriptItem, showToast = true) => {
|
||||||
|
if (!script) return;
|
||||||
if (editorOpeningRef.current) return;
|
if (editorOpeningRef.current) return;
|
||||||
editorOpeningRef.current = true;
|
editorOpeningRef.current = true;
|
||||||
const requestId = editorOpenRequestRef.current + 1;
|
const requestId = editorOpenRequestRef.current + 1;
|
||||||
@@ -760,10 +757,11 @@ function AuthenticatedModelPlatformApp() {
|
|||||||
for (const file of files) {
|
for (const file of files) {
|
||||||
lastCreated = await api.uploadScript(file, uploadParentPath);
|
lastCreated = await api.uploadScript(file, uploadParentPath);
|
||||||
}
|
}
|
||||||
await load(true);
|
// 和新建文件逻辑一致:直接更新 scripts,不调用 load()
|
||||||
|
setScripts((items) => [lastCreated!, ...items]);
|
||||||
|
// 只打开最后一个文件
|
||||||
if (lastCreated) {
|
if (lastCreated) {
|
||||||
openTab(lastCreated.script_id);
|
openTab(lastCreated.script_id);
|
||||||
selectScript(lastCreated.script_id);
|
|
||||||
}
|
}
|
||||||
setToast({
|
setToast({
|
||||||
tone: "success",
|
tone: "success",
|
||||||
|
|||||||
Reference in New Issue
Block a user