feat: 用户操作日志.
This commit is contained in:
@@ -15,11 +15,11 @@ export const openWindow = (
|
||||
url,
|
||||
target,
|
||||
Object.entries(others)
|
||||
.reduce((preValue: string[], curValue) => {
|
||||
const [key, value] = curValue;
|
||||
return [...preValue, `${key}=${value}`];
|
||||
}, [])
|
||||
.join(',')
|
||||
.reduce((preValue: string[], curValue) => {
|
||||
const [key, value] = curValue;
|
||||
return [...preValue, `${key}=${value}`];
|
||||
}, [])
|
||||
.join(',')
|
||||
);
|
||||
};
|
||||
|
||||
@@ -161,10 +161,10 @@ export function replaceNumber(value: string) {
|
||||
*/
|
||||
export const resetObject = (obj: any, ignore: string[] = []) => {
|
||||
Object.keys(obj)
|
||||
.filter(s => !ignore.includes(s))
|
||||
.forEach(k => {
|
||||
obj[k] = undefined;
|
||||
});
|
||||
.filter(s => !ignore.includes(s))
|
||||
.forEach(k => {
|
||||
obj[k] = undefined;
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -172,11 +172,11 @@ export const resetObject = (obj: any, ignore: string[] = []) => {
|
||||
*/
|
||||
export const objectTruthKeyCount = (obj: any, ignore: string[] = []) => {
|
||||
return Object.keys(obj)
|
||||
.filter(s => !ignore.includes(s))
|
||||
.reduce(function(acc, curr) {
|
||||
const currVal = obj[curr];
|
||||
return acc + ~~(currVal !== undefined && currVal !== null && currVal?.length !== 0 && currVal !== '');
|
||||
}, 0);
|
||||
.filter(s => !ignore.includes(s))
|
||||
.reduce(function(acc, curr) {
|
||||
const currVal = obj[curr];
|
||||
return acc + ~~(currVal !== undefined && currVal !== null && currVal?.length !== 0 && currVal !== '');
|
||||
}, 0);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -213,4 +213,52 @@ export function getUUID() {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 清除 xss
|
||||
*/
|
||||
export function cleanXss(s: string) {
|
||||
return s.replaceAll('&', '&')
|
||||
.replaceAll('<', '<')
|
||||
.replaceAll('>', '>')
|
||||
.replaceAll('\'', ''')
|
||||
.replaceAll('"', '"')
|
||||
.replaceAll('\n', '<br/>')
|
||||
.replaceAll('\t', ' ');
|
||||
}
|
||||
|
||||
/**
|
||||
* 替换 html 标签
|
||||
*/
|
||||
export function replaceHtmlTag(message: string) {
|
||||
return cleanXss(message)
|
||||
.replaceAll('<sb 0>', '<span class="span-blue mx0">')
|
||||
.replaceAll('<sb 2>', '<span class="span-blue mx2">')
|
||||
.replaceAll('<sb>', '<span class="span-blue mx4">')
|
||||
.replaceAll('</sb>', '</span>')
|
||||
.replaceAll('<sr 0>', '<span class="span-red mx0">')
|
||||
.replaceAll('<sr 2>', '<span class="span-red mx2">')
|
||||
.replaceAll('<sr>', '<span class="span-red mx4">')
|
||||
.replaceAll('</sr>', '</span>')
|
||||
.replaceAll('<b>', '<b>')
|
||||
.replaceAll('</b>', '</b>');
|
||||
}
|
||||
|
||||
/**
|
||||
* 清除 html 标签
|
||||
*/
|
||||
export function clearHtmlTag(message: string) {
|
||||
return cleanXss(message)
|
||||
.replaceAll('<sb 0>', '')
|
||||
.replaceAll('<sb 2>', '')
|
||||
.replaceAll('<sb>', '')
|
||||
.replaceAll('</sb>', '')
|
||||
.replaceAll('<sr 0>', '')
|
||||
.replaceAll('<sr 2>', '')
|
||||
.replaceAll('<sr>', '')
|
||||
.replaceAll('</sr>', '')
|
||||
.replaceAll('<b>', '')
|
||||
.replaceAll('</b>', '')
|
||||
.replaceAll('<br/>', '\n');
|
||||
}
|
||||
|
||||
export default null;
|
||||
|
||||
@@ -51,3 +51,10 @@ export function isExist(obj: any): boolean {
|
||||
export function isWindow(el: any): el is Window {
|
||||
return el === window;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否为移动端 ua
|
||||
*/
|
||||
export function isMobile(userAgent: string) {
|
||||
return /Mobi|Android|iPhone/i.test(userAgent);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user