Skip to content

Commit e0a0d64

Browse files
committed
🐛 修复脚本储存管理过高与object类型编辑问题
1 parent 8e678da commit e0a0d64

3 files changed

Lines changed: 19 additions & 7 deletions

File tree

src/pages/components/ScriptStorage/index.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ const ScriptStorage: React.FC<{
102102
title: "value",
103103
dataIndex: "value",
104104
key: "value",
105+
className: "max-table-cell",
105106
render(col) {
106107
switch (typeof col) {
107108
case "string":
@@ -224,7 +225,10 @@ const ScriptStorage: React.FC<{
224225
form={form}
225226
initialValues={{
226227
key: currentValue?.key,
227-
value: currentValue?.value,
228+
value:
229+
typeof currentValue?.value === "string"
230+
? currentValue?.value
231+
: JSON.stringify(currentValue?.value),
228232
type: valueType(currentValue?.value || "string"),
229233
}}
230234
>

src/pages/options/index.css

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,9 @@ h6.arco-typography {
1414
.script-list .arco-card-body {
1515
padding: 0 !important;
1616
}
17+
18+
.max-table-cell .arco-table-cell {
19+
display: block;
20+
max-height: 100px;
21+
overflow: auto;
22+
}

src/pages/options/routes/script/ScriptEditor.tsx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,11 @@ function ScriptEditor() {
150150
const [currentScript, setCurrentScript] = useState<Script>();
151151
const [selectSciptButtonAndTab, setSelectSciptButtonAndTab] =
152152
useState<string>("");
153-
const [rightOperationTab, setRightOperationTab] = useState();
153+
const [rightOperationTab, setRightOperationTab] = useState<{
154+
key: string;
155+
uuid: string;
156+
selectSciptButtonAndTab: string;
157+
}>();
154158
const setShow = (key: visibleItem, show: boolean) => {
155159
Object.keys(visible).forEach((k) => {
156160
visible[k] = false;
@@ -374,7 +378,7 @@ function ScriptEditor() {
374378
// 对tab点击右键进行的操作
375379
useEffect(() => {
376380
let newEditors = [];
377-
let selectEditorIndex;
381+
let selectEditorIndex: number = 0;
378382
// 1 关闭当前, 2关闭其它, 3关闭左侧, 4关闭右侧
379383
if (rightOperationTab) {
380384
// eslint-disable-next-line default-case
@@ -414,31 +418,29 @@ function ScriptEditor() {
414418
}
415419
setEditors([...newEditors]);
416420
break;
417-
// eslint-disable-next-line no-fallthrough
418421
case "2":
419-
// eslint-disable-next-line no-case-declarations, no-redeclare
420422
newEditors = editors.filter(
421423
(item) => item.script.uuid === rightOperationTab.uuid
422424
);
423425
setSelectSciptButtonAndTab(rightOperationTab.uuid);
424426
setEditors([...newEditors]);
425427
break;
426428
case "3":
427-
// eslint-disable-next-line array-callback-return
428429
editors.map((item, index) => {
429430
if (item.script.uuid === rightOperationTab.uuid) {
430431
selectEditorIndex = index;
431432
}
433+
return null;
432434
});
433435
newEditors = editors.splice(selectEditorIndex);
434436
setEditors([...newEditors]);
435437
break;
436438
case "4":
437-
// eslint-disable-next-line array-callback-return
438439
editors.map((item, index) => {
439440
if (item.script.uuid === rightOperationTab.uuid) {
440441
selectEditorIndex = index;
441442
}
443+
return null;
442444
});
443445
newEditors = editors.splice(0, selectEditorIndex + 1);
444446
setEditors([...newEditors]);

0 commit comments

Comments
 (0)