Skip to content

Commit

Permalink
1
Browse files Browse the repository at this point in the history
  • Loading branch information
himcs committed Nov 2, 2020
1 parent d14177b commit 66798dc
Show file tree
Hide file tree
Showing 5 changed files with 91 additions and 0 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/pause.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: 雷神自动停止加速

on: [push]

jobs:
build:
runs-on: ubuntu-latest
if: github.event.repository.owner.id == github.event.sender.id
steps:
- uses: actions/checkout@v1
- name: Use Node.js 10.x
uses: actions/setup-node@v1
with:
node-version: 10.x
- name: npm install
run: |
npm install
- name: "运行 【暂停】"
run: |
node main.js
env:
USERNAME: ${{ secrets.LEISHEN_USERNAME }}
PASSWORD: ${{ secrets.LEISHEN_PASSWORD }}
19 changes: 19 additions & 0 deletions api/auth.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
const request = require('../utils/request');

function login(data) {
return request({
url: '/api/auth/login',
method: 'post',
data
})
}

function pause(data) {
return request({
url: '/api/user/pause',
method: 'post',
data
})
}

module.exports = {login, pause}
35 changes: 35 additions & 0 deletions main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
const login = require("./api/auth").login;
const pause = require("./api/auth").pause;

const Secrets = {
username: process.env.LEISHEN_USERNAME,
password: process.env.LEISHEN_PASSWORD
}


function start(username, password) {
if (!username || !password) {
console.log("empty username or password");
return;
}
const user = {
"username": username,
"password": password,
"user_type": "0",
"src_channel": "guanwang",
"lang": "zh_CN",
"region_code": 1
};

login(user).then(res => {
if (res.data.code == 0) {
let account_token = res.data.data.login_info.account_token;
pause({"account_token": account_token, "lang": "zh_CN"}).then(res2 => {
console.log(res2);
})
}
})
}


start(Secrets.username, Secrets.password);
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"dependencies": {
"axios": "^0.21.0"
}
}
9 changes: 9 additions & 0 deletions utils/request.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const axios = require('axios');
const service = axios.create({
//https://webapi.leigod.com
baseURL: process.env.VUE_APP_BASE_API || "https://webapi.leigod.com/", // url = base url + request url
// withCredentials: true, // send cookies when cross-domain requests
timeout: 5000 // request timeout
})

module.exports = service

0 comments on commit 66798dc

Please sign in to comment.