mirror of
https://github.com/naiyQAQ/fanqie-assistant.git
synced 2026-10-21 10:24:47 +00:00
feat: readme & update
This commit is contained in:
1 parent
5626fb6558
commit
f94a7123b4
17 files changed
+6084
-74
No files matched your search
+4
-3
@@ -17,8 +17,9 @@ export function mappingCreationStatus(status: string): string {
|
||||
}
|
||||
|
||||
export async function getBookInfoRaw(bookId: string): Promise<any> {
|
||||
const response = await apiFetch(`https://api5-sinfonlinec.jxbhmy.com/reading/bookapi/multi-detail/v?book_id=${bookId}&aid=13`)
|
||||
const j: any = await response.json()
|
||||
const response = await apiFetch(`https://api5-sinfonlinec.jxbhmy.com/reading/bookapi/multi-detail/v?book_id=${bookId}&aid=1967`)
|
||||
const j: any = response.json()
|
||||
console.log('Book Info:', j)
|
||||
if (
|
||||
typeof j === 'object' &&
|
||||
j !== null &&
|
||||
@@ -41,7 +42,7 @@ export async function getBookInfo(bookId: string): Promise<Book> {
|
||||
cover_url: bookInfo.thumb_url,
|
||||
summary: bookInfo.abstract,
|
||||
// volume_list: bookInfo.volume_list,
|
||||
update_time: moment(bookInfo.last_chapter_first_pass_time).format('YYYY-MM-DD HH:mm:ss'),
|
||||
update_time: moment(bookInfo.last_chapter_first_pass_time * 1000).format('YYYY-MM-DD HH:mm:ss'),
|
||||
status: mappingCreationStatus(bookInfo.creation_status),
|
||||
// chapter_count: bookInfo.chapter_count,
|
||||
} as Book
|
||||
|
||||
+2
-2
@@ -24,8 +24,8 @@ export async function getCatalog(bookId: string): Promise<CatalogResult> {
|
||||
item_id: item.itemId,
|
||||
title: item.title,
|
||||
// YYYY-MM-DD HH:mm:ss
|
||||
update_time: moment(item.updateTime).format('YYYY-MM-DD HH:mm:ss') as string,
|
||||
char_count: item.charCount,
|
||||
update_time: moment(item.firstPassTime * 1000).format('YYYY-MM-DD HH:mm:ss') as string,
|
||||
char_count: item.charCount || 0,
|
||||
volume_title: item.volume_name,
|
||||
} as ChapterItem
|
||||
chapters.push(chapterItem)
|
||||
|
||||
@@ -79,4 +79,11 @@ export async function getChapter(itemId: string, _retry?: number): Promise<any>
|
||||
}
|
||||
j.content = await decryptChapter(j?.content, config.currentConfig)
|
||||
return j
|
||||
}
|
||||
|
||||
export async function getChapterInfo(itemId: string): Promise<unknown> {
|
||||
// use page fetch (includes bytedance security sdk. we reuse it)
|
||||
// same origin
|
||||
const res = await fetch('https://fanqienovel.com/api/reader/full?itemId=' + itemId)
|
||||
return await res.json()
|
||||
}
|
||||
@@ -2,6 +2,14 @@ import apiFetch from '../utils/request'
|
||||
import { getCookie } from '../localStorage'
|
||||
import config from '../config'
|
||||
|
||||
/*
|
||||
关于 baseUrl:
|
||||
- baseUrl 是番茄小说旗下红烛小说的接口,与番茄数据基本通用。
|
||||
- 但与番茄小说相比,红烛小说的 API 风控更低,不要签名。
|
||||
- 该为第一方 API 而非第三方,所以请注意这一点。
|
||||
- 之后如果遇到一些功能需要把 Cookie 传到这里的,请不要来造谣“这个脚本把你的凭据发给了第三方”之类的。
|
||||
- 本项目重视您的账号数据安全,不会泄露您的账号数据,接受大家审查。
|
||||
*/
|
||||
export const baseUrl = 'https://api5-sinfonlinec.jxbhmy.com/redcandle/search';
|
||||
export const baseQuery = {
|
||||
aid: '1967',
|
||||
|
||||
+90
-10
@@ -1,4 +1,10 @@
|
||||
import { fetch } from '../config'
|
||||
import { del, read, write } from '../localStorage'
|
||||
|
||||
export interface UserTitle {
|
||||
title: string
|
||||
desc: string
|
||||
}
|
||||
|
||||
export interface UserInfo {
|
||||
id: string
|
||||
@@ -6,35 +12,109 @@ export interface UserInfo {
|
||||
avatar: string
|
||||
desc: string
|
||||
age: number
|
||||
// detailed
|
||||
gender?: number // 0: 女 | 1: 男 | 2: 未知/没设置
|
||||
recommend_gender?: number // 0: 女频 | 1: 男频 | 2: 我都爱看
|
||||
fans_num?: number
|
||||
following_num?: number
|
||||
is_author?: boolean
|
||||
author_desc?: string
|
||||
read_book_num?: number
|
||||
read_book_time?: bigint // ms
|
||||
}
|
||||
|
||||
export let userInfo: UserInfo | null = null
|
||||
export interface UserState {
|
||||
isLogin: boolean
|
||||
userInfo: UserInfo | null
|
||||
}
|
||||
|
||||
export async function getUserInfo() {
|
||||
if (userInfo) return userInfo
|
||||
export let userState: UserState = {
|
||||
isLogin: false,
|
||||
userInfo: null,
|
||||
}
|
||||
if (read('userState')) {
|
||||
userState = read('userState')
|
||||
}
|
||||
|
||||
export async function getDetailedUserInfo(): Promise<UserInfo | null> {
|
||||
if (!userState?.isLogin || !userState?.userInfo) {
|
||||
return null
|
||||
}
|
||||
if (userState.userInfo.gender !== undefined &&
|
||||
userState.userInfo.recommend_gender !== undefined &&
|
||||
userState.userInfo.fans_num !== undefined &&
|
||||
userState.userInfo.following_num !== undefined &&
|
||||
userState.userInfo.is_author !== undefined &&
|
||||
userState.userInfo.author_desc !== undefined &&
|
||||
userState.userInfo.read_book_num !== undefined &&
|
||||
userState.userInfo.read_book_time !== undefined
|
||||
) {
|
||||
return userState.userInfo
|
||||
}
|
||||
const response = await fetch('https://fanqienovel.com/reading/user/basic_info/get/v?aid=1967')
|
||||
const j = await response.json()
|
||||
if (j?.data) {
|
||||
const data = j.data
|
||||
userState.userInfo.gender = data.profile_gender
|
||||
userState.userInfo.recommend_gender = data.gender
|
||||
userState.userInfo.fans_num = data.fans_num
|
||||
userState.userInfo.following_num = data.follow_user_num
|
||||
userState.userInfo.is_author = data.is_author
|
||||
userState.userInfo.author_desc = data.author_desc
|
||||
userState.userInfo.read_book_num = data.read_book_num
|
||||
userState.userInfo.read_book_time = BigInt(data.read_book_time)
|
||||
// userState.userInfo.titles = data.titles
|
||||
return userState.userInfo
|
||||
}
|
||||
return userState.userInfo
|
||||
}
|
||||
|
||||
export async function getUserInfo(): Promise<UserInfo | null> {
|
||||
if (userState?.isLogin && userState.userInfo) return userState.userInfo
|
||||
const response = await fetch('https://fanqienovel.com/api/user/info/v2')
|
||||
const j = await response.json()
|
||||
userInfo = j?.data
|
||||
return userInfo
|
||||
if (j?.data?.id > 1) {
|
||||
userState = {
|
||||
isLogin: true,
|
||||
userInfo: {
|
||||
id: j?.data?.id,
|
||||
username: j?.data?.name,
|
||||
avatar: j?.data?.avatar,
|
||||
desc: j?.data?.desc,
|
||||
age: j?.data?.age,
|
||||
},
|
||||
}
|
||||
return userState.userInfo
|
||||
} else {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
export async function checkLogin() {
|
||||
// sessionid is HttpOnly. So we use fetch directly to access user api.
|
||||
const response = await fetch('https://fanqienovel.com/api/user/info/v2')
|
||||
const j = await response.json()
|
||||
userInfo = {
|
||||
const _userInfo = {
|
||||
id: j?.data?.id,
|
||||
username: j?.data?.name,
|
||||
avatar: j?.data?.avatar,
|
||||
desc: j?.data?.desc,
|
||||
age: j?.data?.age,
|
||||
} as UserInfo
|
||||
return j?.data?.id > 1
|
||||
}
|
||||
if (j?.data?.id > 1) {
|
||||
userState.isLogin = true
|
||||
userState.userInfo = _userInfo
|
||||
write('userState', userState)
|
||||
return true
|
||||
} else {
|
||||
del('userState')
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
export default async function init(): Promise<void> {
|
||||
await checkLogin()
|
||||
if (userInfo) {
|
||||
console.log('Hello, ', userInfo.username)
|
||||
if (userState.isLogin) {
|
||||
console.log('Hello, ', userState?.userInfo?.username)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user