Skip to content

Commit

Permalink
fix(aigis): support wasm
Browse files Browse the repository at this point in the history
  • Loading branch information
Yukimir committed Mar 11, 2021
1 parent 9b73653 commit 4bff0e1
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 14 deletions.
40 changes: 27 additions & 13 deletions assets/js/fixPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,27 +80,46 @@ ipcrender.on('frame', (event, message) => {
// TODO: 这俩抽到别的文件里去
// 减速
var slow = false;
var skip = 4;

var fps = 15;
var now;
var then = Date.now();
var interval = 1000 / fps;
var delta;
var draw;
// 劫持reqeustAnimationFrame
window['oldRequestAnimationFrame'] = window.requestAnimationFrame;
function genSkipFrame(func) {
return () => {
window['oldRequestAnimationFrame'](func);
};
}
function tick(draw) {
function tick(func) {
if (slow) {
var func = draw;
for (let i = 0; i < skip; i++) {
func = genSkipFrame(func);
if (typeof (func) === "function") draw = func;
now = Date.now();
delta = now - then;
if (delta > interval) {
then = now - (delta % interval);
var temp = draw;
draw = null;
window['oldRequestAnimationFrame'](temp);
} else {
window['oldRequestAnimationFrame'](tick);
}
func();
} else {
window['oldRequestAnimationFrame'](draw);
if (draw) func = draw;
window['oldRequestAnimationFrame'](func);
}
}
window.requestAnimationFrame = tick;

// var oldFetch = window.fetch;
// window.fetch = function () {
// console.log('fetch triggered!', this.location, arguments);
// return oldFetch.apply(this, arguments);
// }

// 暂停
var pauseElement = document.createElement('div');
pauseElement.style.position = 'fixed';
Expand Down Expand Up @@ -129,15 +148,10 @@ ipcrender.on('aigis-tick', (event, message) => {
slow = message;
});

var r18Meta = {
create: 'gKb',
remove: 'zKb',
delete: 'TUb'
};
var allMeta = {};
window.process = undefined;
if (location.hostname === 'r.kamihimeproject.net') {
window.require = undefined;
window.process = undefined;
}
// if (location.hostname === 'assets.millennium-war.net') {
// // 暂时屏蔽全年龄版
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "aigisplayer",
"version": "2.2.4",
"version": "2.2.5",
"description": "Toolkit for Aigis",
"productName": "AigisPlayer",
"homepage": "https://github.com/DogReactor/AigisPlayer",
Expand Down

0 comments on commit 4bff0e1

Please sign in to comment.