代码拉取完成,页面将自动刷新
同步操作将从 BGWP/baye-alpha 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>云存档</title>
<link rel="stylesheet" type="text/css" href="css/baye.css?ver=1"/>
<link rel="icon" href="favicon.png">
<meta content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=no" id="viewport"
name="viewport">
</head>
<body>
<header style="padding: 10px 0;position: relative">
<h3>云存档管理<span class="online-save-msg" style="font-size: .8em; font-weight: normal;padding: 0 10px"></span></h3>
<div>
<a href="https://baye.bbkgames.com">返回首页</a>
</div>
<div class="no-login" style="color: red;position: absolute;right: 0;top: 0">
<a href="https://graph.qq.com/oauth2.0/authorize?response_type=code&client_id=102021419&redirect_uri=https%3A%2F%2Foauth.bbkgames.com%2Fqqcallback%3Furl%3Dhttps%3A%2F%2Fbaye.bbkgames.com%2Fonline-save.html&state=web">
<img src="https://img.bbkgames.com/web/image/bt_blue_76X24.png">
</a>
</div>
<div class="user-info" style="display: none;position: absolute;right: 0;top: 0">
<img class="avatar" src="https://baye.bbkgames.com/favicon.png" style="width: 32px;height: 32px">
</div>
选择版本: <select id="libs" style="height: 2em;line-height: 2em"></select>
</header>
<main>
<div class="online-save-slots"></div>
</main>
<script src="js/jquery.min.js"></script>
<script src="https://img.bbkgames.com/script/js-sdk.js?ver=202111140022"></script>
<script>
$(function () {
if ('undefined' === typeof BBKSDK) {
return;
}
let $libs = $('#libs');
let $onlineSaveMsg = $('.online-save-msg'), $onlineSaveSlots = $('.online-save-slots');
let savDir = ''; //来自登录接口返回
//尝试登录
BBKSDK.getUserInfo(function (res) {
if (!res || !res.nickname) {
return;
}
//save_dir
if (!res.sav_dir) {
showError('未找到存档dir, 请联系开发者');
return;
}
$('.no-login').hide();
$('.avatar').attr('src', res.avatar);
$('.user-info').show();
savDir = res.sav_dir;
});
//mod
$.get('https://baye.bbkgames.com/libs.json', res => {
if (0 === res.length) {
showError('加载lib列表失败');
return
}
$libs.empty();
for (let i = 0; i < res.length; i++) {
let $option = $('<option>');
$option.attr('value', res[i].path).text(res[i].title);
$libs.append($option);
}
renderSaveBtns();
});
//切换时重新加载
$libs.on('change', function () {
showMsg('');
renderSaveBtns();
});
//上传下载
$onlineSaveSlots.on('click', '.upload', function () {
let modName = $libs.val();
if ('' === modName) {
return;
}
modName = modName.split('/').pop();
let $this = $(this), index = $this.attr('data-index');
let localSave0 = localStorage.getItem('baye//data//sango' + (index * 2 - 2) + '.sav')
let localSave1 = localStorage.getItem('baye//data//sango' + (index * 2 - 1) + '.sav')
let data = localSave0 + '\n' + localSave1
$this.prop('disabled', true);
BBKSDK.uploadSave('baye', modName, index, data, function (res) {
$this.prop('disabled', false);
let data = JSON.parse(res);
if (data && 'undefined' !== typeof data.code) {
if (0 === data.code) {
showMsg('上传成功');
$this.parent().find('.save-time').text(`时间: ${data.msg || ''}`);
$this.parent().find('.download').prop('disabled', false).attr('data-url', data.data);
} else {
showError(`上传失败: ${data.msg}`);
}
} else {
showError(`上传失败`);
}
});
});
$onlineSaveSlots.on('click', '.download', function () {
let modName = $libs.val();
if ('' === modName) {
return;
}
modName = modName.split('/').pop();
let $this = $(this), index = $this.attr('data-index'), url = $this.attr('data-url');
$this.prop('disabled', true);
BBKSDK.getSave(url, function (res) {
$this.prop('disabled', false);
let arr = res.split('\n');
if (2 !== arr.length) {
showError('存档不存在或已损坏');
return;
}
//todo sav.lib有点硬编码
localStorage.setItem('baye//data//sango' + (index * 2 - 2) + '.sav.lib', "libs/" + modName);
localStorage.setItem('baye//data//sango' + (index * 2 - 1) + '.sav.lib', "libs/" + modName);
localStorage.setItem('baye//data//sango' + (index * 2 - 2) + '.sav', arr[0]);
localStorage.setItem('baye//data//sango' + (index * 2 - 1) + '.sav', arr[1]);
showMsg('导入成功');
$this.parent().find('.upload').prop('disabled', false);
});
});
//渲染基本dom 本地存档按钮
function renderSaveBtns() {
$onlineSaveSlots.empty();
let modName = $libs.val();
if ('' === modName) {
return;
}
modName = modName.split('/').pop();
//基本mod和本地存档按钮
for (let i = 0; i < 3; i++) {
let $item = $(`<div>
<span class="save-name"></span>
<button type="button" class="upload" disabled>上传</button>
<button type="button" class="download" disabled>下载</button>
<span class="save-time"></span>
</div>`);
$item.find('.save-name').text(`存档-${i + 1}`);
//本地存档
let localSaveLib0 = localStorage.getItem('baye//data//sango' + (i * 2) + '.sav.lib');
let localSaveLib1 = localStorage.getItem('baye//data//sango' + (i * 2 + 1) + '.sav.lib');
let localSave0 = localStorage.getItem('baye//data//sango' + (i * 2) + '.sav');
let localSave1 = localStorage.getItem('baye//data//sango' + (i * 2 + 1) + '.sav');
//本地是否有此mod的存档
let hasLocalSave = false;
if (localSave0 && localSave1 && localSaveLib0 && localSaveLib1
&& localSaveLib0 === localSaveLib1 && localSaveLib0.split('/').pop() === modName) {
hasLocalSave = true;
}
if (hasLocalSave) {
//本地有
$item.find('.upload').prop('disabled', false).attr('data-index', i + 1);
}
$onlineSaveSlots.append($item);
}
//如果已登录, 则加载线上存档状态
if (!savDir) {
return;
}
//加载线上存档状态
BBKSDK.getSaveIndex('baye', savDir, function (res) {
let slots = {};
if (res.length > 0) {
for (let i = 0; i < res.length; i++) {
hasData = true;
let item = res[i];
if ('baye' === item.game && modName === item.mod_name) {
slots[item.index] = item;
}
}
}
//开始渲染
for (let i = 0; i < 3; i++) {
let $item = $onlineSaveSlots.children().eq(i);
//线上存档
let data = slots[i + 1];
if ('undefined' !== typeof data) {
//线上有
$item.find('.download').prop('disabled', false).attr('data-index', i + 1).attr('data-url', data.file);
$item.find('.save-time').text(`时间: ${data.time || ''}`);
}
}
});
}
function showMsg(msg) {
$onlineSaveMsg.css({color: '#000'}).text(msg);
}
function showError(msg) {
$onlineSaveMsg.css({color: 'red'}).text(msg);
}
});
</script>
</body>
</html>
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。