From 08288fa187dab09a970d6551cab98e0153e5e7a6 Mon Sep 17 00:00:00 2001
From: IZUMI-Zu <274620705z@gmail.com>
Date: Thu, 24 Oct 2024 21:45:04 +0800
Subject: [PATCH] fix: resolve user data and interface issues
---
App.js | 47 +++++++++------
CasdoorLoginPage.js | 1 +
EnterCasdoorSdkConfig.js | 121 ++++++++++++++++++++-------------------
Header.js | 4 +-
api.js | 5 +-
app.json | 3 +-
package-lock.json | 31 +++++++---
package.json | 5 +-
8 files changed, 125 insertions(+), 92 deletions(-)
diff --git a/App.js b/App.js
index 6629a30..2961ed2 100644
--- a/App.js
+++ b/App.js
@@ -12,7 +12,9 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-import * as React from "react";
+import React from "react";
+import {Lato_700Bold, useFonts} from "@expo-google-fonts/lato";
+import {Roboto_500Medium} from "@expo-google-fonts/roboto";
import {NavigationContainer} from "@react-navigation/native";
import {PaperProvider} from "react-native-paper";
import {SafeAreaView, Text} from "react-native";
@@ -29,6 +31,11 @@ import migrations from "./drizzle/migrations";
const App = () => {
const {success, error} = useMigrations(db, migrations);
+ const [fontsLoaded] = useFonts({
+ Lato_700Bold,
+ Roboto_500Medium,
+ });
+
const {NotificationsProvider} = createNotifications({
duration: 800,
notificationPosition: "top",
@@ -53,25 +60,27 @@ const App = () => {
);
}
- if (!success) {
+ if (!success || !fontsLoaded) {
return (
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
);
}
diff --git a/CasdoorLoginPage.js b/CasdoorLoginPage.js
index 22a5c6d..f2a4fd1 100644
--- a/CasdoorLoginPage.js
+++ b/CasdoorLoginPage.js
@@ -127,6 +127,7 @@ function CasdoorLoginPage({onWebviewClose, initialMethod}) {
handleLogin(initialMethod)}
onWebviewClose={onWebviewClose}
+ usePortal={false}
/>
),
scanner: (
diff --git a/EnterCasdoorSdkConfig.js b/EnterCasdoorSdkConfig.js
index 7458d10..d5e1a4a 100644
--- a/EnterCasdoorSdkConfig.js
+++ b/EnterCasdoorSdkConfig.js
@@ -19,7 +19,7 @@ import {useNotifications} from "react-native-notificated";
import PropTypes from "prop-types";
import useStore from "./useStorage";
-function EnterCasdoorSdkConfig({onClose, onWebviewClose}) {
+function EnterCasdoorSdkConfig({onClose, onWebviewClose, usePortal = true}) {
const {
serverUrl,
clientId,
@@ -52,72 +52,73 @@ function EnterCasdoorSdkConfig({onClose, onWebviewClose}) {
onClose();
};
- return (
-
-
-
- Casdoor Configuration
-
-
-
-
-
-
-
-
-
-
+ const content = (
+
+
+ Casdoor Configuration
+
+
+
+
+
+
+
+
+
-
+
);
+
+ return usePortal ? {content} : content;
}
EnterCasdoorSdkConfig.propTypes = {
onClose: PropTypes.func.isRequired,
onWebviewClose: PropTypes.func.isRequired,
+ usePortal: PropTypes.bool,
};
const styles = StyleSheet.create({
@@ -142,7 +143,7 @@ const styles = StyleSheet.create({
title: {
fontSize: 20,
fontWeight: "bold",
- fontFamily: "Lato-Bold",
+ fontFamily: "Lato_700Bold",
color: "#212121",
textAlign: "center",
marginBottom: 16,
diff --git a/Header.js b/Header.js
index bc94279..9265ad0 100644
--- a/Header.js
+++ b/Header.js
@@ -159,7 +159,7 @@ const styles = StyleSheet.create({
fontSize: Math.max(24, width * 0.05),
fontWeight: "bold",
color: "#212121",
- fontFamily: "Lato-Bold",
+ fontFamily: "Lato_700Bold",
},
buttonContainer: {
borderRadius: 24,
@@ -179,7 +179,7 @@ const styles = StyleSheet.create({
fontWeight: "600",
marginLeft: 8,
color: "#424242",
- fontFamily: "Roboto-Medium",
+ fontFamily: "Roboto_500Medium",
},
menuContent: {
backgroundColor: "#FAFAFA",
diff --git a/api.js b/api.js
index 963e776..567d070 100644
--- a/api.js
+++ b/api.js
@@ -38,7 +38,10 @@ export const getMfaAccounts = async(serverUrl, owner, name, token, timeoutMs = T
throw new Error(res.msg);
}
- return {updatedTime: res.data.updatedTime, mfaAccounts: res.data.mfaAccounts};
+ return {
+ updatedTime: res.data.updatedTime,
+ mfaAccounts: res.data.mfaAccounts || [],
+ };
} catch (error) {
if (error.name === "AbortError") {
throw new Error("Request timed out");
diff --git a/app.json b/app.json
index a651def..b72df19 100644
--- a/app.json
+++ b/app.json
@@ -50,7 +50,8 @@
"photosPermission": "The app accesses your photos to add Totp account."
}
],
- "expo-asset"
+ "expo-asset",
+ "expo-font"
],
"owner": "casdoor"
}
diff --git a/package-lock.json b/package-lock.json
index d9074b3..1d79d74 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -8,6 +8,8 @@
"name": "casdoor-app",
"version": "1.0.0",
"dependencies": {
+ "@expo-google-fonts/lato": "^0.2.3",
+ "@expo-google-fonts/roboto": "^0.2.3",
"@expo/react-native-action-sheet": "^4.1.0",
"@react-native-async-storage/async-storage": "1.23.1",
"@react-native-community/masked-view": "^0.1.11",
@@ -19,13 +21,14 @@
"casdoor-react-native-sdk": "1.1.0",
"drizzle-orm": "^0.33.0",
"eslint-plugin-import": "^2.28.1",
- "expo": "~51.0.37",
+ "expo": "~51.0.38",
"expo-asset": "~10.0.10",
"expo-camera": "~15.0.16",
"expo-crypto": "~13.0.2",
"expo-dev-client": "~4.0.28",
"expo-document-picker": "~12.0.2",
"expo-drizzle-studio-plugin": "^0.0.2",
+ "expo-font": "~12.0.10",
"expo-image": "~1.13.0",
"expo-image-picker": "~15.0.7",
"expo-sqlite": "^14.0.6",
@@ -3112,6 +3115,18 @@
"url": "https://github.com/sponsors/sindresorhus"
}
},
+ "node_modules/@expo-google-fonts/lato": {
+ "version": "0.2.3",
+ "resolved": "https://registry.npmjs.com/@expo-google-fonts/lato/-/lato-0.2.3.tgz",
+ "integrity": "sha512-X56FEZn2GNYtI2/UqyOps7TShuDwi/k9JKa7VzM0x2ywBOnhTtXGq2IsZyNPzT9KnQA/ID84F9yiMS8e3obu0g==",
+ "license": "MIT"
+ },
+ "node_modules/@expo-google-fonts/roboto": {
+ "version": "0.2.3",
+ "resolved": "https://registry.npmjs.com/@expo-google-fonts/roboto/-/roboto-0.2.3.tgz",
+ "integrity": "sha512-PF6S//ZYWeXfpYTwvY2oEe0d5RnqwR5KMsGjuTgg6y9p/CPK/IkWL+wsbkzjfd+Jck1Q1pRlWOoe5uz42sQFRg==",
+ "license": "MIT"
+ },
"node_modules/@expo/bunyan": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.com/@expo/bunyan/-/bunyan-4.0.1.tgz",
@@ -11260,9 +11275,9 @@
}
},
"node_modules/expo": {
- "version": "51.0.37",
- "resolved": "https://registry.npmjs.com/expo/-/expo-51.0.37.tgz",
- "integrity": "sha512-zMdfTiGNgNWG0HOOFA3zRreS94iQ7fDxxgEIR6wdQCbncTpbeYj+5mscTAlHE9JJ+oBkcNyJXrLSjE/YVbFERg==",
+ "version": "51.0.38",
+ "resolved": "https://registry.npmjs.com/expo/-/expo-51.0.38.tgz",
+ "integrity": "sha512-/B9npFkOPmv6WMIhdjQXEY0Z9k/67UZIVkodW8JxGIXwKUZAGHL+z1R5hTtWimpIrvVhyHUFU3f8uhfEKYhHNQ==",
"license": "MIT",
"dependencies": {
"@babel/runtime": "^7.20.0",
@@ -11277,7 +11292,7 @@
"expo-font": "~12.0.10",
"expo-keep-awake": "~13.0.2",
"expo-modules-autolinking": "1.11.3",
- "expo-modules-core": "1.12.25",
+ "expo-modules-core": "1.12.26",
"fbemitter": "^3.0.0",
"whatwg-url-without-unicode": "8.0.0-3"
},
@@ -11667,9 +11682,9 @@
}
},
"node_modules/expo-modules-core": {
- "version": "1.12.25",
- "resolved": "https://registry.npmjs.com/expo-modules-core/-/expo-modules-core-1.12.25.tgz",
- "integrity": "sha512-HB2LS2LEM41Xq1bG+Jtzqm6XgPaa+mM9BAvCdX1lDGMQ9Ay9vMTL/GVEs2gpsINPofICopjBRwD+wftyCbVrzg==",
+ "version": "1.12.26",
+ "resolved": "https://registry.npmjs.com/expo-modules-core/-/expo-modules-core-1.12.26.tgz",
+ "integrity": "sha512-y8yDWjOi+rQRdO+HY+LnUlz8qzHerUaw/LUjKPU/mX8PRXP4UUPEEp5fjAwBU44xjNmYSHWZDwet4IBBE+yQUA==",
"license": "MIT",
"dependencies": {
"invariant": "^2.2.4"
diff --git a/package.json b/package.json
index d8c716f..f9342d2 100644
--- a/package.json
+++ b/package.json
@@ -10,6 +10,8 @@
"release": "npx -p semantic-release-expo -p semantic-release -p @semantic-release/git -p @semantic-release/changelog -p @semantic-release/exec semantic-release"
},
"dependencies": {
+ "@expo-google-fonts/lato": "^0.2.3",
+ "@expo-google-fonts/roboto": "^0.2.3",
"@expo/react-native-action-sheet": "^4.1.0",
"@react-native-async-storage/async-storage": "1.23.1",
"@react-native-community/masked-view": "^0.1.11",
@@ -21,13 +23,14 @@
"casdoor-react-native-sdk": "1.1.0",
"drizzle-orm": "^0.33.0",
"eslint-plugin-import": "^2.28.1",
- "expo": "~51.0.37",
+ "expo": "~51.0.38",
"expo-asset": "~10.0.10",
"expo-camera": "~15.0.16",
"expo-crypto": "~13.0.2",
"expo-dev-client": "~4.0.28",
"expo-document-picker": "~12.0.2",
"expo-drizzle-studio-plugin": "^0.0.2",
+ "expo-font": "~12.0.10",
"expo-image": "~1.13.0",
"expo-image-picker": "~15.0.7",
"expo-sqlite": "^14.0.6",