Skip to content

Commit

Permalink
🐛 修复脚本储存管理过高与object类型编辑问题
Browse files Browse the repository at this point in the history
  • Loading branch information
CodFrm committed Dec 14, 2022
1 parent 8e678da commit e0a0d64
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
6 changes: 5 additions & 1 deletion src/pages/components/ScriptStorage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ const ScriptStorage: React.FC<{
title: "value",
dataIndex: "value",
key: "value",
className: "max-table-cell",
render(col) {
switch (typeof col) {
case "string":
Expand Down Expand Up @@ -224,7 +225,10 @@ const ScriptStorage: React.FC<{
form={form}
initialValues={{
key: currentValue?.key,
value: currentValue?.value,
value:
typeof currentValue?.value === "string"
? currentValue?.value
: JSON.stringify(currentValue?.value),
type: valueType(currentValue?.value || "string"),
}}
>
Expand Down
6 changes: 6 additions & 0 deletions src/pages/options/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,9 @@ h6.arco-typography {
.script-list .arco-card-body {
padding: 0 !important;
}

.max-table-cell .arco-table-cell {
display: block;
max-height: 100px;
overflow: auto;
}
14 changes: 8 additions & 6 deletions src/pages/options/routes/script/ScriptEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,11 @@ function ScriptEditor() {
const [currentScript, setCurrentScript] = useState<Script>();
const [selectSciptButtonAndTab, setSelectSciptButtonAndTab] =
useState<string>("");
const [rightOperationTab, setRightOperationTab] = useState();
const [rightOperationTab, setRightOperationTab] = useState<{
key: string;
uuid: string;
selectSciptButtonAndTab: string;
}>();
const setShow = (key: visibleItem, show: boolean) => {
Object.keys(visible).forEach((k) => {
visible[k] = false;
Expand Down Expand Up @@ -374,7 +378,7 @@ function ScriptEditor() {
// 对tab点击右键进行的操作
useEffect(() => {
let newEditors = [];
let selectEditorIndex;
let selectEditorIndex: number = 0;
// 1 关闭当前, 2关闭其它, 3关闭左侧, 4关闭右侧
if (rightOperationTab) {
// eslint-disable-next-line default-case
Expand Down Expand Up @@ -414,31 +418,29 @@ function ScriptEditor() {
}
setEditors([...newEditors]);
break;
// eslint-disable-next-line no-fallthrough
case "2":
// eslint-disable-next-line no-case-declarations, no-redeclare
newEditors = editors.filter(
(item) => item.script.uuid === rightOperationTab.uuid
);
setSelectSciptButtonAndTab(rightOperationTab.uuid);
setEditors([...newEditors]);
break;
case "3":
// eslint-disable-next-line array-callback-return
editors.map((item, index) => {
if (item.script.uuid === rightOperationTab.uuid) {
selectEditorIndex = index;
}
return null;
});
newEditors = editors.splice(selectEditorIndex);
setEditors([...newEditors]);
break;
case "4":
// eslint-disable-next-line array-callback-return
editors.map((item, index) => {
if (item.script.uuid === rightOperationTab.uuid) {
selectEditorIndex = index;
}
return null;
});
newEditors = editors.splice(0, selectEditorIndex + 1);
setEditors([...newEditors]);
Expand Down

0 comments on commit e0a0d64

Please sign in to comment.