Skip to content

Commit

Permalink
Merge pull request #225 from mgz0227/dev_2008
Browse files Browse the repository at this point in the history
解决冲突
  • Loading branch information
MaoXiaoone authored Jul 23, 2024
2 parents 22eda56 + d659af5 commit dabb71b
Show file tree
Hide file tree
Showing 22 changed files with 1,389 additions and 466 deletions.
1 change: 1 addition & 0 deletions entry/src/main/ets/common/constants/CommonConstants.ets
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ export default class CommonConstants {
static readonly GROUP_LIST_DATA:string = 'GROUP_LIST_DATA'
static readonly SHELF_LIST_DATA:string = 'SHELF_LIST_DATA'
static readonly HAS_EXPLORE_URL:string = 'HAS_EXPLORE_URL'
static readonly BOOK_IS_BOOK_REFRESHING:string = 'BOOK_IS_BOOK_REFRESHING'
// 订阅源分组数据
//分组是否初始化key
static readonly RSS_SOURCES_GROUP_INIT:string = 'RSS_SOURCES_GROUP_INIT'
Expand Down
26 changes: 22 additions & 4 deletions entry/src/main/ets/common/utils/FileHandler.ets
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import { showMessage } from '../../componets/common/promptShow';
import { picker } from '@kit.CoreFileKit';
import { util } from '@kit.ArkTS';
import { buffer } from '@kit.ArkTS'
import { Books } from '../../database/entities/Books';
import booksUtil from './booksUtils';

let context = getContext(this) as common.UIAbilityContext;
let filePath = context.filesDir;
Expand All @@ -17,12 +19,28 @@ let options: Options = {
};

export class FileHandler {
static CopyFile(srcUrl: string) {
static CopyFile(srcUrl: string, currentIndex:number) {
let file = fs.openSync(srcUrl, fs.OpenMode.READ_WRITE);
let dstPath = filePath + '/' + file.name; // file.name:《幽影之冰》.txt
addShelfBook(0,
new BookList('', file.name, '会说话的肘子·未读过1', '更新至·第340章 镇压', $r('app.media.cover_list'), '测试作者',
'未分组', dstPath))
let book:Books = {
bookName: file.name,
bookUrl: dstPath,
author: '暂无',
bookGroup: 2,
latestChapterTime: 0,
totalChapterNum: 0,
durChapterIndex: 0,
durChapterPos: 0,
durChapterTime: 0,
canUpdate: false,
sort: 0,
originOrder: 0,
syncTime: 0,
bookType: currentIndex,
isTop: false,
isJoin: false
}
booksUtil.addBooks(book)
showMessage('添加到书架成功')
fs.copyFile(file.fd, dstPath, 0).then(() => {
showMessage('导入沙箱成功')
Expand Down
15 changes: 15 additions & 0 deletions entry/src/main/ets/common/utils/booksUtils.ets
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/**
* @author 2008
* @datetime 2024/7/23 10:58
* @className: booksUtils
*/
import BooksDao from '../../database/dao/BooksDao'
import { Books } from '../../database/entities/Books'

class booksUtils{
addBooks(books: Books){
BooksDao.insert(books)
}
}
let booksUtil = new booksUtils();
export default booksUtil as booksUtils;
2 changes: 0 additions & 2 deletions entry/src/main/ets/componets/head/IndexSearchType.ets
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ export default struct IndexSearchType {
@Prop title:string
@Link searchValue:string
@State isShown: boolean = false

@State THEME_NAME: string[] = ['最近阅读', '阅读排序', '更新排序', '手动排序']
// @State THEME_NAMES: string[] = []

build() {
if (this.THEME_NAME.includes(this.title)){
Expand Down
101 changes: 60 additions & 41 deletions entry/src/main/ets/database/AppDatabase/index.ets
Original file line number Diff line number Diff line change
Expand Up @@ -8,53 +8,55 @@ export default {
"entities": [
{
"tableName": "books",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`bookUrl` TEXT NOT NULL DEFAULT '', `tocUrl` TEXT NOT NULL DEFAULT '', `origin` TEXT NOT NULL DEFAULT 'loc_book', `originName` TEXT NOT NULL DEFAULT '', `name` TEXT NOT NULL DEFAULT '', `author` TEXT NOT NULL DEFAULT '', `kind` TEXT, `customTag` TEXT, `coverUrl` TEXT, `customCoverUrl` TEXT, `intro` TEXT, `customIntro` TEXT, `charset` TEXT, `type` INTEGER NOT NULL DEFAULT 0, `group` INTEGER NOT NULL DEFAULT 0, `latestChapterTitle` TEXT, `latestChapterTime` INTEGER NOT NULL DEFAULT 0, `lastCheckTime` INTEGER NOT NULL DEFAULT 0, `lastCheckCount` INTEGER NOT NULL DEFAULT 0, `totalChapterNum` INTEGER NOT NULL DEFAULT 0, `durChapterTitle` TEXT, `durChapterIndex` INTEGER NOT NULL DEFAULT 0, `durChapterPos` INTEGER NOT NULL DEFAULT 0, `durChapterTime` INTEGER NOT NULL DEFAULT 0, `wordCount` TEXT, `canUpdate` INTEGER NOT NULL DEFAULT 1, `order` INTEGER NOT NULL DEFAULT 0, `originOrder` INTEGER NOT NULL DEFAULT 0, `variable` TEXT, `readConfig` TEXT, `syncTime` INTEGER NOT NULL DEFAULT 0, PRIMARY KEY(`bookUrl`))",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` ( `id` INTEGER NOT NULL, `bookUrl` TEXT, `toUrl` TEXT, `origin` TEXT, `originName` TEXT, `bookName` TEXT NOT NULL, `author` TEXT, `cover` TEXT, `customTag` TEXT, `coverUrl` TEXT, `customCoverUrl` TEXT, `intro` TEXT, `customIntro` TEXT, `charset` TEXT, `bookGroup` INTEGER NOT NULL DEFAULT 0, `latestChapterTitle` TEXT, `latestChapterTime` INTEGER NOT NULL DEFAULT 0, `lastCheckTime` INTEGER NOT NULL DEFAULT 0, `lastCheckCount` INTEGER NOT NULL DEFAULT 0, `totalChapterNum` INTEGER NOT NULL DEFAULT 0, `durChapterTitle` TEXT, `durChapterIndex` INTEGER NOT NULL DEFAULT 0, `durChapterPos` INTEGER NOT NULL DEFAULT 0, `durChapterTime` INTEGER NOT NULL DEFAULT 0, `wordCount` TEXT, `canUpdate` INTEGER NOT NULL DEFAULT 1, `sort` INTEGER NOT NULL DEFAULT 0, `originOrder` INTEGER NOT NULL DEFAULT 0, `syncTime` INTEGER NOT NULL DEFAULT 0, `bookType` INTEGER NOT NULL DEFAULT 0, `isTop` INTEGER NOT NULL DEFAULT 0, `createTime` INTEGER NOT NULL DEFAULT 0,`updateTime` INTEGER NOT NULL DEFAULT 0,`isJoin` INTEGER NOT NULL DEFAULT 1,PRIMARY KEY ( `id` ))",
"fields": [
{
"fieldPath": "id",
"columnName": "id",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "bookUrl",
"columnName": "bookUrl",
"affinity": "TEXT",
"notNull": true,
"defaultValue": "''"
"notNull": false
},
{
"fieldPath": "tocUrl",
"columnName": "tocUrl",
"fieldPath": "toUrl",
"columnName": "toUrl",
"affinity": "TEXT",
"notNull": true,
"defaultValue": "''"
"notNull": false
},
{
"fieldPath": "origin",
"columnName": "origin",
"affinity": "TEXT",
"notNull": true,
"defaultValue": "'loc_book'"
"notNull": false
},
{
"fieldPath": "originName",
"columnName": "originName",
"affinity": "TEXT",
"notNull": true,
"defaultValue": "''"
"notNull": false
},
{
"fieldPath": "name",
"columnName": "name",
"fieldPath": "bookName",
"columnName": "bookName",
"affinity": "TEXT",
"notNull": true,
"defaultValue": "''"
"defaultValue":""
},
{
"fieldPath": "author",
"columnName": "author",
"affinity": "TEXT",
"notNull": true,
"defaultValue": "''"
"defaultValue": ""
},
{
"fieldPath": "kind",
"columnName": "kind",
"fieldPath": "cover",
"columnName": "cover",
"affinity": "TEXT",
"notNull": false
},
Expand Down Expand Up @@ -95,15 +97,8 @@ export default {
"notNull": false
},
{
"fieldPath": "type",
"columnName": "type",
"affinity": "INTEGER",
"notNull": true,
"defaultValue": "0"
},
{
"fieldPath": "group",
"columnName": "group",
"fieldPath": "bookGroup",
"columnName": "bookGroup",
"affinity": "INTEGER",
"notNull": true,
"defaultValue": "0"
Expand Down Expand Up @@ -179,12 +174,13 @@ export default {
"fieldPath": "canUpdate",
"columnName": "canUpdate",
"affinity": "INTEGER",
"boolean": true,
"notNull": true,
"defaultValue": "1"
},
{
"fieldPath": "order",
"columnName": "order",
"fieldPath": "sort",
"columnName": "sort",
"affinity": "INTEGER",
"notNull": true,
"defaultValue": "0"
Expand All @@ -197,41 +193,64 @@ export default {
"defaultValue": "0"
},
{
"fieldPath": "variable",
"columnName": "variable",
"affinity": "TEXT",
"fieldPath": "syncTime",
"columnName": "syncTime",
"affinity": "INTEGER",
"notNull": true,
"defaultValue": "0"
},
{
"fieldPath": "bookType",
"columnName": "bookType",
"affinity": "INTEGER",
"notNull": true,
"defaultValue": "0"
},
{
"fieldPath": "isTop",
"columnName": "isTop",
"affinity": "isTop",
"boolean": true,
"notNull": true,
"defaultValue": "1"
},
{
"fieldPath": "createTime",
"columnName": "createTime",
"affinity": "INTEGER",
"notNull": false
},
{
"fieldPath": "readConfig",
"columnName": "readConfig",
"affinity": "TEXT",
"fieldPath": "updateTime",
"columnName": "updateTime",
"affinity": "INTEGER",
"notNull": false
},
{
"fieldPath": "syncTime",
"columnName": "syncTime",
"fieldPath": "isJoin",
"columnName": "isJoin",
"affinity": "INTEGER",
"boolean": true,
"notNull": true,
"defaultValue": "0"
"defaultValue": "1"
}
],
"primaryKey": {
"autoGenerate": false,
"columnNames": [
"bookUrl"
"id"
]
},
"indices": [
{
"name": "index_books_name_author",
"name": "index_books_bookName_author",
"unique": true,
"columnNames": [
"name",
"bookName",
"author"
],
"orders": [],
"createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_books_name_author` ON `${TABLE_NAME}` (`name`, `author`)"
"createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_books_bookName_author` ON `${TABLE_NAME}` (`bookName`, `author`)"
}
],
"foreignKeys": []
Expand Down
Loading

0 comments on commit dabb71b

Please sign in to comment.