refactor(app): 优化登录页面和对话框逻辑
- 修改登录页面布局,增加 SafeView 组件 - 优化用户不存在时的提示对话框 - 调整未签名批次视图的加载逻辑 - 重构 ToolsHelper 中的对话框显示逻辑 - 修改 API 配置的 showLog属性
这个提交包含在:
父节点
b7d0288643
当前提交
699de803ec
@ -28,7 +28,10 @@ export class GlobalContext {
|
||||
static popUIContext(): void {
|
||||
globalThis._uiUIContext.splice(globalThis._uiUIContext.length-1,1)
|
||||
}
|
||||
static getUiContext(): UIContext {
|
||||
static getUiContext(): UIContext|undefined {
|
||||
if (globalThis._uiUIContext === undefined) {
|
||||
return undefined;
|
||||
}
|
||||
return globalThis._uiUIContext[globalThis._uiUIContext.length-1];
|
||||
}
|
||||
}
|
||||
|
||||
@ -295,7 +295,7 @@ export class ToolsHelper {
|
||||
static closeAlertDialog(dialogTag: string) {
|
||||
if (ToolsHelper.mapAlertDialog.get(dialogTag)) {
|
||||
try {
|
||||
GlobalContext.getUiContext().getPromptAction().closeCustomDialog(ToolsHelper.mapAlertDialog.get(dialogTag))
|
||||
GlobalContext.getUiContext()?.getPromptAction().closeCustomDialog(ToolsHelper.mapAlertDialog.get(dialogTag))
|
||||
} catch (err) {
|
||||
}
|
||||
ToolsHelper.mapAlertDialog.remove(dialogTag)
|
||||
@ -309,34 +309,45 @@ export class ToolsHelper {
|
||||
static showAlertDialog(options: AlertOptions) {
|
||||
const dialogTag = ToolsHelper.getUuid()
|
||||
const ui = GlobalContext.getUiContext()
|
||||
const c = new ComponentContent(ui, wrapBuilder(alertDialogBuilder),
|
||||
new AlertBean({ title: options.title, msg: options.msg, confirm: options.action }, dialogTag))
|
||||
ui.getPromptAction().openCustomDialog(c, {
|
||||
autoCancel: false
|
||||
}).then(() => {
|
||||
ToolsHelper.mapAlertDialog.set(dialogTag, c)
|
||||
}).catch(() => {
|
||||
try {
|
||||
promptAction.showDialog({
|
||||
alignment: DialogAlignment.Center,
|
||||
title: options.title,
|
||||
message: options.msg,
|
||||
buttons: [{
|
||||
text: options.action?.text ?? "确定",
|
||||
color: options.action?.color ?? "#000000",
|
||||
}]
|
||||
if (ui) {
|
||||
const c = new ComponentContent(ui, wrapBuilder(alertDialogBuilder),
|
||||
new AlertBean({ title: options.title, msg: options.msg, confirm: options.action }, dialogTag))
|
||||
ui.getPromptAction().openCustomDialog(c, {
|
||||
autoCancel: false
|
||||
}).then(() => {
|
||||
ToolsHelper.mapAlertDialog.set(dialogTag, c)
|
||||
}).catch(() => {
|
||||
ToolsHelper.showCommonAlert(options)
|
||||
})
|
||||
} else {
|
||||
ToolsHelper.showCommonAlert(options)
|
||||
}
|
||||
}
|
||||
|
||||
private static showCommonAlert(options: AlertOptions) {
|
||||
try {
|
||||
promptAction.showDialog({
|
||||
alignment: DialogAlignment.Center,
|
||||
title: options.title,
|
||||
message: options.msg,
|
||||
buttons: [{
|
||||
text: options.action?.text ?? "确定",
|
||||
color: options.action?.color ?? "#000000",
|
||||
}]
|
||||
})
|
||||
.then(() => {
|
||||
options.action?.onClick && options.action?.onClick()
|
||||
})
|
||||
.then(() => {
|
||||
options.action?.onClick && options.action?.onClick()
|
||||
})
|
||||
.catch((err: Error) => {
|
||||
.catch((err: Error) => {
|
||||
if (err.message === 'cancel') {
|
||||
} else {
|
||||
ToolsHelper.showMessage(err.message)
|
||||
})
|
||||
} catch (error) {
|
||||
let message = (error as BusinessError).message
|
||||
ToolsHelper.showMessage(message)
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
} catch (error) {
|
||||
let message = (error as BusinessError).message
|
||||
ToolsHelper.showMessage(message)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -347,49 +358,61 @@ export class ToolsHelper {
|
||||
|
||||
const dialogTag = ToolsHelper.getUuid()
|
||||
const ui = GlobalContext.getUiContext()
|
||||
const c = new ComponentContent(ui, wrapBuilder(alertDialogBuilder),
|
||||
new AlertBean({
|
||||
title: options.title,
|
||||
msg: options.msg,
|
||||
cancel: options.cancel ?? {},
|
||||
confirm: options.confirm
|
||||
}, dialogTag))
|
||||
ui.getPromptAction().openCustomDialog(c, {
|
||||
autoCancel: false
|
||||
}).then(() => {
|
||||
ToolsHelper.mapAlertDialog.set(dialogTag, c)
|
||||
}).catch(() => {
|
||||
try {
|
||||
promptAction.showDialog({
|
||||
alignment: 1,
|
||||
if (ui) {
|
||||
const c = new ComponentContent(ui, wrapBuilder(alertDialogBuilder),
|
||||
new AlertBean({
|
||||
title: options.title,
|
||||
message: options.msg,
|
||||
buttons: [{
|
||||
text: options.cancel?.text ?? "取消",
|
||||
color: options.cancel?.color ?? "#666666",
|
||||
}, {
|
||||
text: options.confirm?.text ?? "确定",
|
||||
color: options.confirm?.color ?? "#000000",
|
||||
},]
|
||||
})
|
||||
.then((data) => {
|
||||
if (data.index === 0) {
|
||||
options.cancel?.onClick && options.cancel.onClick()
|
||||
} else {
|
||||
options.confirm?.onClick && options.confirm.onClick()
|
||||
}
|
||||
})
|
||||
.catch((err: Error) => {
|
||||
ToolsHelper.showMessage(err.message)
|
||||
})
|
||||
} catch (error) {
|
||||
let message = (error as BusinessError).message
|
||||
ToolsHelper.showMessage(message)
|
||||
}
|
||||
})
|
||||
msg: options.msg,
|
||||
cancel: options.cancel ?? {},
|
||||
confirm: options.confirm
|
||||
}, dialogTag))
|
||||
ui.getPromptAction().openCustomDialog(c, {
|
||||
autoCancel: false
|
||||
}).then(() => {
|
||||
ToolsHelper.mapAlertDialog.set(dialogTag, c)
|
||||
}).catch(() => {
|
||||
ToolsHelper.showCommonConfirm(options)
|
||||
})
|
||||
} else {
|
||||
ToolsHelper.showCommonConfirm(options)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static showCommonConfirm(options: ConfirmOptions) {
|
||||
try {
|
||||
promptAction.showDialog({
|
||||
alignment: 1,
|
||||
title: options.title,
|
||||
message: options.msg,
|
||||
buttons: [{
|
||||
text: options.cancel?.text ?? "取消",
|
||||
color: options.cancel?.color ?? "#666666",
|
||||
}, {
|
||||
text: options.confirm?.text ?? "确定",
|
||||
color: options.confirm?.color ?? "#000000",
|
||||
},]
|
||||
})
|
||||
.then((data) => {
|
||||
if (data.index === 0) {
|
||||
options.cancel?.onClick && options.cancel.onClick()
|
||||
} else {
|
||||
options.confirm?.onClick && options.confirm.onClick()
|
||||
}
|
||||
})
|
||||
.catch((err: Error) => {
|
||||
if (err.message === 'cancel') {
|
||||
options.cancel?.onClick && options.cancel.onClick()
|
||||
} else {
|
||||
ToolsHelper.showMessage(err.message)
|
||||
}
|
||||
})
|
||||
} catch (error) {
|
||||
let message = (error as BusinessError).message
|
||||
ToolsHelper.showMessage(message)
|
||||
}
|
||||
}
|
||||
|
||||
public static mapDialog = new HashMap<string, number>()
|
||||
public static mapAlertDialog = new HashMap<string, ComponentContent<Object>>()
|
||||
|
||||
|
||||
@ -30,7 +30,7 @@ export struct SafeView {
|
||||
@Prop hideBack: boolean
|
||||
// 是否显示浅色返回按钮
|
||||
@Prop lightBack: boolean
|
||||
// 是否显示返回按钮
|
||||
// 是否显示导航栏
|
||||
@Prop hideNavBar: boolean
|
||||
/**
|
||||
* 是否显示左侧角标,存在onClickLeft时生效
|
||||
@ -42,7 +42,7 @@ export struct SafeView {
|
||||
@Prop showBadgeRight: boolean;
|
||||
// 设置返回按钮事件,如果hideBack为true,该事件无效
|
||||
onBackEvent?: () => void
|
||||
// 设置返回按钮事件
|
||||
// 设置导航栏点击事件
|
||||
@Prop onClickLeft: TitleBarBtn
|
||||
@Prop onClickRight: TitleBarBtn
|
||||
// 设置导航栏底下标题
|
||||
|
||||
正在加载...
在新工单中引用
屏蔽一个用户