This commit is contained in:
cansnow
2026-02-09 07:29:02 +08:00
parent 2860c46ec1
commit 6720c15e30
19 changed files with 996 additions and 207 deletions
+30 -4
View File
@@ -3,6 +3,9 @@ import IMSDK,{IMMethods} from "openim-uniapp-polyfill";
import {offlinePushInfo} from "@/util/imCommon";
import {upload} from "@/api/login.js";
import {getVideoInfo} from "@/util/common";
// #ifdef APP
import {downloadFile} from "@/uni_modules/network-manage";
// #endif
export const imapi = (method,data)=>{
return new Promise((resolve, reject) => {
IMSDK.asyncApi(method,IMSDK.uuid(),data)
@@ -19,10 +22,30 @@ export const copyFileToTempPath = (src) => {
console.log('src', src);
console.log('src', src.includes(plus.io.PRIVATE_DOC));
return new Promise((resolve, reject) => {
plus.io.resolveLocalFileSystemURL(src, (entry) => {
const cacheFilePath = '_doc/uniapp_temp/'+entry.name;
console.log('cacheFilePath', cacheFilePath);
const task = downloadFile({
url:src,
timeout: 30000,
filePath:cacheFilePath,
success(res) {
console.log('res',res);
},
fail(e){
console.log('e',e);
},
complate(){
task = null;
}
});
});
return ;
plus.io.resolveLocalFileSystemURL(src, (entry) => {
console.log('entry name', entry.name);
console.log('dir', '_doc/uniapp_temp/');
entry.copyTo('_doc/uniapp_temp/', entry.name, (newEntry) => {
entry.copyTo(plus.io.PUBLIC_DOCUMENTS, '/uniapp_temp/'+entry.name, (newEntry) => {
console.log('newEntry', newEntry.fullPath);
resolve(newEntry.toLocalURL());
}, reject);
@@ -61,9 +84,9 @@ export const getVideoCover = async (path)=>{
export const createVideoMessage = (path)=>{
return new Promise(async(resolve, reject) => {
console.log('处理前的可用路径', path);
const realVideoPath = await copyFileToTempPath(path);
//const realVideoPath = await getPurePath(path);
console.log('处理后的可用路径', realVideoPath);
//const realVideoPath = await copyFileToTempPath(path);
const realVideoPath = await getPurePath(path);
//console.log('处理后的可用路径', realVideoPath);
const info = await getVideoInfo(realVideoPath);
console.log('info', info);
const cover = await getVideoCover(realVideoPath);
@@ -80,6 +103,9 @@ export const createVideoMessage = (path)=>{
})
});
console.log('videoresult', videoresult);
const video_url = "";
//封面
const cover_url = `${video_url}?x-oss-process=video/snapshot,t_7000,f_jpg,w_800,h_600,m_fast`;
uni.hideLoading();
if(videoresult.code !=0){
+18
View File
@@ -245,6 +245,23 @@ const get_absolute_path = (fn)=>{
return plus.io.convertLocalFileSystemURL(fn);
}
const pendingDownloads = new Map();
const getCachePath = (url,saveDir)=>{
if(!url || !url.startsWith('http')){
return url;
}
const key = md5(url);
var ext = "png"
if(url.toLowerCase().indexOf('.mp4')!==-1){
ext = "mp4";
}
let cacheDir = plus.io.convertLocalFileSystemURL(`_doc/{{dir}}/{{key}}.{{ext}}`);
if(uni.getSystemInfoSync().osName == 'android'){
cacheDir = cacheDir.replace('apps/'+plus.runtime.appid+'/doc','cache');
}
return cacheDir.replace('{{dir}}',saveDir)
.replace('{{key}}',key)
.replace('{{ext}}',ext);
}
const cacheFile = (url, saveDir,progressCallback) => {
//console.log(url);
// #ifndef APP
@@ -462,6 +479,7 @@ export default{
toMapAPP,
cacheFile,
fileExsit,
getCachePath,
get_absolute_path,
// #ifdef APP
downloadFile,
+7
View File
@@ -19,6 +19,13 @@ module.exports = (vm) => {
...config.header,
token:uni.getStorageSync("BusinessToken"),
operationID: uuidV4(),
client:uni.getSystemInfoSync().osName,
// #ifdef APP-PLUS
ClientVersion:plus.runtime.versionCode,
// #endif
// #ifndef APP-PLUS
ClientVersion:350,
// #endif
};
if(typeof config.data === 'object'){
config.data = JSON.stringify(config.data);