util
工具函数
gmlog
使用示例:
gmlog.debug('debug调试')
gmlog.info('info...信息')
gmlog.success('success...成功')
gmlog.warn('warn...警告')
gmlog.error('error...错误')
apiClient
使用示例:
function testApiClient() {
apiClient.get('https://httpbin.org/get').then((resp) => {
console.log(resp)
}).catch((reason) => {
console.log(reason)
})
//get请求,通过传入params自动构造?a=b参数
apiClient.get('https://httpbin.org/get', {
params: {
'a': 'b'
}
}).then((resp) => {
console.log(resp)
}).catch((reason) => {
console.log(reason)
})
//post请求,通过传入data传入请求参数
apiClient.post('https://httpbin.org/post', {
data: {
'a': 'b'
}
}).then((resp) => {
console.log(resp)
}).catch((reason) => {
console.log(reason)
})
apiClient.get('https://httpbin.org/status/404').then((resp) => {
console.log(resp)
}).catch((reason) => {
console.log(reason)
})
apiClient.post('https://httpbin.org/status/404').then((resp) => {
console.log(resp)
}).catch((reason) => {
console.log(reason)
})
//get请求,状态码异常则抛出异常
apiClient.okget('https://httpbin.org/status/404').then((resp) => {
console.log(resp)
}).catch((reason) => {
console.log(reason)
})
apiClient.okpost('https://httpbin.org/status/404').then((resp) => {
console.log(resp)
}).catch((reason) => {
console.log(reason)
})
apiClient.okget('https://raw.githubusercontent.com/nomeqc/sublime_text_channel/main/channel_v3.json1').then((resp) => {
console.log(resp)
}).catch((reason) => {
console.log(reason)
})
}
testApiClient()
storageManager
使用示例:
//面向对象地修改本地存储
let fortest = storageManager.getItemProxy('fortest_key')
fortest.list = ['a', 'b', 'c']
//修改后的list
fortest = storageManager.getItemProxy('fortest_key')
console.log('list', fortest.list)
Script Score
No one has rated the script yet. Be the first to rate it!