diff --git a/extension.json b/extension.json index 5d6923c..f74c68e 100644 --- a/extension.json +++ b/extension.json @@ -82,12 +82,14 @@ ] }, "ext.isekai.feedList": { - "scripts": [ - "feedList/ext.isekai.feedList.js" - ], "styles": [ "feedList/ext.isekai.feedList.less" ], + "packageFiles": [ + { "name": "isekaiFeedList", "file": "feedList/ext.isekai.feedList.js", "main": true }, + { "name": "FeedList.vue", "file": "feedList/FeedList.vue" } + ], + "es6": true, "dependencies": [ "oojs", "oojs-ui-core", diff --git a/modules/feedList/FeedList.vue b/modules/feedList/FeedList.vue new file mode 100644 index 0000000..64ce5cd --- /dev/null +++ b/modules/feedList/FeedList.vue @@ -0,0 +1,161 @@ + + + diff --git a/modules/feedList/ext.isekai.feedList.js b/modules/feedList/ext.isekai.feedList.js index 38eca02..f972c5a 100644 --- a/modules/feedList/ext.isekai.feedList.js +++ b/modules/feedList/ext.isekai.feedList.js @@ -1,122 +1,6 @@ const Vue = require("vue"); if (document.querySelector('#isekai-feed-list')) { - new Vue({ - el: '#isekai-feed-list', - data: { - mounted: false, - loading: true, - feedList: [] - }, - mounted() { - this.$data.mounted = true; - const api = new mw.Api(); - - let recentData = { - recentNew: null, - recentEdit: null, - }; - const onLoaded = () => { - if (Array.isArray(recentData.recentNew) && Array.isArray(recentData.recentEdit)) { - // 混合两个列表 - let recentList = [ - ...recentData.recentNew, - ...recentData.recentEdit - ]; - recentList.sort((a, b) => b.orderWeight - a.orderWeight); - // 去除重复,获取pageid列表 - let pageIdList = []; - recentList = recentList.filter((item) => { - if (pageIdList.includes(item.pageid)) { - return false; - } else { - pageIdList.push(item.pageid); - return true; - } - }); - - // 获取页面详细信息 - api.get({ - "action": "query", - "prop": "extracts|info", - "pageids": pageIdList.join('|'), - "redirects": 1, - "converttitles": 1, - "exchars": 100, - "exintro": 1, - "explaintext": 1, - "inprop": "url" - }).done((data) => { - if (data.query && data.query.pages) { - const pageInfoList = data.query.pages; - recentList = recentList.map((info) => { - if (info.pageid in pageInfoList) { - const pageInfo = pageInfoList[info.pageid]; - return { - pageid: info.pageid, - title: pageInfo.title, - description: pageInfo.extract, - url: pageInfo.fullurl - } - } else { - return { - pageid: info.pageid, - title: info.title, - description: '', - url: mw.util.getUrl(info.title) - } - } - }); - // 设置data - this.$data.feedList = recentList; - this.$data.loading = false; - } - }); - } - }; - api.get({ - action: 'query', - list: 'recentchanges', - rctype: 'edit', - rcnamespace: 0, - rclimit: 20, - }).done((data) => { - recentData.recentEdit = []; - if (data.query && Array.isArray(data.query.recentchanges)) { //有成功取到数据 - data.query.recentchanges.forEach((one) => { - if (one.timestamp) { - one.timestamp = new Date(one.timestamp).getTime(); - one.orderWeight = one.timestamp; - } else { - one.orderWeight = 0; - } - recentData.recentEdit.push(one); - }); - onLoaded(); - } - }); - - api.get({ - action: 'query', - list: 'recentchanges', - rctype: 'new', - rcnamespace: 0, - rclimit: 20, - }).done((data) => { - recentData.recentNew = []; - if (data.query && Array.isArray(data.query.recentchanges)) { // 成功取到数据 - data.query.recentchanges.forEach((one) => { - if (one.timestamp) { - one.timestamp = new Date(one.timestamp).getTime(); - one.orderWeight = one.timestamp + (86400 * 1000); // 新页面保护,权重比页面更新高7天 - } else { - one.orderWeight = 0; - } - recentData.recentNew.push(one); - }); - onLoaded(); - } - }); - } - }); + const App = require("./FeedList.vue"); + Vue.createMwApp(App).mount("#isekai-feed-list"); } \ No newline at end of file diff --git a/modules/feedList/ext.isekai.feedList.less b/modules/feedList/ext.isekai.feedList.less index 97368bc..0fbeefb 100644 --- a/modules/feedList/ext.isekai.feedList.less +++ b/modules/feedList/ext.isekai.feedList.less @@ -5,7 +5,7 @@ height: 2.25rem; } -#isekai-feed-list { +.isekai-feed-list { margin: 0; height: @feed-list-height; overflow-y: auto; diff --git a/modules/feedList/ext.isekai.feedList.tpl b/modules/feedList/ext.isekai.feedList.tpl index d388ea4..decbf8c 100644 --- a/modules/feedList/ext.isekai.feedList.tpl +++ b/modules/feedList/ext.isekai.feedList.tpl @@ -3,25 +3,6 @@ parse()?>
-
-
-
-
-
-
-
-
- -
+
\ No newline at end of file diff --git a/modules/tile/style.less b/modules/tile/style.less index 0c0920f..91ef973 100644 --- a/modules/tile/style.less +++ b/modules/tile/style.less @@ -6,6 +6,10 @@ a { &.tile-app { color: #fff; + &:visited { + color: #fff; + } + &:visited:hover { color: #fff; }