Skip to content

Commit

Permalink
🐛 修复了点击左侧脚本tab没有选择对应的内容,以及点击左侧脚本没有选中的效果
Browse files Browse the repository at this point in the history
  • Loading branch information
duoluodexiaoxiaoyuan committed Dec 4, 2022
1 parent 2eed348 commit 9ad2b53
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/pages/options/routes/script/ScriptEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,8 @@ function ScriptEditor() {
>([]);
const [scriptList, setScriptList] = useState<Script[]>([]);
const [currentScript, setCurrentScript] = useState<Script>();

const [selectSciptButtonAndTab, setSelectSciptButtonAndTab] =
useState<string>();
const setShow = (key: visibleItem, show: boolean) => {
Object.keys(visible).forEach((k) => {
visible[k] = false;
Expand Down Expand Up @@ -539,8 +540,11 @@ function ScriptEditor() {
overflow: "hidden",
textOverflow: "ellipsis",
whiteSpace: "nowrap",
backgroundColor:
selectSciptButtonAndTab === script.uuid ? "gray" : "",
}}
onClick={() => {
setSelectSciptButtonAndTab(script.uuid);
// 如果已经打开则激活
let flag = false;
for (let i = 0; i < editors.length; i += 1) {
Expand Down Expand Up @@ -581,6 +585,7 @@ function ScriptEditor() {
onChange={(index: string) => {
editors.forEach((_, i) => {
if (i.toString() === index) {
setSelectSciptButtonAndTab(editors[i].script.uuid);
editors[i].active = true;
} else {
editors[i].active = false;
Expand All @@ -594,6 +599,7 @@ function ScriptEditor() {
prev.forEach((item) => {
item.active = false;
});
setSelectSciptButtonAndTab(e.script.uuid);
prev.push(e);
return [...prev];
});
Expand Down Expand Up @@ -643,8 +649,10 @@ function ScriptEditor() {
style={{
// eslint-disable-next-line no-nested-ternary
color: e.isChanged
? "rgb(var(--orange-5))"
: e.script.id === 0
? "rgb(var(--orange-5))" // eslint-disable-next-line no-nested-ternary
: e.script.uuid === selectSciptButtonAndTab
? "rgb(var(--green-7))"
: e.active
? "rgb(var(--green-7))"
: "var(--color-text-1)",
}}
Expand Down

0 comments on commit 9ad2b53

Please sign in to comment.