没有企业登录逻辑修改
parent
7191c4f42f
commit
7ebd28f177
|
|
@ -166,10 +166,11 @@ class HomePageState extends RouteAwareState<HomePage>
|
||||||
_scrollController.addListener(_onScroll);
|
_scrollController.addListener(_onScroll);
|
||||||
WidgetsBinding.instance.addObserver(this);
|
WidgetsBinding.instance.addObserver(this);
|
||||||
RouteService().addListener(onRouteConfigLoaded);
|
RouteService().addListener(onRouteConfigLoaded);
|
||||||
|
|
||||||
|
if (_isShowCheckLogin) {
|
||||||
Future.microtask(() {
|
Future.microtask(() {
|
||||||
_updateModuleAndButtonVisibility();
|
_updateModuleAndButtonVisibility();
|
||||||
});
|
});
|
||||||
if (_isShowCheckLogin) {
|
|
||||||
_getToDoWorkList(pcType);
|
_getToDoWorkList(pcType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1105,6 +1106,9 @@ class HomePageState extends RouteAwareState<HomePage>
|
||||||
|
|
||||||
// 获取待办事项
|
// 获取待办事项
|
||||||
void _getToDoWorkList(int type) async {
|
void _getToDoWorkList(int type) async {
|
||||||
|
if (!_isShowCheckLogin) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
Map data = {
|
Map data = {
|
||||||
"eqAppFlag": type == 1 ? "1" : "",
|
"eqAppFlag": type == 1 ? "1" : "",
|
||||||
"eqPcFlag": type == 1 ? "" : "1",
|
"eqPcFlag": type == 1 ? "" : "1",
|
||||||
|
|
|
||||||
|
|
@ -94,6 +94,7 @@ class _MainPageState extends State<MainPage> with WidgetsBindingObserver {
|
||||||
Future<void> _getRoute() async {
|
Future<void> _getRoute() async {
|
||||||
try {
|
try {
|
||||||
Map? route;
|
Map? route;
|
||||||
|
if (widget.isChooseFirm) {
|
||||||
// 接口获取
|
// 接口获取
|
||||||
try {
|
try {
|
||||||
LoadingDialogHelper.show(message: '加载中...');
|
LoadingDialogHelper.show(message: '加载中...');
|
||||||
|
|
@ -109,15 +110,18 @@ class _MainPageState extends State<MainPage> with WidgetsBindingObserver {
|
||||||
'AppMenuApi.getAppMenu error: $e -> fallback to local assets.',
|
'AppMenuApi.getAppMenu error: $e -> fallback to local assets.',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
}else{
|
||||||
// 本地获取
|
// 本地获取
|
||||||
// try {
|
try {
|
||||||
// final routeString = await loadFromAssets();
|
final routeString = await loadFromAssets();
|
||||||
// route = jsonDecode(routeString) as Map<String, dynamic>;
|
route = jsonDecode(routeString) as Map<String, dynamic>;
|
||||||
// } catch (e) {
|
} catch (e) {
|
||||||
// debugPrint('loadFromAssets error: $e');
|
debugPrint('loadFromAssets error: $e');
|
||||||
// }
|
}
|
||||||
final data = route?['data'] ?? [];
|
final data = route?['data'] ?? [];
|
||||||
RouteService().initializeRoutes(data);
|
RouteService().initializeRoutes(data);
|
||||||
|
}
|
||||||
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
debugPrint('获取路由配置失败: $e');
|
debugPrint('获取路由配置失败: $e');
|
||||||
} finally {
|
} finally {
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,106 @@
|
||||||
|
import 'dart:async';
|
||||||
|
|
||||||
|
import 'package:flutter/foundation.dart';
|
||||||
|
|
||||||
|
typedef GuardedTapCallback = FutureOr<void> Function();
|
||||||
|
|
||||||
|
/// 通用防连点工具。
|
||||||
|
///
|
||||||
|
/// 适用于 `TextButton`、`IconButton`、`GestureDetector`、`InkWell` 等
|
||||||
|
/// 任意需要点击防抖的场景。
|
||||||
|
class ClickUtil {
|
||||||
|
ClickUtil._();
|
||||||
|
|
||||||
|
static const int defaultDelayMs = 800;
|
||||||
|
|
||||||
|
static final Map<Object, DateTime> _lastTriggerTimes = <Object, DateTime>{};
|
||||||
|
static final Set<Object> _runningKeys = <Object>{};
|
||||||
|
static final Object _globalKey = Object();
|
||||||
|
|
||||||
|
/// 运行一个带防连点保护的点击事件。
|
||||||
|
///
|
||||||
|
/// `key` 相同的点击事件会共用一把锁;
|
||||||
|
/// `delayMs` 内重复点击会被忽略;
|
||||||
|
/// `lockDuringExecution` 为 true 时,异步执行期间也会被锁住。
|
||||||
|
static Future<void> run(
|
||||||
|
GuardedTapCallback action, {
|
||||||
|
Object? key,
|
||||||
|
int delayMs = defaultDelayMs,
|
||||||
|
bool lockDuringExecution = true,
|
||||||
|
}) async {
|
||||||
|
final Object guardKey = key ?? action;
|
||||||
|
final DateTime now = DateTime.now();
|
||||||
|
final DateTime? lastTriggerTime = _lastTriggerTimes[guardKey];
|
||||||
|
|
||||||
|
if (lastTriggerTime != null &&
|
||||||
|
now.difference(lastTriggerTime).inMilliseconds < delayMs) {
|
||||||
|
debugPrint('请稍后点击');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (lockDuringExecution && _runningKeys.contains(guardKey)) {
|
||||||
|
debugPrint('操作进行中,请稍后');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_lastTriggerTimes[guardKey] = now;
|
||||||
|
if (lockDuringExecution) {
|
||||||
|
_runningKeys.add(guardKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
await action();
|
||||||
|
} finally {
|
||||||
|
if (lockDuringExecution) {
|
||||||
|
final int elapsedMs = DateTime.now().difference(now).inMilliseconds;
|
||||||
|
final int remainingMs = delayMs - elapsedMs;
|
||||||
|
if (remainingMs > 0) {
|
||||||
|
await Future.delayed(Duration(milliseconds: remainingMs));
|
||||||
|
}
|
||||||
|
_runningKeys.remove(guardKey);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 直接包装成可绑定给按钮的回调。
|
||||||
|
///
|
||||||
|
/// 对于会在 `build` 中频繁新建的匿名函数,推荐显式传入 `key`。
|
||||||
|
static VoidCallback? wrap(
|
||||||
|
GuardedTapCallback? action, {
|
||||||
|
Object? key,
|
||||||
|
int delayMs = defaultDelayMs,
|
||||||
|
bool lockDuringExecution = true,
|
||||||
|
}) {
|
||||||
|
if (action == null) return null;
|
||||||
|
|
||||||
|
return () {
|
||||||
|
unawaited(
|
||||||
|
run(
|
||||||
|
action,
|
||||||
|
key: key,
|
||||||
|
delayMs: delayMs,
|
||||||
|
lockDuringExecution: lockDuringExecution,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 兼容旧调用方式:全局共用一把锁。
|
||||||
|
static Future<void> noMultipleClicks(
|
||||||
|
GuardedTapCallback action, {
|
||||||
|
int delayMs = 2000,
|
||||||
|
}) {
|
||||||
|
return run(action, key: _globalKey, delayMs: delayMs);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void reset([Object? key]) {
|
||||||
|
if (key == null) {
|
||||||
|
_lastTriggerTimes.clear();
|
||||||
|
_runningKeys.clear();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_lastTriggerTimes.remove(key);
|
||||||
|
_runningKeys.remove(key);
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue