From ff13a53022087e3e9d6d6926e0e4c3b1a2e177e9 Mon Sep 17 00:00:00 2001 From: XiaoMo Date: Sun, 4 Jun 2023 18:28:32 +0800 Subject: [PATCH] modified --- src/components/header/ConversationHeaderShare.tsx | 15 ++++++++------- src/http/api.ts | 8 +++----- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/components/header/ConversationHeaderShare.tsx b/src/components/header/ConversationHeaderShare.tsx index 449ac4f..94dbbad 100644 --- a/src/components/header/ConversationHeaderShare.tsx +++ b/src/components/header/ConversationHeaderShare.tsx @@ -16,13 +16,14 @@ export default () => { var conversation = currentConversation(); fetchData({id:conversation.id, title: conversation.name }, function(data) { if(data.code==200){ - if (navigator.userAgent.match(/Android/i) - || navigator.userAgent.match(/webOS/i) - || navigator.userAgent.match(/iPhone/i) - || navigator.userAgent.match(/iPad/i) - || navigator.userAgent.match(/iPod/i) - || navigator.userAgent.match(/BlackBerry/i) - || navigator.userAgent(/Windows Phone/i)) { + + if (window.navigator.userAgent.match(/Android/i) + || window.navigator.userAgent.match(/webOS/i) + || window.navigator.userAgent.match(/iPhone/i) + || window.navigator.userAgent.match(/iPad/i) + || window.navigator.userAgent.match(/iPod/i) + || window.navigator.userAgent.match(/BlackBerry/i) + || window.navigator.userAgent.match(/Windows Phone/i)) { window.location.href = data.url; } else { window.open(data.url); diff --git a/src/http/api.ts b/src/http/api.ts index 3eaf941..f709734 100644 --- a/src/http/api.ts +++ b/src/http/api.ts @@ -24,13 +24,8 @@ export function baseUrl(){ } export function getToken(){ - const sessionId = localStorage.getItem('AnsnidSessionId') || generateSessionId(); - localStorage.setItem('AnsnidSessionId', sessionId) - - console.log(sessionId) - return sessionId; } @@ -55,6 +50,9 @@ export function fetchData(data: Data | null, callback: (data: ResponseData) => v fetch(url, fetchOptions).then(response => response.json().then(data => { callback(data); })).catch(error => { + + console.log(error) + throw new Error('Request failed', { cause: error?.error, })