koishi-plugin-lutu 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/api/evmOpenApi.d.ts +33 -0
- package/lib/api/evmOpenApi.js +114 -0
- package/lib/api/truckersMpApi.d.ts +34 -0
- package/lib/api/truckersMpApi.js +133 -0
- package/lib/api/truckersMpMapApi.d.ts +6 -0
- package/lib/api/truckersMpMapApi.js +25 -0
- package/lib/api/truckyAppApi.d.ts +12 -0
- package/lib/api/truckyAppApi.js +48 -0
- package/lib/command/ets-app/queryPoint.js +74 -0
- package/lib/command/ets-app/resetPassword.js +111 -0
- package/lib/command/tmpActivityService.js +603 -0
- package/lib/command/tmpBind.d.ts +2 -0
- package/lib/command/tmpBind.js +18 -0
- package/lib/command/tmpDlcMap.d.ts +3 -0
- package/lib/command/tmpDlcMap.js +33 -0
- package/lib/command/tmpMileageRanking.d.ts +3 -0
- package/lib/command/tmpMileageRanking.js +55 -0
- package/lib/command/tmpPosition.d.ts +3 -0
- package/lib/command/tmpPosition.js +107 -0
- package/lib/command/tmpQuery/tmpQuery.d.ts +2 -0
- package/lib/command/tmpQuery/tmpQuery.js +12 -0
- package/lib/command/tmpQuery/tmpQueryImg.d.ts +3 -0
- package/lib/command/tmpQuery/tmpQueryImg.js +103 -0
- package/lib/command/tmpQuery/tmpQueryText.d.ts +2 -0
- package/lib/command/tmpQuery/tmpQueryText.js +175 -0
- package/lib/command/tmpServer.d.ts +2 -0
- package/lib/command/tmpServer.js +41 -0
- package/lib/command/tmpTraffic/tmpTraffic.d.ts +2 -0
- package/lib/command/tmpTraffic/tmpTraffic.js +15 -0
- package/lib/command/tmpTraffic/tmpTrafficMap.d.ts +3 -0
- package/lib/command/tmpTraffic/tmpTrafficMap.js +163 -0
- package/lib/command/tmpTraffic/tmpTrafficText.d.ts +2 -0
- package/lib/command/tmpTraffic/tmpTrafficText.js +60 -0
- package/lib/command/tmpVersion.d.ts +2 -0
- package/lib/command/tmpVersion.js +14 -0
- package/lib/command/tmpVtc.js +29 -0
- package/lib/database/guildBind.d.ts +15 -0
- package/lib/database/guildBind.js +41 -0
- package/lib/database/model.d.ts +2 -0
- package/lib/database/model.js +65 -0
- package/lib/database/translateCache.d.ts +14 -0
- package/lib/database/translateCache.js +31 -0
- package/lib/index.d.ts +35 -0
- package/lib/index.js +276 -0
- package/lib/resource/dlc.html +115 -0
- package/lib/resource/mileage-leaderboard.html +363 -0
- package/lib/resource/package/SEGUIEMJ.TTF +0 -0
- package/lib/resource/package/leaflet/heatmap.min.js +9 -0
- package/lib/resource/package/leaflet/leaflet-heatmap.js +246 -0
- package/lib/resource/package/leaflet/leaflet.min.css +1 -0
- package/lib/resource/package/leaflet/leaflet.min.js +1 -0
- package/lib/resource/position.html +223 -0
- package/lib/resource/query.html +363 -0
- package/lib/resource/traffic.html +207 -0
- package/lib/util/baiduTranslate.d.ts +2 -0
- package/lib/util/baiduTranslate.js +30 -0
- package/lib/util/common.d.ts +1 -0
- package/lib/util/common.js +5 -0
- package/lib/util/constant.d.ts +8 -0
- package/lib/util/constant.js +16 -0
- package/package.json +41 -0
- package/readme.md +143 -0
package/lib/index.js
ADDED
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Config = exports.inject = exports.name = void 0;
|
|
4
|
+
exports.apply = apply;
|
|
5
|
+
|
|
6
|
+
const koishi_1 = require("koishi");
|
|
7
|
+
const model = require('./database/model');
|
|
8
|
+
const { MileageRankingType } = require('./util/constant');
|
|
9
|
+
|
|
10
|
+
const commands = {
|
|
11
|
+
tmpQuery: require('./command/tmpQuery/tmpQuery'),
|
|
12
|
+
tmpServer: require('./command/tmpServer'),
|
|
13
|
+
tmpBind: require('./command/tmpBind'),
|
|
14
|
+
tmpTraffic: require('./command/tmpTraffic/tmpTraffic'),
|
|
15
|
+
tmpPosition: require('./command/tmpPosition'),
|
|
16
|
+
tmpVersion: require('./command/tmpVersion'),
|
|
17
|
+
tmpDlcMap: require('./command/tmpDlcMap'),
|
|
18
|
+
tmpMileageRanking: require('./command/tmpMileageRanking'),
|
|
19
|
+
resetPassword: require('./command/ets-app/resetPassword'),
|
|
20
|
+
queryPoint: require('./command/ets-app/queryPoint'),
|
|
21
|
+
tmpVtc: require('./command/tmpVtc')
|
|
22
|
+
};
|
|
23
|
+
const { ActivityService } = require('./command/tmpActivityService');
|
|
24
|
+
|
|
25
|
+
const __defProp = Object.defineProperty;
|
|
26
|
+
const __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
27
|
+
const __getOwnPropNames = Object.getOwnPropertyNames;
|
|
28
|
+
const __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
29
|
+
const __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
30
|
+
const __export = (target, all) => {
|
|
31
|
+
for (const name2 in all)
|
|
32
|
+
__defProp(target, name2, { get: all[name2], enumerable: true });
|
|
33
|
+
};
|
|
34
|
+
const __copyProps = (to, from, except, desc) => {
|
|
35
|
+
if (from && (typeof from === "object" || typeof from === "function")) {
|
|
36
|
+
for (const key of __getOwnPropNames(from))
|
|
37
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
38
|
+
__defProp(to, key, {
|
|
39
|
+
get: () => from[key],
|
|
40
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
return to;
|
|
44
|
+
};
|
|
45
|
+
const __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
46
|
+
|
|
47
|
+
const src_exports = {};
|
|
48
|
+
__export(src_exports, {
|
|
49
|
+
Config: () => Config,
|
|
50
|
+
apply: () => apply,
|
|
51
|
+
name: () => name
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
exports.name = 'tmp-bot';
|
|
55
|
+
exports.inject = {
|
|
56
|
+
required: ['database'],
|
|
57
|
+
optional: ['puppeteer']
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
exports.Config = koishi_1.Schema.intersect([
|
|
61
|
+
koishi_1.Schema.object({
|
|
62
|
+
debugMode: koishi_1.Schema.boolean().default(false).description('启用调试模式(输出详细日志)')
|
|
63
|
+
}).description('基本配置'),
|
|
64
|
+
koishi_1.Schema.object({
|
|
65
|
+
commands: koishi_1.Schema.object({
|
|
66
|
+
tmpQuery: koishi_1.Schema.boolean().default(true).description('是否启用查询功能'),
|
|
67
|
+
tmpTraffic: koishi_1.Schema.boolean().default(true).description('是否启用路况查询'),
|
|
68
|
+
tmpServer: koishi_1.Schema.boolean().default(true).description('是否启用服务器查询'),
|
|
69
|
+
tmpPosition: koishi_1.Schema.boolean().default(true).description('是否启用定位功能'),
|
|
70
|
+
tmpVersion: koishi_1.Schema.boolean().default(true).description('是否启用版本查询'),
|
|
71
|
+
tmpDlcMap: koishi_1.Schema.boolean().default(true).description('是否启用DLC地图查询'),
|
|
72
|
+
tmpMileageRanking: koishi_1.Schema.boolean().default(true).description('是否启用里程排行榜'),
|
|
73
|
+
tmpVtc: koishi_1.Schema.boolean().default(true).description('是否启用VTC查询'),
|
|
74
|
+
mainSettings: koishi_1.Schema.boolean().default(false).description('是否启用车队平台积分查询功能'),
|
|
75
|
+
resetPassword: koishi_1.Schema.boolean().default(false).description('是否启用车队平台重置密码功能'),
|
|
76
|
+
tmpActivityService: koishi_1.Schema.boolean().default(false).description('是否启用车队活动查询')
|
|
77
|
+
}).description('指令配置'),
|
|
78
|
+
baiduTranslate: koishi_1.Schema.object({
|
|
79
|
+
enable: koishi_1.Schema.boolean().default(false).description('是否启用百度翻译'),
|
|
80
|
+
appId: koishi_1.Schema.string().description('百度翻译APP ID'),
|
|
81
|
+
key: koishi_1.Schema.string().description('百度翻译秘钥'),
|
|
82
|
+
enableCache: koishi_1.Schema.boolean().default(false).description('是否启用翻译缓存')
|
|
83
|
+
}).description('百度翻译配置'),
|
|
84
|
+
tmpQuery: koishi_1.Schema.object({
|
|
85
|
+
showAvatar: koishi_1.Schema.boolean().default(false).description('是否显示玩家头像(部分玩家的擦边头像可能导致封号)'),
|
|
86
|
+
type: koishi_1.Schema.union([
|
|
87
|
+
koishi_1.Schema.const(1).description('文字'),
|
|
88
|
+
koishi_1.Schema.const(2).description('图片')
|
|
89
|
+
]).default(1).description('玩家信息展示方式'),
|
|
90
|
+
}).description('玩家查询配置'),
|
|
91
|
+
tmpTraffic: koishi_1.Schema.object({
|
|
92
|
+
type: koishi_1.Schema.union([
|
|
93
|
+
koishi_1.Schema.const(1).description('文字'),
|
|
94
|
+
koishi_1.Schema.const(2).description('热力图')
|
|
95
|
+
]).default(1).description('路况信息展示方式'),
|
|
96
|
+
}).description('路况查询配置'),
|
|
97
|
+
mainSettings: koishi_1.Schema.object({
|
|
98
|
+
settings: koishi_1.Schema.object({
|
|
99
|
+
url: koishi_1.Schema.string().description("API服务器地址"),
|
|
100
|
+
token: koishi_1.Schema.string().description("API认证令牌"),
|
|
101
|
+
logOutput: koishi_1.Schema.boolean().description("是否输出日志").default(true)
|
|
102
|
+
})
|
|
103
|
+
}).description("车队平台配置"),
|
|
104
|
+
resetPassword: koishi_1.Schema.object({
|
|
105
|
+
settings: koishi_1.Schema.object({
|
|
106
|
+
adminUsers: koishi_1.Schema.array(koishi_1.Schema.string()).description("管理员用户ID(拥有重置任意teamId权限)").default([])
|
|
107
|
+
})
|
|
108
|
+
}).description("重置密码功能配置"),
|
|
109
|
+
tmpActivityService: koishi_1.Schema.object({
|
|
110
|
+
api: koishi_1.Schema.object({
|
|
111
|
+
useHttps: koishi_1.Schema.boolean().description("使用HTTPS协议").default(true),
|
|
112
|
+
url: koishi_1.Schema.string().description("车队平台URL(不包含协议)").default(""),
|
|
113
|
+
token: koishi_1.Schema.string().description("车队平台TOKEN").default(""),
|
|
114
|
+
vtcId: koishi_1.Schema.string().description("VTC ID(用于TMP API)").default("")
|
|
115
|
+
}).description("API配置"),
|
|
116
|
+
admin: koishi_1.Schema.object({
|
|
117
|
+
checkTimes: koishi_1.Schema.array(koishi_1.Schema.string()).role("table").description("活动检查时间(HH:mm格式)").default(["08:00", "12:00", "14:00", "20:00"]),
|
|
118
|
+
sendTimes: koishi_1.Schema.array(koishi_1.Schema.string()).role("table").description("信息发送时间(HH:mm格式)").default(["08:05", "12:05", "14:05", "20:05"]),
|
|
119
|
+
groups: koishi_1.Schema.array(koishi_1.Schema.string()).role("table").description("管理群组ID列表").default([])
|
|
120
|
+
}).description("管理群配置"),
|
|
121
|
+
dataSource: koishi_1.Schema.object({
|
|
122
|
+
serverSource: koishi_1.Schema.union([
|
|
123
|
+
koishi_1.Schema.const("platform").description("车队平台API"),
|
|
124
|
+
koishi_1.Schema.const("tmp").description("TMP API")
|
|
125
|
+
]).description("服务器信息来源").default("tmp"),
|
|
126
|
+
startPointSource: koishi_1.Schema.union([
|
|
127
|
+
koishi_1.Schema.const("platform").description("车队平台API"),
|
|
128
|
+
koishi_1.Schema.const("tmp").description("TMP API")
|
|
129
|
+
]).description("起点信息来源").default("tmp"),
|
|
130
|
+
endPointSource: koishi_1.Schema.union([
|
|
131
|
+
koishi_1.Schema.const("platform").description("车队平台API"),
|
|
132
|
+
koishi_1.Schema.const("tmp").description("TMP API")
|
|
133
|
+
]).description("终点信息来源").default("tmp"),
|
|
134
|
+
showBanner: koishi_1.Schema.boolean().description("是否显示活动横幅").default(false)
|
|
135
|
+
}).description("数据源配置"),
|
|
136
|
+
messages: koishi_1.Schema.object({
|
|
137
|
+
profileUploaded: koishi_1.Schema.string().description("活动档已上传时的消息").default("今日活动档已做/上传"),
|
|
138
|
+
profileNotUploaded: koishi_1.Schema.string().description("活动档未上传时的消息").default("今日活动档还没做,请负责的管理注意!")
|
|
139
|
+
}).description("管理群消息配置"),
|
|
140
|
+
noActivity: koishi_1.Schema.object({
|
|
141
|
+
enable: koishi_1.Schema.boolean().description("启用今日无活动通知").default(false),
|
|
142
|
+
time: koishi_1.Schema.string().description("今日无活动通知发送时间(HH:mm格式)").default("09:00"),
|
|
143
|
+
message: koishi_1.Schema.string().description("今日无活动通知消息").default("今日没活动")
|
|
144
|
+
}).description("无活动通知配置"),
|
|
145
|
+
mainGroup: koishi_1.Schema.object({
|
|
146
|
+
groups: koishi_1.Schema.array(koishi_1.Schema.string()).role("table").description("主群群号列表").default([]),
|
|
147
|
+
activityReminderMessage: koishi_1.Schema.string().description("活动提醒消息模板,支持变量:{name}, {server}, {startingPoint}, {terminalPoint}, {distance}, {banner}, {timeLeft}").default("活动 {name} 还有 {timeLeft} 分钟就要开始啦!\n服务器: {server}\n起点: {startingPoint}\n终点: {terminalPoint}\n距离: {distance}KM"),
|
|
148
|
+
activityStartReminderMessage: koishi_1.Schema.string().description("活动开始提醒消息模板,支持变量:{name}, {server}, {startingPoint}, {terminalPoint}, {distance}, {banner}").default("活动 {name} 现在开始集合啦!\n服务器: {server}\n起点: {startingPoint}\n终点: {terminalPoint}\n距离: {distance}KM\n活动将于20:30分开始!"),
|
|
149
|
+
activityReminderTimes: koishi_1.Schema.array(koishi_1.Schema.number()).role("table").description("活动开始前提醒时间(分钟)").default([60, 30, 15])
|
|
150
|
+
}).description("主群配置"),
|
|
151
|
+
debug: koishi_1.Schema.object({
|
|
152
|
+
debugMode: koishi_1.Schema.boolean().description("启用调试模式").default(false),
|
|
153
|
+
logApiResponses: koishi_1.Schema.boolean().description("记录API响应详情").default(false),
|
|
154
|
+
logTimingDetails: koishi_1.Schema.boolean().description("记录定时任务执行详情").default(false),
|
|
155
|
+
logActivityMatching: koishi_1.Schema.boolean().description("记录活动匹配过程").default(false),
|
|
156
|
+
logMessageSending: koishi_1.Schema.boolean().description("记录消息发送详情").default(false)
|
|
157
|
+
}).description("开发者选项")
|
|
158
|
+
}).description("活动查询配置")
|
|
159
|
+
}).description('功能配置')
|
|
160
|
+
]);
|
|
161
|
+
|
|
162
|
+
function registerBaseCommands(ctx, cfg) {
|
|
163
|
+
if (cfg.commands?.tmpQuery) {
|
|
164
|
+
ctx.command('查询 <tmpId>')
|
|
165
|
+
.usage("查询TMP玩家信息")
|
|
166
|
+
.action(async ({ session }, tmpId) => await commands.tmpQuery(ctx, cfg, session, tmpId));
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
if (cfg.commands?.tmpServer) {
|
|
170
|
+
ctx.command('美卡服务器')
|
|
171
|
+
.usage("查询美国卡车模拟器TMP服务器信息")
|
|
172
|
+
.action(async () => await commands.tmpServer(ctx, cfg, 'ATS'));
|
|
173
|
+
|
|
174
|
+
ctx.command('欧卡服务器')
|
|
175
|
+
.usage("查询欧洲卡车模拟2TMP服务器信息")
|
|
176
|
+
.action(async () => await commands.tmpServer(ctx, cfg, 'ETS2'));
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
if (cfg.commands?.tmpQuery) {
|
|
180
|
+
ctx.command('绑定 <tmpId>')
|
|
181
|
+
.usage("绑定TmpId")
|
|
182
|
+
.action(async ({ session }, tmpId) => await commands.tmpBind(ctx, cfg, session, tmpId));
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
if (cfg.commands?.tmpTraffic) {
|
|
186
|
+
ctx.command('路况 <serverName>')
|
|
187
|
+
.usage("查询欧洲卡车模拟2服务器路况")
|
|
188
|
+
.example("路况 - s1")
|
|
189
|
+
.action(async ({ session }, serverName) => await commands.tmpTraffic(ctx, cfg, serverName));
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
if (cfg.commands?.tmpPosition) {
|
|
193
|
+
ctx.command('定位 <tmpId>')
|
|
194
|
+
.usage("定位玩家线上位置")
|
|
195
|
+
.action(async ({ session }, tmpId) => await commands.tmpPosition(ctx, cfg, session, tmpId));
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
if (cfg.commands?.tmpVersion) {
|
|
199
|
+
ctx.command('tmp版本')
|
|
200
|
+
.usage("查询TruckersMP支持的游戏版本")
|
|
201
|
+
.action(async () => await commands.tmpVersion(ctx));
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
if (cfg.commands?.tmpDlcMap) {
|
|
205
|
+
ctx.command('地图dlc价格')
|
|
206
|
+
.usage("查询欧洲卡车模拟2地图dlc价格")
|
|
207
|
+
.action(async ({ session }) => await commands.tmpDlcMap(ctx, session));
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
if (cfg.commands?.tmpMileageRanking) {
|
|
211
|
+
ctx.command('里程排行榜')
|
|
212
|
+
.usage("查询欧洲卡车模拟2里程排行榜")
|
|
213
|
+
.action(async ({ session }) => await commands.tmpMileageRanking(ctx, session, MileageRankingType.total));
|
|
214
|
+
|
|
215
|
+
ctx.command('今日里程排行榜')
|
|
216
|
+
.usage("查询欧洲卡车模拟2今日里程排行榜")
|
|
217
|
+
.action(async ({ session }) => await commands.tmpMileageRanking(ctx, session, MileageRankingType.today));
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
if (cfg.commands?.tmpVtc) {
|
|
221
|
+
ctx.command('vtc查询 <vtcid>')
|
|
222
|
+
.usage("查询TruckersMP VTC信息")
|
|
223
|
+
.action(async ({ session }, vtcid) => await commands.tmpVtc(ctx, cfg, session, vtcid));
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
if (cfg.commands?.resetPassword) {
|
|
227
|
+
ctx.command(`重置密码 [targetTeamId:string]`, "重置欧卡车队平台密码")
|
|
228
|
+
.usage("重置自己的密码,或管理员重置指定teamId的密码")
|
|
229
|
+
.example(`重置密码 - 重置自己的密码`)
|
|
230
|
+
.example(`重置密码 - 管理员重置指定teamId的密码`)
|
|
231
|
+
.action(async ({ session }, targetTeamId) => await commands.resetPassword(ctx, cfg, session, targetTeamId));
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
if (cfg.commands?.mainSettings) {
|
|
235
|
+
ctx.command(`查询积分 [targetQQ:string]`, "查询欧卡车队平台积分")
|
|
236
|
+
.usage("查询自己或指定QQ号的积分,在群聊中可@他人查询")
|
|
237
|
+
.example(`查询积分 - 查询自己的积分`)
|
|
238
|
+
.example(`查询积分 123456 - 查询指定QQ号的积分`)
|
|
239
|
+
.action(async ({ session }, targetQQ) => await commands.queryPoint(ctx, cfg, session, targetQQ));
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
ctx.command('规则查询')
|
|
243
|
+
.action(async () => 'TruckersMP官方规则链接:https://truckersmp.com/knowledge-base/article/746');
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
function apply(ctx, cfg) {
|
|
247
|
+
try {
|
|
248
|
+
model(ctx);
|
|
249
|
+
if (cfg.debugMode) {
|
|
250
|
+
ctx.logger.debug("[TMP-BOT] 数据库模型初始化成功");
|
|
251
|
+
}
|
|
252
|
+
} catch (error) {
|
|
253
|
+
ctx.logger.error("[TMP-BOT] 数据库模型初始化失败:", error.message);
|
|
254
|
+
return;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
registerBaseCommands(ctx, cfg);
|
|
258
|
+
|
|
259
|
+
if (cfg.commands?.tmpActivityService) {
|
|
260
|
+
const activityConfig = {
|
|
261
|
+
...cfg.tmpActivityService,
|
|
262
|
+
debugMode: cfg.debugMode,
|
|
263
|
+
debug: cfg.tmpActivityService.debug
|
|
264
|
+
};
|
|
265
|
+
const activityService = new ActivityService(ctx, activityConfig);
|
|
266
|
+
activityService.start();
|
|
267
|
+
} else if (cfg.debugMode) {
|
|
268
|
+
ctx.logger.debug("[TMP-BOT] 活动查询功能已禁用");
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
__name(apply, "apply");
|
|
272
|
+
0 && (module.exports = {
|
|
273
|
+
Config,
|
|
274
|
+
apply,
|
|
275
|
+
name
|
|
276
|
+
});
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8">
|
|
5
|
+
<title>DLC</title>
|
|
6
|
+
<style>
|
|
7
|
+
#dlc-info-container {
|
|
8
|
+
width: 600px;
|
|
9
|
+
background-color: #222d33;
|
|
10
|
+
padding: 14px;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.dlc-box {
|
|
14
|
+
display: flex;
|
|
15
|
+
flex-direction: row;
|
|
16
|
+
box-sizing: border-box;
|
|
17
|
+
padding: 12px;
|
|
18
|
+
margin-top: 12px;
|
|
19
|
+
background-size: cover;
|
|
20
|
+
background-repeat: no-repeat;
|
|
21
|
+
background-position: center;
|
|
22
|
+
}
|
|
23
|
+
.dlc-box:nth-of-type(1) {
|
|
24
|
+
margin-top: 0;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.dlc-box .header-image {
|
|
28
|
+
width: 210px;
|
|
29
|
+
display: inline-block;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.dlc-box .dlc-info {
|
|
33
|
+
flex: 1;
|
|
34
|
+
width: 0;
|
|
35
|
+
//border: 1px solid red;
|
|
36
|
+
box-sizing: border-box;
|
|
37
|
+
padding: 2px 12px;
|
|
38
|
+
}
|
|
39
|
+
.dlc-info .name {
|
|
40
|
+
color: #ffffff;
|
|
41
|
+
font-size: 18px;
|
|
42
|
+
font-weight: 600;
|
|
43
|
+
overflow: hidden;
|
|
44
|
+
text-overflow: ellipsis;
|
|
45
|
+
white-space: nowrap;
|
|
46
|
+
}
|
|
47
|
+
.dlc-info .desc {
|
|
48
|
+
color: #e5e5e5;
|
|
49
|
+
font-size: 14px;
|
|
50
|
+
overflow: hidden;
|
|
51
|
+
text-overflow: ellipsis;
|
|
52
|
+
display: -webkit-box;
|
|
53
|
+
-webkit-line-clamp: 2;
|
|
54
|
+
-webkit-box-orient: vertical;
|
|
55
|
+
}
|
|
56
|
+
.dlc-info .price-box {
|
|
57
|
+
margin-top: 8px;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.dlc-info .price-box span {
|
|
61
|
+
display: inline-block;
|
|
62
|
+
color: #BEEE11;
|
|
63
|
+
font-size: 16px;
|
|
64
|
+
}
|
|
65
|
+
.dlc-info .price-box .discount-price {
|
|
66
|
+
color: #cbcbcb;
|
|
67
|
+
text-decoration: line-through;
|
|
68
|
+
}
|
|
69
|
+
.dlc-info .price-box .discount {
|
|
70
|
+
font-size: 14px;
|
|
71
|
+
color: #BEEE11;
|
|
72
|
+
background-color: #4c6b22;
|
|
73
|
+
padding: 2px 6px;
|
|
74
|
+
margin-left: 4px;
|
|
75
|
+
}
|
|
76
|
+
</style>
|
|
77
|
+
</head>
|
|
78
|
+
<body>
|
|
79
|
+
<div id="dlc-info-container">
|
|
80
|
+
</div>
|
|
81
|
+
|
|
82
|
+
<script>
|
|
83
|
+
function setData(dlcList) {
|
|
84
|
+
// 遍历渲染DLC列表
|
|
85
|
+
for (let dlc of dlcList) {
|
|
86
|
+
let dom = document.createElement(`div`);
|
|
87
|
+
dom.className = 'dlc-box';
|
|
88
|
+
dom.style.backgroundImage = `url('${dlc.backgroundImageUrl}')`;
|
|
89
|
+
|
|
90
|
+
let priceDiscountDom = ''
|
|
91
|
+
if (dlc.discount > 0) {
|
|
92
|
+
priceDiscountDom = `
|
|
93
|
+
<span class="discount-price">¥${Math.ceil(dlc.originalPrice / 100)}</span>
|
|
94
|
+
<span class="discount">-${dlc.discount}%</span>
|
|
95
|
+
`;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
dom.innerHTML = `
|
|
99
|
+
<img class="header-image" src="${dlc.headerImageUrl}"/>
|
|
100
|
+
<div class="dlc-info">
|
|
101
|
+
<div class="name">${dlc.name}</div>
|
|
102
|
+
<div class="desc">${dlc.desc}</div>
|
|
103
|
+
<div class="price-box">
|
|
104
|
+
<span>¥${Math.ceil(dlc.finalPrice / 100)}</span>
|
|
105
|
+
${priceDiscountDom}
|
|
106
|
+
</div>
|
|
107
|
+
</div>
|
|
108
|
+
`;
|
|
109
|
+
|
|
110
|
+
document.querySelector('#dlc-info-container').appendChild(dom);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
</script>
|
|
114
|
+
</body>
|
|
115
|
+
</html>
|