-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20 from Nil-nil-zero/main
新增函数:浏览器禁止切换页面
- Loading branch information
Showing
2 changed files
with
35 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |