You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

19 lines
501 B
JavaScript

let socket = io();
socket.on('connect', () => {
let persistToken = localStorage.getItem('playerToken')
if (persistToken) {
socket.emit('token:set', persistToken);
} else {
socket.emit('token:refresh');
}
});
socket.on('token:expired', () => { // token已过期重载整个播放器
socket.emit('token:refresh');
});
socket.on('token:update', (token) => { // 收到token
console.log('new token: ', token);
localStorage.setItem('playerToken', token)
});