|
@@ -249,7 +249,13 @@ extension UserStateHost on UserState {
|
|
/// 是否有指定权限
|
|
/// 是否有指定权限
|
|
///
|
|
///
|
|
/// [key] 权限Key
|
|
/// [key] 权限Key
|
|
- bool hasFeature(String key) => features.contains(key);
|
|
|
|
|
|
+ bool hasFeature(String key) {
|
|
|
|
+ if (features.length == 0) {
|
|
|
|
+ logger.e("current features is empty");
|
|
|
|
+ setAuthFeatures();
|
|
|
|
+ }
|
|
|
|
+ return features.contains(key);
|
|
|
|
+ }
|
|
|
|
|
|
/// 是否有机构管理员的权限
|
|
/// 是否有机构管理员的权限
|
|
bool? hasOrgFeature() {
|
|
bool? hasOrgFeature() {
|
|
@@ -304,7 +310,7 @@ extension UserStateHost on UserState {
|
|
else
|
|
else
|
|
return;
|
|
return;
|
|
} catch (e) {
|
|
} catch (e) {
|
|
- // logger.e("defaultThesaurus fetch features error.", e);
|
|
|
|
|
|
+ logger.e("defaultThesaurus fetch error.", e);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -391,9 +397,13 @@ extension UserStateHost on UserState {
|
|
}
|
|
}
|
|
|
|
|
|
/// 处理科研版获取权限的事件
|
|
/// 处理科研版获取权限的事件
|
|
- Future<void> handleSetAuth() async {
|
|
|
|
- await _fetchFeatures();
|
|
|
|
- await Store.persistent();
|
|
|
|
|
|
+ Future<void> handleSetLabAuth() async {
|
|
|
|
+ try {
|
|
|
|
+ await _fetchFeatures();
|
|
|
|
+ await Store.persistent();
|
|
|
|
+ } catch (err) {
|
|
|
|
+ logger.e("UserState set lab features error.", err);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
/// 处理注册成功之后事件
|
|
/// 处理注册成功之后事件
|
|
@@ -406,6 +416,10 @@ extension UserStateHost on UserState {
|
|
await Store.persistent();
|
|
await Store.persistent();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ void setAuthFeatures() async {
|
|
|
|
+ await _fetchFeatures();
|
|
|
|
+ }
|
|
|
|
+
|
|
void _clearFeatures() => _features = RxList<String>();
|
|
void _clearFeatures() => _features = RxList<String>();
|
|
void _setFeatures(Iterable<String> arr) =>
|
|
void _setFeatures(Iterable<String> arr) =>
|
|
_features.value = List.unmodifiable(arr);
|
|
_features.value = List.unmodifiable(arr);
|