增加接口,增加index
Some checks reported errors
continuous-integration/drone/push Build was killed

This commit is contained in:
编码猿
2024-12-12 11:10:07 +08:00
parent 443d248cb4
commit 4dd0c5d928
10 changed files with 92 additions and 20 deletions

23
.gitignore Normal file
View File

@@ -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?

View File

@@ -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"
- 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

2
app.js
View File

@@ -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(`

View File

@@ -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`

View File

@@ -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 = []

40
router/hot.js Normal file
View File

@@ -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

View File

@@ -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`)

View File

@@ -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: [],
}

View File

@@ -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: []
}

View File

@@ -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)
}
/**
*
* 响应拦截器