对amap封装
This commit is contained in:
parent
dbdad78008
commit
2bbe67f8af
|
|
@ -28,6 +28,7 @@
|
|||
"mocha": "^8.2.1",
|
||||
"oak-domain": "file:../oak-domain",
|
||||
"oak-memory-tree-store": "file:../oak-memory-tree-store",
|
||||
"oak-wechat-sdk": "file:../oak-wechat-sdk",
|
||||
"ts-node": "^9.1.1",
|
||||
"typescript": "^4.5.2"
|
||||
},
|
||||
|
|
|
|||
|
|
@ -0,0 +1,16 @@
|
|||
import { AmapSDK, AmapInstance } from 'oak-wechat-sdk';
|
||||
|
||||
export async function amap<T extends 'getDrivingPath' | 'regeo' | 'ipLoc' | 'getDistrict' | 'geocode'>(options: {
|
||||
key: string;
|
||||
method: T;
|
||||
data: Parameters<AmapInstance[T]>[0];
|
||||
}) {
|
||||
const { key, method, data } = options;
|
||||
const instance = AmapSDK.getInstance(key);
|
||||
const fn = instance[method];
|
||||
if (!fn) {
|
||||
throw new Error('method not implemented');
|
||||
}
|
||||
// data any后面再改
|
||||
return fn(data as any);
|
||||
}
|
||||
|
|
@ -1,7 +1,9 @@
|
|||
import { operate, select } from './crud';
|
||||
import { amap } from './amap';
|
||||
const aspectDict = {
|
||||
operate,
|
||||
select,
|
||||
amap,
|
||||
};
|
||||
|
||||
export default aspectDict;
|
||||
Loading…
Reference in New Issue