Skip to content

Commit

Permalink
feat: update logger
Browse files Browse the repository at this point in the history
  • Loading branch information
Allen Zhang (张涛) committed Oct 15, 2024
1 parent 0988698 commit 31103d2
Show file tree
Hide file tree
Showing 3 changed files with 106 additions and 1 deletion.
2 changes: 1 addition & 1 deletion plugins/babel-plugin-canyon/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "babel-plugin-canyon",
"version": "1.8.78",
"version": "1.8.78-alpha.1",
"description": "",
"main": "lib/index.js",
"files": [
Expand Down
3 changes: 3 additions & 0 deletions plugins/babel-plugin-canyon/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {generateInitialCoverage} from "./helpers/generate-initial-coverage";
import {generateCanyon} from "./helpers/generate-canyon";
const canyonTemplate = template(tep["templates/canyon.template.js"]);
const writeCanyonToLocalTemplate = template(tep["templates/write-canyon-to-local-template.js"])
const injectInPagePopupTemplate = template(tep["templates/inject-in-page-popup.js"])
import packageJson from '../package.json'

// 转换配置,优先级:babel配置 > 环境变量
Expand Down Expand Up @@ -71,9 +72,11 @@ export default declare((api,config) => {
const writeCanyonToLocal = writeCanyonToLocalTemplate({
JSON: 'JSON'
})
const injectInPagePopup = injectInPagePopupTemplate()
path.node.body.unshift(canyon)
// TODO: 需要删除writeCanyonToLocal
path.node.body.unshift(writeCanyonToLocal)
path.node.body.unshift(injectInPagePopup)


// 必须校验数据完整性
Expand Down
102 changes: 102 additions & 0 deletions plugins/babel-plugin-canyon/templates/inject-in-page-popup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
(function () {
var globalObj = undefined;
try {
globalObj = new Function('return this')();
} catch (e) {
if (typeof window !== "undefined") {
globalObj = window;
} else if (typeof global !== "undefined") {
globalObj = global;
} else {
// do nothing
}
}
if (globalObj){

// ***start***

if (globalObj.ssssssssssssss) {
} else {
globalObj.ssssssssssssss = true
if (globalObj.document && globalObj.document.addEventListener) {


// 逻辑




// 点击它打开一个全屏弹窗

// 插入一个div
const modal = document.createElement('div');
modal.innerHTML = '全屏弹窗';
document.body.appendChild(modal);
// 添加样式
modal.style.display = 'none';
modal.style.position = 'fixed';
modal.style.top = 0;
modal.style.left = 0;
modal.style.width = '100%';
modal.style.height = '100%';
modal.style.backgroundColor = 'rgba(0, 0, 0, 0.8)';
modal.style.color = 'white';
modal.style.display = 'flex';
modal.style.justifyContent = 'center';
modal.style.alignItems = 'center';
modal.style.zIndex = 9998;

// 点击关闭按钮关闭弹窗
const close = document.createElement('div');

close.innerHTML = '关闭';
modal.appendChild(close);
// 添加样式
close.style.position = 'absolute';
close.style.top = '20px';
close.style.right = '20px';
close.style.padding = '10px';
close.style.backgroundColor = 'red';
close.style.color = 'white';
close.style.border = 'none';
close.style.cursor = 'pointer';


// 点击关闭按钮关闭弹窗
close.addEventListener('click', () => {
modal.style.display = 'none';
});

let clickCount = 0;
let clickTimeout;
document.addEventListener('click', () => {
clickCount++;

if (clickCount === 1) {
// 开始1秒计时
clickTimeout = setTimeout(() => {
// 1秒结束,重置计数
clickCount = 0;
}, 1000);
}

if (clickCount >= 5) {
// 1秒内点击超过6次,触发痰喘
clearTimeout(clickTimeout); // 清除计时器
clickCount = 0; // 重置计数

modal.style.display = 'flex';
}
});


//



}
}

// **end***
}
})()

0 comments on commit 31103d2

Please sign in to comment.