Merge remote-tracking branch 'origin/master'

这个提交包含在:
徐勤民 2024-10-22 10:06:37 +08:00
当前提交 79d69e0350
共有 2 个文件被更改,包括 34 次插入24 次删除

查看文件

@ -17,7 +17,7 @@ type HttpParamsPost = {
} }
type HttpParamsForm = { type HttpParamsForm = {
url: string url: string
data?: Record<string, string> | Object data?: Record<string, string> | Object|undefined
query?: Record<string, string> | Object query?: Record<string, string> | Object
headers?: Record<string, string> headers?: Record<string, string>
} }
@ -185,7 +185,7 @@ export class HttpHelper {
connectTimeout: 20000, connectTimeout: 20000,
readTimeout: 20000, readTimeout: 20000,
header: header, header: header,
extraData: encodeURI(data) extraData: data?encodeURI(data):undefined
}) })
.then((data: http.HttpResponse) => { .then((data: http.HttpResponse) => {
console.info(`=====>Result:${data.result as string}(${apiNo})`); console.info(`=====>Result:${data.result as string}(${apiNo})`);
@ -324,7 +324,10 @@ export class HttpHelper {
return u return u
} }
private getContent(data: Record<string, string> | Object) { private getContent(data?: Record<string, string> | Object) {
if (!data) {
return undefined
}
let u = '' let u = ''
let q = data let q = data
if (typeof data === 'object') { if (typeof data === 'object') {

查看文件

@ -12,8 +12,8 @@ export interface Btn {
} }
export interface AlertOptions { export interface AlertOptions {
title?: string title?: string,
msg?: string msg?: string,
action?: Btn action?: Btn
} }
@ -37,7 +37,7 @@ interface ListItem {
} }
@Builder @Builder
function customDialogBuilder<T>(option: ListOptions<T>, dialogId: number) { function customDialogBuilder<T>(option: ListOptions<T>, dialogTag: string) {
Column() { Column() {
Text(option.title) Text(option.title)
@ -58,9 +58,9 @@ function customDialogBuilder<T>(option: ListOptions<T>, dialogId: number) {
.fontSize(16) .fontSize(16)
.textAlign(TextAlign.Center) .textAlign(TextAlign.Center)
.onClick(() => { .onClick(() => {
if (ToolsHelper.mapDialog.get(dialogId)) { if (ToolsHelper.mapDialog.get(dialogTag)) {
promptAction.closeCustomDialog(ToolsHelper.mapDialog.get(dialogId)) promptAction.closeCustomDialog(ToolsHelper.mapDialog.get(dialogTag))
ToolsHelper.mapDialog.remove(dialogId) ToolsHelper.mapDialog.remove(dialogTag)
} }
option.onSelected(index, item) option.onSelected(index, item)
}) })
@ -149,22 +149,19 @@ export class ToolsHelper {
* 弹出Alert弹窗 * 弹出Alert弹窗
* @param options * @param options
*/ */
static showAlertDialog( static showAlertDialog(options: AlertOptions) {
title?: string,
msg?: string,
action?: Btn) {
try { try {
promptAction.showDialog({ promptAction.showDialog({
alignment: 1, alignment: DialogAlignment.Center,
title: title, title: options.title,
message: msg, message: options.msg,
buttons: [{ buttons: [{
text: action?.text ?? "确定", text: options.action?.text ?? "确定",
color: action?.color ?? "#000000", color: options.action?.color ?? "#000000",
}] }]
}) })
.then(() => { .then(() => {
action?.onClick && action?.onClick() options.action?.onClick && options.action?.onClick()
}) })
.catch((err: Error) => { .catch((err: Error) => {
ToolsHelper.showMessage(err.message) ToolsHelper.showMessage(err.message)
@ -209,7 +206,7 @@ export class ToolsHelper {
} }
} }
public static mapDialog = new HashMap<number, number>() public static mapDialog = new HashMap<string, number>()
/** /**
* 弹出List弹窗 * 弹出List弹窗
@ -228,7 +225,7 @@ export class ToolsHelper {
if (isSuccess.length > 0) { if (isSuccess.length > 0) {
options.onError && options.onError(`第(${isSuccess.join("、")})个数据中,没有content字段。`) options.onError && options.onError(`第(${isSuccess.join("、")})个数据中,没有content字段。`)
} else { } else {
const dialogTag = new Date().getTime() const dialogTag = ToolsHelper.getUuid()
promptAction.openCustomDialog({ promptAction.openCustomDialog({
alignment: 1, alignment: 1,
builder: customDialogBuilder.bind(p, options, dialogTag) builder: customDialogBuilder.bind(p, options, dialogTag)
@ -242,8 +239,7 @@ export class ToolsHelper {
* 弹出自定义弹窗 * 弹出自定义弹窗
* @param alignment 弹窗在竖直方向上的对齐方式 * @param alignment 弹窗在竖直方向上的对齐方式
*/ */
static showCustomDialog(b: CustomBuilder, alignment?: DialogAlignment) { static showCustomDialog(dialogTag: string, b: CustomBuilder, alignment?: DialogAlignment) {
const dialogTag = new Date().getTime()
promptAction.openCustomDialog({ promptAction.openCustomDialog({
alignment: alignment ?? DialogAlignment.Center, alignment: alignment ?? DialogAlignment.Center,
builder: b builder: b
@ -254,6 +250,17 @@ export class ToolsHelper {
}) })
} }
/**
* 关闭自定义弹窗
* @param dialogTag 开启时的tag
*/
static closeCustomDialog(dialogTag: string) {
if (ToolsHelper.mapDialog.get(dialogTag)) {
promptAction.closeCustomDialog(ToolsHelper.mapDialog.get(dialogTag))
ToolsHelper.mapDialog.remove(dialogTag)
}
}
/** /**
* 获取调用栈第一个类 * 获取调用栈第一个类
*/ */
@ -314,7 +321,7 @@ export class ToolsHelper {
private static setTimeOutMap: Map<string, ThrottleInterface> = new Map() private static setTimeOutMap: Map<string, ThrottleInterface> = new Map()
private static uniqueIdMap = new WeakMap<Function, string>(); private static uniqueIdMap = new WeakMap<Function, string>();
private static getUuid() { public static getUuid() {
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => { return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {
let r = (Math.random() * 16) | 0, v = c == 'x' ? r : (r & 0x3) | 0x8; let r = (Math.random() * 16) | 0, v = c == 'x' ? r : (r & 0x3) | 0x8;
return v.toString(16); return v.toString(16);