没有企业登录逻辑修改

master
hs 2026-06-03 16:51:06 +08:00
parent 7191c4f42f
commit 7ebd28f177
3 changed files with 140 additions and 26 deletions

View File

@ -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",

View File

@ -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 {

106
lib/tools/click_util.dart Normal file
View File

@ -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);
}
}