# vm-sandbox **Repository Path**: wbgitee/vm-sandbox ## Basic Information - **Project Name**: vm-sandbox - **Description**: 补环境框架 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 0 - **Created**: 2024-07-26 - **Last Updated**: 2025-03-07 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # 补环境框架简介 - 基于 `node16`, `vm2`模块, 纯js设计一个补环境框架 - 目前的设计思路以及实现的方式,检测点相对来说是比较少的 - 因为是前期版本, 所以并没有加入动态`dom解析` - 内部使用`弱引用`, 不会影响内存回收问题 - 优化实例产生的方式 ## 声明(必看) - 不会把同一种类型的所以api都实现,但是该有的必须有 - 推荐`vscode`插件`Code Runner` 右键运行 - 工作代码在z_working目录, 有两个demo, 入口文件格式为**Vm.js结尾 ## 调用方式(z_working目录) ```js const QXVM_GENERATE = require('../qxVm_sanbox/qxVm.sanbox'); const js_code = "function get_form (){ return '' }"; // 导出函数是一定要写的 const user_config = { // 用户配置 isTest: true, // 是不是测试状态, 如果是, 则会固定时间戳, 随机数 compress: false, // 是否压缩js, 准对检测格式化的网站 runConfig: { proxy: false, logOpen: true }, // 运行配置 window_attribute: {}, env: { // 浏览器环境 canvas: "", plugin: [ { description: "Portable Document Format", filename: "internal-pdf-viewer", name: "Chrome PDF Plugin", MimeTypes: [{ description: "Portable Document Format", suffixes: "pdf", type: "application/x-google-chrome-pdf" }] } ], navigator: { userAgent: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36 Edg/100.0.1185.55" }, location: { }, document: { referrer: ""} } } let result = QXVM_GENERATE.QXVm_sanbox(js_code, "get_form", user_config, ); console.log(result.get_form()) ``` - 三个参数 (需要运行的目标js, 需要导出的目标函数, 个人配置) - 框架内部均有默认值, `user_config`为空不影响运行