登录页面和文件打开方式
This commit is contained in:
@@ -346,6 +346,7 @@
|
||||
chooseFile
|
||||
} from '@/uni_modules/lime-choose-file'
|
||||
import socketManager from '../../utils/socket';
|
||||
import { openFile as openFileNative, downloadAndOpen } from '@/utils/fileOpener.js'
|
||||
|
||||
const friendSocketStore = useFriendSocketStore()
|
||||
// 连接实时通讯eriendsocket
|
||||
@@ -523,15 +524,7 @@
|
||||
}
|
||||
// 打开文件
|
||||
const openFile = (url) => {
|
||||
uni.downloadFile({
|
||||
url: url,
|
||||
success: (res) => {
|
||||
uni.openDocument({
|
||||
filePath: res.tempFilePath,
|
||||
showMenu: true
|
||||
})
|
||||
}
|
||||
})
|
||||
downloadAndOpen(url);
|
||||
}
|
||||
// 文件大小格式化
|
||||
const formatFileSize = (size) => {
|
||||
@@ -906,12 +899,8 @@
|
||||
success: (downloadRes) => {
|
||||
if (downloadRes.statusCode === 200) {
|
||||
hideDownloadToast()
|
||||
uni.openDocument({
|
||||
filePath: downloadRes.tempFilePath,
|
||||
showMenu: true,
|
||||
fail: () => {
|
||||
showDownloadToast('error', '无法打开此文件', 2500)
|
||||
}
|
||||
openFileNative(downloadRes.tempFilePath, () => {
|
||||
showDownloadToast('error', '无法打开此文件', 2500)
|
||||
})
|
||||
} else {
|
||||
showDownloadToast('error', '下载失败', 2500)
|
||||
@@ -1188,14 +1177,16 @@
|
||||
if (reason === 'pc offline') {
|
||||
isThinking.value = false
|
||||
socketStore.authFailReason = ''
|
||||
nextTick(() => {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: 'PC端不在线,不可聊天',
|
||||
showCancel: false,
|
||||
confirmText: '知道了'
|
||||
})
|
||||
uni.showToast({
|
||||
title: 'PC端不在线,请先登录',
|
||||
icon: 'none',
|
||||
duration: 500
|
||||
})
|
||||
setTimeout(() => {
|
||||
uni.reLaunch({
|
||||
url: '/pages/Login/Login'
|
||||
})
|
||||
}, 500)
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
@@ -475,6 +475,7 @@
|
||||
uploadCloudDbFile,
|
||||
deleteCloudDb
|
||||
} from '@/utils/cloud-api.js';
|
||||
import { openFile as openFileNative } from '@/utils/fileOpener.js'
|
||||
|
||||
const userToken = ref('');
|
||||
const userId = ref('');
|
||||
@@ -826,19 +827,10 @@
|
||||
}
|
||||
};
|
||||
|
||||
// 使用系统默认应用打开
|
||||
// 打开文件(弹出应用选择菜单)
|
||||
const openFile = (filePath) => {
|
||||
uni.openDocument({
|
||||
filePath: filePath,
|
||||
success: () => uni.showToast({
|
||||
title: '打开成功',
|
||||
icon: 'success'
|
||||
}),
|
||||
fail: (err) => {
|
||||
console.error('打开文件失败:', err);
|
||||
// 如果默认应用打开失败,尝试弹出选择菜单
|
||||
openFileWithMenu(filePath);
|
||||
}
|
||||
openFileNative(filePath, () => {
|
||||
openFileWithMenu(filePath);
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@@ -121,6 +121,7 @@
|
||||
workspaceUploadFileByURL,
|
||||
updateWorkspaceFileName
|
||||
} from '@/utils/cloud-api.js'
|
||||
import { openFile as openFileNative } from '@/utils/fileOpener.js'
|
||||
|
||||
const UserToken = ref('')
|
||||
const workspaceId = ref('')
|
||||
@@ -435,40 +436,10 @@
|
||||
}
|
||||
};
|
||||
|
||||
// 使用系统默认应用打开
|
||||
// 打开文件(弹出应用选择菜单)
|
||||
const openFile = (filePath) => {
|
||||
uni.openDocument({
|
||||
filePath: filePath,
|
||||
success: () => uni.showToast({
|
||||
title: '打开成功',
|
||||
icon: 'success'
|
||||
}),
|
||||
fail: (err) => {
|
||||
console.error('打开文件失败:', err);
|
||||
uni.showToast({
|
||||
title: '无法打开此文件',
|
||||
icon: 'error'
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// 选择其他应用打开
|
||||
const openFileWithMenu = (filePath) => {
|
||||
uni.openDocument({
|
||||
filePath: filePath,
|
||||
showMenu: true,
|
||||
success: () => uni.showToast({
|
||||
title: '打开成功',
|
||||
icon: 'success'
|
||||
}),
|
||||
fail: (err) => {
|
||||
console.error('打开文件失败:', err);
|
||||
uni.showToast({
|
||||
title: '无法打开此文件',
|
||||
icon: 'error'
|
||||
});
|
||||
}
|
||||
openFileNative(filePath, () => {
|
||||
uni.showToast({ title: '无法打开此文件', icon: 'error' });
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@@ -325,6 +325,7 @@
|
||||
chooseFile
|
||||
} from '@/uni_modules/lime-choose-file'
|
||||
import socketManager from '../../utils/socket';
|
||||
import { openFile as openFileNative } from '@/utils/fileOpener.js'
|
||||
|
||||
const friendSocketStore = useFriendSocketStore()
|
||||
// 连接实时通讯eriendsocket
|
||||
@@ -490,15 +491,7 @@
|
||||
}
|
||||
// 打开文件
|
||||
const openFile = (url) => {
|
||||
uni.downloadFile({
|
||||
url: url,
|
||||
success: (res) => {
|
||||
uni.openDocument({
|
||||
filePath: res.tempFilePath,
|
||||
showMenu: true
|
||||
})
|
||||
}
|
||||
})
|
||||
downloadAndOpen(url);
|
||||
}
|
||||
// 文件大小格式化
|
||||
const formatFileSize = (size) => {
|
||||
@@ -1131,14 +1124,16 @@
|
||||
if (reason === 'pc offline') {
|
||||
isThinking.value = false
|
||||
socketStore.authFailReason = ''
|
||||
nextTick(() => {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: 'PC端不在线,不可聊天',
|
||||
showCancel: false,
|
||||
confirmText: '知道了'
|
||||
})
|
||||
uni.showToast({
|
||||
title: 'PC端不在线',
|
||||
icon: 'none',
|
||||
duration: 1500
|
||||
})
|
||||
setTimeout(() => {
|
||||
uni.reLaunch({
|
||||
url: '/pages/Login/Login'
|
||||
})
|
||||
}, 1500)
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user