
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
killglobal
Advanced tools
npm i killglobal --save
项目中使用:
pages/index/index.js
``
import { getWechat } from "killglobal";
const BasePage = getWechat().page;
const Router = getWechat().router;
Page(BasePage({
data:{},
onTapPage1(){ // 跳转到page1
//
/*
_page_onload_params: 页面启动参数, 同url+params
_kgData: 额外参数,传到另一个页面的数据,为了防止污染,_kgData会被深拷贝后传到page1页面
onPage: page1的实例(page1的onLoad被回调时,onPage才会被执行)
*/
const _page_onload_params = { onload: 'onload' };
const _kgData = { kgdata: 'kgdata' }
Router.push('pages/page1/index',_page_onload_params).withKGData(_kgData).onPage(page=>{
page.showAlert();
// 执行结果: I'm Page1!
});
},
}))
``
pages/page1/index.js
``
import { getWechat } from "killglobal";
const BasePage = getWechat().page;
const Router = getWechat().router;
Page(BasePage({
data:{},
onKGData(data){
console.log(params);
// 执行结果: { kgdata: 'kgdata' }
},
onLoad(params){
console.log(params);
// 执行结果: { onload: 'onload' }
}
showAlert(){
console.log("I'm Page1!");
},
}))
``
push 页面
router.navigateTo和另外两个功能一致,为了照顾个人习惯写了另外两个别名:goto、push
参数 :
path: string page的路径,绝对或相对路径
options: JSON格式的数据 例如:{a: 1, b: 2};,此数据会拼接到path(path?a=1&b=2)后面,在onLoad的入参options中捕获
push 页面
router.redirectTo和另外1个功能一致,为了照顾个人习惯写了另外1个别名:redirect
参数 :
path: string page的路径,绝对或相对路径
options: JSON格式的数据 例如:{a: 1, b: 2};,此数据会拼接到path(path?a=1&b=2)后面,在onLoad的入参options中捕获
返回 页面
router.navigateBack和另外1个功能一致,为了照顾个人习惯写了另外1个别名:back
参数 :
重启到某个页面
参数 :
path: string page的路径,绝对或相对路径
options: JSON格式的数据 例如:{a: 1, b: 2};,此数据会拼接到path(path?a=1&b=2)后面,在onLoad的入参options中捕获
函数: withKGData(obj)
向目标页面传递obj,为了保护数据不受污染,传到下一个页面的obj将被深拷贝,所以在目标页面操作obj不用担心前一个页面的数据收到影响
使用
在当前页面使用
pages/index/index.js
``
import { getWechat } from "killglobal";
const BasePage = getWechat().page;
const Router = getWechat().router;
Page(BasePage({
data:{},
gotoTargetPage(data){
const _obj = {a:1};
Router.navigateTo('/pages/target/index').withKGData(_obj);
// Router.redirectTo().withKGData(obj);
// Router.reLaunch().withKGData(obj);
// Router.navigateBack().withKGData(obj);
},
}))
``
在目标页面接收
pages/target/index.js
``
import { getWechat } from "killglobal";
const BasePage = getWechat().page;
Page(BasePage({
data:{},
onKGData(data){
console.log(params);
// 执行结果: {a:1}
},
}))
``
函数: onPage(page=>{})
使用
在当前页面使用
pages/index/index.js
``
import { getWechat } from "killglobal";
const BasePage = getWechat().page;
const Router = getWechat().router;
Page(BasePage({
data:{},
gotoTargetPage(data){
Router.navigateTo('/pages/target/index').onPage(page=>{
page.showAlert();
// 打印结果: I'm target!
});
// Router.redirectTo().onPage(page=>{});
// Router.reLaunch().onPage(page=>{});
// Router.navigateBack().onPage(page=>{});
},
}))
``
目标页面
pages/target/index.js
``
import { getWechat } from "killglobal";
const BasePage = getWechat().page;
Page(BasePage({
data:{},
showAlert(){
console.log("I'm target!")
},
}))
``
提供针对跳转目标page对象实例获取:
router.push('/pages/index').onPage(page=>{ console.log('跳转目标page的实例:', page); })
参数错误提示
修复递归调用的 deepcopy 问题
修复抛出问题
添加 readme 文件
将 withKGData 的数据进行深拷贝,解决空数组和对象没有被拷贝的 bug
FAQs
kill global data in program
We found that killglobal demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.