Skip to content

Commit 4e309c3

Browse files
committed
feat(addDialog): add action type selection for copying or moving books
1 parent ecbaa7e commit 4e309c3

File tree

6 files changed

+57
-16
lines changed

6 files changed

+57
-16
lines changed

main.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,10 @@ const createMainWin = () => {
374374
if (isPreventSleep && !readerWindow.isDestroyed()) {
375375
id && powerSaveBlocker.stop(id);
376376
}
377-
mainWin.webContents.send('reading-finished', {});
377+
if (mainWin && !mainWin.isDestroyed()) {
378+
mainWin.webContents.send('reading-finished', {});
379+
}
380+
378381
});
379382

380383

src/assets/locales/zh-CN/translation.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,9 @@
256256
"Language auto-detection may not be accurate. Please try selecting the source language manually": "语言自动检测可能不够准确,请尝试手动选择源语言",
257257
"Minute": "分钟",
258258
"Empty": "这里什么都没有",
259+
"Action": "动作",
260+
"Copy to": "复制到",
261+
"Move to": "移动到",
259262
"Next chapter": "下一章",
260263
"Previous chapter": "上一章",
261264
"Less": "收起",

src/components/dialogs/addDialog/addDialog.css

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,16 @@
1616
opacity: 1;
1717
width: 100%;
1818
text-align: center;
19-
position: absolute;
20-
top: 22px;
2119
font-weight: 500;
20+
margin-top: 15px;
2221
}
2322
.add-dialog-shelf-list-container {
2423
width: 100%;
2524
font-size: 15px;
2625
line-height: 14px;
2726
opacity: 1;
28-
position: absolute;
29-
top: 55px;
27+
margin-top: 15px;
28+
height: 30px;
3029
}
3130
.add-dialog-shelf-list-text {
3231
width: 50px;
@@ -55,14 +54,6 @@
5554
cursor: pointer;
5655
text-align: left;
5756
}
58-
.add-dialog-new-shelf-container {
59-
width: 100%;
60-
font-size: 15px;
61-
line-height: 14px;
62-
opacity: 1;
63-
position: absolute;
64-
top: 95px;
65-
}
6657
.add-dialog-new-shelf-text {
6758
width: 50px;
6859
float: left;

src/components/dialogs/addDialog/component.tsx

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { ConfigService } from "../../../assets/lib/kookit-extra-browser.min";
88
class AddDialog extends Component<AddDialogProps, AddDialogState> {
99
constructor(props: AddDialogProps) {
1010
super(props);
11-
this.state = { isNew: true, shelfTitle: "" };
11+
this.state = { isNew: true, shelfTitle: "", actionType: "copy" };
1212
}
1313

1414
handleCancel = () => {
@@ -43,13 +43,29 @@ class AddDialog extends Component<AddDialogProps, AddDialogState> {
4343
}
4444
if (this.props.isSelectBook) {
4545
this.props.selectedBooks.forEach((item) => {
46+
if (this.state.actionType === "move") {
47+
ConfigService.deleteFromMapConfig(
48+
this.props.shelfTitle,
49+
item,
50+
"shelfList"
51+
);
52+
}
4653
ConfigService.setMapConfig(shelfTitle, item, "shelfList");
4754
});
4855
this.props.handleSelectBook(!this.props.isSelectBook);
4956
if (this.props.isSelectBook) {
5057
this.props.handleSelectedBooks([]);
5158
}
5259
} else {
60+
console.log(this.state.actionType, "actionType");
61+
if (this.state.actionType === "move") {
62+
ConfigService.deleteFromMapConfig(
63+
this.props.shelfTitle,
64+
this.props.currentBook.key,
65+
"shelfList"
66+
);
67+
}
68+
5369
ConfigService.setMapConfig(
5470
shelfTitle,
5571
this.props.currentBook.key,
@@ -90,10 +106,33 @@ class AddDialog extends Component<AddDialogProps, AddDialogState> {
90106
});
91107
};
92108
return (
93-
<div className="add-dialog-container">
109+
<div
110+
className="add-dialog-container"
111+
style={{ height: this.props.mode === "shelf" ? "240px" : "189px" }}
112+
>
94113
<div className="add-dialog-title">
95114
<Trans>Add to shelf</Trans>
96115
</div>
116+
{this.props.mode === "shelf" && (
117+
<div className="add-dialog-shelf-list-container">
118+
<div className="add-dialog-shelf-list-text">
119+
<Trans>Action</Trans>
120+
</div>
121+
<select
122+
className="add-dialog-shelf-list-box"
123+
onChange={(event: React.ChangeEvent<HTMLSelectElement>) => {
124+
this.setState({ actionType: event.target.value });
125+
}}
126+
>
127+
<option value="copy" className="add-dialog-shelf-list-option">
128+
{this.props.t("Copy to")}
129+
</option>
130+
<option value="move" className="add-dialog-shelf-list-option">
131+
{this.props.t("Move to")}
132+
</option>
133+
</select>
134+
</div>
135+
)}
97136
<div className="add-dialog-shelf-list-container">
98137
<div className="add-dialog-shelf-list-text">
99138
<Trans>Select</Trans>
@@ -107,7 +146,7 @@ class AddDialog extends Component<AddDialogProps, AddDialogState> {
107146
{renderShelfList()}
108147
</select>
109148
</div>
110-
<div className="add-dialog-new-shelf-container">
149+
<div className="add-dialog-shelf-list-container">
111150
<div className="add-dialog-new-shelf-text">
112151
<Trans>New</Trans>
113152
</div>

src/components/dialogs/addDialog/index.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ const mapStateToProps = (state: stateType) => {
1919
isOpenDeleteDialog: state.book.isOpenDeleteDialog,
2020
currentBook: state.book.currentBook,
2121
bookmarks: state.reader.bookmarks,
22+
mode: state.sidebar.mode,
23+
shelfTitle: state.sidebar.shelfTitle,
2224
notes: state.reader.notes,
2325
};
2426
};

src/components/dialogs/addDialog/interface.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ export interface AddDialogProps {
77
currentBook: BookModel;
88
selectedBooks: string[];
99
isSelectBook: boolean;
10+
mode: string;
11+
shelfTitle: string;
1012
t: (title: string) => string;
1113
handleMode: (mode: string) => void;
1214
handleShelf: (shelfTitle: string) => void;
@@ -15,4 +17,5 @@ export interface AddDialogProps {
1517
export interface AddDialogState {
1618
isNew: boolean;
1719
shelfTitle: string;
20+
actionType: string;
1821
}

0 commit comments

Comments
 (0)