fix(runtime): onGenerateRoute pathElements 越界 RangeError

- buy-service/renew-minioffice 加长度检查 (pathElements.length >= 4/3)
- 根因: Flutter web 深链接渐进式路径解析, onGenerateRoute 被调用多次,
  pathElements 递增 ([,buy-service] -> [,buy-service,1] -> 完整),
  前几次路径短但 pathElements[1]已匹配 -> int.parse([2])/[3] 越界
- 直接访问/刷新 /buy-service/x/y, /renew-minioffice/x 时崩溃
- 恢复 buy_service 实验代码 (data 校验 + mounted 保留)
This commit is contained in:
2026-08-02 00:13:33 +08:00
parent af8934fe7f
commit 901e42a41b
13 changed files with 192 additions and 5 deletions

View File

@@ -36,7 +36,7 @@ void main() {
FlutterError.onError = (details) {
FlutterError.presentError(details);
print('CK_ERROR: ${details.exceptionAsString()}');
print('CK_CTX: ${details.context.toString()}');
print('CK_CTX: ${details.context}');
print('CK_STACK: ${details.stack}');
};
// Enable configureApp will cause route problem.
@@ -171,12 +171,12 @@ class MyApp extends StatelessWidget {
),
);
}
if (pathElements[1] == 'renew-minioffice') {
if (pathElements[1] == 'renew-minioffice' && pathElements.length >= 3) {
return MaterialPageRoute(builder: (BuildContext context) =>
RenewMiniOffice(int.parse(pathElements[2]))
);
}
if (pathElements[1] == 'buy-service') {
if (pathElements[1] == 'buy-service' && pathElements.length >= 4) {
return MaterialPageRoute(builder: (BuildContext context) =>
BuyService(int.parse(pathElements[2]), pathElements[3])
);