Initial commit of akmon project

This commit is contained in:
2026-01-20 08:04:15 +08:00
commit 77a2bab985
1309 changed files with 343305 additions and 0 deletions

View File

@@ -0,0 +1,36 @@
import { OpenLocation, OpenLocationOptions, OpenLocationSuccessImpl, OpenLocationErrorCode } from "../interface.uts"
import { OpenLocationFailImpl } from "../unierror.uts"
export const openLocation : OpenLocation = function (options : OpenLocationOptions) {
const uuid = `${Date.now()}${Math.floor(Math.random() * 1e7)}`
const baseEventName = `uni_open_location_${uuid}`
const readyEventName = `${baseEventName}_ready`
const optionsEventName = `${baseEventName}_options`
const successEventName = `${baseEventName}_success`
const failEventName = `${baseEventName}_fail`
const readyEventId = uni.$on(readyEventName, () => {
uni.$emit(optionsEventName, JSON.parse(JSON.stringify(options)))
})
const successEventId = uni.$on(successEventName, () => {
const res = new OpenLocationSuccessImpl()
options.success?.(res)
options.complete?.(res)
})
const failEventId = uni.$on(failEventName, (errCode : OpenLocationErrorCode) => {
const res = new OpenLocationFailImpl(errCode)
options.fail?.(res)
options.complete?.(res)
})
uni.openDialogPage({
url: `/uni_modules/uni-openLocation/pages/openLocation/openLocation?readyEventName=${readyEventName}&optionsEventName=${optionsEventName}&successEventName=${successEventName}&failEventName=${failEventName}`,
fail(err) {
const res = new OpenLocationFailImpl(4)
options.fail?.(res)
options.complete?.(res)
uni.$off(readyEventName, readyEventId)
uni.$off(successEventName, successEventId)
uni.$off(failEventName, failEventId)
}
})
};

View File

@@ -0,0 +1,36 @@
import { OpenLocation, OpenLocationOptions, OpenLocationSuccessImpl, OpenLocationErrorCode } from "../interface.uts"
import { OpenLocationFailImpl } from "../unierror.uts"
export const openLocation : OpenLocation = function (options : OpenLocationOptions) {
const uuid = `${Date.now()}${Math.floor(Math.random() * 1e7)}`
const baseEventName = `uni_open_location_${uuid}`
const readyEventName = `${baseEventName}_ready`
const optionsEventName = `${baseEventName}_options`
const successEventName = `${baseEventName}_success`
const failEventName = `${baseEventName}_fail`
const readyEventId = uni.$on(readyEventName, () => {
uni.$emit(optionsEventName, JSON.parse(JSON.stringify(options)))
})
const successEventId = uni.$on(successEventName, () => {
const res = new OpenLocationSuccessImpl()
options.success?.(res)
options.complete?.(res)
})
const failEventId = uni.$on(failEventName, (errCode : OpenLocationErrorCode) => {
const res = new OpenLocationFailImpl(errCode)
options.fail?.(res)
options.complete?.(res)
})
uni.openDialogPage({
url: `/uni_modules/uni-openLocation/pages/openLocation/openLocation?readyEventName=${readyEventName}&optionsEventName=${optionsEventName}&successEventName=${successEventName}&failEventName=${failEventName}`,
fail(err) {
const res = new OpenLocationFailImpl(4)
options.fail?.(res)
options.complete?.(res)
uni.$off(readyEventName, readyEventId)
uni.$off(successEventName, successEventId)
uni.$off(failEventName, failEventId)
}
})
};

View File

@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>LSApplicationQueriesSchemes</key>
<array>
<string>qqmap</string>
<string>iosamap</string>
<string>baidumap</string>
</array>
</dict>
</plist>

View File

@@ -0,0 +1,36 @@
import { OpenLocation, OpenLocationOptions, OpenLocationSuccessImpl } from "../interface.uts"
import { OpenLocationFailImpl } from "../unierror.uts"
export const openLocation : OpenLocation = function (options : OpenLocationOptions) {
const uuid = `${Date.now()}${Math.floor(Math.random() * 1e7)}`
const baseEventName = `uni_open_location_${uuid}`
const readyEventName = `${baseEventName}_ready`
const optionsEventName = `${baseEventName}_options`
const successEventName = `${baseEventName}_success`
const failEventName = `${baseEventName}_fail`
uni.$on(readyEventName, () => {
uni.$emit(optionsEventName, JSON.parse(JSON.stringify(options)!))
})
uni.$on(successEventName, () => {
const res = new OpenLocationSuccessImpl()
options.success?.(res)
options.complete?.(res)
})
uni.$on(failEventName, () => {
const res = new OpenLocationFailImpl(4)
options.fail?.(res)
options.complete?.(res)
})
uni.openDialogPage({
url: `/uni_modules/uni-openLocation/pages/openLocation/openLocation?readyEventName=${readyEventName}&optionsEventName=${optionsEventName}&successEventName=${successEventName}&failEventName=${failEventName}`,
fail(err) {
const res = new OpenLocationFailImpl(4)
options.fail?.(res)
options.complete?.(res)
uni.$off(readyEventName)
uni.$off(successEventName)
uni.$off(failEventName)
}
})
};

View File

@@ -0,0 +1,418 @@
/**
* 错误码
*/
export type OpenLocationErrorCode =
/**
* 框架内部错误
* @uniPlatform {
* "app": {
* "android": {
* "osVer": "5.0",
* "uniVer": "√",
* "unixVer": "4.41"
* },
* "ios": {
* "osVer": "12.0",
* "uniVer": "√",
* "unixVer": "4.41"
* },
* "harmony": {
* "osVer": "3.0",
* "uniVer": "4.23",
* "unixVer": "4.61"
* }
* },
* "web": {
* "uniVer": "√",
* "unixVer": "4.0"
* },
* "mp": {
* "weixin": {
* "uniVer": "x",
* "unixVer": "x"
* }
* }
* }
*/
4;
export interface OpenLocationSuccess {
errMsg: string
}
type OpenLocationSuccessCallback = (result : OpenLocationSuccess) => void
export interface OpenLocationFail extends IUniError {
errCode : OpenLocationErrorCode
}
type OpenLocationFailCallback = (result : OpenLocationFail) => void
export type OpenLocationComplete = any
type OpenLocationCompleteCallback = (result : OpenLocationComplete) => void
/**
* uni.openLocation函数参数定义
*/
export type OpenLocationOptions = {
/**
* 纬度,范围为-90~90负数表示南纬使用 gcj02 国测局坐标系
* @uniPlatform {
* "app": {
* "android": {
* "osVer": "5.0",
* "uniVer": "√",
* "unixVer": "4.41"
* },
* "ios": {
* "osVer": "12.0",
* "uniVer": "√",
* "unixVer": "4.41"
* },
* "harmony": {
* "osVer": "3.0",
* "uniVer": "4.23",
* "unixVer": "4.61"
* }
* },
* "web": {
* "uniVer": "√",
* "unixVer": "4.0"
* },
* "mp": {
* "weixin": {
* "uniVer": "√",
* "unixVer": "4.41"
* }
* }
* }
*/
latitude : number,
/**
* 经度,范围为-180~180负数表示西经使用 gcj02 国测局坐标系
* @uniPlatform {
* "app": {
* "android": {
* "osVer": "5.0",
* "uniVer": "√",
* "unixVer": "4.41"
* },
* "ios": {
* "osVer": "12.0",
* "uniVer": "√",
* "unixVer": "4.41"
* },
* "harmony": {
* "osVer": "3.0",
* "uniVer": "4.23",
* "unixVer": "4.61"
* }
* },
* "web": {
* "uniVer": "√",
* "unixVer": "4.0"
* },
* "mp": {
* "weixin": {
* "uniVer": "√",
* "unixVer": "4.41"
* }
* }
* }
*/
longitude : number,
/**
* 缩放比例范围5~18默认为18微信小程序
* @uniPlatform {
* "app": {
* "android": {
* "osVer": "5.0",
* "uniVer": "√",
* "unixVer": "4.41"
* },
* "ios": {
* "osVer": "12.0",
* "uniVer": "√",
* "unixVer": "4.41"
* },
* "harmony": {
* "osVer": "3.0",
* "uniVer": "4.23",
* "unixVer": "4.61"
* }
* },
* "web": {
* "uniVer": "√",
* "unixVer": "4.0"
* },
* "mp": {
* "weixin": {
* "uniVer": "√",
* "unixVer": "4.41"
* }
* }
* }
*/
scale ?: number | null,
/**
* 位置名
* @uniPlatform {
* "app": {
* "android": {
* "osVer": "5.0",
* "uniVer": "√",
* "unixVer": "4.41"
* },
* "ios": {
* "osVer": "12.0",
* "uniVer": "√",
* "unixVer": "4.41"
* },
* "harmony": {
* "osVer": "3.0",
* "uniVer": "4.23",
* "unixVer": "4.61"
* }
* },
* "web": {
* "uniVer": "√",
* "unixVer": "4.0"
* },
* "mp": {
* "weixin": {
* "uniVer": "√",
* "unixVer": "4.41"
* }
* }
* }
*/
name ?: string | null,
/**
* 地址的详细说明
* @uniPlatform {
* "app": {
* "android": {
* "osVer": "5.0",
* "uniVer": "√",
* "unixVer": "4.41"
* },
* "ios": {
* "osVer": "12.0",
* "uniVer": "√",
* "unixVer": "4.41"
* },
* "harmony": {
* "osVer": "3.0",
* "uniVer": "4.23",
* "unixVer": "4.61"
* }
* },
* "web": {
* "uniVer": "√",
* "unixVer": "4.0"
* },
* "mp": {
* "weixin": {
* "uniVer": "√",
* "unixVer": "4.41"
* }
* }
* }
*/
address ?: string | null,
/**
* 接口调用成功的回调函数
* @uniPlatform {
* "app": {
* "android": {
* "osVer": "5.0",
* "uniVer": "√",
* "unixVer": "4.41"
* },
* "ios": {
* "osVer": "12.0",
* "uniVer": "√",
* "unixVer": "4.41"
* },
* "harmony": {
* "osVer": "3.0",
* "uniVer": "4.23",
* "unixVer": "4.61"
* }
* },
* "web": {
* "uniVer": "√",
* "unixVer": "4.0"
* },
* "mp": {
* "weixin": {
* "uniVer": "√",
* "unixVer": "4.41"
* }
* }
* }
*/
success ?: OpenLocationSuccessCallback | null,
/**
* 接口调用失败的回调函数
* @uniPlatform {
* "app": {
* "android": {
* "osVer": "5.0",
* "uniVer": "√",
* "unixVer": "4.41"
* },
* "ios": {
* "osVer": "12.0",
* "uniVer": "√",
* "unixVer": "4.41"
* },
* "harmony": {
* "osVer": "3.0",
* "uniVer": "4.23",
* "unixVer": "4.61"
* }
* },
* "web": {
* "uniVer": "√",
* "unixVer": "4.0"
* },
* "mp": {
* "weixin": {
* "uniVer": "√",
* "unixVer": "4.41"
* }
* }
* }
*/
fail ?: OpenLocationFailCallback | null,
/**
* 接口调用结束的回调函数(调用成功、失败都会执行)
* @uniPlatform {
* "app": {
* "android": {
* "osVer": "5.0",
* "uniVer": "√",
* "unixVer": "4.41"
* },
* "ios": {
* "osVer": "12.0",
* "uniVer": "√",
* "unixVer": "4.41"
* },
* "harmony": {
* "osVer": "3.0",
* "uniVer": "4.23",
* "unixVer": "4.61"
* }
* },
* "web": {
* "uniVer": "√",
* "unixVer": "4.0"
* },
* "mp": {
* "weixin": {
* "uniVer": "√",
* "unixVer": "4.41"
* }
* }
* }
*/
complete ?: OpenLocationCompleteCallback | null
};
/**
* 使用应用内置地图查看位置
*
* @param {OpenLocationOptions} options
* @tutorial https://doc.dcloud.net.cn/uni-app-x/api/prompt.html#openLocation
* @uniPlatform {
* "app": {
* "android": {
* "osVer": "5.0",
* "uniVer": "√",
* "unixVer": "4.41"
* },
* "ios": {
* "osVer": "12.0",
* "uniVer": "√",
* "unixVer": "4.41"
* },
* "harmony": {
* "osVer": "3.0",
* "uniVer": "4.23",
* "unixVer": "4.61"
* }
* },
* "web": {
* "uniVer": "√",
* "unixVer": "4.0"
* },
* "mp": {
* "weixin": {
* "uniVer": "√",
* "unixVer": "4.41"
* }
* }
* }
*/
export type OpenLocation = (options : OpenLocationOptions) => void;
export interface Uni {
/**
* @description 使用应用内置地图查看位置
* @example
* ```typescript
uni.openLocation({
latitude: 39.908823,
longitude: 116.39747,
success: (res) => {
console.log('res: ', res)
},
fail: (err) => {
console.log('err: ', err)
},
complete: (res) => {
console.log('complete: ', res)
}
});
* ```
* @tutorial https://doc.dcloud.net.cn/uni-app-x/api/prompt.html#openLocation
* @uniPlatform {
* "app": {
* "android": {
* "osVer": "5.0",
* "uniVer": "√",
* "unixVer": "4.41"
* },
* "ios": {
* "osVer": "12.0",
* "uniVer": "√",
* "unixVer": "4.41"
* },
* "harmony": {
* "osVer": "3.0",
* "uniVer": "4.23",
* "unixVer": "4.61"
* }
* },
* "web": {
* "uniVer": "√",
* "unixVer": "4.0"
* },
* "mp": {
* "weixin": {
* "uniVer": "√",
* "unixVer": "4.41"
* }
* }
* }
*/
openLocation(options : OpenLocationOptions) : void;
}
export class OpenLocationSuccessImpl implements OpenLocationSuccess {
errMsg : string
constructor(errMsg : string = 'chooseLocation:ok') {
this.errMsg = errMsg
}
}

View File

@@ -0,0 +1,30 @@
import { OpenLocationErrorCode, OpenLocationFail } from "./interface.uts"
/**
* 错误主题
*/
export const UniErrorSubject = 'uni-openLocation';
/**
* 错误码
* @UniError
*/
export const UniErrors : Map<OpenLocationErrorCode, string> = new Map([
/**
* 框架内部错误
*/
[4, 'internal error']
]);
export class OpenLocationFailImpl extends UniError implements OpenLocationFail {
// #ifndef APP-IOS
override errCode : OpenLocationErrorCode;
// #endif
constructor(errCode : OpenLocationErrorCode) {
super();
this.errSubject = UniErrorSubject;
this.errCode = errCode;
this.errMsg = UniErrors.get(errCode) ?? "";
}
}

View File

@@ -0,0 +1,36 @@
import { OpenLocation, OpenLocationOptions, OpenLocationSuccessImpl, OpenLocationErrorCode } from "../interface.uts"
import { OpenLocationFailImpl } from "../unierror.uts"
export const openLocation : OpenLocation = function (options : OpenLocationOptions) {
const uuid = `${Date.now()}${Math.floor(Math.random() * 1e7)}`
const baseEventName = `uni_open_location_${uuid}`
const readyEventName = `${baseEventName}_ready`
const optionsEventName = `${baseEventName}_options`
const successEventName = `${baseEventName}_success`
const failEventName = `${baseEventName}_fail`
const readyEventId = uni.$on(readyEventName, () => {
uni.$emit(optionsEventName, JSON.parse(JSON.stringify(options)))
})
const successEventId = uni.$on(successEventName, () => {
const res = new OpenLocationSuccessImpl()
options.success?.(res)
options.complete?.(res)
})
const failEventId = uni.$on(failEventName, (errCode : OpenLocationErrorCode) => {
const res = new OpenLocationFailImpl(errCode)
options.fail?.(res)
options.complete?.(res)
})
uni.openDialogPage({
url: `/uni_modules/uni-openLocation/pages/openLocation/openLocation?readyEventName=${readyEventName}&optionsEventName=${optionsEventName}&successEventName=${successEventName}&failEventName=${failEventName}`,
fail(err) {
const res = new OpenLocationFailImpl(4)
options.fail?.(res)
options.complete?.(res)
uni.$off(readyEventName, readyEventId)
uni.$off(successEventName, successEventId)
uni.$off(failEventName, failEventId)
}
})
};