功能:同步小程序流程

This commit is contained in:
xiaowang
2026-05-23 18:45:41 +08:00
parent 844516988b
commit 30ae763e18
117 changed files with 8823 additions and 76 deletions
+48
View File
@@ -1,9 +1,21 @@
/**
* Purpose: fileApi supports upload.js by holding or executing the file api page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
const fileApi = require('../api/file')
/**
* Purpose: getFileSystemManager supports upload.js by holding or executing the get file system manager page or API role.
* Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow.
*/
function getFileSystemManager() {
return wx.getFileSystemManager()
}
/**
* Purpose: getFileInfo supports upload.js by holding or executing the get file info page or API role.
* Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow.
*/
function getFileInfo(filePath) {
return new Promise((resolve, reject) => {
wx.getFileInfo({
@@ -14,6 +26,10 @@ function getFileInfo(filePath) {
})
}
/**
* Purpose: readFileBuffer supports upload.js by holding or executing the read file buffer page or API role.
* Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow.
*/
function readFileBuffer(filePath) {
return new Promise((resolve, reject) => {
getFileSystemManager().readFile({
@@ -24,6 +40,10 @@ function readFileBuffer(filePath) {
})
}
/**
* Purpose: writeChunkFile supports upload.js by holding or executing the write chunk file page or API role.
* Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow.
*/
function writeChunkFile(filePath, data) {
return new Promise((resolve, reject) => {
getFileSystemManager().writeFile({
@@ -36,6 +56,10 @@ function writeChunkFile(filePath, data) {
})
}
/**
* Purpose: removeFile supports upload.js by holding or executing the remove file page or API role.
* Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow.
*/
function removeFile(filePath) {
return new Promise(resolve => {
getFileSystemManager().unlink({
@@ -46,6 +70,10 @@ function removeFile(filePath) {
})
}
/**
* Purpose: normalizeSelectedFiles supports upload.js by holding or executing the normalize selected files page or API role.
* Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow.
*/
function normalizeSelectedFiles(files) {
return (Array.isArray(files) ? files : []).map((item, index) => {
if (typeof item === 'string') {
@@ -62,6 +90,10 @@ function normalizeSelectedFiles(files) {
}).filter(item => item.tempFilePath)
}
/**
* Purpose: createFingerprint supports upload.js by holding or executing the create fingerprint page or API role.
* Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow.
*/
function createFingerprint(seed) {
let hash = 0
const text = String(seed || '')
@@ -74,6 +106,10 @@ function createFingerprint(seed) {
return `mini-${Math.abs(hash)}`
}
/**
* Purpose: resolveContentType supports upload.js by holding or executing the resolve content type page or API role.
* Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow.
*/
function resolveContentType(fileName) {
const value = String(fileName || '').toLowerCase()
if (value.endsWith('.png')) {
@@ -88,6 +124,10 @@ function resolveContentType(fileName) {
return 'image/jpeg'
}
/**
* Purpose: uploadSingleFile supports upload.js by holding or executing the upload single file page or API role.
* Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow.
*/
async function uploadSingleFile(file, scene, onProgress) {
const fileInfo = await getFileInfo(file.tempFilePath)
const buffer = await readFileBuffer(file.tempFilePath)
@@ -155,6 +195,10 @@ async function uploadSingleFile(file, scene, onProgress) {
return result
}
/**
* Purpose: uploadImageFiles supports upload.js by holding or executing the upload image files page or API role.
* Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow.
*/
async function uploadImageFiles(options) {
const files = normalizeSelectedFiles(options && options.files)
const scene = options && options.scene ? options.scene : 'admin-product-image'
@@ -176,6 +220,10 @@ async function uploadImageFiles(options) {
return results
}
/**
* Purpose: chooseImageFiles supports upload.js by holding or executing the choose image files page or API role.
* Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow.
*/
function chooseImageFiles(options) {
const config = options || {}