feat: update rules from remote

This commit is contained in:
DIYgod
2019-08-01 00:42:00 +08:00
parent 1d3c443d05
commit 03a218e166
11 changed files with 200 additions and 608 deletions
-277
View File
@@ -1,277 +0,0 @@
({
'bilibili.com': {
_name: 'bilibili',
www: [{
title: '分区视频',
docs: 'https://docs.rsshub.app/social-media.html#bilibili',
source: '/v/*tpath',
target: (params) => {
let tid;
switch (params.tpath) {
case 'douga/mad':
tid = '24';
break;
default:
return false;
}
return `/bilibili/partion/${tid}`;
},
}, {
title: '视频评论',
docs: 'https://docs.rsshub.app/social-media.html#bilibili',
source: '/video/:aid',
target: (params, url) => `/bilibili/video/reply/${params.aid.replace('av', '')}`
}, {
title: '视频弹幕',
docs: 'https://docs.rsshub.app/social-media.html#bilibili',
source: '/video/:aid',
target: (params, url) => {
let pid = new URL(url).searchParams.get('p');
return `/bilibili/video/danmaku/${params.aid.replace('av', '')}/${pid ? pid : 1}`;
}
}],
space: [{
title: 'UP 主动态',
docs: 'https://docs.rsshub.app/social-media.html#bilibili',
source: '/:uid',
target: '/bilibili/user/dynamic/:uid'
}, {
title: 'UP 主投稿',
docs: 'https://docs.rsshub.app/social-media.html#bilibili',
source: '/:uid',
target: '/bilibili/user/video/:uid'
}],
},
'weibo.com': {
_name: '微博',
'.': [{
title: '博主',
docs: 'https://docs.rsshub.app/social-media.html#%E5%BE%AE%E5%8D%9A',
source: ['/u/:id', '/:id'],
target: '/weibo/user/:uid',
script: '({uid: document.querySelector(\'head\').innerHTML.match(/\\$CONFIG\\[\'uid\']=\'(\\d+)\'/)[1]})',
verification: (params) => params.uid,
}],
},
'pixiv.net': {
_name: 'Pixiv',
'www': [{
title: '用户收藏',
docs: 'https://docs.rsshub.app/social-media.html#pixiv',
source: '/bookmark.php',
target: (params, url) => `/pixiv/user/bookmarks/${new URL(url).searchParams.get('id')}`,
}, {
title: '用户动态',
docs: 'https://docs.rsshub.app/social-media.html#pixiv',
source: '/member.php',
target: (params, url) => `/pixiv/user/bookmarks/${new URL(url).searchParams.get('id')}`,
}, {
title: '排行榜',
docs: 'https://docs.rsshub.app/social-media.html#pixiv',
source: '/ranking.php',
target: (params, url) => `/pixiv/user/bookmarks/${new URL(url).searchParams.get('id')}`,
}, {
title: '关键词',
docs: 'https://docs.rsshub.app/social-media.html#pixiv',
source: '/search.php',
target: (params, url) => `/pixiv/user/bookmarks/${new URL(url).searchParams.get('id')}`,
}],
},
'twitter.com': {
_name: 'Twitter',
'.': [{
title: '用户时间线',
docs: 'https://docs.rsshub.app/social-media.html#twitter',
source: '/:id',
target: '/twitter/user/:id',
verification: (params) => (params.id !== 'home' && params.id !== 'explore' && params.id !== 'notifications' && params.id !== 'messages' && params.id !== 'explore'),
}, {
title: '用户关注时间线',
docs: 'https://docs.rsshub.app/social-media.html#twitter',
source: '/:id',
target: '/twitter/followings/:id',
verification: (params) => (params.id !== 'home' && params.id !== 'explore' && params.id !== 'notifications' && params.id !== 'messages' && params.id !== 'explore'),
}, {
title: '用户喜欢列表',
docs: 'https://docs.rsshub.app/social-media.html#twitter',
source: '/:id',
target: '/twitter/likes/:id',
verification: (params) => (params.id !== 'home' && params.id !== 'explore' && params.id !== 'notifications' && params.id !== 'messages' && params.id !== 'explore'),
}, {
title: '列表时间线',
docs: 'https://docs.rsshub.app/social-media.html#twitter',
source: '/:id/lists/:name',
target: '/twitter/list/:id/:name',
verification: (params) => (params.id !== 'home' && params.id !== 'explore' && params.id !== 'notifications' && params.id !== 'messages' && params.id !== 'explore'),
}],
},
'youtube.com': {
_name: 'Youtube',
'www': [{
title: '用户',
docs: 'https://docs.rsshub.app/social-media.html#youtube',
source: '/user/:username',
target: '/youtube/user/:username',
}, {
title: '频道',
docs: 'https://docs.rsshub.app/social-media.html#youtube',
source: '/channel/:id',
target: '/youtube/channel/:id',
}, {
title: '播放列表',
docs: 'https://docs.rsshub.app/social-media.html#youtube',
source: '/playlist',
target: (params, url) => `/youtube/playlist/${new URL(url).searchParams.get('list')}`,
}],
},
'github.com': {
_name: 'GitHub',
'.': [{
title: '用户仓库',
docs: 'https://docs.rsshub.app/programming.html#github',
source: '/:user',
target: '/github/repos/:user',
}, {
title: '用户 Followers',
docs: 'https://docs.rsshub.app/programming.html#github',
source: '/:user',
target: '/github/user/followers/:user',
}, {
title: 'Trending',
docs: 'https://docs.rsshub.app/programming.html#github',
source: '/trending',
target: '/github/trending/:since',
}, {
title: '仓库 Issue',
docs: 'https://docs.rsshub.app/programming.html#github',
source: ['/:user/:repo/issues', '/:user/:repo/issues/:id', '/:user/:repo'],
target: '/github/issue/:user/:repo',
}, {
title: '仓库 Pull Requests',
docs: 'https://docs.rsshub.app/programming.html#github',
source: ['/:user/:repo/pulls', '/:user/:repo/pulls/:id', '/:user/:repo'],
target: '/github/pull/:user/:repo',
}, {
title: '仓库 Stars',
docs: 'https://docs.rsshub.app/programming.html#github',
source: ['/:user/:repo/stargazers', '/:user/:repo'],
target: '/github/stars/:user/:repo',
}, {
title: '仓库 Branches',
docs: 'https://docs.rsshub.app/programming.html#github',
source: ['/:user/:repo/branches', '/:user/:repo'],
target: '/github/branches/:user/:repo',
}, {
title: '文件 Commits',
docs: 'https://docs.rsshub.app/programming.html#github',
source: '/:user/:repo/blob/:branch/*filepath',
target: '/github/file/:user/:repo/:branch/:filepath',
}],
},
'zhihu.com': {
_name: '知乎',
'www': [{
title: '收藏夹',
docs: 'https://docs.rsshub.app/social-media.html#%E7%9F%A5%E4%B9%8E',
source: '/collection/:id',
target: '/zhihu/collection/:id',
}, {
title: '用户动态',
docs: 'https://docs.rsshub.app/social-media.html#%E7%9F%A5%E4%B9%8E',
source: '/people/:id/activities',
target: '/zhihu/people/activities/:id',
}, {
title: '用户回答',
docs: 'https://docs.rsshub.app/social-media.html#%E7%9F%A5%E4%B9%8E',
source: '/people/:id/answers',
target: '/zhihu/people/answers/:id',
}, {
title: '用户想法',
docs: 'https://docs.rsshub.app/social-media.html#%E7%9F%A5%E4%B9%8E',
source: '/people/:id/pins',
target: '/zhihu/people/pins/:id',
}, {
title: '热榜',
docs: 'https://docs.rsshub.app/social-media.html#%E7%9F%A5%E4%B9%8E',
source: '/hot',
target: '/zhihu/hotlist',
}, {
title: '想法热榜',
docs: 'https://docs.rsshub.app/social-media.html#%E7%9F%A5%E4%B9%8E',
target: '/zhihu/pin/hotlist',
}, {
title: '问题',
docs: 'https://docs.rsshub.app/social-media.html#%E7%9F%A5%E4%B9%8E',
source: '/question/:questionId',
target: '/zhihu/question/:questionId',
}, {
title: '话题',
docs: 'https://docs.rsshub.app/social-media.html#%E7%9F%A5%E4%B9%8E',
source: '/topic/:topicId/:type',
target: '/zhihu/topic/:topicId',
}, {
title: '新书',
docs: 'https://docs.rsshub.app/social-media.html#%E7%9F%A5%E4%B9%8E',
source: '/zhihu/bookstore/newest',
target: '/zhihu/pin/hotlist',
}, {
title: '想法-24 小时新闻汇总',
docs: 'https://docs.rsshub.app/social-media.html#%E7%9F%A5%E4%B9%8E',
source: '/pin/special/972884951192113152',
target: '/zhihu/pin/daily',
}, {
title: '书店-周刊',
docs: 'https://docs.rsshub.app/social-media.html#%E7%9F%A5%E4%B9%8E',
source: '/pub/weekly',
target: '/zhihu/weekly',
}],
'zhuanlan': [{
title: '专栏',
docs: 'https://docs.rsshub.app/social-media.html#%E7%9F%A5%E4%B9%8E',
source: '/:id',
target: '/zhihu/zhuanlan/:id',
}],
'daily': [{
title: '日报',
docs: 'https://docs.rsshub.app/social-media.html#%E7%9F%A5%E4%B9%8E',
source: '',
target: '/zhihu/daily',
}, {
title: '日报',
docs: 'https://docs.rsshub.app/social-media.html#%E7%9F%A5%E4%B9%8E',
source: '/*tpath',
target: '/zhihu/daily',
}],
},
'smzdm.com': {
_name: '什么值得买',
'www': [{
title: '关键词',
docs: 'https://docs.rsshub.app/shopping.html#%E4%BB%80%E4%B9%88%E5%80%BC%E5%BE%97%E4%B9%B0',
target: '/smzdm/keyword/:keyword',
}, {
title: '排行榜',
docs: 'https://docs.rsshub.app/shopping.html#%E4%BB%80%E4%B9%88%E5%80%BC%E5%BE%97%E4%B9%B0',
source: '/top',
}],
},
'rsshub.app': {
_name: 'RSSHub',
'docs': [{
title: '有新路由啦',
docs: 'https://docs.rsshub.app/program-update.html#rsshub',
source: ['', '/*tpath'],
target: '/rsshub/rss',
}],
},
'ximalaya.com': {
_name: '喜马拉雅',
'www': [{
title: '专辑',
docs: 'https://docs.rsshub.app/multimedia.html#%E5%96%9C%E9%A9%AC%E6%8B%89%E9%9B%85',
source: '/:type/:id',
target: '/ximalaya/album/:id/',
verification: (params) => parseInt(params.id) + '' === params.id,
}],
},
})
+2 -1
View File
@@ -29,5 +29,6 @@
"tabs",
"storage",
"notifications"
]
],
"content_security_policy": "script-src 'self' 'unsafe-eval'; object-src 'self'"
}
+27 -1
View File
@@ -1,8 +1,9 @@
import rules from '../common/rules';
import { getRules, getRulesDate, refreshRules } from '../common/rules';
import parseDomain from 'parse-domain';
import RouteRecognizer from 'route-recognizer';
import { getConfig } from '../common/config';
let config;
let rules = {};
window.pageRSS = {};
window.pageRSSHub = {};
@@ -10,12 +11,37 @@ window.websiteRSSHub = {};
getConfig((conf) => {
config = conf;
getRules((rul) => {
rules = rul;
getRulesDate((lastDate) => {
if (!lastDate || (+new Date - lastDate > config.refreshTimeout * 1000)) {
refreshRules();
schedule();
} else {
schedule(config.refreshTimeout * 1000 - (+new Date - lastDate));
}
});
});
});
function schedule (time) {
setTimeout(() => {
refreshRules();
schedule();
}, time ? time : config.refreshTimeout * 1000);
}
chrome.storage.onChanged.addListener((result) => {
if (result.config) {
config = result.config.newValue;
}
if (result.rules) {
getRules((rul) => {
rules = rul;
});
}
});
chrome.browserAction.setBadgeBackgroundColor({
+2 -1
View File
@@ -8,7 +8,8 @@ export const defaultConfig = {
ttrssDomain: '',
feedly: true,
inoreader: false,
}
},
refreshTimeout: 5 * 60 * 60,
};
export function getConfig (success) {
+42 -276
View File
@@ -1,277 +1,43 @@
export default {
'bilibili.com': {
_name: 'bilibili',
www: [{
title: '分区视频',
docs: 'https://docs.rsshub.app/social-media.html#bilibili',
source: '/v/*tpath',
target: (params) => {
let tid;
switch (params.tpath) {
case 'douga/mad':
tid = '24';
break;
default:
return false;
}
return `/bilibili/partion/${tid}`;
},
}, {
title: '视频评论',
docs: 'https://docs.rsshub.app/social-media.html#bilibili',
source: '/video/:aid',
target: (params, url) => `/bilibili/video/reply/${params.aid.replace('av', '')}`
}, {
title: '视频弹幕',
docs: 'https://docs.rsshub.app/social-media.html#bilibili',
source: '/video/:aid',
target: (params, url) => {
let pid = new URL(url).searchParams.get('p');
return `/bilibili/video/danmaku/${params.aid.replace('av', '')}/${pid ? pid : 1}`;
let rules = null;
export function refreshRules (success) {
fetch('https://raw.githubusercontent.com/DIYgod/RSSHub/master/assets/radar-rules.js')
.then((response) => {
response.text()
.then((text) => {
rules = eval(text);
chrome.storage.local.set({
rules: text,
rulesDate: +new Date(),
});
success && success();
});
});
}
export function getRules (success) {
if (rules) {
success(rules);
} else {
chrome.storage.local.get('rules', (result) => {
if (result && result.rules) {
rules = eval(result.rules);
success(rules);
} else {
refreshRules(() => {
success(rules);
});
}
}],
space: [{
title: 'UP 主动态',
docs: 'https://docs.rsshub.app/social-media.html#bilibili',
source: '/:uid',
target: '/bilibili/user/dynamic/:uid'
}, {
title: 'UP 主投稿',
docs: 'https://docs.rsshub.app/social-media.html#bilibili',
source: '/:uid',
target: '/bilibili/user/video/:uid'
}],
},
'weibo.com': {
_name: '微博',
'.': [{
title: '博主',
docs: 'https://docs.rsshub.app/social-media.html#%E5%BE%AE%E5%8D%9A',
source: ['/u/:id', '/:id'],
target: '/weibo/user/:uid',
script: '({uid: document.querySelector(\'head\').innerHTML.match(/\\$CONFIG\\[\'uid\']=\'(\\d+)\'/)[1]})',
verification: (params) => params.uid,
}],
},
'pixiv.net': {
_name: 'Pixiv',
'www': [{
title: '用户收藏',
docs: 'https://docs.rsshub.app/social-media.html#pixiv',
source: '/bookmark.php',
target: (params, url) => `/pixiv/user/bookmarks/${new URL(url).searchParams.get('id')}`,
}, {
title: '用户动态',
docs: 'https://docs.rsshub.app/social-media.html#pixiv',
source: '/member.php',
target: (params, url) => `/pixiv/user/bookmarks/${new URL(url).searchParams.get('id')}`,
}, {
title: '排行榜',
docs: 'https://docs.rsshub.app/social-media.html#pixiv',
source: '/ranking.php',
target: (params, url) => `/pixiv/user/bookmarks/${new URL(url).searchParams.get('id')}`,
}, {
title: '关键词',
docs: 'https://docs.rsshub.app/social-media.html#pixiv',
source: '/search.php',
target: (params, url) => `/pixiv/user/bookmarks/${new URL(url).searchParams.get('id')}`,
}],
},
'twitter.com': {
_name: 'Twitter',
'.': [{
title: '用户时间线',
docs: 'https://docs.rsshub.app/social-media.html#twitter',
source: '/:id',
target: '/twitter/user/:id',
verification: (params) => (params.id !== 'home' && params.id !== 'explore' && params.id !== 'notifications' && params.id !== 'messages' && params.id !== 'explore'),
}, {
title: '用户关注时间线',
docs: 'https://docs.rsshub.app/social-media.html#twitter',
source: '/:id',
target: '/twitter/followings/:id',
verification: (params) => (params.id !== 'home' && params.id !== 'explore' && params.id !== 'notifications' && params.id !== 'messages' && params.id !== 'explore'),
}, {
title: '用户喜欢列表',
docs: 'https://docs.rsshub.app/social-media.html#twitter',
source: '/:id',
target: '/twitter/likes/:id',
verification: (params) => (params.id !== 'home' && params.id !== 'explore' && params.id !== 'notifications' && params.id !== 'messages' && params.id !== 'explore'),
}, {
title: '列表时间线',
docs: 'https://docs.rsshub.app/social-media.html#twitter',
source: '/:id/lists/:name',
target: '/twitter/list/:id/:name',
verification: (params) => (params.id !== 'home' && params.id !== 'explore' && params.id !== 'notifications' && params.id !== 'messages' && params.id !== 'explore'),
}],
},
'youtube.com': {
_name: 'Youtube',
'www': [{
title: '用户',
docs: 'https://docs.rsshub.app/social-media.html#youtube',
source: '/user/:username',
target: '/youtube/user/:username',
}, {
title: '频道',
docs: 'https://docs.rsshub.app/social-media.html#youtube',
source: '/channel/:id',
target: '/youtube/channel/:id',
}, {
title: '播放列表',
docs: 'https://docs.rsshub.app/social-media.html#youtube',
source: '/playlist',
target: (params, url) => `/youtube/playlist/${new URL(url).searchParams.get('list')}`,
}],
},
'github.com': {
_name: 'GitHub',
'.': [{
title: '用户仓库',
docs: 'https://docs.rsshub.app/programming.html#github',
source: '/:user',
target: '/github/repos/:user',
}, {
title: '用户 Followers',
docs: 'https://docs.rsshub.app/programming.html#github',
source: '/:user',
target: '/github/user/followers/:user',
}, {
title: 'Trending',
docs: 'https://docs.rsshub.app/programming.html#github',
source: '/trending',
target: '/github/trending/:since',
}, {
title: '仓库 Issue',
docs: 'https://docs.rsshub.app/programming.html#github',
source: ['/:user/:repo/issues', '/:user/:repo/issues/:id', '/:user/:repo'],
target: '/github/issue/:user/:repo',
}, {
title: '仓库 Pull Requests',
docs: 'https://docs.rsshub.app/programming.html#github',
source: ['/:user/:repo/pulls', '/:user/:repo/pulls/:id', '/:user/:repo'],
target: '/github/pull/:user/:repo',
}, {
title: '仓库 Stars',
docs: 'https://docs.rsshub.app/programming.html#github',
source: ['/:user/:repo/stargazers', '/:user/:repo'],
target: '/github/stars/:user/:repo',
}, {
title: '仓库 Branches',
docs: 'https://docs.rsshub.app/programming.html#github',
source: ['/:user/:repo/branches', '/:user/:repo'],
target: '/github/branches/:user/:repo',
}, {
title: '文件 Commits',
docs: 'https://docs.rsshub.app/programming.html#github',
source: '/:user/:repo/blob/:branch/*filepath',
target: '/github/file/:user/:repo/:branch/:filepath',
}],
},
'zhihu.com': {
_name: '知乎',
'www': [{
title: '收藏夹',
docs: 'https://docs.rsshub.app/social-media.html#%E7%9F%A5%E4%B9%8E',
source: '/collection/:id',
target: '/zhihu/collection/:id',
}, {
title: '用户动态',
docs: 'https://docs.rsshub.app/social-media.html#%E7%9F%A5%E4%B9%8E',
source: '/people/:id/activities',
target: '/zhihu/people/activities/:id',
}, {
title: '用户回答',
docs: 'https://docs.rsshub.app/social-media.html#%E7%9F%A5%E4%B9%8E',
source: '/people/:id/answers',
target: '/zhihu/people/answers/:id',
}, {
title: '用户想法',
docs: 'https://docs.rsshub.app/social-media.html#%E7%9F%A5%E4%B9%8E',
source: '/people/:id/pins',
target: '/zhihu/people/pins/:id',
}, {
title: '热榜',
docs: 'https://docs.rsshub.app/social-media.html#%E7%9F%A5%E4%B9%8E',
source: '/hot',
target: '/zhihu/hotlist',
}, {
title: '想法热榜',
docs: 'https://docs.rsshub.app/social-media.html#%E7%9F%A5%E4%B9%8E',
target: '/zhihu/pin/hotlist',
}, {
title: '问题',
docs: 'https://docs.rsshub.app/social-media.html#%E7%9F%A5%E4%B9%8E',
source: '/question/:questionId',
target: '/zhihu/question/:questionId',
}, {
title: '话题',
docs: 'https://docs.rsshub.app/social-media.html#%E7%9F%A5%E4%B9%8E',
source: '/topic/:topicId/:type',
target: '/zhihu/topic/:topicId',
}, {
title: '新书',
docs: 'https://docs.rsshub.app/social-media.html#%E7%9F%A5%E4%B9%8E',
source: '/zhihu/bookstore/newest',
target: '/zhihu/pin/hotlist',
}, {
title: '想法-24 小时新闻汇总',
docs: 'https://docs.rsshub.app/social-media.html#%E7%9F%A5%E4%B9%8E',
source: '/pin/special/972884951192113152',
target: '/zhihu/pin/daily',
}, {
title: '书店-周刊',
docs: 'https://docs.rsshub.app/social-media.html#%E7%9F%A5%E4%B9%8E',
source: '/pub/weekly',
target: '/zhihu/weekly',
}],
'zhuanlan': [{
title: '专栏',
docs: 'https://docs.rsshub.app/social-media.html#%E7%9F%A5%E4%B9%8E',
source: '/:id',
target: '/zhihu/zhuanlan/:id',
}],
'daily': [{
title: '日报',
docs: 'https://docs.rsshub.app/social-media.html#%E7%9F%A5%E4%B9%8E',
source: '',
target: '/zhihu/daily',
}, {
title: '日报',
docs: 'https://docs.rsshub.app/social-media.html#%E7%9F%A5%E4%B9%8E',
source: '/*tpath',
target: '/zhihu/daily',
}],
},
'smzdm.com': {
_name: '什么值得买',
'www': [{
title: '关键词',
docs: 'https://docs.rsshub.app/shopping.html#%E4%BB%80%E4%B9%88%E5%80%BC%E5%BE%97%E4%B9%B0',
target: '/smzdm/keyword/:keyword',
}, {
title: '排行榜',
docs: 'https://docs.rsshub.app/shopping.html#%E4%BB%80%E4%B9%88%E5%80%BC%E5%BE%97%E4%B9%B0',
source: '/top',
}],
},
'rsshub.app': {
_name: 'RSSHub',
'docs': [{
title: '有新路由啦',
docs: 'https://docs.rsshub.app/program-update.html#rsshub',
source: ['', '/*tpath'],
target: '/rsshub/rss',
}],
},
'ximalaya.com': {
_name: '喜马拉雅',
'www': [{
title: '专辑',
docs: 'https://docs.rsshub.app/multimedia.html#%E5%96%9C%E9%A9%AC%E6%8B%89%E9%9B%85',
source: '/:type/:id',
target: '/ximalaya/album/:id/',
verification: (params) => parseInt(params.id) + '' === params.id,
}],
},
};
});
}
}
export function getRulesDate (success) {
chrome.storage.local.get('rulesDate', (result) => {
if (result && result.rulesDate) {
success(result.rulesDate);
} else {
success(null);
}
});
}
+6
View File
@@ -0,0 +1,6 @@
export function secondToTime (second) {
const hour = Math.floor(second / 3600);
const min = Math.floor((second - hour * 3600) / 60);
const sec = Math.floor(second - hour * 3600 - min * 60);
return `${hour ? hour + '小时' : ''}${min ? min + '分钟' : ''}${sec}秒`;
}
+5 -1
View File
@@ -24,7 +24,7 @@
<el-footer class="footer">版本 v{{ version }}<br>Made with <i style="color:#d43f57">♥</i> by <a target="_blank" href="https://diygod.me">DIYgod</a></el-footer>
</el-menu>
</el-aside>
<el-container>
<el-container class="sub-container">
<!-- <el-main><router-view></router-view></el-main> -->
<router-view></router-view>
</el-container>
@@ -63,6 +63,10 @@ body {
height: 100%;
}
.sub-container {
overflow: scroll;
}
.menu {
height: 100%;
+2 -1
View File
@@ -5,7 +5,7 @@ import App from './App.vue';
import Setting from './views/Setting.vue';
import List from './views/List.vue';
import About from './views/About.vue';
import { Container, Menu, MenuItem, Aside, Header, Main, Footer, Input, Checkbox, Message, Loading, Collapse, CollapseItem, Button } from 'element-ui';
import { Container, Menu, MenuItem, Aside, Header, Main, Footer, Input, Checkbox, Message, Loading, Collapse, CollapseItem, Button, Progress } from 'element-ui';
Vue.use(VueRouter);
Vue.use(Container);
@@ -21,6 +21,7 @@ Vue.use(Loading.directive);
Vue.use(Collapse);
Vue.use(CollapseItem);
Vue.use(Button);
Vue.use(Progress);
Vue.prototype.$loading = Loading.service;
Vue.prototype.$message = Message;
-1
View File
@@ -39,7 +39,6 @@ a {
max-width: 800px;
margin: 0 auto;
padding: 40px 10px;
overflow: scroll;
}
.title {
+31 -5
View File
@@ -2,8 +2,11 @@
<div class="list">
<el-main>
<div class="title">支持列表</div>
<div class="tip">更多规则支持中,快来<a target="_blank" href="https://docs.rsshub.app/joinus/">参与我们</a>吧!</div>
<div class="content">
<div class="tip">
<p>更多规则支持中,快来<a target="_blank" href="https://docs.rsshub.app/joinus/">参与我们</a>吧!</p>
<p>{{ time }}前更新</p>
</div>
<div class="content" v-loading="loading">
<el-collapse accordion>
<el-collapse-item v-for="(rule, domain) in rules" :key="domain" :title="rule._name + ' - ' + domain">
<div v-for="(subrule, subdomain) in rule" v-if="subdomain[0] !== '_'" :key="subdomain">
@@ -19,13 +22,37 @@
</template>
<script>
import rules from '../../common/rules';
import { getRules, getRulesDate } from '../../common/rules';
import { secondToTime } from '../../common/utils';
export default {
name: 'List',
data: () => ({
rules,
loading: true,
rules: {},
time: '',
}),
created() {
getRulesDate((date) => {
let second = (+new Date - +date) / 1000;
this.time = secondToTime(second);
this.refreshTime();
});
getRules((rules) => {
this.rules = rules;
this.loading = false;
});
},
methods: {
refreshTime() {
getRulesDate((date) => {
this.time = secondToTime((+new Date - +date) / 1000);
setTimeout(() => {
this.refreshTime();
}, 1000);
});
}
}
}
</script>
@@ -40,7 +67,6 @@ a {
max-width: 800px;
margin: 0 auto;
padding: 40px 10px;
overflow: scroll;
}
.title {
+83 -44
View File
@@ -1,51 +1,57 @@
<template>
<div class="setting">
<el-main>
<div class="title">设置</div>
<div class="content" v-loading="loading">
<div v-if="!loading">
<div class="subtitle">常规</div>
<div class="setting-item">
<div class="setting-name">自定义 RSSHub 域名</div>
<div class="setting-input">
<el-input @change="saveConfig" v-model="config.rsshubDomain" placeholder="请输入你的 RSSHub 域名,留空使用官方域名"></el-input>
</div>
<div class="setting-name">快捷键</div>
<div class="setting-input">
<el-button size="medium" @click="toHotkey">点此设置</el-button>
</div>
<div class="title">设置</div>
<div class="content" v-loading="loading">
<div v-if="!loading">
<div class="subtitle">常规</div>
<div class="setting-item">
<div class="setting-name">自定义 RSSHub 域名</div>
<div class="setting-input">
<el-input @change="saveConfig" v-model="config.rsshubDomain" placeholder="请输入你的 RSSHub 域名,留空使用官方域名"></el-input>
</div>
<div class="subtitle">通知与提醒</div>
<div class="setting-item">
<div class="setting-name">角标提醒</div>
<div class="setting-input">
<el-checkbox @change="saveConfig" v-model="config.notice.badge">开启</el-checkbox>
</div>
<div class="setting-name">快捷键</div>
<div class="setting-input">
<el-button size="medium" @click="toHotkey">点此设置</el-button>
</div>
<div class="subtitle">一键订阅</div>
<div class="setting-item">
<div class="setting-name">Tiny Tiny RSS <a target="_blank" href="https://ttrss.henry.wang/zh/"><i class="el-icon-info"></i></a></div>
<div class="setting-input">
<el-checkbox @change="saveConfig" v-model="config.submitto.ttrss">开启</el-checkbox>
<el-input @change="saveConfig" style="margin-left: 20px;" v-if="config.submitto.ttrss" v-model="config.submitto.ttrssDomain" placeholder="必填,请输入你的 Tiny Tiny RSS 地址"></el-input>
</div>
<div class="setting-name">Feedly <a target="_blank" href="https://feedly.com/"><i class="el-icon-info"></i></a></div>
<div class="setting-input">
<el-checkbox @change="saveConfig" v-model="config.submitto.feedly">开启</el-checkbox>
</div>
<div class="setting-name">Inoreader <a target="_blank" href="https://www.inoreader.com/"><i class="el-icon-info"></i></a></div>
<div class="setting-input">
<el-checkbox @change="saveConfig" v-model="config.submitto.inoreader">开启</el-checkbox>
</div>
</div>
<div class="subtitle">规则更新</div>
<div class="setting-item">
<div class="setting-input">
<el-button style="width: 98px" size="medium" @click="refreshRu" :disabled="refreshDisabled">{{ refreshDisabled ? '更新中' : '手动更新' }}</el-button><el-progress :text-inside="true" :stroke-width="20" :percentage="percentage"></el-progress><span class="time"> {{ time }}前更新 </span>
</div>
</div>
<div class="subtitle">一键订阅</div>
<div class="setting-item">
<div class="setting-name">Tiny Tiny RSS <a target="_blank" href="https://ttrss.henry.wang/zh/"><i class="el-icon-info"></i></a></div>
<div class="setting-input">
<el-checkbox @change="saveConfig" v-model="config.submitto.ttrss">开启</el-checkbox>
<el-input @change="saveConfig" style="margin-left: 20px;" v-if="config.submitto.ttrss" v-model="config.submitto.ttrssDomain" placeholder="必填,请输入你的 Tiny Tiny RSS 地址"></el-input>
</div>
<div class="setting-name">Feedly <a target="_blank" href="https://feedly.com/"><i class="el-icon-info"></i></a></div>
<div class="setting-input">
<el-checkbox @change="saveConfig" v-model="config.submitto.feedly">开启</el-checkbox>
</div>
<div class="setting-name">Inoreader <a target="_blank" href="https://www.inoreader.com/"><i class="el-icon-info"></i></a></div>
<div class="setting-input">
<el-checkbox @change="saveConfig" v-model="config.submitto.inoreader">开启</el-checkbox>
</div>
</div>
<div class="subtitle">通知与提醒</div>
<div class="setting-item">
<div class="setting-name">角标提醒</div>
<div class="setting-input">
<el-checkbox @change="saveConfig" v-model="config.notice.badge">开启</el-checkbox>
</div>
</div>
</div>
</el-main>
</div>
</div>
</template>
<script>
import { getRulesDate, refreshRules } from '../../common/rules';
import { defaultConfig, getConfig, saveConfig } from '../../common/config';
import { secondToTime } from '../../common/utils';
export default {
name: 'Setting',
@@ -53,17 +59,24 @@ export default {
loading: true,
defaultConfig,
config: defaultConfig,
time: '',
second: 0,
refreshDisabled: false,
}),
computed: {
percentage: function () {
return (this.second / this.config.refreshTimeout * 100).toFixed(2);
},
},
created() {
this.getConfig();
getConfig((config) => {
this.config = config;
this.loading = false;
this.refreshTime();
});
},
methods: {
getConfig() {
getConfig((config) => {
this.config = config;
this.loading = false;
});
},
saveConfig() {
saveConfig(this.config, () => {
this.$message({
@@ -77,6 +90,22 @@ export default {
url: 'chrome://extensions/shortcuts'
});
},
refreshRu() {
this.refreshDisabled = true;
refreshRules(() => {
this.second = 0;
this.refreshDisabled = false;
});
},
refreshTime() {
getRulesDate((date) => {
this.second = (+new Date - +date) / 1000;
this.time = secondToTime(this.second);
setTimeout(() => {
this.refreshTime();
}, 1000);
});
}
}
}
</script>
@@ -87,7 +116,6 @@ export default {
max-width: 800px;
margin: 0 auto;
padding: 40px 10px;
overflow: scroll;
}
.title {
@@ -100,6 +128,7 @@ export default {
.content {
margin-top: 20px;
margin-bottom: 30px;
color: #222;
}
@@ -136,4 +165,14 @@ export default {
color: #777;
margin-left: 2px;
}
.el-progress {
width: 170px;
margin: 0 20px;
}
.time {
color: #606266;
font-size: 14px;
}
</style>