!131 新增米游社公告列表(只显示前五条)

* 米游社公告列表
This commit is contained in:
帮帮 2023-12-11 19:15:32 +00:00 committed by Kokomi
parent 06b5d3c154
commit 1d5e8f922f
8 changed files with 437 additions and 14 deletions

View File

@ -12,10 +12,10 @@ export class mysNews extends plugin {
name: '米游社公告',
dsc: '#公告 #资讯 #活动',
event: 'message',
priority: 700,
priority: 7000,
rule: [
{
reg: '^#*(官方|星铁|原神|崩坏三|崩三|绝区零|崩坏二|崩二|崩坏学园二|未定|未定事件簿)?(公告|资讯|活动)[0-9]*$',
reg: '^#*(官方|星铁|原神|崩坏三|崩三|绝区零|崩坏二|崩二|崩坏学园二|未定|未定事件簿)?(公告|资讯|活动)(列表|[0-9])*$',
fnc: 'news'
},
{
@ -138,7 +138,7 @@ export class mysNews extends plugin {
}
gids() {
let msg = this.e.msg.replace(/[#公告资讯活动开启关闭推送]/g, '');
let msg = this.e.msg.replace(/[#公告资讯活动开启关闭推送列表]/g, '');
switch (msg) {
case '崩坏三':
case '崩三':

View File

@ -25,7 +25,7 @@ export default class MysNews extends base {
typeName = '活动'
}
const res = await this.postData('getNewsList', { gids: gid, page_size: 20, type })
const res = await this.postData('getNewsList', { gids: gid, page_size: this.e.msg.includes('列表') ? 5 : 20, type })
if (!res) return
const data = res.data.list
@ -33,6 +33,23 @@ export default class MysNews extends base {
return true
}
let param = {}
let game = this.game(gid)
if (this.e.msg.includes('列表')) {
this.model = 'mysNews-list'
data.forEach(element => {
element.post.created_at = new Date(element.post.created_at * 1000).toLocaleString()
})
param = {
...this.screenData,
saveId: this.e.user_id,
data,
game,
typeName
}
} else {
const page = this.e.msg.replace(/#||官方|星铁|原神|崩坏三|崩三|绝区零|崩坏二|崩二|崩坏学园二|未定|未定事件簿|公告|资讯|活动/g, '').trim() || 1
if (page > data.length) {
await this.e.reply('目前只查前20条最新的公告请输入1-20之间的整数。')
@ -41,11 +58,11 @@ export default class MysNews extends base {
const postId = data[page - 1].post.post_id
const param = await this.newsDetail(postId, gid)
param = await this.newsDetail(postId, gid)
}
const img = await this.render(param)
let game = this.game()
return this.replyMsg(img, `${game}${typeName}${param.data.post.subject}`)
return this.replyMsg(img, `${game}${typeName}${param?.data?.post?.subject || `米游社${game}${typeName}列表`}`)
}
render(param) {

View File

@ -0,0 +1,152 @@
* {
margin: 0;
padding: 0;
box-sizing: border-box;
user-select: none;
font-family: sans-serif;
}
@font-face {
font-family: "tttgbnumber";
src: url("../../font/tttgbnumber.ttf");
font-weight: normal;
font-style: normal;
}
.container {
width: 700px;
padding: 20px 15px 10px 15px;
background-color: #f5f6fb;
}
.head_box {
border-radius: 15px 50px 50px 15px;
font-family: "tttgbnumber";
padding: 35px 40px;
position: relative;
box-shadow: 0 5px 10px 0 rgb(0 0 0 / 15%);
background: url(./蒙德.png) #fff;
background-repeat: no-repeat;
background-size: 100% auto;
}
.head_box h1 {
font-size: 30px;
line-height: 36px;
margin: 0;
word-break: break-word;
word-wrap: break-word;
display: block;
}
body {
background: #f0f1f5;
line-height: 150%;
color: #333;
font-size: 16px;
width: 700px;
transform: scale(1.2);
transform-origin: 0 0;
}
.body_box {
padding: 20px 0px;
}
.data_box {
box-shadow: 0 5px 10px 0 rgb(0 0 0 / 15%);
border-radius: 15px;
background-color: #fff;
/* font-family: "tttgbnumber"; */
padding: 10px 0px 10px 0px;
font-size: 16px;
word-wrap: break-word;
word-break: break-word;
height: auto;
overflow-x: hidden;
}
.newscard {
display: flex;
padding: 16px 20px 16px 20px;
border-bottom: 1px solid #ddd;
}
.newscard-left {
width: 40px;
-ms-flex-negative: 0;
flex-shrink: 0;
font-size: 26px;
}
.newscard-comment {
width: 40px;
height: 30px;
position: relative;
text-align: center;
display: table-cell;
display: table;
vertical-align: middle;
}
.newscard-info {
display: block;
margin-left: 14px;
padding: 8px 0 6px;
overflow: hidden;
-webkit-box-flex: 1;
-ms-flex-positive: 1;
flex-grow: 1;
}
.newscard-title {
font-size: 22px;
line-height: 24px;
font-weight: 600;
color: #333;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.newscard-content {
display: -webkit-box;
margin-top: 14px;
color: #999;
overflow: hidden;
-o-text-overflow: ellipsis;
text-overflow: ellipsis;
-webkit-line-clamp: 3;
-webkit-box-orient: vertical;
line-height: 30px;
max-height: 86px;
word-break: break-word;
word-wrap: break-word;
font-size: 18px;
outline: none;
}
.newscard-num {
display: table-cell;
text-align: center;
vertical-align: middle;
font-family: "tttgbnumber";
}
.newscard-time {
font-size: 16px;
color: #999;
line-height: 1;
margin-top: 14px;
font-family: "tttgbnumber";
}
.newscard-cover {
margin-top: 10px;
width: 242px;
height: 124px;
-ms-flex-negative: 0;
flex-shrink: 0;
margin-left: 14px;
overflow: hidden;
}
.newscard-img {
width: 100%;
height: 100%;
border-radius: 8px;
background-position: 50%;
background-repeat: no-repeat;
/* background-size: 60%; */
background-color: #f6f6f6;
background-size: cover;
}
.logo {
font-size: 14px;
font-family: "tttgbnumber";
text-align: center;
color: #7994a7;
}

View File

@ -0,0 +1,51 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<link rel="shortcut icon" href="#" />
<link rel="stylesheet" type="text/css" href="{{pluResPath}}html/mysNews-list/mysNews-list.css" />
<link rel="preload" href="{{pluResPath}}font/tttgbnumber.ttf" as="font" />
</head>
<body>
<div class="container" id="container">
<div class="container">
<div class="head_box">
<h1>米游社·{{game}}{{typeName}}列表</h1>
</div>
<div class="body_box">
<div class="data_box">
{{each data data iCount}}
{{if iCount == data.length - 1}}
<div class="newscard" style="border-bottom: 0px">
{{else}}
<div class="newscard">
{{/if}}
<div class="newscard-left">
<div style="height:100%;display:table;width:100%">
<span class="newscard-num">{{iCount + 1}}</span>
</div>
</div>
<div class="newscard-info">
<h3 class="newscard-title">{{data.post.subject}}</h3>
<div class="newscard-content">{{data.post.content}}</div>
<div class="newscard-time">{{data.post.created_at}}</div>
</div>
<div class="newscard-cover">
<div class="newscard-img"
style='background-image: url("{{data.post.images[0]}}?x-oss-process=image/resize,s_200/quality,q_80/auto-orient,0/interlace,1/format,jpg");'>
</div>
</div>
</div>
{{/each}}
</div>
</div>
<div class="logo">详情内容使用【#{{game}}{{typeName}}】加上序号查看,如【#{{game}}{{typeName}}2】</div>
<div class="logo">Created By Miao-Yunzai</div>
</div>
</div>
</body>
<script type="text/javascript"></script>
</html>

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

View File

@ -0,0 +1,152 @@
* {
margin: 0;
padding: 0;
box-sizing: border-box;
user-select: none;
font-family: sans-serif;
}
@font-face {
font-family: "tttgbnumber";
src: url("../../font/tttgbnumber.ttf");
font-weight: normal;
font-style: normal;
}
.container {
width: 700px;
padding: 20px 15px 10px 15px;
background-color: #f5f6fb;
}
.head_box {
border-radius: 15px 50px 50px 15px;
font-family: "tttgbnumber";
padding: 35px 40px;
position: relative;
box-shadow: 0 5px 10px 0 rgb(0 0 0 / 15%);
background: url(./蒙德.png) #fff;
background-repeat: no-repeat;
background-size: 100% auto;
}
.head_box h1 {
font-size: 30px;
line-height: 36px;
margin: 0;
word-break: break-word;
word-wrap: break-word;
display: block;
}
body {
background: #f0f1f5;
line-height: 150%;
color: #333;
font-size: 16px;
width: 700px;
transform: scale(1.2);
transform-origin: 0 0;
}
.body_box {
padding: 20px 0px;
}
.data_box {
box-shadow: 0 5px 10px 0 rgb(0 0 0 / 15%);
border-radius: 15px;
background-color: #fff;
/* font-family: "tttgbnumber"; */
padding: 10px 0px 10px 0px;
font-size: 16px;
word-wrap: break-word;
word-break: break-word;
height: auto;
overflow-x: hidden;
}
.newscard {
display: flex;
padding: 16px 20px 16px 20px;
border-bottom: 1px solid #ddd;
}
.newscard-left {
width: 40px;
-ms-flex-negative: 0;
flex-shrink: 0;
font-size: 26px;
}
.newscard-comment {
width: 40px;
height: 30px;
position: relative;
text-align: center;
display: table-cell;
display: table;
vertical-align: middle;
}
.newscard-info {
display: block;
margin-left: 14px;
padding: 8px 0 6px;
overflow: hidden;
-webkit-box-flex: 1;
-ms-flex-positive: 1;
flex-grow: 1;
}
.newscard-title {
font-size: 22px;
line-height: 24px;
font-weight: 600;
color: #333;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.newscard-content {
display: -webkit-box;
margin-top: 14px;
color: #999;
overflow: hidden;
-o-text-overflow: ellipsis;
text-overflow: ellipsis;
-webkit-line-clamp: 3;
-webkit-box-orient: vertical;
line-height: 30px;
max-height: 86px;
word-break: break-word;
word-wrap: break-word;
font-size: 18px;
outline: none;
}
.newscard-num {
display: table-cell;
text-align: center;
vertical-align: middle;
font-family: "tttgbnumber";
}
.newscard-time {
font-size: 16px;
color: #999;
line-height: 1;
margin-top: 14px;
font-family: "tttgbnumber";
}
.newscard-cover {
margin-top: 10px;
width: 242px;
height: 124px;
-ms-flex-negative: 0;
flex-shrink: 0;
margin-left: 14px;
overflow: hidden;
}
.newscard-img {
width: 100%;
height: 100%;
border-radius: 8px;
background-position: 50%;
background-repeat: no-repeat;
/* background-size: 60%; */
background-color: #f6f6f6;
background-size: cover;
}
.logo {
font-size: 14px;
font-family: "tttgbnumber";
text-align: center;
color: #7994a7;
}

View File

@ -0,0 +1,51 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<link rel="shortcut icon" href="#" />
<link rel="stylesheet" type="text/css" href="{{pluResPath}}html/mysNews-list/mysNews-list.css" />
<link rel="preload" href="{{pluResPath}}font/tttgbnumber.ttf" as="font" />
</head>
<body>
<div class="container" id="container">
<div class="container">
<div class="head_box">
<h1>米游社·{{game}}{{typeName}}列表</h1>
</div>
<div class="body_box">
<div class="data_box">
{{each data data iCount}}
{{if iCount == data.length - 1}}
<div class="newscard" style="border-bottom: 0px">
{{else}}
<div class="newscard">
{{/if}}
<div class="newscard-left">
<div style="height:100%;display:table;width:100%">
<span class="newscard-num">{{iCount + 1}}</span>
</div>
</div>
<div class="newscard-info">
<h3 class="newscard-title">{{data.post.subject}}</h3>
<div class="newscard-content">{{data.post.content}}</div>
<div class="newscard-time">{{data.post.created_at}}</div>
</div>
<div class="newscard-cover">
<div class="newscard-img"
style='background-image: url("{{data.post.images[0]}}?x-oss-process=image/resize,s_200/quality,q_80/auto-orient,0/interlace,1/format,jpg");'>
</div>
</div>
</div>
{{/each}}
</div>
</div>
<div class="logo">详情内容使用【#{{game}}{{typeName}}】加上序号查看,如【#{{game}}{{typeName}}2】</div>
<div class="logo">Created By Miao-Yunzai</div>
</div>
</div>
</body>
<script type="text/javascript"></script>
</html>

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB