Skip to content

Commit

Permalink
fix(yuque-sdk): 修复爬取目录时鉴权问题
Browse files Browse the repository at this point in the history
  • Loading branch information
LetTTGACO committed Aug 10, 2023
1 parent 501d8bf commit 8328951
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions packages/sdk-yuque/src/pwd/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { out, request, RequestOptions } from '@elog/shared'
import { encrypt, getProps } from '../utils'
import { YuQueResponse, YuqueDoc, YuqueDocProperties } from '../types'
import { DocDetail, YuqueCatalog, DocCatalog } from '@elog/types'
import { JSDOM, VirtualConsole } from 'jsdom'
import { JSDOM } from 'jsdom'
import { YuqueWithPwdConfig, YuqueLogin, YuqueLoginCookie } from './types'

/** 默认语雀API 路径 */
Expand Down Expand Up @@ -103,12 +103,8 @@ class YuqueClient {
*/
async getToc() {
try {
const res = await this.request(this.namespace, { method: 'get' })
const virtualConsole = new VirtualConsole()
const dom = new JSDOM(`${res}`, { runScripts: 'dangerously', virtualConsole })
virtualConsole.on('error', () => {
// don't do anything
})
const res = await this.request(this.namespace, { method: 'get', dataType: 'text' }, true)
const dom = new JSDOM(`${res}`, { runScripts: 'dangerously' })
const { book } = dom?.window?.appData || {}
dom.window.close()
if (!book) {
Expand Down

0 comments on commit 8328951

Please sign in to comment.