Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

新增函数:浏览器禁止切换页面 #20

Merged
merged 5 commits into from
Jul 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions lib/yd_browser_denyChange.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/**
* 浏览器禁止切换页面
* @param {Function} 函数
* @param {number} number 切换次数,默认是3次
* @param {String} msg 切换次数,默认提示内容“切换次数超过限制”
* @author Nil <https://github.com/Nil-nil-zero>
* @summary 应用场景:线上考试场景
*/

export function browser_denyChange(number, msg) {
window.onblur = function () {
let i = number || 3;
i--;
if (i == 0) {
let res = msg || '切换次数超过限制';
alert(res);
}
};
return window.onblur;
}
15 changes: 15 additions & 0 deletions lib/yd_phone_Masking.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/**
* 手机号脱敏
* @param {Function} 手机号脱敏的函数
* @param {number} 手机号
* @author Nil <https://github.com/Nil-nil-zero>
* @return {String}
* @summary 应用场景:用于数据安全合规,个人隐私保护
*/
export function phone_Masking(number) {
if (!/^\d{11,}$/.test(number)) {
return '手机号码必须是11位数字';
}
const result = number.substring(0, 3) + '****' + number.substring(7);
return result;
}