Files
uTools-quickcommand/src/js/utools.js
2022-04-08 10:26:32 +08:00

51 lines
812 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* 阉割utools同时返回一个满血版的UTOOLS
* 防止输出html输出时通过script标签调用utools执行危险函数
*/
// 禁用危险函数
let whole = window.utools
// 数据库前缀
const DBPRE = {
QC: 'qc_',
CFG: 'cfg_',
PAN: 'pan_'
}
// 数据库函数封装
let getDB = id => {
let db = whole.db.get(id)
return db ? db.data : {}
}
let putDB = (value, id) => {
let db = whole.db.get(id);
if (db) whole.db.put({
_id: id,
data: value,
_rev: db._rev
})
else whole.db.put({
_id: id,
data: value
});
}
let delDB = id => {
return whole.db.remove(id)
}
let getDocs = key => {
return whole.db.allDocs(key)
}
export default {
whole,
getDB,
putDB,
delDB,
getDocs,
DBPRE,
}