diff --git a/ .gitignore b/ .gitignore new file mode 100644 index 0000000..798d824 --- /dev/null +++ b/ .gitignore @@ -0,0 +1,23 @@ +.DS_Store +node_modules/ +/dist + + +# local env files +.env.local +.env.*.local + +# Log files +npm-debug.log* +yarn-debug.log* +yarn-error.log* +pnpm-debug.log* + +# Editor directories and files +.idea +.vscode +*.suo +*.ntvs* +*.njsproj +*.sln +*.sw? \ No newline at end of file diff --git a/.drone.yml b/.drone.yml index d3fcb4e..82a59e9 100644 --- a/.drone.yml +++ b/.drone.yml @@ -10,10 +10,9 @@ clone: steps: - name: myclone - image: drone/git:latest + image: 2271608011/bmygit:v1 commands: - - echo "192.168.31.100 git.buyusdt.xyz" >> /etc/hosts - - git config --global http.sslVerify "false" + - echo "192.168.31.100 git.buyusdt.xyz" >> /etc/hosts - git clone https://git.buyusdt.xyz/bmy/xiezheng.git - name: pc-dev @@ -21,7 +20,6 @@ steps: network_mode: host commands: - cd /drone/src/xiezheng/ - - node -v - npm config set registry https://registry.npmmirror.com - npm install - npm run dev diff --git a/app.js b/app.js index 90b76d4..9fd2ba7 100644 --- a/app.js +++ b/app.js @@ -6,6 +6,7 @@ import tagsRouter from "./router/tags.js"; import infoRouter from "./router/info.js"; import searchRouter from "./router/search.js"; import homeRouter from "./router/home.js"; +import hotRouter from "./router/hot.js"; import http from "http"; const app = express() @@ -31,6 +32,7 @@ app.use('/v1/api/tag', tagsRouter); app.use('/v1/api/info', infoRouter); app.use('/v1/api/search', searchRouter); app.use('/v1/api/home', homeRouter); +app.use('/v1/api/hot', hotRouter); http.createServer(app).listen(config.port, "::",() => { console.log(` diff --git a/config/config.js b/config/config.js index 46068d1..88bc769 100644 --- a/config/config.js +++ b/config/config.js @@ -1,6 +1,6 @@ export default { port: 9940, - proxyPort: '7890', + proxyPort: 7890, baseUrl: 'https://www.06se.com', hot_tags: function () { return `${this.baseUrl}/hot_tags` diff --git a/router/home.js b/router/home.js index 006355c..9986bf6 100644 --- a/router/home.js +++ b/router/home.js @@ -5,7 +5,7 @@ import Config from '../config/config.js' const router = express.Router(); // 获取首页banner图 -// http://192.168.31.101:3030/v1/api/home/banner +// http://192.168.31.101:9940/v1/api/home/banner router.get('/banner', async (req, res) => { let $ = await Util.get(`${Config.baseUrl}/?orderby=rand`) let result = [] @@ -25,7 +25,7 @@ router.get('/banner', async (req, res) => { }) // 获取热门推荐的写真 -// http://192.168.31.101:3030/v1/api/home/hot +// http://192.168.31.101:9940/v1/api/home/hot router.get('/hot', async (req, res) => { let $ = await Util.get(`${Config.baseUrl}/?orderby=rand`) let result = [] @@ -49,7 +49,7 @@ router.get('/hot', async (req, res) => { // 获取首页 默认的随机写真 -// http://192.168.31.101:3030/v1/api/home/list +// http://192.168.31.101:9940/v1/api/home/list router.get('/list', async (req, res) => { let $ = await Util.get(`${Config.baseUrl}/?orderby=rand`) let result = [] diff --git a/router/hot.js b/router/hot.js new file mode 100644 index 0000000..9318dcd --- /dev/null +++ b/router/hot.js @@ -0,0 +1,40 @@ +import express from "express"; +import Util from '../utils/index.js' +import Config from '../config/config.js' +import utils from "../utils/index.js"; + +const router = express.Router(); + +// 进入详情的接口 +// http://192.168.31.101:9940/v1/api/hot/list&page=1 +router.get('/list', async (req, res) => { + let { page } = req.query + page = page || 1 + + let $ = await Util.get(`${Config.baseUrl}/other/page/${page}`) + + let result = { + currentPage: page, + totalPage: utils.maxPage(".pagenav a", $), + message: $(".search-content .badg .focus-color").text(), + list: [], + } + + $(".posts-row .posts-item").each(function() { + result.list.push({ + id: Util.split($(this).find(".item-thumbnail a").attr("href")).replace(/[^\d]/g, ""), + thumbnail: $(this).find(".item-thumbnail a img").attr("data-src"), + title: $(this).find(".item-heading a").text(), + time: $(this).find(".item-meta .icon-circle").text(), + view: $(this).find(".item-meta .meta-right .meta-view").text() + }) + }) + + res.json({ + status: 200, + copyright: `bmy ${new Date()}`, + data: result + }) +}) + +export default router \ No newline at end of file diff --git a/router/info.js b/router/info.js index 0006eb0..2decee1 100644 --- a/router/info.js +++ b/router/info.js @@ -5,7 +5,7 @@ import Config from '../config/config.js' const router = express.Router(); // 进入详情的接口 -// http://192.168.31.101:3030/v1/api/info/list?id=6808 +// http://192.168.31.101:9940/v1/api/info/list?id=6808 router.get('/list', async (req, res) => { let { id } = req.query let $ = await Util.get(`${Config.baseUrl}/${id}.html`) diff --git a/router/search.js b/router/search.js index 52edbe6..8002bb3 100644 --- a/router/search.js +++ b/router/search.js @@ -5,7 +5,7 @@ import Config from '../config/config.js' const router = express.Router(); // 搜索页面的 热门关键词 & 推荐 -// http://192.168.31.101:3030/v1/api/search/hot +// http://192.168.31.101:9940/v1/api/search/hot router.get('/hot', async (req, res) => { let $ = await Util.get(`${Config.baseUrl}/wp-admin/admin-ajax.php?action=search_box`) let result = { @@ -36,7 +36,7 @@ router.get('/hot', async (req, res) => { // 搜索接口 -// http://192.168.31.101:3030/v1/api/search/key?keyword=杨晨晨&page=1 +// http://192.168.31.101:9940/v1/api/search/key?keyword=杨晨晨&page=1 router.get('/key', async (req, res) => { let { keyword, page } = req.query page = page || 1 @@ -44,7 +44,7 @@ router.get('/key', async (req, res) => { let $ = await Util.get(`${Config.baseUrl}/page/${page}?s=${encodeURI(keyword)}&type=post`) let result = { currentPage: page, - totalPage: Number($(".pagenav .dots+a").text()), + totalPage: utils.maxPage(".pagenav a", $), message: $(".search-content .badg .focus-color").text(), list: [], } diff --git a/router/tags.js b/router/tags.js index 1bb50bd..e9a3616 100644 --- a/router/tags.js +++ b/router/tags.js @@ -5,22 +5,22 @@ import Config from '../config/config.js' const router = express.Router(); // 获取 推荐标签 -// http://192.168.31.101:3030/v1/api/tag/recommend +// http://192.168.31.101:9940/v1/api/tag/recommend router.get('/recommend', async (req, res) => { res.json({ status: 200, copyright: `bmy ${new Date()}`, data: [ - { title: '秀人网', count: '9059', url: '/xiuren' }, - { title: 'ROSI写真', count: '6580', url: '/domestic/rosi' }, - { title: '蜜桃社', count: '122', url: '/domestic/miitao' }, - { title: '尤物馆', count: '138', url: '/domestic/youwu' }, + { title: '秀人网', count: '9059', url: '/xiuren', index: 0 }, + { title: 'ROSI写真', count: '6580', url: '/domestic/rosi', index: 2 }, + { title: '蜜桃社', count: '122', url: '/domestic/miitao', index: 26 }, + { title: '尤物馆', count: '138', url: '/domestic/youwu', index: 28 }, ] }); }) // 获取 所有标签 -// http://192.168.31.101:3030/v1/api/tag/list +// http://192.168.31.101:9940/v1/api/tag/list router.get('/list', async (req, res) => { let $ = await Util.get(Config.hot_tags()) let result = [] @@ -41,7 +41,7 @@ router.get('/list', async (req, res) => { }) // 进入对应标签的列表页面 -// http://192.168.31.101:3030/v1/api/tag/info?url=/xiuren&page=1 +// http://192.168.31.101:9940/v1/api/tag/info?url=/xiuren&page=1 router.get('/info', async (req, res) => { let { url, page } = req.query page = page || 1 @@ -50,7 +50,7 @@ router.get('/info', async (req, res) => { let result = { count: $(".content-layout .title-h-left .icon-spot").text().replace(/[^\d]/g, ""), introduce: $(".content-layout .muted-2-color").text(), - totalPage: Number($(".pagenav .dots+a").text()), + totalPage: utils.maxPage(".pagenav a", $), currentPage: page, list: [] } diff --git a/utils/index.js b/utils/index.js index ae06594..fba543e 100644 --- a/utils/index.js +++ b/utils/index.js @@ -47,6 +47,15 @@ class utils { }); } + maxPage(el, $) { + let pageArr = [] + $(el).each(function() { + let page = Number($(this).text()) + page ? pageArr.push(page) : null + }) + return Math.max(...pageArr) + } + /** * * 响应拦截器