diff --git a/package.json b/package.json index 2b9368b..00c064a 100644 --- a/package.json +++ b/package.json @@ -1,15 +1,15 @@ { "name": "magnetw", - "version": "3.1.0", + "version": "3.1.1", "description": "磁力链接聚合搜索", "license": "GNU General Public License v3.0", "main": "./dist/electron/main.js", "scripts": { - "build": "cross-env BUILD_TARGET=electron node .electron-vue/build.js && electron-builder --platform=all", + "build": "cross-env BUILD_TARGET=electron node .electron-vue/build.js && electron-builder -mwl", "build:dir": "cross-env BUILD_TARGET=electronnode .electron-vue/build.js && electron-builder --dir", "build:clean": "cross-env BUILD_TARGET=clean node .electron-vue/build.js", - "build:mac": "cross-env BUILD_TARGET=electron node .electron-vue/build.js && electron-builder --platform=mac", - "build:win": "cross-env BUILD_TARGET=electron node .electron-vue/build.js && electron-builder --platform=win", + "build:mac": "cross-env BUILD_TARGET=electron node .electron-vue/build.js && electron-builder --mac", + "build:win": "cross-env BUILD_TARGET=electron node .electron-vue/build.js && electron-builder --win", "build:service": "node scripts/build-service.js", "dev": "cross-env BUILD_TARGET=electron node .electron-vue/dev-runner.js", "lint": "eslint --ext .js,.vue -f ./node_modules/eslint-friendly-formatter src", @@ -85,6 +85,7 @@ "request": "^2.88.0", "request-promise-native": "^1.0.7", "socks-proxy-agent": "^4.0.2", + "tunnel": "0.0.6", "urijs": "^1.19.2", "vue": "^2.6.11", "vue-clipboard2": "^0.3.1", @@ -116,8 +117,8 @@ "del": "^3.0.0", "devtron": "^1.4.0", "electron": "^7.1.8", - "electron-builder": "^21.2.0", - "electron-debug": "^1.5.0", + "electron-builder": "^22.2.0", + "electron-debug": "^3.0.0", "electron-devtools-installer": "^2.2.4", "element-ui": "^2.13.0", "eslint": "^4.19.1", diff --git a/rule.json b/rule.json index d6c1a60..3852e7c 100644 --- a/rule.json +++ b/rule.json @@ -106,6 +106,7 @@ { "id": "btdb", "name": " BTDB", + "proxy": true, "url": "https://btdb.io", "paths": { "time": "?s={k}&sort=time&page={p}", @@ -124,7 +125,7 @@ { "id": "btdiguo", "name": "BT目录", - "url": "https://www.btweb.xyz", + "url": "https://www.aixiazai.xyz", "paths": { "time": "/search-update/{k}/page-{p}.html", "size": "/search-size/{k}/page-{p}.html", @@ -160,7 +161,7 @@ { "id": "bthub", "name": "BThub", - "url": "https://bthub.site", + "url": "https://bthub.xyz", "paths": { "preset": "/main-search-kw-{k}-{p}.html", "size": "/main-search-kw-{k}-length-{p}.html", @@ -194,6 +195,21 @@ "hot": "./div[2]/span[5]/b[1]" } }, + { + "id": "alibt", + "name": " 阿里BT", + "url": "https://alibt.pw", + "paths": { + "preset": "/zh-cn/s/{p}/{k}" + }, + "xpath": { + "group": "//*[@id=\"wrapper\"]/ul/li", + "magnet": "./p[1]/a/@href", + "name": "./p[1]/a", + "size": "./p[2]/span[2]", + "date": "./p[2]/span[1]" + } + }, { "id": "mag", "name": "MAG磁力站", @@ -274,7 +290,7 @@ { "id": "btfox", "name": " btfox", - "url": "http://www.btfox.biz", + "url": "http://www.btfox.in", "paths": { "time": "/s?wd={k}&sort=time&page={p}", "size": "/s?wd={k}&sort=length&page={p}", diff --git a/scripts/icns.sh b/scripts/icns.sh deleted file mode 100755 index 6b12744..0000000 --- a/scripts/icns.sh +++ /dev/null @@ -1,21 +0,0 @@ -filepath=256x256.png -iconset=.icns.iconset - -cd build/icons -if [ ! -d $iconset ];then - mkdir $iconset -fi - -sips -z 16 16 $filepath --out $iconset/icon_16x16.png -sips -z 32 32 $filepath --out $iconset/icon_16x16@2x.png -sips -z 32 32 $filepath --out $iconset/icon_32x32.png -sips -z 64 64 $filepath --out $iconset/icon_32x32@2x.png -sips -z 128 128 $filepath --out $iconset/icon_128x128.png -sips -z 256 256 $filepath --out $iconset/icon_128x128@2x.png -sips -z 256 256 $filepath --out $iconset/icon_256x256.png -sips -z 512 512 $filepath --out $iconset/icon_256x256@2x.png -sips -z 512 512 $filepath --out $iconset/icon_512x512.png -sips -z 1024 1024 $filepath --out $iconset/icon_512x512@2x.png - -iconutil -c icns $iconset -o icon.icns -icotool -c $iconset/icon_256x256.png -o icon.ico diff --git a/scripts/merge-filter-db.js b/scripts/merge-filter-db.js index 6dbe018..8a1561d 100644 --- a/scripts/merge-filter-db.js +++ b/scripts/merge-filter-db.js @@ -42,4 +42,4 @@ function unique (arr) { return result } -fs.writeFileSync('src/main/filter/keywords.txt', Buffer.from(uniqueWords.join('\n')).toString('base64')) +fs.writeFileSync('static/keywords.txt', Buffer.from(uniqueWords.join('\n')).toString('base64')) diff --git a/src/main/axios.js b/src/main/axios.js index 2e77dc2..b29449d 100644 --- a/src/main/axios.js +++ b/src/main/axios.js @@ -1,5 +1,3 @@ -import {remote} from 'electron' - const axios = require('axios') const tunnel = require('tunnel') const SocksProxyAgent = require('socks-proxy-agent') diff --git a/src/main/defaultConfig.js b/src/main/defaultConfig.js index fff4a6f..af6bcf4 100644 --- a/src/main/defaultConfig.js +++ b/src/main/defaultConfig.js @@ -21,9 +21,9 @@ module.exports = function () { // 使用代理 proxy: false, // http|socks5 - proxyType: 'http', + proxyType: 'socks5', proxyHost: '127.0.0.1', - proxyPort: 1087, + proxyPort: 1080, // 是否启用预加载 启用后会预加载下一页和下一个源站 preload: true, // 缓存过期时间 diff --git a/src/main/filter/filter.js b/src/main/filter/filter.js index 363b363..1413662 100644 --- a/src/main/filter/filter.js +++ b/src/main/filter/filter.js @@ -4,12 +4,15 @@ const fs = require('fs') const map = {} let load = false +const isDev = process.env.NODE_ENV === 'development' + async function loadFilterData () { if (load) { return } load = true - const original = Buffer.from(fs.readFileSync(path.resolve(__dirname, './keywords.txt'), 'utf-8'), 'base64') + const file = isDev ? path.resolve('static/keywords.txt') : path.resolve(__dirname, './static/keywords.txt') + const original = Buffer.from(fs.readFileSync(file, 'utf-8'), 'base64') const words = original.toString().split('\n') words.forEach((line) => { if (line) { diff --git a/src/main/ipc.js b/src/main/ipc.js index b5928da..c255229 100644 --- a/src/main/ipc.js +++ b/src/main/ipc.js @@ -1,5 +1,4 @@ -// import fs from 'fs' - +const moment = require('moment') const logger = require('./logger') const path = require('path') const {ipcMain, app} = require('electron') @@ -30,6 +29,12 @@ function getLocalConfig () { } function registerIPC (mainWindow) { + ipcMain.on('get-server-info', function (event) { + const configVariable = store.get('config_variable') + const newConfig = getConfig(configVariable) + event.sender.send('on-get-server-info', getServerInfo(), newConfig) + }) + ipcMain.on('window-max', function () { if (mainWindow.isMaximized()) { mainWindow.unmaximize() diff --git a/src/main/middleware/response-template.js b/src/main/middleware/response-template.js index a3d21e7..8bd77e1 100644 --- a/src/main/middleware/response-template.js +++ b/src/main/middleware/response-template.js @@ -13,10 +13,13 @@ module.exports = async (ctx, next) => { ctx.throw(ctx.status, ctx.message) } } catch (e) { + let message = e.message const statusCode = e.statusCode || 500 console.error(statusCode, e.message) const maxLength = 100 - const message = `${statusCode} - 请求异常,请查看日志` + if (statusCode !== 500) { + message = `${statusCode} - 请求源站异常,请查看日志` + } ctx.status = statusCode ctx.body = { success: false, diff --git a/src/main/repository.js b/src/main/repository.js index 22906f8..267e4d7 100644 --- a/src/main/repository.js +++ b/src/main/repository.js @@ -251,16 +251,21 @@ function parseDetailDocument (document, expression) { async function loadRuleByURL () { const url = config.ruleUrl let rule - if (url.startsWith('http')) { - // 如果是网络文件 - console.info('获取网络规则文件', url) - rule = await request(url, {timeout: 8000, json: true}) - } else { - console.info('读取本地规则文件', url) - rule = JSON.parse(fs.readFileSync(url)) - } - if (!Array.isArray(rule) || rule.length <= 0) { - throw new Error('规则格式不正确') + try { + if (url.startsWith('http')) { + // 如果是网络文件 + console.info('获取网络规则文件', url) + rule = await request(url, {timeout: 8000, json: true}) + } else { + console.info('读取本地规则文件', url) + rule = JSON.parse(fs.readFileSync(url)) + } + if (!Array.isArray(rule) || rule.length <= 0) { + throw new Error('规则格式不正确') + } + } catch (e) { + console.error(e.message, '规则加载失败,将使用内置规则') + rule = require('../../rule.json') } cacheManager.set('rule_json', JSON.stringify(rule)) diff --git a/src/renderer/components/GuidePage.vue b/src/renderer/components/GuidePage.vue index 3f04968..ce9d468 100644 --- a/src/renderer/components/GuidePage.vue +++ b/src/renderer/components/GuidePage.vue @@ -10,6 +10,15 @@ {{title}}