Skip to content

Commit

Permalink
fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
troyeguo committed Jun 24, 2023
1 parent 08a0fbd commit e1d26eb
Show file tree
Hide file tree
Showing 21 changed files with 331 additions and 258 deletions.
23 changes: 22 additions & 1 deletion main.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const fs = require("fs");
const configDir = app.getPath("userData");
const { ra } = require("./edge-tts");
const dirPath = path.join(configDir, "uploads");
const { Blob } = require("buffer");
let mainWin;
const singleInstance = app.requestSingleInstanceLock();
var filePath = null;
Expand Down Expand Up @@ -119,8 +120,28 @@ const createMainWin = () => {
event.returnValue = "success";
});
ipcMain.handle("edge-tts", async (event, config) => {
console.log(dirPath);
let { text } = config;
return await ra(text);
let audioName = new Date().getTime() + ".webm";
if (!fs.existsSync(path.join(dirPath, "tts"))) {
fs.mkdirSync(path.join(dirPath, "tts"));
fs.writeFileSync(path.join(dirPath, "tts", audioName), await ra(text));
console.log("文件夹创建成功");
} else {
fs.writeFileSync(path.join(dirPath, "tts", audioName), await ra(text));
console.log("文件夹已存在");
}

return path.join(dirPath, "tts", audioName);
});
ipcMain.handle("clear-tts", async (event, config) => {
if (!fs.existsSync(path.join(dirPath, "tts"))) {
return "pong";
} else {
const fsExtra = require("fs-extra");
fsExtra.emptyDirSync(path.join(dirPath, "tts"));
return "pong";
}
});
ipcMain.handle("change-path", async (event) => {
var path = await dialog.showOpenDialog({
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"epub-cfi-resolver": "^1.0.2",
"font-list": "^1.4.5",
"fs-extra": "^9.1.0",
"howler": "^2.2.3",
"mhtml2html": "^3.0.0",
"react-hot-toast": "^2.1.1",
"request": "^2.88.2",
Expand Down
8 changes: 4 additions & 4 deletions public/lib/kookit/kookit.min.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/components/dialogs/actionDialog/actionDialog.css
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
overflow-y: scroll;
height: 185px;
text-align: left;
overflow-x: hidden;
}
.action-dialog-book-title {
font-size: 15px;
Expand Down
12 changes: 10 additions & 2 deletions src/components/dialogs/actionDialog/component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class ActionDialog extends React.Component<
super(props);
this.state = {
isShowExport: false,
isExceed: false,
};
}
handleDeleteBook = () => {
Expand Down Expand Up @@ -125,8 +126,15 @@ class ActionDialog extends React.Component<
</div>
<div
className="action-dialog-edit"
onMouseEnter={() => {
onMouseEnter={(event) => {
this.setState({ isShowExport: true });
const e = event || window.event;
let x = e.clientX;
if (x > document.body.clientWidth - 300) {
this.setState({ isExceed: true });
} else {
this.setState({ isExceed: false });
}
}}
onMouseLeave={(event) => {
this.setState({ isShowExport: false });
Expand Down Expand Up @@ -241,7 +249,7 @@ class ActionDialog extends React.Component<
this.state.isShowExport
? {
position: "absolute",
left: this.props.left,
left: this.props.left + (this.state.isExceed ? -400 : 0),
top: this.props.top + 70,
}
: { display: "none" }
Expand Down
1 change: 1 addition & 0 deletions src/components/dialogs/actionDialog/interface.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ export interface ActionDialogProps {
}
export interface ActionDialogState {
isShowExport: boolean;
isExceed: boolean;
}
16 changes: 9 additions & 7 deletions src/components/searchBox/component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -137,13 +137,15 @@ class SearchBox extends React.Component<SearchBoxProps> {
<span className="icon-close"></span>
</span>
) : (
<span
className="icon-search header-search-icon"
onClick={() => {
this.handleMouse();
}}
style={this.props.mode === "nav" ? { right: "5px" } : {}}
></span>
<span className="header-search-text">
<span
className="icon-search header-search-icon"
onClick={() => {
this.handleMouse();
}}
style={this.props.mode === "nav" ? { right: "5px" } : {}}
></span>
</span>
)}
</div>
);
Expand Down
17 changes: 7 additions & 10 deletions src/components/searchBox/searchBox.css
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
.header-search-box {
width: 100%;
width: calc(100% - 20px);
height: 38px;
border-radius: 22px;
border-style: none;
outline: none;
padding-left: 20px;
font-size: 15px;
padding: 0px;
padding-left: 20px;
}
input::-webkit-input-placeholder,
input::-moz-placeholder,
Expand All @@ -15,28 +16,24 @@ textarea::-moz-placeholder,
textarea::-ms-input-placeholder {
font-size: 15px;
line-height: 38px;

/* opacity: 1; */
}
.header-search-icon {
position: absolute;
top: 10px;
right: -6px;
font-size: 22px;
display: inline-block;
opacity: 0.6;
cursor: pointer;
margin-right: 10px;
}
.header-search-text {
position: absolute;
top: 0px;
right: -15px;
right: 0px;
font-size: 15px;
display: inline-block;
width: 44px;
height: 44px;
width: 40px;
height: 100%;
cursor: pointer;
margin-right: 5px;
display: flex;
align-items: center;
justify-content: center;
Expand Down
Loading

0 comments on commit e1d26eb

Please sign in to comment.