From 1404d4666b539bdf470a6dd5429de72f6f9fb074 Mon Sep 17 00:00:00 2001 From: shijian <2954700422@qq.com> Date: Mon, 4 Dec 2023 09:22:18 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=BA=E5=85=B6=E4=BB=96=E8=87=AA=E5=AE=9A?= =?UTF-8?q?=E4=B9=89=E5=B9=B3=E5=8F=B0=E6=8F=90=E4=BE=9B=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E8=AF=BB=E5=86=99=E5=87=BD=E6=95=B0=E8=B5=8B=E5=80=BC=E7=9A=84?= =?UTF-8?q?=E4=B8=80=E7=A7=8D=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- game/game.js | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/game/game.js b/game/game.js index e87d54ecb..6ef70f010 100644 --- a/game/game.js +++ b/game/game.js @@ -10284,14 +10284,33 @@ new Promise(resolve=>{ } } else{ - window.onbeforeunload=function(){ - if(lib.config.confirm_exit&&!_status.reloading){ + //为其他自定义平台提供文件读写函数赋值的一种方式。 + //但这种方式只能修改game的文件读写函数。 + if(window.initRWFunction){ + const g={}; + const RWFunctionName=['download','readFile','readFileAsText','writeFile','removeFile','getFileList','ensureDirectory','createDir']; + RWFunctionName.forEach(prop=>{ + Object.defineProperty(g,prop,{ + configurable:true, + get(){ return undefined; }, + set(newValue) { + if(typeof newValue=='function'){ + delete g[prop]; + g[prop]=game[prop]=newValue; + } + } + }) + }); + window.initRWFunction(g); + } + window.onbeforeunload = function () { + if (lib.config.confirm_exit && !_status.reloading) { return '是否离开游戏?' } - else{ + else { return null; } - } + }; } lib.config=window.config;