Commit d2999c75 authored by 神楽坂玲奈's avatar 神楽坂玲奈

some file

parent 5577fb23
const raw = require('raw-socket');
const socket = raw.createSocket({ protocol: raw.Protocol.UDP });
const handler = {
connect(local_port, remote_port, remote_address) {
let buffer = Buffer.alloc(9);
buffer.writeUInt16BE(local_port, 0);
buffer.writeUInt16BE(remote_port, 2);
buffer.writeUInt16BE(buffer.length, 4);
socket.send(buffer, 0, buffer.length, remote_address, (error, bytes) => {
if (error) {
throw error;
}
});
},
};
process.on('message', (message) => {
handler[message.action](...message.arguments);
});
process.on('disconnect', process.exit);
process.send('initialized');
This diff is collapsed.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<!--<meta name="description" content="">-->
<!--<meta name="author" content="">-->
<!--<link rel="icon" href="../../favicon.ico">-->
<title id="title"></title>
<!-- Bootstrap core CSS -->
<link href="node_modules/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet">
<script src="node_modules/vue/dist/vue.min.js"></script>
<style>
h1 {
margin-top: 10px;
margin-bottom: 20px;
text-align: center;
}
#actions {
margin-top: 20px;
text-align: center;
}
</style>
</head>
<body>
<div id="vueApp">
<div class="container">
<h1>{{pageText.updateTitle}}</h1>
<p v-for="(msg, index) in pageText.updateMsg" >{{msg}}</p>
<p>{{pageText.updateFailed.p1}} <a href="https://mycard.moe" target="_blank">{{pageText.updateFailed.p2}}</a> {{pageText.updateFailed.p3}}</p>
<p id="actions">
<button @click="onClose" type="button" class="btn btn-secondary">{{pageText.actions.close}}</button>
<button @click="onUpdate" type="button" class="btn btn-primary">{{pageText.actions.update}}</button>
</p>
</div>
</div>
<script>
const {ipcRenderer, remote} = require('electron');
const lang = require('./lang.js')
var app = new Vue({
el: '#vueApp',
created: function () {
let locale = localStorage.getItem('locale') || remote.app.getLocale();
if (locale.startsWith('zh-')) {
locale = 'zh-CN'
} else {
locale = 'en-US'
}
this.pageText = lang['update'][locale]
document.getElementById('title').innerHTML = this.pageText.pageTitle
},
methods: {
onClose(){
window.close()
},
onUpdate(){
ipcRenderer.send('update')
}
},
data: {
message: 'Hello Vue!',
pageText:{}
}
})
</script>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link href="../node_modules/font-awesome/css/font-awesome.min.css" rel="stylesheet" />
<style>
@font-face {
font-family: 'Mogra';
font-style: normal;
font-weight: 400;
src: url('../font/Mogra-Regular.ttf');
}
html,div,body,td,tr{
background: rgba(0,0,0,0);
font-size:14px;
font-family:-apple-system, Arial, 'Source Sans Pro', "Microsoft YaHei", 'Microsoft JhengHei', "WenQuanYi Micro Hei", sans-serif;
/*font-family: Mogra;*/
padding:0;
margin:0;
/*color:#00a4d9;*/
}
td{
line-height: 17px;
}
i:hover {
color: #0b88b1;
}
.window{
padding:5px;
border: #00a4d9 1px solid;
width:200px;
position: relative;
height: 220px;
}
.icon{
width:60px;
height:60px;
float: left;
}
.icon img{
height: 100%
}
.info{
float:left;
line-height: 20px;
}
.again{
cursor: pointer;
font-size: 12px;
background:#00a4d9;
color:#fff;
border-radius: 15px;
width:130px;
height: 30px;
line-height: 30px;
text-align: center;
margin:5px auto 0;
position: absolute;
bottom : 5px;
left: 35px;
}
.red{
color:red;
}
.green{
color:green;
}
.close{
position:absolute;
top:5px;
left:5px;
z-index: 999;
}
#winOrLose{
position: absolute;
right: 5px;
top: 5px;
}
#winOrLose div{
font-family: Mogra;
font-weight: 900;
font-size: 25px;
display: none;
}
#win{
color:#00a4d9;
}
#lose{
color:#922
}
#draw{
color: green;
}
#title{
text-align: center;
}
#info td:nth-child(1){
width:70px;
}
#rewards td:nth-child(1){
width:150px;
}
</style>
</head>
<body>
<div class="window">
<i onclick="window.opener=null;window.close();" class="fa fa-times close" title="关闭"></i>
<div>
<div id="title"></div>
<div>
<div class="icon">
<img id="icon" src="https://ygobbs.com/user_avatar/ygobbs.com/breakegg/25/1.png"/>
</div>
<div class="info">
<span id="myName">myname</span>
<table id="info">
</table>
</div>
</div>
<div id="winOrLose">
<div id="win">Win!</div>
<div id="lose">LOSE</div>
<div id="draw">DRAW</div>
</div>
<div style="clear:both"></div>
</div>
<hr/>
<div>
奖励结算
<table id="rewards">
</table>
<div class="again" onclick="again()">再来一局!</div>
</div>
</div>
<!--<div class="window">-->
<!--<div>-->
<!--<div id="title">竞技匹配</div>-->
<!--<div>-->
<!--<div class="icon">-->
<!--<img src="https://ygobbs.com/user_avatar/ygobbs.com/breakegg/25/1.png"/>-->
<!--</div>-->
<!--<div class="info">-->
<!--<span id="myName">myname</span>-->
<!--<table id="info">-->
<!--<tr>-->
<!--<td>胜:<span id="winTimes">11</span></td>-->
<!--<td>负:<span id="loseTimes">10</span></td>-->
<!--</tr>-->
<!--<tr>-->
<!--<td>排名:<span id="rank">10</span></td>-->
<!--<td><span id="EXPORDP">DP:</span><span id="EXP_DP">793</span></td>-->
<!--</tr>-->
<!--</table>-->
<!--</div>-->
<!--</div>-->
<!--<div id="winOrLose">-->
<!--<div id="win">Win!</div>-->
<!--<div id="lose">LOSE</div>-->
<!--<div id="draw">DRAW</div>-->
<!--</div>-->
<!--<div style="clear:both"></div>-->
<!--</div>-->
<!--<hr/>-->
<!--<div>-->
<!--奖励结算-->
<!--<table id="rewards">-->
<!--<tr>-->
<!--<td>D.P</td>-->
<!--<td>+7</td>-->
<!--</tr>-->
<!--<tr>-->
<!--<td>EXP</td>-->
<!--<td>+1</td>-->
<!--</tr>-->
<!--<tr>-->
<!--<td>D.P(首胜)</td>-->
<!--<td>+4</td>-->
<!--</tr>-->
<!--</table>-->
<!--<div class="again">再来一局!</div>-->
<!--</div>-->
<!--</div>-->
<script>
window.exports = {}
</script>
<script src="end_YGOPro_single.js"></script>
</body>
</html>
/**
* Created by break on 2017/6/9.
*/
import $ from 'jquery';
let data_url = (new URL(document.location.toString())).searchParams;
let data_str = data_url.get('data');
// {
// "usernamea": "Joe1991",
// "usernameb": "zh99998",
// "userscorea": 1,
// "userscoreb": 2,
// "expa": 1,
// "expb": 30,
// "expa_ex": 0.5,
// "expb_ex": 29,
// "pta": -2.45677803214143,
// "ptb": 562.760086898395,
// "pta_ex": -1.25048918195558,
// "ptb_ex": 561.553798048209,
// "type": "athletic",
// "start_time": "2017-06-17T12:26:33.000Z",
// "end_time": "2017-06-17T12:26:33.000Z",
// "winner": "zh99998",
// "isfirstwin": false,
// "myname":"zh99998",
// "athletic_win":23,
// "athletic_lose":0,
// "entertain_win":7,
// "entertain_lose":0,
// "exp_rank":"1685",
// "arena_rank":"335",
// "exp_rank_ex":"1685",
// "arena_rank_ex":"335",
// }
let data = JSON.parse(data_str!);
let titleStr;
let icon = 'https://ygobbs.com/user_avatar/ygobbs.com/' + data.myname + '/120/1.png';
let myMame = data.myname;
let winTimes, loseTimes, rank, rank_up, DP, DP_up, DP_up_sum, EXP, EXP_up;
let winOrLose = 0;
let isMyFirstWin;
if (data.type === 'entertain') {
titleStr = '娱乐匹配';
winTimes = data.entertain_win;
loseTimes = data.entertain_lose;
rank = data.exp_rank;
rank_up = data.exp_rank_ex - data.exp_rank ;
} else {
titleStr = '竞技匹配';
winTimes = data.athletic_win;
loseTimes = data.athletic_lose;
rank = data.arena_rank;
rank_up = data.arena_rank_ex - data.arena_rank ;
}
if (data.usernamea === data.myname) {
if ( data.userscorea > data.userscoreb) {
winOrLose = 1;
}else if ( data.userscorea < data.userscoreb) {
winOrLose = -1;
}else {
winOrLose = 0;
}
DP = parseInt(data.pta);
DP_up_sum = Math.floor( data.pta - data.pta_ex );
EXP = parseInt(data.expa);
EXP_up = Math.floor( data.expa - data.expa_ex );
}else {
if ( data.userscorea < data.userscoreb) {
winOrLose = 1;
}else if ( data.userscorea > data.userscoreb) {
winOrLose = -1;
}else {
winOrLose = 0;
}
DP = parseInt(data.ptb);
DP_up_sum = Math.floor( data.ptb - data.ptb_ex );
EXP = parseInt(data.expb);
EXP_up = Math.floor( data.expb - data.expb_ex );
}
isMyFirstWin = (winOrLose > 0 && data.isfirstwin) ? true : false;
DP_up = DP_up_sum - (isMyFirstWin ? 4 : 0);
// =========================================================================
$('#title').html(titleStr);
$('#icon').attr('src', icon);
$('#myName').html(myMame);
$('#' + (winOrLose ? (winOrLose > 0 ? 'win' : 'lose') : 'draw') ).show();
let tr1 = '<tr>' +
'<td>胜:<span class="' + (winOrLose > 0 ? 'green' : '') + '">' + winTimes + '</span></td>' +
'<td>负:<span class="' + (winOrLose < 0 ? 'red' : '') + '">' + loseTimes + '</span></td>' +
'</tr>';
let tr2 = `<tr>
<td>排名:<span id="rank" class="${rank_up ? (rank_up > 0 ? 'green' : 'red') : '' } ">${rank}</span></td>
<td>${data.type === 'entertain' ? 'EXP:' : 'DP:'}
<span id="EXP_DP" ${data.type === 'entertain' ?
('class="' + (EXP_up > 0 ? 'green' : (EXP_up < 0 ? 'red' : '')) + '">' + EXP) :
('class="' + (DP_up_sum > 0 ? 'green' : (DP_up_sum < 0 ? 'red' : '')) + '">' + DP)
}</span>
</td>
</tr>`;
$('#info').append(tr1).append(tr2);
let tr_DP = DP_up ? `
<tr>
<td>D.P</td>
${DP_up > 0 ? `<td class="green">+${ DP_up }</td>` : `<td class="red">${ DP_up }</td>`}
</tr>
` : ``;
let tr_EXP = EXP_up ? `
<tr>
<td>EXP</td>
${EXP_up > 0 ? `<td class="green">+${ EXP_up }</td>` : `<td class="red">${ EXP_up }</td>`}
</tr>
` : ``;
let tr_FirstWin = isMyFirstWin ? `
<tr>
<td>首胜</td>
<td class="green">+4</td>
</tr>
` : ``
let tr_rewards = tr_EXP + tr_DP + tr_FirstWin;
tr_rewards = tr_rewards === '' ? '<tr><td>无</td></tr>' : tr_rewards;
$('#rewards').append(tr_rewards);
function again() {
let {ipcRenderer} = require('electron');
ipcRenderer.send('YGOPro', data.type);
window.opener=null;
window.close();
}
let t = setTimeout(function () {
window.opener = null;
window.close();
}, 5000);
$('html').hover(function () {
clearTimeout(t);
});
......@@ -5,6 +5,7 @@ module.exports = {
externals: {
bufferutil: 'commonjs2 bufferutil',
'utf-8-validate': 'commonjs2 utf-8-validate',
'raw-socket': 'commonjs2 raw-socket',
},
plugins: [
new CopyPlugin({
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment