forked from oceanbase/ob-operator
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix resource pool related defects (oceanbase#279)
* Fix resource pool related defects * fix:Avoid repeated requests for public keys
- Loading branch information
1 parent
43c7f39
commit ae84363
Showing
8 changed files
with
108 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,31 @@ | ||
import React, { useEffect } from 'react'; | ||
import { getAppInfoFromStorage } from '@/utils/helper'; | ||
import { getAppInfo } from '@/services'; | ||
import { useModel } from '@umijs/max'; | ||
import JSEncrypt from 'jsencrypt'; | ||
import { useEffect } from 'react'; | ||
|
||
export const usePublicKey = () => { | ||
const [publicKey, setPublicKey] = React.useState<string>(''); | ||
const { publicKey, setPublicKey } = useModel('global'); | ||
|
||
useEffect(() => { | ||
getAppInfoFromStorage().then((appInfo) => { | ||
setPublicKey(appInfo.publicKey); | ||
}).catch((err) => { | ||
console.log(err) | ||
}); | ||
}, []) | ||
if (!publicKey) { | ||
getAppInfo() | ||
.then(({ data }) => { | ||
setPublicKey(data.publicKey); | ||
}) | ||
.catch((err) => { | ||
console.log(err); | ||
}); | ||
} | ||
}, []); | ||
|
||
return publicKey; | ||
} | ||
}; | ||
|
||
export const encryptText = (text: string, publicKey: string): string | false => { | ||
const encrypt = new JSEncrypt(); | ||
export const encryptText = ( | ||
text: string, | ||
publicKey: string, | ||
): string | false => { | ||
const encrypt = new JSEncrypt(); | ||
encrypt.setPublicKey(publicKey); | ||
return encrypt.encrypt(text); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters