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

第二周作业_1 #122

Open
wants to merge 8 commits 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
4 changes: 2 additions & 2 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:

runs-on: ubuntu-latest

strategy:
strategy: # strategy 定义 job 的运行参数
matrix:
node-version: [16.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
Expand All @@ -27,4 +27,4 @@ jobs:
node-version: ${{ matrix.node-version }}
- run: npm i
# Just run tests once
- run: npm test
- run: npm test
11 changes: 10 additions & 1 deletion Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,13 @@

### 注意

大家可以选择 [email protected],也可以选择 [email protected],这个看大家个人喜好哈,虽然我用的是0.2
大家可以选择 [email protected],也可以选择 [email protected],这个看大家个人喜好哈,虽然我用的是0.2

### 项目克隆至本地之后, npm install 、 npm run test 之后报如下错误
> Cannot start ChromeHeadless
> Can not find the binary C:\Users\唐明响\Desktop\前端进阶培训_极客时间\homework\homework2\node_modules\puppeteer\.local-chromium\win64-1022525\chrome-win\chrome.exe
> Please set env variable CHROME_BIN
> 此时只需要将 karma.conf.js 配置文件中的
> process.env.CHROME_BIN = require('puppeteer').executablePath() 改为
> process.env.CHROME_BIN = 'C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe' (即本地 Chrome 浏览器启动的路径即可)
> 参考 https://www.npmjs.com/package/karma-chrome-launcher
4 changes: 3 additions & 1 deletion karma.conf.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Karma configuration
// Generated on Fri Aug 11 2017 22:02:05 GMT+0800 (CST)
process.env.CHROME_BIN = require('puppeteer').executablePath()
// process.env.CHROME_BIN = require('puppeteer').executablePath()
process.env.CHROME_BIN = 'C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe'
console.log(process.env.CHROME_BIN);
module.exports = function(config) {
config.set({

Expand Down
44 changes: 40 additions & 4 deletions lib/db.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,48 @@
const Tapable = require('tapable')

class DB extends Tapable {
constructor() {
// TODO
constructor(options) {
// TODO
super()
this.options = options
}

request() {
// TODO
// request(options) {
// // TODO
// // return this.applyPluginsWaterfall('endpoint') // 1
// // return this.applyPluginsWaterfall0('endpoint') // 1
// // return this.applyPluginsBailResult('endpoint') // 1
// // if (this.options) {
// // this.options = this.applyPluginsWaterfall0('options',this.options) //
// // }
// return this.applyPluginsBailResult('endpoint',options) // 1 2
// }

// request(options) {
// if (!this.options) {
// this.options = {}
// }
// Object.assign(this.options, options);
// this.options = this.applyPluginsWaterfall0('options',this.options) //
// return this.applyPluginsBailResult('endpoint', this.options) // 1 2 3
// }

request(params = {}) {
if (!this.options) {
this.options = {}
}
let newParams = Object.assign(params, this.options)
this.applyPluginsWaterfall0('options',newParams)
newParams = Object.assign(newParams, this.options)
return new Promise((resolve,reject) => {
this.applyPluginsBailResult('endpoint', newParams).then(res => {
// 超时
// return this.applyPluginsWaterfall('judge',res) ? reject(res) : resolve(res)
return this.applyPluginsBailResult('judge',res) ? reject(res) : resolve(res)
}, res => {
return reject()
})
})
}
}

Expand Down