This commit is contained in:
XiaoMo 2023-06-04 18:28:32 +08:00
parent 28f854f89c
commit ff13a53022
2 changed files with 11 additions and 12 deletions

View File

@ -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);

View File

@ -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,
})