This repository has been archived by the owner on Apr 16, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 15.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #922 from makeding/huggy_edit
更新 UA 列表,更改随机 UA 相关逻辑
- Loading branch information
Showing
7 changed files
with
279 additions
and
261 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,5 @@ | ||
.DS_Store | ||
node_modules | ||
*.log | ||
|
||
.idea/ | ||
|
||
|
||
.idea | ||
.vscode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,80 +1,82 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>更新头像</title> | ||
</head> | ||
<body> | ||
<input id="file" type="file" name="filename" /> | ||
<img id="avatar" style="height: 200px; width: 200px; border-radius: 50%;" /> | ||
<script src="https://cdn.bootcdn.net/ajax/libs/axios/0.20.0-0/axios.min.js | ||
<html lang="zh"> | ||
|
||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>更新头像</title> | ||
</head> | ||
|
||
<body> | ||
<input id="file" type="file" name="filename" /> | ||
<img id="avatar" style="height: 200px; width: 200px; border-radius: 50%;" /> | ||
<script src="https://cdn.bootcdn.net/ajax/libs/axios/0.20.0-0/axios.min.js | ||
"></script> | ||
<script> | ||
const phone = '' | ||
const password = '' | ||
const port = 3000 | ||
let cookieToken = '' | ||
if (!phone || !password) { | ||
const msg = '请设置你的手机号码和密码' | ||
alert(msg) | ||
throw new Error(msg) | ||
} | ||
<script> | ||
const phone = '' | ||
const password = '' | ||
let cookieToken = '' | ||
if (!phone || !password) { | ||
const msg = '请设置你的手机号码和密码' | ||
alert(msg) | ||
throw new Error(msg) | ||
} | ||
|
||
main() | ||
login() | ||
async function main() { | ||
document.querySelector('input[type="file"]').addEventListener( | ||
'change', | ||
function (e) { | ||
var file = this.files[0] | ||
upload(file) | ||
}, | ||
false | ||
) | ||
const res = await axios({ | ||
url: `http://localhost:${port}/user/detail?uid=32953014×tamp=${Date.now()}`, | ||
withCredentials: true, //关键 | ||
}) | ||
document.querySelector('#avatar').src = res.data.profile.avatarUrl | ||
} | ||
async function login() { | ||
const res = await axios({ | ||
url: `http://localhost:${port}/login/cellphone?phone=${phone}&password=${password}`, | ||
withCredentials: true, //关键 | ||
}) | ||
cookieToken = res.data.cookie | ||
} | ||
async function upload(file) { | ||
var formData = new FormData() | ||
formData.append('imgFile', file) | ||
const imgSize = await getImgSize(file) | ||
const res = await axios({ | ||
method: 'post', | ||
url: `http://localhost:3000/avatar/upload?cookie=${cookieToken}&imgSize=${imgSize.width}&imgX=0&imgY=0×tamp=${Date.now()}`, | ||
headers: { | ||
'Content-Type': 'multipart/form-data', | ||
}, | ||
data: formData, | ||
}) | ||
document.querySelector('#avatar').src = res.data.data.url | ||
} | ||
function getImgSize(file) { | ||
return new Promise((resolve, reject) => { | ||
let reader = new FileReader() | ||
reader.readAsDataURL(file) | ||
reader.onload = function (theFile) { | ||
let image = new Image() | ||
image.src = theFile.target.result | ||
image.onload = function () { | ||
resolve({ | ||
width: this.width, | ||
height: this.height | ||
}) | ||
} | ||
main() | ||
login() | ||
async function main() { | ||
document.querySelector('input[type="file"]').addEventListener( | ||
'change', | ||
function (e) { | ||
var file = this.files[0] | ||
upload(file) | ||
}, | ||
false | ||
) | ||
const res = await axios({ | ||
url: `/user/detail?uid=32953014×tamp=${Date.now()}`, | ||
withCredentials: true, //关键 | ||
}) | ||
document.querySelector('#avatar').src = res.data.profile.avatarUrl | ||
} | ||
async function login() { | ||
const res = await axios({ | ||
url: `/login/cellphone?phone=${phone}&password=${password}`, | ||
withCredentials: true, //关键 | ||
}) | ||
cookieToken = res.data.cookie | ||
} | ||
async function upload(file) { | ||
var formData = new FormData() | ||
formData.append('imgFile', file) | ||
const imgSize = await getImgSize(file) | ||
const res = await axios({ | ||
method: 'post', | ||
url: `http://localhost:3000/avatar/upload?cookie=${cookieToken}&imgSize=${imgSize.width}&imgX=0&imgY=0×tamp=${Date.now()}`, | ||
headers: { | ||
'Content-Type': 'multipart/form-data', | ||
}, | ||
data: formData, | ||
}) | ||
document.querySelector('#avatar').src = res.data.data.url | ||
} | ||
function getImgSize(file) { | ||
return new Promise((resolve, reject) => { | ||
let reader = new FileReader() | ||
reader.readAsDataURL(file) | ||
reader.onload = function (theFile) { | ||
let image = new Image() | ||
image.src = theFile.target.result | ||
image.onload = function () { | ||
resolve({ | ||
width: this.width, | ||
height: this.height | ||
}) | ||
} | ||
}) | ||
} | ||
</script> | ||
</body> | ||
</html> | ||
} | ||
}) | ||
} | ||
</script> | ||
</body> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
346593e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs: