-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* develop: 1.0.13 feat: use utils from ntks/toolbox instead Fix issue's URL
- Loading branch information
Showing
32 changed files
with
181 additions
and
1,042 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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 |
---|---|---|
@@ -1,19 +1,15 @@ | ||
import { isFunction } from '../../../utils/is/type'; | ||
import { mixin } from '../../../utils/collection'; | ||
import { retrieveData } from '../../../utils/storage/helper'; | ||
import { isFunction, mixin, retrieveData } from '@ntks/toolbox'; | ||
|
||
/** | ||
* 调用钉钉 API | ||
* | ||
* @param {*} ref API 引用 | ||
* @param {*} opts 配置项 | ||
*/ | ||
export function invokeDingTalkApi( ref: string, opts?: any ): any { | ||
export function invokeDingTalkApi(ref: string, opts?: any): any { | ||
// const handler = retrieveData(dd, ref); | ||
|
||
// if ( !isFunction(handler) ) { | ||
// return; | ||
// } | ||
|
||
// return handler(mixin({onFail: ( ...args: any[] ) => console.log(...args)}, opts)); | ||
} |
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 |
---|---|---|
@@ -1,84 +1,94 @@ | ||
import { isFunction, isPlainObject } from '../../../utils/is/type'; | ||
import { map, mixin } from '../../../utils/collection'; | ||
import { isFunction, isPlainObject, map, mixin } from '@ntks/toolbox'; | ||
import { invokeDingTalkApi } from './helper'; | ||
|
||
/** | ||
* 调用通知类 API | ||
* | ||
* | ||
* @param {*} shortcut API 简写 | ||
* @param {*} opts 配置项 | ||
*/ | ||
function invokeNotificationApi( shortcut: string, opts: any ): void { | ||
function invokeNotificationApi(shortcut: string, opts: any): void { | ||
return invokeDingTalkApi(`device.notification.${shortcut}`, opts); | ||
} | ||
|
||
export default { | ||
alert( message: any, callback: Function = function() {} ): void { | ||
invokeNotificationApi('alert', mixin({ | ||
title: '', | ||
buttonName: '知道了', | ||
onSuccess: callback | ||
}, isPlainObject(message) ? message : {message})); | ||
alert(message: any, callback: Function = function () {}): void { | ||
invokeNotificationApi( | ||
'alert', | ||
mixin( | ||
{ | ||
title: '', | ||
buttonName: '知道了', | ||
onSuccess: callback, | ||
}, | ||
isPlainObject(message) ? message : { message }, | ||
), | ||
); | ||
}, | ||
confirm( message: any, agreed: Function = function() {}, cancelled: Function = function() {} ): void { | ||
invokeNotificationApi('confirm', mixin({ | ||
title: '', | ||
buttonLabels: ['确定', '取消'], | ||
onSuccess: ( result: any ) => result.buttonIndex === 0 ? agreed() : cancelled() | ||
}, isPlainObject(message) ? message : {message})); | ||
confirm(message: any, agreed: Function = function () {}, cancelled: Function = function () {}): void { | ||
invokeNotificationApi( | ||
'confirm', | ||
mixin( | ||
{ | ||
title: '', | ||
buttonLabels: ['确定', '取消'], | ||
onSuccess: (result: any) => (result.buttonIndex === 0 ? agreed() : cancelled()), | ||
}, | ||
isPlainObject(message) ? message : { message }, | ||
), | ||
); | ||
}, | ||
// prompt() {}, | ||
toast( opts: any ): void { | ||
toast(opts: any): void { | ||
const { text, icon, duration, callback: onSuccess } = opts; | ||
|
||
invokeNotificationApi('toast', { | ||
text, | ||
icon: icon === 'fail' ? 'error' : icon, | ||
duration, | ||
delay: 0, | ||
onSuccess | ||
onSuccess, | ||
}); | ||
}, | ||
loading: { | ||
show( opts: any ): void { | ||
show(opts: any): void { | ||
const { text, callback: onSuccess } = opts; | ||
|
||
invokeNotificationApi('showPreloader', { | ||
text, | ||
showIcon: true, | ||
onSuccess | ||
onSuccess, | ||
}); | ||
}, | ||
hide( callback: Function ): void { | ||
invokeNotificationApi('hidePreloader', {onSuccess: callback}); | ||
} | ||
hide(callback: Function): void { | ||
invokeNotificationApi('hidePreloader', { onSuccess: callback }); | ||
}, | ||
}, | ||
actionSheet( opts: any ): void { | ||
actionSheet(opts: any): void { | ||
const { title, cancel, actions } = opts; | ||
|
||
invokeNotificationApi('actionSheet', { | ||
title, | ||
cancelButton: cancel.text, | ||
otherButtons: map(actions, ( action: any ) => action.text), | ||
onSuccess: ( result: any ) => { | ||
otherButtons: map(actions, (action: any) => action.text), | ||
onSuccess: (result: any) => { | ||
const { buttonIndex: idx } = result; | ||
|
||
let action, handler; | ||
if ( idx === -1 ) { | ||
|
||
if (idx === -1) { | ||
handler = cancel.handler; | ||
} | ||
else { | ||
} else { | ||
action = actions[idx]; | ||
handler = action.handler; | ||
} | ||
if ( !isFunction(handler) ) { | ||
|
||
if (!isFunction(handler)) { | ||
handler = opts.handler; | ||
} | ||
|
||
return action ? handler(action) : handler(); | ||
} | ||
}, | ||
}); | ||
} | ||
} | ||
}, | ||
}; |
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 |
---|---|---|
@@ -1,13 +1,13 @@ | ||
import { isNumeric } from '../../../utils/is/type'; | ||
import { isNumeric } from '@ntks/toolbox'; | ||
import { invokeDingTalkApi } from './helper'; | ||
|
||
export default { | ||
image( opts: any ): void { | ||
image(opts: any): void { | ||
const { urls = [], current = 0 } = opts; | ||
|
||
invokeDingTalkApi('biz.util.previewImage', { | ||
urls, | ||
current: isNumeric(current) ? urls[current * 1] : current | ||
current: isNumeric(current) ? urls[current * 1] : current, | ||
}); | ||
} | ||
} | ||
}, | ||
}; |
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
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
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
Oops, something went wrong.