|
|
@@ -63,8 +63,29 @@ function App() {
|
|
|
}
|
|
|
}, []);
|
|
|
|
|
|
+ const handleConfigPermission = useCallback(async () => {
|
|
|
+ try {
|
|
|
+ const response = await fetch(`http://localhost:3001/api/configPermission?url=${encodeURIComponent(window.location.href)}`);
|
|
|
+ const config = await response.json();
|
|
|
+
|
|
|
+ await Dingdocs.base.host.configPermission(
|
|
|
+ config.agentId,
|
|
|
+ config.corpId,
|
|
|
+ config.timeStamp,
|
|
|
+ config.nonceStr,
|
|
|
+ config.signature,
|
|
|
+ ['DingdocsScript.base.readWriteAll']
|
|
|
+ );
|
|
|
+ console.log('权限配置成功');
|
|
|
+ } catch (error: any) {
|
|
|
+ console.warn('权限配置失败:', error);
|
|
|
+ }
|
|
|
+ }, []);
|
|
|
+
|
|
|
const handleAutoLogin = useCallback(async () => {
|
|
|
try {
|
|
|
+ await handleConfigPermission();
|
|
|
+
|
|
|
const urlParams = new URLSearchParams(window.location.search);
|
|
|
const corpId = urlParams.get('corpId') || '';
|
|
|
const authResult = await Dingdocs.base.host.getAuthCode(corpId);
|
|
|
@@ -78,7 +99,7 @@ function App() {
|
|
|
setError(error.message || '登录失败');
|
|
|
throw error;
|
|
|
}
|
|
|
- }, []);
|
|
|
+ }, [handleConfigPermission]);
|
|
|
|
|
|
const loadDocumentInfo = useCallback(async () => {
|
|
|
try {
|