This commit is contained in:
Liwanyi 2023-05-26 10:40:29 +08:00
parent aa9d6dbaf3
commit 0e5e3180c9
5 changed files with 86 additions and 7 deletions

View File

@ -5,6 +5,14 @@
# CHANGE # CHANGE
## 0.9.2
2023年05月26日
### 添加
- 快速浏览通知
## 0.9.1 ## 0.9.1
2023年05月04日 2023年05月04日

View File

@ -1,6 +1,6 @@
{ {
"name": "wuhu-torn-helper", "name": "wuhu-torn-helper",
"version": "0.9.1", "version": "0.9.2",
"description": "芜湖助手", "description": "芜湖助手",
"scripts": { "scripts": {
"release": "cross-env NODE_ENV=production rollup -c && node build.mjs", "release": "cross-env NODE_ENV=production rollup -c && node build.mjs",

File diff suppressed because one or more lines are too long

66
src/vue/EventsViewer.vue Normal file
View File

@ -0,0 +1,66 @@
<script lang="ts">
export default {
name: "EventsViewer"
}
</script>
<script lang="ts" setup>
import { inject, onMounted, Ref, ref } from "vue";
import { LoggerKey } from "../ts/class/Logger";
const logger = inject(LoggerKey);
const loading = ref(true);
const doFetch = () => fetch("https://www.torn.com/page.php", {
"headers": {
"accept": "*/*",
"content-type": "multipart/form-data; boundary=----WebKitFormBoundaryqnl8FNrJpu0CEGSU",
"sec-ch-ua-mobile": "?0",
"sec-fetch-dest": "empty",
"sec-fetch-mode": "cors",
"sec-fetch-site": "same-origin",
"x-requested-with": "XMLHttpRequest"
},
"referrer": "https://www.torn.com/page.php?sid=events",
"referrerPolicy": "strict-origin-when-cross-origin",
"body": "------WebKitFormBoundaryqnl8FNrJpu0CEGSU\r\nContent-Disposition: form-data; name=\"sid\"\r\n\r\neventsData\r\n------WebKitFormBoundaryqnl8FNrJpu0CEGSU--\r\n",
"method": "POST",
"mode": "cors",
"credentials": "include"
});
const events: Ref<{ ID: string, message: string, time: number, isNew: boolean }[]> = ref([]);
const DateTimeFormatter = (ts: number) => {
let date = new Date(ts);
return date.toLocaleDateString() + ' ' + date.toLocaleTimeString();
};
onMounted(async () => {
let res;
try {
res = await (await doFetch()).json();
if (res.success) {
events.value = res.events;
if (res['newEventsAmount']) {
for (let i = 0; i < res['newEventsAmount']; i++) {
events.value[i].isNew = true;
}
}
loading.value = false;
}
} catch (e) {
logger.error(e.stack);
}
});
</script>
<template>
<el-timeline v-loading="loading">
<el-timeline-item v-for="ev in events" :color="ev.isNew?'#0bbd87':''"
:timestamp="DateTimeFormatter(ev.time*1000)">
<span v-html="ev.message"></span>
</el-timeline-item>
</el-timeline>
</template>
<style scoped>
</style>

View File

@ -86,6 +86,7 @@ import { BATTLE_STAT } from "../ts/class/utils/NetHighLvlWrapper";
import { QuickFlyBtnHandlerKey } from "../ts/class/handler/QuickFlyBtnHandler"; import { QuickFlyBtnHandlerKey } from "../ts/class/handler/QuickFlyBtnHandler";
import { ElMessage, ElMessageBox } from "element-plus"; import { ElMessage, ElMessageBox } from "element-plus";
import QuickCrime from "./QuickCrime.vue"; import QuickCrime from "./QuickCrime.vue";
import EventsViewer from "./EventsViewer.vue";
const logger = inject(LoggerKey); const logger = inject(LoggerKey);
const quickGymTrain = inject(QuickGymTrainKey); const quickGymTrain = inject(QuickGymTrainKey);
@ -169,6 +170,10 @@ const menuItemList = [
title: '🌸 飞花库存', title: '🌸 飞花库存',
template: ForeignStock, template: ForeignStock,
}, },
{
title: '📢 浏览通知',
template: EventsViewer,
},
// { // {
// title: '🔫 LOOT', // title: '🔫 LOOT',
// template: Test, // template: Test,