登录页面和文件打开方式

This commit is contained in:
2026-07-31 16:38:01 +08:00
parent 09f4d3ba52
commit 314a714248
8 changed files with 413 additions and 297 deletions

View File

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

View File

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

View File

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

View File

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