Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

添加根据内容定位页数 #21

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion out/bookUtil.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion out/bookUtil.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion out/extension.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{
"name": "thief-book",
"displayName": "Thief-Book",
"description": "摸鱼看书神器 & Looking book tools",
"version": "0.1.0",
Expand Down Expand Up @@ -30,6 +32,11 @@
"default": 1,
"description": "当前小说页数(支持跳转) & Pages of Current Novels (Support jumping)"
},
"thiefBook.searchWord": {
"type": "string",
"default": "",
"description": "搜索文字 & search the word"
},
"thiefBook.pageSize": {
"type": "number",
"default": 50,
Expand Down Expand Up @@ -118,4 +125,3 @@
},
"homepage": "https://github.com/cteams/Thief-Book-VSCode/blob/master/README.md"
}

11 changes: 10 additions & 1 deletion src/bookUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,17 @@ export class Book {

getPage(type: string) {

var curr_page = <number>workspace.getConfiguration().get('thiefBook.currPageNumber');
var page = 0;
var curr_page = <number>workspace.getConfiguration().get('thiefBook.currPageNumber');
var searchWord = <string>workspace.getConfiguration().get('thiefBook.searchWord');
if (searchWord) {
let text = this.readFile();
let index = text.indexOf(searchWord.replace(/^\s$/g, ""));
if (index > -1) {
curr_page = Math.floor(index / this.page_size!) + 1;
}
workspace.getConfiguration().update('thiefBook.searchWord', '', true);
}

if (type === "previous") {
if (curr_page! <= 1) {
Expand Down
Binary file added thief-book-0.1.0.vsix
Binary file not shown.