From db2edebeaff1d9e30dfcb05cc19bd340a53bf030 Mon Sep 17 00:00:00 2001 From: satori Date: Tue, 14 Dec 2021 19:39:24 +0800 Subject: [PATCH] bate --- collection.js | 21 +++++++++++++++++++++ index.js | 1 + 2 files changed, 22 insertions(+) create mode 100644 collection.js diff --git a/collection.js b/collection.js new file mode 100644 index 0000000..848191e --- /dev/null +++ b/collection.js @@ -0,0 +1,21 @@ +import https from 'https' + +export default function (url) { + if (!this.item.link) return false; + + var reg = /^([hH][tT]{2}[pP]:\/\/|[hH][tT]{2}[pP][sS]:\/\/)(([A-Za-z0-9-~]+)\.)+([A-Za-z0-9-~\/])+$/; + if (!reg.test(url)) url = "https://" + url; + + https.get(url, resp => { + let data = '' + resp.on('data', chunk => data += chunk) + resp.on('end', () => { + console.log(JSON.parse(data).explanation) + }) + }).on('error', err => { + console.log(err.message) + }) + //this.$axios.get(this.item.link).then((res) => { + // console.log(res.data); + //}); +} \ No newline at end of file diff --git a/index.js b/index.js index 444123e..62558cd 100644 --- a/index.js +++ b/index.js @@ -7,6 +7,7 @@ import random from 'string-random' import formidable from 'formidable' import md5 from 'md5-node' import HUB from './fmhub.js' +import site from './collection.js' const app = expressWs(express()).app const databases = new Map() // 所有数据库