npm install 尚未发布:>
$cacheUtil.cachePromise('getGoods',
new Promise(()=>{}),
{cache:true,lasttime:3}
).then(res=>console.log('ret',res) );
let url = 'https://etradetest.linkedcare.cn/etrade/product/productClass';
let params = {shoppingGroup:0, tenantId:'8ff89de7-1c0b-4849-93b9-e68e8e201d51',userId:'8ff89de7-1c0b-4849-93b9-e68e8e201d51:55:80'};
$cacheUtil.cachePost($axios,
url,
params,
{cache:true,lasttime:3}
).then(res=>console.log('ret',res) );
let url = 'https://etradetest.linkedcare.cn/etrade/product/productClass';
let params = {shoppingGroup:0, tenantId:'8ff89de7-1c0b-4849-93b9-e68e8e201d51',userId:'8ff89de7-1c0b-4849-93b9-e68e8e201d51:55:80'};
$cacheUtil.cacheGet($axios,
url,
params,
{cache:true,lasttime:3}
).then(res=>console.log('ret',res) );
import cacheUtil from './src/czm/libs/util/cache'
import axios from 'axios'
window.$cacheUtil = cacheUtil;
window.$axios = axios;
function getPromise(key,params) {
return new Promise((rj,re)=>{
rj({key:key,params:params,timestamp:new Date().getTime()})
}
);
}
function testPromise() {
window.$cacheUtil.cachePromise('getGoods',getPromise('p1',{id:10001}),{cache:true,lasttime:3}).then(res=>{
console.log('ret',res)
});
}
function testPost() {
let url = 'https://etradetest.linkedcare.cn/etrade/product/productClass';
let params = {shoppingGroup:0, tenantId:'8ff89de7-1c0b-4849-93b9-e68e8e201d51',userId:'8ff89de7-1c0b-4849-93b9-e68e8e201d51:55:80'};
window.$cacheUtil.cachePost(window.$axios, url, params,{cache: false, lasttime: 3}).then(res => {console.log('ret', res)});
}
let imageUrl = 'https://oscimg.oschina.net/oscnet/d49ee0030b41c8ed36ff85e442767f0cfd5.jpg';
$cacheUtil.cacheImage(imageUrl,{cache:true,lasttime:3}) .then(base64=>console.log(base64) );
import imageCache from './src/czm/libs/util/cache-image'
window.$imageCache = imageCache;
function testImageCache(){
let imgTest = [
'https://desk-fd.zol-img.com.cn/t_s960x600c5/g5/M00/03/02/ChMkJlv9AveIDfZfACROyMb514AAAtasgOPc88AJE7g811.jpg',
'https://oscimg.oschina.net/oscnet/d49ee0030b41c8ed36ff85e442767f0cfd5.jpg'
]
for(let i=0;i<imgTest.length;i++){
window.$imageCache.cacheImage(imgTest[i],{lasttime:10})
.then(base64=>{
let img = new Image();
img.src = base64;
document.body.append(img);
window.$imageCache.log()
}
);
}
}
import webdb from './src/czm/libs/util/cache-webdb'
window.$webdb = webdb;
//模拟 INSERT 操作
window.$webdb.insert("INSERT INTO goods (name,age,type) VALUES ('xiaoming',29,1) ")
//模拟 INSERT 操作 Obj形式
window.$webdb.insert("tablename",{name:'daming',age:20,type:1})
//模拟 SELECT 操作
window.$webdb.select("SELECT name,age,type FROM goods WHERE age >= 50 AND type = 1")
//模拟 UPDATE 操作
window.$webdb.update("UPDATE goods SET (name,age,type) VALUES ('mayun',80,2) WHERE age >= 50 AND type = 1")
//模拟 DELETE 操作
window.$webdb.delete("delete WHERE age >= 50 AND type = 1")