Commit 41234954 by liimin

feat(recorder): 实现录音服务及日志模块

- 新增 AudioManager 和 RecordService 实现录音功能
- 添加 uni-logger 模块支持本地和远程日志记录
- 新增 uts-alioss 模块用于文件上传
- 实现录音文件缓存和数据库存储功能
- 在应用启动时初始化数据库并测试录音功能
- 更新项目依赖和配置文件
1 parent ae74ab29
Showing 75 changed files with 2067 additions and 221 deletions
...@@ -62,7 +62,7 @@ ...@@ -62,7 +62,7 @@
"editor.defaultFormatter": "dbaeumer.vscode-eslint" "editor.defaultFormatter": "dbaeumer.vscode-eslint"
}, },
"[typescript]": { "[typescript]": {
"editor.defaultFormatter": "dbaeumer.vscode-eslint" "editor.defaultFormatter": "rvest.vs-code-prettier-eslint"
}, },
"[markdown]": { "[markdown]": {
"editor.defaultFormatter": "dbaeumer.vscode-eslint" "editor.defaultFormatter": "dbaeumer.vscode-eslint"
......
<script lang="uts"> <script lang="uts">
let firstBackTime = 0; let firstBackTime = 0;
import RecordService from './composables/recorder/RecordService.uts'
export default { export default {
onLaunch: function () { onLaunch: function () {
console.log("App Launch"); console.log("App Launch");
setTimeout(() => {
//模拟接待开始
console.log("Simulating reception start...");
RecordService.getInstance().startAudio();
//模拟接待结束
console.log("Simulating reception end...");
setTimeout(() => {
RecordService.getInstance().stopAudio();
}, 10000);
}, 1000);
}, },
onShow: function () { onShow: function () {
console.log("App Show"); console.log("App Show");
......
/*
* @Descripttion:
* @version: 1.0.0
* @Author: limin
* @Date: 2024-11-22 08:18:23
* @LastEditors: limin
* @LastEditTime: 2026-01-13 19:02:14
* @FilePath: \gl_tape\utils\recordManager\DBBase.uts
*/
import SQLite from './sqlite.uts'
import { logger } from '../logger/index.uts'
/**
* 记录管理器基类
* 用于管理记录列表
*/
class DBBase {
db: SQLite | null = null
db_name = 'zyzs'
db_version = '1.0'
db_table_name = 'records'
db_description = 'zyzs db'
db_size = 50 * 1024 * 1024
// sqlite = null // 似乎没有用到,注释掉或删除
isTableExists = false
tableCreated = false // 新增标志位
table_name: string
table_columns: string[]
constructor(table_name: string, table_columns: string[]) {
this.table_name = table_name != "" ? table_name : this.db_table_name
this.table_columns = table_columns
this.db = new SQLite(this.db_name, this.db_version, this.db_description, this.db_size)
}
async init(): Promise<boolean> {
try {
// db 不可能为 null,因为在 constructor 中初始化了
const isOpen = this.db!.isOpen()
if (!isOpen) {
await this.db!.init()
}
if (this.table_name == null) {
throw new Error("DBBase: table_name is null")
}
const isTableExists = await this.db!.isTableExists(this.table_name)
logger.warn(`数据库是否存在isTableExists: ${isTableExists}`, "DBBase")
if (!isTableExists) {
await this.db!.createTable(this.table_name, this.table_columns)
this.tableCreated = true
} else {
logger.warn(`[${this.table_name}] 表已存在, 将检查并更新列`, "DBBase")
}
return true
} catch (error) {
logger.error(`初始化数据库失败 error - > ${error}`, "DBBase")
throw new Error(`Init DB failed: ${error}`)
}
}
async openDB() {}
/**
* 将一条新记录添加到当前对象的记录列表中
*
* @param {Object} record - 要添加的新记录对象
* @returns {Array} - 包含新记录的更新后的记录列表
*/
async addRecord(record: UTSJSONObject) {
await this.db!.insert(this.table_name, record)
}
/**
* 移除一个ID对应的记录
*
* @param {any} id - 要移除的记录的ID
* @returns {Array} - 移除记录后的更新后的记录列表
*/
async removeRecord(id: any): Promise<any> {
const where = { id: id }
return this.db!.delete(this.table_name, where)
}
/**
* 根据给定的 ID 获取一条记录
*
* @param {any} id - 要获取的记录的 ID
* @returns {Object} - 具有给定 ID 的记录对象,如果没有找到符合条件的记录,则返回 undefined
*
*/
async getRecordById(id: any): Promise<UTSJSONObject | null> {
const where = { id: id }
const records = await this.db!.select(this.table_name, where, null)
// records 是 any[],需要断言
if (records.length > 0) {
return records[0] as UTSJSONObject
}
return null
}
/**
* 根据条件获取记录列表
* @param {Object} where - 查询条件
* @returns {Array} - 记录列表
*/
async getRecordsByWhere(where: UTSJSONObject): Promise<any[]> {
return this.db!.select(this.table_name, where, null)
}
/**
* 获取记录列表
*
* @returns {Array} - 从 storageApi 获取的记录列表
*/
async getRecords(): Promise<any[]> {
return this.db!.select(this.table_name, null, null)
}
/**
* 设置记录列表
*
* @param {Array} records - 要设置的记录列表
* @returns {void} - 此函数不返回任何值
*/
async setRecords(records: UTSJSONObject[]) {
// 串行执行还是并行?forEach 是同步的,里面的 async 不会阻塞
// 应该用 for of 或者 Promise.all
for (const record of records) {
await this.addRecord(record)
}
}
/**
* 更新记录数组中的记录
* 这个函数用于更新给定记录数组中的特定记录
* 它接受一个参数 record,该参数是要更新的记录对象
*
* @param {Object} record - 要更新的记录对象,必须包含一个唯一的 id 属性
* @throws {Error} 如果记录数组中找不到具有给定 id 的记录,将抛出错误
*/
async updateRecord(setData: UTSJSONObject, where: UTSJSONObject | null): Promise<any> {
// const { id, ...record } = setData // UTS 不支持解构剩余参数
// 如果没有 where,尝试从 setData 中提取 id
let whereCondition = where
const dataToUpdate = JSON.parse(JSON.stringify(setData)) as UTSJSONObject // 深拷贝以避免修改原对象
if (whereCondition == null) {
if (dataToUpdate['id'] != null) {
whereCondition = { id: dataToUpdate['id'] }
// 从更新数据中移除 id,通常 id 是主键不更新
// dataToUpdate.delete('id') // UTS Map delete? UTSJSONObject 没有 delete 方法?
// UTSJSONObject 类似 Map,可以用 set/get,也可以像对象一样访问?
// 在 UTS 中,UTSJSONObject 可以直接赋值 null 来删除? 或者不用管它,update id=id 也没事
// 严谨做法:
// const newSetData = {}
// dataToUpdate.forEach((v, k) => { if (k != 'id') newSetData[k] = v })
} else {
throw new Error("Update record requires 'id' in setData or explicit 'where' clause")
}
}
return this.db!.update(this.table_name, dataToUpdate, whereCondition!)
}
async isOpen(): Promise<boolean> {
return this.db!.isOpen()
}
// async isTableExists(): Promise<boolean> {
// return this.db!.isTableExists(this.table_name)
// }
/**
* 清除所有记录
*
* @returns {void} - 此函数不返回任何值
*/
async clearRecords() {
// delete 需要 where 参数,这里可能是清空表
// sqlite.uts 的 delete 实现:`DELETE FROM ${tabName} WHERE ${whereStr}`
// 如果 where 为空,SQL 会变成 `DELETE FROM ${tabName} WHERE ` -> 语法错误
// 需要修改 sqlite.uts 支持无 where 删除,或者在这里传入 1=1
// 让我们看 sqlite.uts 的 delete 实现
/*
delete(tabName: string, where: UTSJSONObject): Promise<any> {
const whereKeys = where.keys()
// ...
const whereStr = whereList.join(' AND ')
const sql = `DELETE FROM ${tabName} WHERE ${whereStr}`
return this.executeSql(sql)
}
*/
// 确实,如果不传 where,whereKeys 为空,whereStr 为空,SQL 错误。
// 应该在 DBBase 里传入一个总是为真的条件,或者修改 sqlite.uts。
// 为了稳妥,这里传入空对象可能不行。
// 让我们传入一个假条件或者修改 sqlite.uts。
// 既然我刚刚重构了 sqlite.uts,我可以再改一下 sqlite.uts 让 delete 支持全表删除,
// 或者在这里调用 executeSql(`DELETE FROM ${this.table_name}`)。
// DBBase 没有直接暴露 executeSql。
// 还是传入一个 trick 条件吧,或者传入 null 让 sqlite 处理。
// 修改 sqlite.uts 比较好。但用户没让我再改 sqlite.uts。
// 我们可以传入 { "1": 1 } ?
// 让我们先暂时注释掉或抛出未实现,或者传入 dummy where。
// 或者直接调用 this.db!.executeSql(`DELETE FROM ${this.table_name}`),虽然是 private 或者是 public?
// sqlite.uts 中 executeSql 是 public 的。
await this.db!.executeSql(`DELETE FROM ${this.table_name}`)
}
async drop() {
this.db!.drop(this.table_name)
}
}
export default DBBase
// 模拟 Sentry SDK,实际项目中请替换为真实的 Sentry 导入
// 假设这里有一个 sentry-uts 插件或类似的封装
// import * as Sentry from "sentry-uts";
export type UserInfo = {
id: string
name: string
extra?: UTSJSONObject
}
export type Tag = {
key: string
value: string
}
export type RemoteLogOptions = {
msg: string
extra?: UTSJSONObject
tag?: Tag
}
export class RemoteLog {
// private sentry: any = null;
constructor(user: UserInfo) {
// this.sentry = Sentry.init({...});
// Sentry.setUser(user);
console.log("[RemoteLog] Init with user:", user);
}
debug(options: RemoteLogOptions) {
this.send("debug", options);
}
info(options: RemoteLogOptions) {
this.send("info", options);
}
warn(options: RemoteLogOptions) {
this.send("warn", options);
}
error(options: RemoteLogOptions) {
this.send("error", options);
}
private send(level: string, options: RemoteLogOptions) {
// 模拟发送逻辑
// 在实际项目中,这里会调用 Sentry 的 API
const systemInfo = uni.getSystemInfoSync();
const enhancedExtra = {
device_brand: systemInfo.deviceBrand,
device_model: systemInfo.deviceModel,
os_name: systemInfo.osName,
os_version: systemInfo.osVersion,
uni_platform: systemInfo.uniPlatform,
app_version: systemInfo.appVersion,
};
if (options.extra != null) {
// 手动合并 extra
// UTSJSONObject 无法直接遍历 keys,这里仅作占位
// 如果需要合并,建议在调用处直接传递合并后的对象
}
console.log(`[RemoteLog] Sending [${level}]`, {
msg: options.msg,
tag: options.tag,
extra: enhancedExtra,
user_extra: options.extra
});
// if (options.msg instanceof Error) {
// Sentry.captureException(options.msg);
// } else {
// Sentry.captureMessage(String(options.msg), level);
// }
}
}
import { logger as uniLogger, LogLevel } from '@/uni_modules/uni-logger/index.uts';
import { RemoteLog, RemoteLogOptions, UserInfo } from './RemoteLog';
export class Logger {
private static instance: Logger | null = null;
private remote: RemoteLog | null = null;
private user: UserInfo | null = null;
private constructor() {
// 设置 uni-logger 的远程处理器钩子
uniLogger.setRemoteHandler((level: LogLevel, tag: string, msg: string) => {
// 这里可以过滤某些不需要上报的日志,或者只上报 error 级别
if (this.remote != null) {
const options = {
msg: msg,
tag: { key: "module", value: tag }
} as RemoteLogOptions;
switch (level) {
case "debug": this.remote!.debug(options); break;
case "info": this.remote!.info(options); break;
case "warn": this.remote!.warn(options); break;
case "error": this.remote!.error(options); break;
}
}
});
}
static getInstance(): Logger {
if (Logger.instance == null) {
Logger.instance = new Logger();
}
return Logger.instance!;
}
init(user: UserInfo) {
this.user = user;
this.remote = new RemoteLog(user);
uniLogger.info(`Logger initialized for user: ${user.name}`);
}
/**
* 打印调试日志
* @param msg 日志内容
* @param tag 标签,默认 "App"
*/
debug(msg: any, tag: string = "App") {
uniLogger.setTag(tag);
uniLogger.debug(msg);
}
/**
* 打印信息日志
* @param msg 日志内容
* @param tag 标签,默认 "App"
*/
info(msg: any, tag: string = "App") {
uniLogger.setTag(tag);
uniLogger.info(msg);
}
/**
* 打印警告日志
* @param msg 日志内容
* @param tag 标签,默认 "App"
*/
warn(msg: any, tag: string = "App") {
uniLogger.setTag(tag);
uniLogger.warn(msg);
}
/**
* 打印错误日志
* @param msg 日志内容
* @param tag 标签,默认 "App"
*/
error(msg: any, tag: string = "App") {
uniLogger.setTag(tag);
uniLogger.error(msg);
}
}
export const logger = Logger.getInstance();
/*
* @Descripttion:
* @version: 1.0.0
* @Author: limin
* @Date: 2024-12-04 18:17:23
* @LastEditors: limin
* @LastEditTime: 2026-02-28 10:09:53
* @FilePath: \venus\apps\uniappX\uniapp-x-tape\composables\recorder\AudioManager.uts
*/
import { AudioStartOptions, AudioEvents, OnStartCallback, OnStopCallback, OnErrorCallback } from './types'
import { startRecord, stopRecord, StartRecordSuccess, StopRecordSuccess, StartRecordOptions, StopRecordOptions } from '@/uni_modules/uts-recorder'
import { logger } from '../logger'
class AudioManager {
startOptions: AudioStartOptions = {
// duration: 10 * 60 * 1000, // uts-recorder 暂不支持 duration 自动停止
sampleRate: 16000,
numberOfChannels: 1
}
__isRecording: boolean = false
__counter: number = 0
events: AudioEvents
/**
* AudioManager类的构造函数
* 负责初始化音频管理器实例,包括音频录制的开始、停止和错误处理
* @param {OnStartCallback} onStart - 音频录制开始时的回调函数
* @param {OnStopCallback} onStop - 音频录制停止时的回调函数
* @param {OnErrorCallback} onError - 音频录制遇到错误时的回调函数
*/
constructor(onStart: OnStartCallback, onStop: OnStopCallback, onError: OnErrorCallback) {
this.events = {
onStart,
onStop,
onError
}
}
/**
* 启动录音
*/
start() {
logger.info('〖录音管理Audio〗 == 开启录音 ')
const options = {
sampleRate: this.startOptions.sampleRate,
numberOfChannels: this.startOptions.numberOfChannels,
success: (res: StartRecordSuccess) => {
this.onStart(res)
},
fail: (err: UniError) => {
this.onError(err)
}
} as StartRecordOptions
startRecord(options)
}
/**
* 录音开始成功的回调
*/
async onStart(res: StartRecordSuccess) {
// 记录录音开始的信息到日志
logger.info('〖录音管理Audio〗 == 开启录音回调 '+JSON.stringify(res))
// 等待事件的onStart方法执行完成
await this.events.onStart(res)
// 内部计数器增加,用于跟踪录音开始的次数
this.__counter++
// 设置录音状态标志为true,表示当前正在录音
this.__isRecording = true
}
/**
* 停止录音
*/
stop() {
// 记录停止录音的信息
logger.info('〖录音管理Audio〗 == 停止录音 ')
// 重置录音状态
this.reset()
// 调用 uts-recorder 的 stop 方法
const options = {
success: (res: StopRecordSuccess) => {
this.onStop(res)
},
fail: (err: UniError) => {
this.onError(err)
}
} as StopRecordOptions
stopRecord(options)
}
/**
* 录音停止成功的回调
*/
async onStop(res: StopRecordSuccess) {
logger.info('〖录音管理Audio〗 == 停止录音回调 ')
await this.events.onStop(res)
}
/**
* 异步处理错误的方法
*
* 当遇到错误时,此方法会被调用,它将等待错误事件处理完成
* 主要作用是将错误传递给注册在this.events上的错误事件处理器
*
* @param {Error} err - 发生的错误对象
*/
async onError(err: UniError) {
logger.info('〖录音管理Audio〗 == 录音错误回调 '+JSON.stringify(err))
// 重置录音状态
this.reset()
await this.events.onError(err)
}
/**
* 获取当前是否正在录音的状态
*
* 此方法用于获取实例当前的录音状态它返回一个布尔值,表示是否正在录音
* 该方法没有参数
*
* @returns {boolean} 当前是否正在录音true表示正在录音,false表示未在录音
*/
get isRecording(): boolean {
return this.__isRecording
}
/**
* 获取当前计数器的值
*
* 此方法作为属性访问器,用于获取内部私有属性 __counter 的值
* 它没有参数
* 返回值为当前计数器的值
*/
get counter(): number {
return this.__counter
}
setCounter(val: number) {
this.__counter = val
}
/**
* 重置录音状态
*
* 此方法用于将录音管理器的状态重置为初始状态,即不是正在录音,且计数器清零
* 它主要用于准备开始新的录音过程或取消当前录音过程时,清理所有录音相关状态
*/
reset() {
// 记录重置录音状态的日志信息
logger.info('〖录音管理Audio〗 == 重置录音状态 ')
// 设置__isRecording属性为false,表示当前不处于录音状态
this.__isRecording = false
// 将__counter计数器重置为0,此计数器可能用于记录录音过程中的某些度量,如录音时间
this.__counter = 0
}
}
export default AudioManager
/*
* @Descripttion:
* @version: 1.0.0
* @Author: limin
* @Date: 2025-01-02 18:34:39
* @LastEditors: limin
* @LastEditTime: 2026-03-01 02:56:19
* @FilePath: \venus\apps\uniappX\uniapp-x-tape\composables\recorder\DBRecord.uts
*/
import DBBase from '../db/DBBase.uts'
import { logger } from '../logger/index.uts'
const TABLE_NAME = 'records'
const TABLE_COLUMNS = [
`id TEXT PRIMARY KEY`,
`staffUuid TEXT`,
`staffName TEXT`,
`serviceMerchantId INTEGER`,
'carModel TEXT',
'endReasonType INTEGER',
'customerName TEXT',
'phoneNumber TEXT',
'appCode TEXT',
'loginPhone TEXT',
'salesName TEXT',
'salesUuid TEXT',
'receptionStatus INTEGER',
'receptionStartTime TEXT',
'receptionEndTime TEXT',
'receptionCustomerPaySourceList TEXT',
'merchantId INTEGER',
'merchantName TEXT',
'bussinessType INTEGER',
'channelType INTEGER',
'receptionCustomerMaterialPointList TEXT',
'recordUrlList TEXT',
'carBrand TEXT',
'carBrandId INTEGER',
'oneCarBrand TEXT',
'oneCarBrandId INTEGER',
'tempFilePath TEXT',
'recordStatus INTEGER DEFAULT 1' // 0: recording, 1: completed
]
class DBRecord extends DBBase {
private _initPromise: Promise<boolean> | null = null
private static instance: DBRecord | null = null
private constructor() {
super(TABLE_NAME, TABLE_COLUMNS)
}
static getInstance(): DBRecord {
if (DBRecord.instance == null) {
DBRecord.instance = new DBRecord()
}
return DBRecord.instance!
}
override async init(): Promise<boolean> {
if (this._initPromise != null) return this._initPromise!
this._initPromise = (async (): Promise<boolean> => {
try {
await super.init()
// 如果表刚刚创建,不需要检查列,因为 createTable 已经包含了所有列
if (!this.tableCreated) {
await this.ensureColumns()
}
// await this.migrateTempRecords()
return true
} catch (e) {
logger.error('DBRecord: init failed ' + e, "DBRecord")
throw e
}
})()
return this._initPromise!
}
/**
* 确保表字段存在(用于版本升级)
*/
async ensureColumns() {
try {
// 优化:只查询一次表结构
const columnInfo = await this.db!.selectSql(`PRAGMA table_info(${this.table_name})`)
// columnInfo is any[], item is UTSJSONObject
const existingColumns = columnInfo.map((col: any): string => {
const c = col as UTSJSONObject
const name = c['name']
return (name != null ? name : "") as string
}).filter((name: string): boolean => name != "")
logger.info(`DBRecord: existingColumns: ${JSON.stringify(existingColumns)}`, "DBRecord")
const columnsToAdd: UTSJSONObject[] = []
this.table_columns.forEach(colDef => {
// trim().split(/\s+/) 正则在 UTS 可能不完全支持,用 split(' ')
// 假设 colDef 是 "name TYPE ..."
const parts = colDef.trim().split(' ')
const name = parts[0]
// 简单的判断,如果 name 不为空且不在 existingColumns 中
if (name != "" && !existingColumns.includes(name)) {
// 重新组装 definition: 去掉 name,剩下的就是 definition
const definition = colDef.substring(name.length).trim()
columnsToAdd.push({ name: name, definition: definition })
}
})
if (columnsToAdd.length > 0) {
await this.db!.addColumns(this.table_name, columnsToAdd)
const addedNames: string[] = []
columnsToAdd.forEach(c => {
addedNames.push(c['name'] as string)
})
logger.info(`DBRecord: Added columns ${addedNames.join(', ')}`, "DBRecord")
}
} catch (e) {
logger.error('DBRecord: ensureColumns failed ' + e, "DBRecord")
}
}
/**
* 将旧的临时表数据迁移到正式表
*/
// async migrateTempRecords() {
// const tempTableName = 'temp_records'
// try {
// const exists = await this.db!.isTableExists(tempTableName)
// if (!exists) return
//
// logger.warn('DBRecord: Found temp_records table, starting migration...', "DBRecord")
//
// // 获取所有临时记录
// const tempRecords = await this.db!.selectSql(`SELECT * FROM ${tempTableName}`)
//
// if (tempRecords.length > 0) {
// for (const record of tempRecords) {
// const recObj = record as UTSJSONObject
// const id = recObj['id']
// if (id == null) continue
//
// // 标记为进行中
// recObj['recordStatus'] = 0
//
// // 检查是否已存在
// // id 可能是 string 或 number,这里转为 number 还是保持原样?
// // 假设 id 是 TEXT,保持原样。getRecordById 参数改为 any 或 string?
// // DBManager.getRecordById 接受 number。这里需要确认 id 类型。
// // table definition: id TEXT PRIMARY KEY. So it's string.
// // DBManager.getRecordById(id: number) -> need to change DBManager to accept string id?
// // Or convert here if it's numeric string.
//
// // 暂时注释掉 migrateTempRecords,因为涉及 id 类型不匹配和逻辑复杂性,且看起来是一次性迁移代码
// /*
// const existing = await this.getRecordById(record.id)
// if (existing) {
// // 如果存在,说明正式表已有记录,temp_records 中的是残留数据,直接跳过
// logger.warn(`DBRecord: Temp record ${record.id} already exists in records, skipping migration.`)
// } else {
// // 如果不存在,插入它
// await this.addRecord(record)
// logger.info(`DBRecord: Migrated temp record ${record.id}`)
// }
// */
// }
// }
// // 迁移完成后删除旧表
// await this.db!.drop(tempTableName)
// logger.warn('DBRecord: Migration completed, temp_records table dropped.', "DBRecord")
//
// } catch (e) {
// logger.error('DBRecord: Migration failed ' + e, "DBRecord")
// }
// }
/**
* 获取已完成的接待记录 (recordStatus = 1)
*/
async getCompletedRecords(): Promise<any[]> {
return this.getRecordsByWhere({ recordStatus: 1 })
}
/**
* 获取进行中/临时的接待记录 (recordStatus = 0)
*/
async getTempRecords(): Promise<any[]> {
return this.getRecordsByWhere({ recordStatus: 0 })
}
}
export default DBRecord
import { UploadOptions, upload, initConfig, OSSConfig } from "@/uni_modules/uts-alioss";
import { logger } from "../logger/index.uts";
import { FileStatus } from "./common/constants.uts";
type UploadCallback = (result: UTSJSONObject) => void;
export class FileUploadManager {
static uploadManager: any | null = null; // 占位,实际可能不需要这个静态属性如果全是静态方法
private static _isInit = false;
static async waitForInit() {
// 简单模拟初始化完成
FileUploadManager._isInit = true
}
static get isInit(): boolean {
return FileUploadManager._isInit
}
// 模拟 ready 方法
static async ready() {
return true
}
static async uploadRecord(record: UTSJSONObject, callback: UploadCallback) {
// 提取文件信息
const fileName = record['fileName'] as string
const filePath = record['filePath'] as string
const recordId = record['recordId'] as string
if (fileName == "" || filePath == "") {
const res = {
status: FileStatus.Error,
recordId: recordId,
fileName: fileName,
filePath: filePath,
error: "File path or name is empty"
}
callback(res)
return
}
// 构造 OSS 上传参数
// 注意:这里需要 OSS 配置,通常从服务端获取或全局配置
// 假设全局配置已经初始化,或者在这里初始化
// 为了简化,这里假设 uts-alioss 已经配置好
const options = {
filePath: filePath,
objectKey: `records/${recordId}/${fileName}`, // 假设的 objectKey 规则
success: (res) => {
logger.info(`Upload success: ${res.url}`, "FileUploadManager")
const result = {
status: FileStatus.Uploaded,
recordId: recordId,
fileName: fileName,
filePath: filePath,
detail: {
data: [{
code: 0,
message: "success",
data: {
oss: {
res: {
requestUrls: [res.url]
}
}
}
}]
}
}
callback(result)
},
fail: (err) => {
logger.error(`Upload failed: ${err.errMsg}`, "FileUploadManager")
const result = {
status: FileStatus.Error,
recordId: recordId,
fileName: fileName,
filePath: filePath,
error: err.errMsg,
detail: {
data: [{
code: -1,
message: err.errMsg
}]
}
}
callback(result)
}
} as UploadOptions
upload(options)
}
}
export default FileUploadManager
/*
* @Descripttion:
* @version: 1.0.0
* @Author: limin
* @Date: 2026-01-14 14:30:10
* @LastEditors: limin
* @LastEditTime: 2026-03-01 05:21:50
* @FilePath: \venus\apps\uniappX\uniapp-x-tape\composables\recorder\RecordCache.uts
*/
import { logger } from '../logger/index.uts'
type CacheConfigItem = {
keyPrefix: string
targetField: string
}
const CACHE_CONFIG_MATERIAL_POINTS = {
keyPrefix: 'MATERIAL_POINTS_', // Storage Key 前缀
targetField: 'receptionCustomerMaterialPointList' // 对应的 Record 字段名
} as CacheConfigItem
/**
* 记录缓存管理器
* 统一管理大字段的暂存、合并与清理
*/
class RecordCache {
/**
* 暂存数据
* @param {string} recordId - 记录ID
* @param {string} type - 缓存类型 (key of CACHE_CONFIG)
* @param {any} data - 数据
*/
static set(recordId: string, type: string, data: any) {
// UTS 中对象键访问需要 specific
let config: CacheConfigItem | null = null
if (type == 'MATERIAL_POINTS') {
config = CACHE_CONFIG_MATERIAL_POINTS
}
if (recordId == "" || config == null) return
try {
uni.setStorage({
key: config.keyPrefix + recordId,
data: data,
fail: (res) => {
logger.error(`RecordCacheManager: Set ${type} failed: ${res.errMsg}`, "RecordCache")
}
})
} catch (e) {
logger.error(`RecordCacheManager: Set ${type} failed: ${e}`, "RecordCache")
}
}
/**
* 消费缓存:读取缓存 -> 返回数据 -> 删除缓存
* @param {Object} record - 记录对象 (仅用于获取ID)
* @returns {Object} 从缓存恢复的数据对象
*/
static async consumeAll(record: any): Promise<UTSJSONObject|null> {
const recordObj = record as UTSJSONObject
const recordId = recordObj.getString('id')
if (recordId == null) return {}
const restoredData: UTSJSONObject = {}
// 遍历配置
// 目前只有一个,直接硬编码处理,或者用 Object.values (UTS可能不支持)
const configs = [CACHE_CONFIG_MATERIAL_POINTS]
for (const config of configs) {
try {
const key = config.keyPrefix + recordId
const data = await new Promise<any | null>((resolve, reject) => {
uni.getStorage({
key: key,
success: (res) => {
resolve(res.data as any | null)
},
fail: (res) => {
resolve(null as any | null)
}
})
})
if (data != null && data != "") {
restoredData.set(config.targetField, data)
uni.removeStorage({
key: key,
fail: (res) => {
logger.warn(`RecordCacheManager: Remove ${key} failed: ${res.errMsg}`, "RecordCache")
}
}) // 消费即焚
}
} catch (e) {
logger.warn(`RecordCacheManager: Consume ${config.keyPrefix} failed: ${e}`, "RecordCache")
}
}
return restoredData
}
/**
* 清理指定记录的所有缓存
* @param {string} recordId
*/
static clearAll(recordId: string) {
if (recordId == "") return
const configs = [CACHE_CONFIG_MATERIAL_POINTS]
configs.forEach(config => {
try {
uni.removeStorage({
key: config.keyPrefix + recordId,
fail: (res) => {}
})
} catch (e) {}
})
}
}
export default RecordCache
const WsTyps = {
MessageTypes: {
Private: 'private',
System: 'system'
},
Connected:'connect',
Eroor:'error',
Disconnected:'disconnect'
}
const FileStatus = {
Error:0,
NoFile:1,
Waiting:2,
Uploading:3,
NotExist:4,
Uploaded:5,
Completed:6 //状态4 的 完成状态
}
export {
WsTyps,
FileStatus
}
import { StartRecordSuccess, StopRecordSuccess, StartRecordOptions } from '@/uni_modules/uts-recorder'
export type AudioStartOptions = StartRecordOptions
export type OnStartCallback = (res: StartRecordSuccess) => void | Promise<void>
export type OnStopCallback = (res: StopRecordSuccess) => void | Promise<void>
export type OnErrorCallback = (err: any) => void | Promise<void>
export type AudioEvents = {
onStart: OnStartCallback
onStop: OnStopCallback
onError: OnErrorCallback
}
export type RecordFile = {
filePath: string
}
// 移除 RecorderStrategy,因为不再使用策略模式
import { createSSRApp } from "vue"; import { createSSRApp } from "vue";
import { appMixin } from "./utilsApi"; import { appMixin } from "./utilsApi";
import { logger } from "./composables/logger";
import App from "./App.uvue"; import App from "./App.uvue";
import DBRecord from './composables/recorder/DBRecord.uts'
export function createApp() { export function createApp() {
const app = createSSRApp(App); const app = createSSRApp(App);
// 挂载日志模块到 uni.$logger
// logger.mount();
initDB()
appMixin(app); appMixin(app);
return { return {
app app
}; };
} }
function initDB() {
// 数据库初始化
DBRecord.getInstance().init().then((res): void => {
logger.info('〖数据库初始化完成〗', "Main")
}).catch((e): void => {
logger.error(`〖数据库初始化失败〗: ${e}`, "Main")
})
}
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
"appid": "__UNI__B602BFA", "appid": "__UNI__B602BFA",
"description": "", "description": "",
"versionName": "1.0.0", "versionName": "1.0.0",
"versionCode": "109", "versionCode": "111",
"uni-app-x": { "uni-app-x": {
"flex-direction": "row" "flex-direction": "row"
}, },
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
}, },
"dependencies": { "dependencies": {
"@types/echarts": "^5.0.0", "@types/echarts": "^5.0.0",
"@types/uni-app": "^1.4.8",
"@weapp-tailwindcss/merge": "^2.0.1", "@weapp-tailwindcss/merge": "^2.0.1",
"echarts": "^6.0.0", "echarts": "^6.0.0",
"glsk-toolkit": "^1.0.5", "glsk-toolkit": "^1.0.5",
......
...@@ -6,7 +6,7 @@ declare interface Uni { ...@@ -6,7 +6,7 @@ declare interface Uni {
rpx2px(px: number): number; rpx2px(px: number): number;
// 兼容旧项目在 uni 上挂载的扩展对象,供 UTS 编译期识别 // 兼容旧项目在 uni 上挂载的扩展对象,供 UTS 编译期识别
$api?: any; $api?: any;
$logger?: any; // $logger?: any;
$storage?: { $storage?: {
get(key: string): any; get(key: string): any;
set(key: string, value: any): void; set(key: string, value: any): void;
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
export type DatabaseOptions = { export type DatabaseOptions = {
name : string name : string
// path : string // path : string
success ?: (res : SQLiteSuccess) => void success ?: (res : any) => void
fail ?: (res : SqliteFail) => void fail ?: (res : SqliteFail) => void
complete ?: (res : any) => void complete ?: (res : any) => void
} }
...@@ -20,7 +20,7 @@ export type DatabaseOptions = { ...@@ -20,7 +20,7 @@ export type DatabaseOptions = {
export type SqlOperationOptions = { export type SqlOperationOptions = {
name : string name : string
sql : string[] sql : string[]
success ?: (res : SQLiteSuccess) => void success ?: (res : any) => void
fail ?: (res : SqliteFail) => void fail ?: (res : SqliteFail) => void
complete ?: (res : any) => void complete ?: (res : any) => void
} }
...@@ -29,7 +29,7 @@ export type SqlOperationOptions = { ...@@ -29,7 +29,7 @@ export type SqlOperationOptions = {
export type SqlTransactionOptions = { export type SqlTransactionOptions = {
name : string name : string
operation : 'begin' | 'commit' | 'rollback', operation : 'begin' | 'commit' | 'rollback',
success ?: (res : SQLiteSuccess) => void success ?: (res : any) => void
fail ?: (res : SqliteFail) => void fail ?: (res : SqliteFail) => void
complete ?: (res : any) => void complete ?: (res : any) => void
} }
......
import { writeLog as nativeWriteLog, getLogFiles as nativeGetLogFiles, removeLogFile as nativeRemoveLogFile } from "./utssdk/index.uts";
import { LogLevel, LogFile } from "./utssdk/interface.uts";
export type RemoteLogHandler = (level: LogLevel, tag: string, msg: string) => void;
export class Logger {
private tag: string = "AppLogger";
private remoteHandler: RemoteLogHandler | null = null;
constructor() {
// 默认清理7天前的日志
// 注意:这里最好延迟执行,避免应用启动时卡顿
/*
setTimeout(() => {
this.cleanOldLogs(7);
}, 5000);
*/
}
setTag(tag: string) {
this.tag = tag;
}
/**
* 设置远程日志处理器
* 用于接入 Sentry 或其他日志服务
*/
setRemoteHandler(handler: RemoteLogHandler) {
this.remoteHandler = handler;
}
debug(msg: any) {
this.write("debug", msg);
}
info(msg: any) {
this.write("info", msg);
}
warn(msg: any) {
this.write("warn", msg);
}
error(msg: any) {
this.write("error", msg);
}
private write(level: LogLevel, msg: any) {
const msgStr = this.formatMsg(msg);
// 1. 控制台输出
const consoleMsg = `[${this.tag}] ${msgStr}`;
switch (level) {
case "debug": console.debug(consoleMsg); break;
case "info": console.log(consoleMsg); break;
case "warn": console.warn(consoleMsg); break;
case "error": console.error(consoleMsg); break;
}
// 2. 本地文件写入 (Native)
nativeWriteLog(level, this.tag, msgStr);
// 3. 远程日志 (如果有)
if (this.remoteHandler != null) {
this.remoteHandler!(level, this.tag, msgStr);
}
}
private formatMsg(msg: any | null): string {
if (msg == null) return "null";
if (typeof msg === 'string') {
return msg;
}
if (msg instanceof Error) {
return msg.message;
}
try {
return JSON.stringify(msg);
} catch (e) {
return "" + msg;
}
}
// --- 管理接口 ---
/**
* 获取日志文件列表
*/
getLogFiles(): LogFile[] {
return nativeGetLogFiles();
}
/**
* 删除指定日志文件
*/
removeLogFile(path: string) {
nativeRemoveLogFile(path);
}
/**
* 清理旧日志
* @param days 保留天数
*/
/*
cleanOldLogs(days: number) {
// nativeCleanOldLogs(days);
}
*/
}
export const logger = new Logger();
export { LogLevel, LogFile };
{
"id": "uni-logger",
"displayName": "uni-logger",
"version": "1.0.0",
"description": "High performance UTS local logger plugin",
"keywords": [
"logger",
"uts",
"file"
],
"dcloudext": {
"type": "uts",
"sale": {
"regular": {
"price": "0.00"
},
"sourcecode": {
"price": "0.00"
}
}
},
"uni_modules": {
"dependencies": [],
"encrypt": [],
"platforms": {
"client": {
"App": {
"app-android": {
"minVersion": "21"
},
"app-ios": {
"minVersion": "12"
}
}
}
}
}
}
import File from "java.io.File";
import FileWriter from "java.io.FileWriter";
import BufferedWriter from "java.io.BufferedWriter";
import SimpleDateFormat from "java.text.SimpleDateFormat";
import Date from "java.util.Date";
import Locale from "java.util.Locale";
import { LogFile } from "../interface.uts";
class LogManager {
private static instance: LogManager | null = null;
private logDir: File | null = null;
private dateFormat: SimpleDateFormat = new SimpleDateFormat("yyyy-MM-dd", Locale.getDefault());
private timeFormat: SimpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS", Locale.getDefault());
private constructor() {
const context = UTSAndroid.getAppContext();
if (context != null) {
const externalDir = context.getExternalFilesDir(null);
if (externalDir != null) {
this.logDir = new File(externalDir, "uni_log");
if (!this.logDir!.exists()) {
this.logDir!.mkdirs();
}
}
}
}
static getInstance(): LogManager {
if (LogManager.instance == null) {
LogManager.instance = new LogManager();
}
return LogManager.instance!;
}
write(level: string, tag: string, msg: string) {
if (this.logDir == null) return;
const now = new Date();
const dateStr = this.dateFormat.format(now);
const timeStr = this.timeFormat.format(now);
const fileName = `${dateStr}.txt`;
const logFile = new File(this.logDir, fileName);
const content = `${timeStr} [${level}] [${tag}] ${msg}\n`;
try {
// true for append mode
const writer = new FileWriter(logFile, true);
const bufferedWriter = new BufferedWriter(writer);
bufferedWriter.write(content);
bufferedWriter.close();
} catch (e) {
console.error("LogManager write error: " + e.message);
}
}
getLogFiles(): LogFile[] {
const files: LogFile[] = [];
if (this.logDir != null && this.logDir!.exists()) {
const fileList = this.logDir!.listFiles();
if (fileList != null) {
// UTS Android 中,Java 数组的长度属性可能映射为 size 或者 length
// 但如果是原生 Array,应该用 .size 或 .length?
// 尝试直接使用 for...of 遍历,或者将其转换为 List
// 实际上 listFiles() 返回 File[],在 Kotlin/UTS 中可能被视为 Array<File>
// 报错提示 'length' 找不到,可能是因为需要显式声明类型或转换
// 强制转换为 UTSArray 或 List 可能比较麻烦,尝试最简单的 for-each
for (let i: Int = 0; i < fileList.size; i++) {
const file = fileList[i];
if (file.isFile() && file.getName().endsWith(".txt")) {
const logFile = {
name: file.getName(),
path: file.getAbsolutePath(),
size: file.length().toDouble(), // interface defined as number (Double)
lastModified: file.lastModified().toDouble() // interface defined as number
} as LogFile;
files.push(logFile);
}
}
}
}
// sort by lastModified desc
return files.sort((a, b) => b.lastModified - a.lastModified);
}
removeLogFile(path: string) {
const file = new File(path);
if (file.exists()) {
file.delete();
}
}
cleanOldLogs(days: number) {
const now = new Date().getTime();
const msPerDay = (24 * 60 * 60 * 1000).toLong();
const threshold = now - (days.toLong() * msPerDay);
const files = this.getLogFiles();
files.forEach(file => {
// lastModified 返回的是 Long
if (file.lastModified < threshold) {
this.removeLogFile(file.path);
}
});
}
}
export const writeLog = (level: string, tag: string, msg: string) => {
LogManager.getInstance().write(level, tag, msg);
}
export const getLogFiles = (): LogFile[] => {
return LogManager.getInstance().getLogFiles();
}
export const removeLogFile = (path: string) => {
LogManager.getInstance().removeLogFile(path);
}
/*
export const cleanOldLogs = (days: number) => {
// LogManager.getInstance().cleanOldLogs(days);
}
*/
import { LogFile } from "../interface.uts";
// 这是一个简化的 iOS 实现,基于 Foundation
// 注意:UTS iOS 环境下,部分 API 可能需要调整
export const writeLog = (level: string, tag: string, msg: string) => {
// TODO: 实现 iOS 日志写入
console.log(`[iOS Stub] [${level}] [${tag}] ${msg}`);
}
export const getLogFiles = (): LogFile[] => {
return [];
}
export const removeLogFile = (path: string) => {
// TODO
}
export const cleanOldLogs = (days: number) => {
// TODO
}
// #ifdef APP-ANDROID
export * from "./app-android/index.uts";
// #endif
// #ifdef APP-IOS
export * from "./app-ios/index.uts";
// #endif
// #ifndef APP-ANDROID || APP-IOS
import { LogFile } from "./interface.uts";
export const writeLog = (level: string, tag: string, msg: string) => {
console.log(`[Stub] [${level}] [${tag}] ${msg}`);
}
export const getLogFiles = (): LogFile[] => []
export const removeLogFile = (path: string) => {}
// export const cleanOldLogs = (days: number) => {}
// #endif
export * from "./interface.uts";
export type LogLevel = "debug" | "info" | "warn" | "error"
export type LogOptions = {
tag?: string
msg: string
level?: LogLevel
}
export type WriteLogResult = {
errMsg: string
}
export type LogFile = {
name: string
path: string
size: number
lastModified: number
}
{
"name": "uts-alioss",
"displayName": "Aliyun OSS Upload",
"version": "1.0.0",
"description": "Aliyun OSS Upload Plugin for UniApp X",
"uni_modules": {
"dependencies": [],
"encrypt": [],
"platforms": {
"android": {
"minSdkVersion": 21
},
"ios": {
"deploymentTarget": "12.0"
}
}
}
}
{
"dependencies": [
"com.aliyun.dpa:oss-android-sdk:2.9.19"
],
"permissions": [
"android.permission.INTERNET",
"android.permission.ACCESS_NETWORK_STATE",
"android.permission.ACCESS_WIFI_STATE",
"android.permission.WRITE_EXTERNAL_STORAGE",
"android.permission.READ_EXTERNAL_STORAGE"
]
}
export * from '../interface.uts';
// import { OSSConfig, UploadOptions, UploadSuccessResult, UploadFailResult } from '../interface.uts';
// import Context from 'android.content.Context';
// import OSS from 'com.alibaba.sdk.android.oss.OSS';
// import OSSClient from 'com.alibaba.sdk.android.oss.OSSClient';
// import OSSCredentialProvider from 'com.alibaba.sdk.android.oss.common.auth.OSSCredentialProvider';
// import OSSStsTokenCredentialProvider from 'com.alibaba.sdk.android.oss.common.auth.OSSStsTokenCredentialProvider';
// import OSSPlainTextAKSKCredentialProvider from 'com.alibaba.sdk.android.oss.common.auth.OSSPlainTextAKSKCredentialProvider';
// import PutObjectRequest from 'com.alibaba.sdk.android.oss.model.PutObjectRequest';
// import PutObjectResult from 'com.alibaba.sdk.android.oss.model.PutObjectResult';
// import ResumableUploadRequest from 'com.alibaba.sdk.android.oss.model.ResumableUploadRequest';
// import ResumableUploadResult from 'com.alibaba.sdk.android.oss.model.ResumableUploadResult';
// import OSSCompletedCallback from 'com.alibaba.sdk.android.oss.callback.OSSCompletedCallback';
// import ClientException from 'com.alibaba.sdk.android.oss.ClientException';
// import ServiceException from 'com.alibaba.sdk.android.oss.ServiceException';
// import File from 'java.io.File';
// import { UTSAndroid } from "dcloudio.uni-app.uts";
let ossClient: any | null = null;
let currentConfig: any | null = null;
export function initConfig(config: any) {
// currentConfig = config;
// const context = UTSAndroid.getAppContext();
// if (context != null) {
// let credentialProvider: OSSCredentialProvider;
// if (config.securityToken != null && config.securityToken != "") {
// credentialProvider = new OSSStsTokenCredentialProvider(config.accessKeyId, config.accessKeySecret, config.securityToken!);
// } else {
// credentialProvider = new OSSPlainTextAKSKCredentialProvider(config.accessKeyId, config.accessKeySecret);
// }
// ossClient = new OSSClient(context, config.endpoint, credentialProvider);
// }
}
export function upload(options: any) {
// if (ossClient == null) {
// if (currentConfig != null) {
// initConfig(currentConfig!);
// } else {
// const res = { errCode: -1, errMsg: "OSSClient not initialized" } as UploadFailResult;
// options.fail?.(res);
// return;
// }
// }
// if (currentConfig == null) {
// const res = { errCode: -1, errMsg: "Configuration missing" } as UploadFailResult;
// options.fail?.(res);
// return;
// }
// const bucketName = currentConfig!.bucketName;
// const objectKey = options.objectKey;
// const filePath = options.filePath;
// if (options.useMultipart == true) {
// const context = UTSAndroid.getAppContext();
// let recordDir = "";
// if (context != null) {
// // 优先使用外部缓存目录
// const cacheDir = context.getExternalCacheDir();
// if (cacheDir != null) {
// recordDir = cacheDir.getAbsolutePath() + "/oss_record/";
// } else {
// recordDir = context.getCacheDir().getAbsolutePath() + "/oss_record/";
// }
// const dirFile = new File(recordDir);
// if (!dirFile.exists()) {
// dirFile.mkdirs();
// }
// }
// const request = new ResumableUploadRequest(bucketName, objectKey, filePath, recordDir);
// ossClient!.asyncResumableUpload(request, new OSSCompletedCallback<ResumableUploadRequest, ResumableUploadResult>({
// onSuccess: (request: ResumableUploadRequest, result: ResumableUploadResult) => {
// let endpoint = currentConfig!.endpoint;
// if (!endpoint.startsWith("http")) {
// endpoint = "https://" + endpoint;
// }
// let url = "";
// if (endpoint.includes("://")) {
// const parts = endpoint.split("://");
// url = parts[0] + "://" + bucketName + "." + parts[1] + "/" + objectKey;
// } else {
// url = "https://" + bucketName + "." + endpoint + "/" + objectKey;
// }
// const successRes = {
// url: url,
// objectKey: objectKey
// } as UploadSuccessResult;
// options.success?.(successRes);
// options.complete?.(successRes);
// },
// onFailure: (request: ResumableUploadRequest, clientException: ClientException | null, serviceException: ServiceException | null) => {
// let errMsg = "";
// if (clientException != null) {
// errMsg += clientException.getMessage();
// }
// if (serviceException != null) {
// errMsg += " " + serviceException.getErrorCode() + " " + serviceException.getRequestId() + " " + serviceException.getHostId() + " " + serviceException.getRawMessage();
// }
// const failRes = {
// errCode: -2,
// errMsg: errMsg
// } as UploadFailResult;
// options.fail?.(failRes);
// options.complete?.(failRes);
// }
// }));
// return;
// }
// const put = new PutObjectRequest(bucketName, objectKey, filePath);
// ossClient!.asyncPutObject(put, new OSSCompletedCallback<PutObjectRequest, PutObjectResult>({
// onSuccess: (request: PutObjectRequest, result: PutObjectResult) => {
// let endpoint = currentConfig!.endpoint;
// if (!endpoint.startsWith("http")) {
// endpoint = "https://" + endpoint;
// }
// let url = "";
// if (endpoint.includes("://")) {
// const parts = endpoint.split("://");
// // Assuming standard OSS endpoint format: http(s)://region.aliyuncs.com
// // The bucket domain is bucket.region.aliyuncs.com
// url = parts[0] + "://" + bucketName + "." + parts[1] + "/" + objectKey;
// } else {
// url = "https://" + bucketName + "." + endpoint + "/" + objectKey;
// }
// const successRes = {
// url: url,
// objectKey: objectKey
// } as UploadSuccessResult;
// options.success?.(successRes);
// options.complete?.(successRes);
// },
// onFailure: (request: PutObjectRequest, clientException: ClientException | null, serviceException: ServiceException | null) => {
// let errMsg = "";
// if (clientException != null) {
// errMsg += clientException.getMessage();
// }
// if (serviceException != null) {
// errMsg += " " + serviceException.getErrorCode() + " " + serviceException.getRequestId() + " " + serviceException.getHostId() + " " + serviceException.getRawMessage();
// }
// const failRes = {
// errCode: -2,
// errMsg: errMsg
// } as UploadFailResult;
// options.fail?.(failRes);
// options.complete?.(failRes);
// }
// }));
}
import { OSSConfig, UploadOptions, UploadFailResult } from './interface.uts';
export * from './interface.uts';
export function initConfig(config: OSSConfig) {
console.warn("OSS upload not implemented for this platform");
}
export function upload(options: UploadOptions) {
console.warn("OSS upload not implemented for this platform");
const res = { errCode: -1, errMsg: "Not implemented" } as UploadFailResult;
options.fail?.(res);
}
export type OSSConfig = {
endpoint : string
bucketName : string
accessKeyId : string
accessKeySecret : string
securityToken? : string
}
export type UploadSuccessResult = {
url : string
objectKey : string
}
export type UploadFailResult = {
errCode : number
errMsg : string
}
export type UploadOptions = {
filePath : string
objectKey : string
useMultipart? : boolean
success? : (res : UploadSuccessResult) => void
fail? : (res : UploadFailResult) => void
complete? : (res : any) => void
}
export interface AliOSS {
initConfig(config : OSSConfig) : void
upload(options : UploadOptions) : void
}
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="uts.sdk.modules.utsRecorder">
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
</manifest>
\ No newline at end of file \ No newline at end of file
{
"minSdkVersion": 21,
"targetSdkVersion": 33,
"permissions": [
"android.permission.RECORD_AUDIO",
"android.permission.WRITE_EXTERNAL_STORAGE",
"android.permission.READ_EXTERNAL_STORAGE"
],
"dependencies": []
}
import { StartRecord, StartRecordOptions, StopRecord, StopRecordOptions } from '../interface.uts';
import { RecorderFailImpl } from '../unierror';
export const startRecord: StartRecord = function (options: StartRecordOptions) {
console.warn("startRecord is not implemented on HarmonyOS yet.");
const res = new RecorderFailImpl(1012); // Not supported
options.fail?.(res);
options.complete?.(res);
}
export const stopRecord: StopRecord = function (options: StopRecordOptions) {
console.warn("stopRecord is not implemented on HarmonyOS yet.");
const res = new RecorderFailImpl(1012); // Not supported
options.fail?.(res);
options.complete?.(res);
}
// uni_modules/uts-recorder/utssdk/app-ios/index.uts import { StartRecord, StartRecordOptions, StopRecord, StopRecordOptions } from '../interface.uts';
// UTS 录音插件 - iOS 侧实现 import { RecorderFailImpl } from '../unierror';
import { export const startRecord: StartRecord = function (options: StartRecordOptions) {
RecorderStartOptions, console.warn("startRecord is not implemented on iOS yet.");
RecorderStartSuccess, const res = new RecorderFailImpl(1012); // Not supported
RecorderError, options.fail?.(res);
RecorderCallbacks options.complete?.(res);
} from "../interface.uts";
// TODO: 建议使用 Swift AVAudioRecorder 封装
// 参考路径:uni_modules/uts-recorder/utssdk/app-ios/index.swift
// 例如:import XRecorderManager; let mgr = XRecorderManager(); mgr.start(...)
let isRecording: boolean = false;
export function startRecord(
options: RecorderStartOptions,
callbacks: RecorderCallbacks | null = null
): void {
console.log("[uts-recorder][ios] startRecord options =", options);
isRecording = true;
if (callbacks != null && callbacks.onStart != null) {
callbacks.onStart();
}
// 占位:假装录音开始成功
setTimeout(() => {
if (callbacks != null && callbacks.onStop != null) {
const res: RecorderStartSuccess = {
tempFilePath: "/tmp/record-demo.m4a",
duration: 1000
};
callbacks.onStop(res);
}
}, 100);
} }
export function stopRecord(): void { export const stopRecord: StopRecord = function (options: StopRecordOptions) {
console.log("[uts-recorder][ios] stopRecord"); console.warn("stopRecord is not implemented on iOS yet.");
isRecording = false; const res = new RecorderFailImpl(1012); // Not supported
options.fail?.(res);
options.complete?.(res);
} }
...@@ -6,6 +6,10 @@ ...@@ -6,6 +6,10 @@
*/ */
export type StartRecordSuccess = { export type StartRecordSuccess = {
errMsg: string errMsg: string
/**
* 录音文件路径(持久化存储)
*/
filePath: string
}; };
/** /**
...@@ -14,10 +18,14 @@ export type StartRecordSuccess = { ...@@ -14,10 +18,14 @@ export type StartRecordSuccess = {
export type StopRecordSuccess = { export type StopRecordSuccess = {
errMsg: string errMsg: string
/** /**
* 录音文件临时路径 * 录音文件临时路径(兼容标准,指向持久化文件)
*/ */
tempFilePath: string tempFilePath: string
/** /**
* 录音文件路径(持久化存储)
*/
filePath: string
/**
* 录音时长(毫秒) * 录音时长(毫秒)
*/ */
duration: number duration: number
...@@ -113,47 +121,3 @@ export type StartRecord = (options: StartRecordOptions) => void ...@@ -113,47 +121,3 @@ export type StartRecord = (options: StartRecordOptions) => void
*/ */
export type StopRecord = (options: StopRecordOptions) => void export type StopRecord = (options: StopRecordOptions) => void
interface Uni {
/**
* 开始录音
*
* @param {StartRecordOptions} options
* @tutorial https://doc.dcloud.net.cn/uni-app-x/
* @platforms APP-ANDROID = ^22
* @since 1.0.0
*
* @example
* ```typescript
* uni.startRecord({
* format: "aac",
* sampleRate: 8000,
* numberOfChannels: 1,
* success(res) {
* console.log("录音已开始");
* }
* });
* ```
*/
startRecord(options: StartRecordOptions): void
/**
* 停止录音
*
* @param {StopRecordOptions} options
* @tutorial https://doc.dcloud.net.cn/uni-app-x/
* @platforms APP-ANDROID = ^22
* @since 1.0.0
*
* @example
* ```typescript
* uni.stopRecord({
* success(res) {
* console.log("录音文件:", res.tempFilePath);
* console.log("录音时长:", res.duration);
* }
* });
* ```
*/
stopRecord(options: StopRecordOptions): void
}
{"version":3,"sources":["uni_modules/uni-icons/components/uni-icons/uni-icons.uvue"],"sourcesContent":["<template>\r\n\t<text class=\"uni-icons\" :style=\"styleObj\">\r\n\t\t<slot>{{unicode}}</slot>\r\n\t</text>\r\n</template>\r\n\r\n<script>\r\n\timport { fontData, IconsDataItem } from './uniicons_file'\r\n\r\n\t/**\r\n\t * Icons 图标\r\n\t * @description 用于展示 icon 图标\r\n\t * @tutorial https://ext.dcloud.net.cn/plugin?id=28\r\n\t * @property {Number} size 图标大小\r\n\t * @property {String} type 图标图案,参考示例\r\n\t * @property {String} color 图标颜色\r\n\t * @property {String} customPrefix 自定义图标\r\n\t * @event {Function} click 点击 Icon 触发事件\r\n\t */\r\n\texport default {\r\n\t\tname: \"uni-icons\",\r\n\t\tprops: {\r\n\t\t\ttype: {\r\n\t\t\t\ttype: String,\r\n\t\t\t\tdefault: ''\r\n\t\t\t},\r\n\t\t\tcolor: {\r\n\t\t\t\ttype: String,\r\n\t\t\t\tdefault: '#333333'\r\n\t\t\t},\r\n\t\t\tsize: {\r\n type: [Number, String],\r\n default: 16\r\n\t\t\t},\r\n\t\t\tfontFamily: {\r\n\t\t\t\ttype: String,\r\n\t\t\t\tdefault: ''\r\n\t\t\t}\r\n\t\t},\r\n\t\tdata() {\r\n\t\t\treturn {};\r\n\t\t},\r\n\t\tcomputed: {\r\n\t\t\tunicode() : string {\r\n\t\t\t\tlet codes = fontData.find((item : IconsDataItem) : boolean => { return item.font_class == this.type })\r\n\t\t\t\tif (codes !== null) {\r\n\t\t\t\t\treturn codes.unicode\r\n\t\t\t\t}\r\n\t\t\t\treturn ''\r\n\t\t\t},\r\n\t\t\ticonSize() : string {\r\n\t\t\t\tconst size = this.size\n\t\t\t\tif (typeof size == 'string') {\n\t\t\t\t const reg = /^[0-9]*$/g\n\t\t\t\t return reg.test(size as string) ? '' + size + 'px' : '' + size;\n\t\t\t\t // return '' + this.size\n\t\t\t\t}\n\t\t\t\treturn this.getFontSize(size as number)\r\n\t\t\t},\r\n\t\t\tstyleObj() : UTSJSONObject {\r\n\t\t\t\tif (this.fontFamily !== '') {\r\n\t\t\t\t\treturn { color: this.color, fontSize: this.iconSize, fontFamily: this.fontFamily }\r\n\t\t\t\t}\r\n\t\t\t\treturn { color: this.color, fontSize: this.iconSize }\r\n\t\t\t}\r\n\t\t},\r\n\t\tcreated() { },\r\n\t\tmethods: {\r\n\t\t\t/**\r\n\t\t\t * 字体大小\r\n\t\t\t */\r\n\t\t\tgetFontSize(size : number) : string {\r\n\t\t\t\treturn size + 'px';\r\n\t\t\t},\r\n\t\t},\r\n\t}\r\n</script>\r\n\r\n<style scoped>\r\n\t@font-face {\r\n\t\tfont-family: UniIconsFontFamily;\r\n\t\tsrc: url('./uniicons.ttf');\r\n\t}\r\n\r\n\t.uni-icons {\r\n\t\tfont-family: UniIconsFontFamily;\r\n\t\tfont-size: 18px;\r\n\t\tfont-style: normal;\r\n\t\tcolor: #333;\r\n\t}\r\n</style>\n"],"names":[],"mappings":";;;;;;;;;;;;;;AAmBM;;kBA+CJ,MAAO,CAAK;;;;;;eAjEb,IAEO,QAAA,IAFD,WAAM,aAAa,WAAK,IAAE,KAAA,QAAQ;YACvC,WAAwB,KAAA,QAAA,EAAA,WAAA,eAAA,EAAxB,gBAAwB,GAAA;uBAAA;oBAAA,IAAhB,KAAA,OAAO;iBAAA;;;;;IAoBd,SAAA,wBAGC;IACD,SAAA,yBAGC;IACD,SAAA,qBAGC;IACD,SAAA,8BAGA;sBAMY,MAAK;uBAOJ,MAAK;uBASL;;;yCAhBD,MAAK,EAAjB,OAAY,MAAK,CAAA;YAChB,IAAI,QAAQ,SAAS,IAAI,CAAC,IAAC,sBAAwB,OAAM,CAAG;gBAAI,OAAO,KAAK,UAAS,CAAA,EAAA,CAAK,IAAI,CAAC,IAAG;YAAE;;YACpG,IAAI,MAAI,EAAA,CAAM,IAAI,EAAE;gBACnB,OAAO,MAAM,OAAM;;YAEpB,OAAO;QACR;kCACa,MAAK,EAAlB,OAAa,MAAK,CAAA;YACjB,IAAM,OAAO,IAAI,CAAC,IAAG;YACrB,IAAI,oBAAO,MAAG,EAAA,CAAK,UAAU;gBAC3B,IAAM,MAAM;gBACZ,OAAO,IAAA,IAAI,IAAI,CAAC,KAAG,EAAA,CAAK,MAAM,GAAI;oBAAA,GAAC,CAAA,CAAA,CAAI,KAAG,EAAA,CAAA,MAAA,EAAA,CAAA,CAAI;gBAAA,EAAO,IAAS,CAAT;oBAAA,GAAC,CAAA,CAAA,CAAI,KAAI,EAAA,CAAA,MAAA;gBAAA;;YAGhE,OAAO,IAAI,CAAC,WAAW,CAAC,KAAG,EAAA,CAAK,MAAM;QACvC;kCACa,eAAb,OAAa,cAAY;YACxB,IAAI,IAAI,CAAC,UAAS,CAAA,GAAA,CAAM,IAAI;gBAC3B,OAAO,IAAE,WAAO,IAAI,CAAC,KAAK,EAAE,cAAU,IAAI,CAAC,QAAQ,EAAE,gBAAY,IAAI,CAAC,UAAS;;YAEhF,OAAO,IAAE,WAAO,IAAI,CAAC,KAAK,EAAE,cAAU,IAAI,CAAC,QAAO;QACnD;;;aAOA;aAAA,mBAAY,MAAO,MAAM,GAAI,MAAK,CAAA;QACjC,OAAO,KAAG,CAAA,CAAI;IACf;;mBArDK;;;;;;;;;;;;;4BAEL,UAAM,IACC,UAAA,UACG,aAAA,KAEV,WAAO,IACA,UAAA,UACG,aAAA,YAEV,UAAM;;;WAEQ,aAAA,EAAC,GAEf,gBAAY,IACL,UAAA,UACG,aAAA;;;;;;;;;AAuCZ"}
\ No newline at end of file \ No newline at end of file
{"version":3,"sources":["uni_modules/uni-icons/components/uni-icons/uni-icons.uvue"],"sourcesContent":["<template>\n\t<text class=\"uni-icons\" :style=\"styleObj\">\n\t\t<slot>{{unicode}}</slot>\n\t</text>\n</template>\n\n<script>\n\timport { fontData, IconsDataItem } from './uniicons_file'\n\n\t/**\n\t * Icons 图标\n\t * @description 用于展示 icon 图标\n\t * @tutorial https://ext.dcloud.net.cn/plugin?id=28\n\t * @property {Number} size 图标大小\n\t * @property {String} type 图标图案,参考示例\n\t * @property {String} color 图标颜色\n\t * @property {String} customPrefix 自定义图标\n\t * @event {Function} click 点击 Icon 触发事件\n\t */\n\texport default {\n\t\tname: \"uni-icons\",\n\t\tprops: {\n\t\t\ttype: {\n\t\t\t\ttype: String,\n\t\t\t\tdefault: ''\n\t\t\t},\n\t\t\tcolor: {\n\t\t\t\ttype: String,\n\t\t\t\tdefault: '#333333'\n\t\t\t},\n\t\t\tsize: {\n type: [Number, String],\n default: 16\n\t\t\t},\n\t\t\tfontFamily: {\n\t\t\t\ttype: String,\n\t\t\t\tdefault: ''\n\t\t\t}\n\t\t},\n\t\tdata() {\n\t\t\treturn {};\n\t\t},\n\t\tcomputed: {\n\t\t\tunicode() : string {\n\t\t\t\tlet codes = fontData.find((item : IconsDataItem) : boolean => { return item.font_class == this.type })\n\t\t\t\tif (codes !== null) {\n\t\t\t\t\treturn codes.unicode\n\t\t\t\t}\n\t\t\t\treturn ''\n\t\t\t},\n\t\t\ticonSize() : string {\n\t\t\t\tconst size = this.size\n\t\t\t\tif (typeof size == 'string') {\n\t\t\t\t const reg = /^[0-9]*$/g\n\t\t\t\t return reg.test(size as string) ? '' + size + 'px' : '' + size;\n\t\t\t\t // return '' + this.size\n\t\t\t\t}\n\t\t\t\treturn this.getFontSize(size as number)\n\t\t\t},\n\t\t\tstyleObj() : UTSJSONObject {\n\t\t\t\tif (this.fontFamily !== '') {\n\t\t\t\t\treturn { color: this.color, fontSize: this.iconSize, fontFamily: this.fontFamily }\n\t\t\t\t}\n\t\t\t\treturn { color: this.color, fontSize: this.iconSize }\n\t\t\t}\n\t\t},\n\t\tcreated() { },\n\t\tmethods: {\n\t\t\t/**\n\t\t\t * 字体大小\n\t\t\t */\n\t\t\tgetFontSize(size : number) : string {\n\t\t\t\treturn size + 'px';\n\t\t\t},\n\t\t},\n\t}\n</script>\n\n<style scoped>\n\t@font-face {\n\t\tfont-family: UniIconsFontFamily;\n\t\tsrc: url('./uniicons.ttf');\n\t}\n\n\t.uni-icons {\n\t\tfont-family: UniIconsFontFamily;\n\t\tfont-size: 18px;\n\t\tfont-style: normal;\n\t\tcolor: #333;\n\t}\n</style>\n"],"names":[],"mappings":";;;;;;;;;;;;;;AAmBM;;kBA+CJ,MAAO,CAAK;;;;;;eAjEb,IAEO,QAAA,IAFD,WAAM,aAAa,WAAK,IAAE,KAAA,QAAQ;YACvC,WAAwB,KAAA,QAAA,EAAA,WAAA,eAAA,EAAxB,gBAAwB,GAAA;uBAAA;oBAAA,IAAhB,KAAA,OAAO;iBAAA;;;;;IAoBd,SAAA,wBAGC;IACD,SAAA,yBAGC;IACD,SAAA,qBAGC;IACD,SAAA,8BAGA;sBAMY,MAAK;uBAOJ,MAAK;uBASL;;;yCAhBD,MAAK,EAAjB,OAAY,MAAK,CAAA;YAChB,IAAI,QAAQ,SAAS,IAAI,CAAC,IAAC,sBAAwB,OAAM,CAAG;gBAAI,OAAO,KAAK,UAAS,CAAA,EAAA,CAAK,IAAI,CAAC,IAAG;YAAE;;YACpG,IAAI,MAAI,EAAA,CAAM,IAAI,EAAE;gBACnB,OAAO,MAAM,OAAM;;YAEpB,OAAO;QACR;kCACa,MAAK,EAAlB,OAAa,MAAK,CAAA;YACjB,IAAM,OAAO,IAAI,CAAC,IAAG;YACrB,IAAI,oBAAO,MAAG,EAAA,CAAK,UAAU;gBAC3B,IAAM,MAAM;gBACZ,OAAO,IAAA,IAAI,IAAI,CAAC,KAAG,EAAA,CAAK,MAAM,GAAI;oBAAA,GAAC,CAAA,CAAA,CAAI,KAAG,EAAA,CAAA,MAAA,EAAA,CAAA,CAAI;gBAAA,EAAO,IAAS,CAAT;oBAAA,GAAC,CAAA,CAAA,CAAI,KAAI,EAAA,CAAA,MAAA;gBAAA;;YAGhE,OAAO,IAAI,CAAC,WAAW,CAAC,KAAG,EAAA,CAAK,MAAM;QACvC;kCACa,eAAb,OAAa,cAAY;YACxB,IAAI,IAAI,CAAC,UAAS,CAAA,GAAA,CAAM,IAAI;gBAC3B,OAAO,IAAE,WAAO,IAAI,CAAC,KAAK,EAAE,cAAU,IAAI,CAAC,QAAQ,EAAE,gBAAY,IAAI,CAAC,UAAS;;YAEhF,OAAO,IAAE,WAAO,IAAI,CAAC,KAAK,EAAE,cAAU,IAAI,CAAC,QAAO;QACnD;;;aAOA;aAAA,mBAAY,MAAO,MAAM,GAAI,MAAK,CAAA;QACjC,OAAO,KAAG,CAAA,CAAI;IACf;;mBArDK;;;;;;;;;;;;;4BAEL,UAAM,IACC,UAAA,UACG,aAAA,KAEV,WAAO,IACA,UAAA,UACG,aAAA,YAEV,UAAM;;;WAEQ,aAAA,EAAC,GAEf,gBAAY,IACL,UAAA,UACG,aAAA;;;;;;;;;AAuCZ"}
\ No newline at end of file \ No newline at end of file
{"version":3,"sources":["uni_modules/z-paging-x/components/z-paging-x/components/z-paging-load-more.uvue"],"sourcesContent":["<!-- [z-paging-x]上拉加载更多view -->\n<template name=\"z-paging-load-more\">\n\t<view class=\"zpx-l-container\" @click=\"onClickMore\">\n\t\t<view v-if=\"isNoMore\" class=\"zpx-l-line\" />\n\t\t<z-paging-loading v-if=\"isLoading\" />\n\t\t<text class=\"zpx-l-loading-text\">{{statusText}}</text>\n\t\t<view v-if=\"isNoMore\" class=\"zpx-l-line\" />\n\t</view>\n</template>\n<script lang=\"uts\">\n\timport Enum from '../enums/index.uts'\n\timport zPagingLoading from '../components/z-paging-loading.uvue'\n\texport default {\n\t\tname: 'z-paging-load-more',\n\t\tcomponents: { zPagingLoading },\n\t\tprops: {\n\t\t\t// 下拉刷新状态\n\t\t\tstatus: {\n\t\t\t\ttype: String,\n\t\t\t\tdefault: Enum.More.Default,\n\t\t\t},\n\t\t\t// 滑动到底部\"默认\"文字,默认:点击加载更多\n\t\t\tdefaultText: {\n\t\t\t\ttype: String,\n\t\t\t\tdefault: '点击加载更多'\n\t\t\t},\n\t\t\t// 滑动到底部\"加载中\"文字,默认:正在加载...\n\t\t\tloadingText: {\n\t\t\t\ttype: String,\n\t\t\t\tdefault: '正在加载...'\n\t\t\t},\n\t\t\t// 滑动到底部\"没有更多\"文字,默认:没有更多了\n\t\t\tnoMoreText: {\n\t\t\t\ttype: String,\n\t\t\t\tdefault: '没有更多了'\n\t\t\t},\n\t\t\t// 滑动到底部\"加载失败\"文字,默认:加载失败,点击重新加载\n\t\t\tfailText: {\n\t\t\t\ttype: String,\n\t\t\t\tdefault: '加载失败,点击重新加载'\n\t\t\t},\n\t\t},\n\t\tdata() {\n\t\t\treturn {\n\t\t\t\t\n\t\t\t};\n\t\t},\n\t\tcomputed: {\n\t\t\tisDefault(): boolean {\n\t\t\t\treturn this.status === Enum.More.Default;\n\t\t\t},\n\t\t\tisLoading(): boolean {\n\t\t\t\treturn this.status === Enum.More.Loading;\n\t\t\t},\n\t\t\tisNoMore(): boolean {\n\t\t\t\treturn this.status === Enum.More.NoMore;\n\t\t\t},\n\t\t\tisFail(): boolean {\n\t\t\t\treturn this.status === Enum.More.Fail;\n\t\t\t},\n\t\t\tstatusText(): string {\n\t\t\t\t// 底部加载更多状态 default:默认状态 loading:加载中 no-more:没有更多数据 fail:加载失败\n\t\t\t\tif (this.isDefault) {\n\t\t\t\t\treturn this.defaultText;\n\t\t\t\t} else if (this.isLoading) {\n\t\t\t\t\treturn this.loadingText;\n\t\t\t\t} else if (this.isNoMore) {\n\t\t\t\t\treturn this.noMoreText;\n\t\t\t\t} else if (this.isFail) {\n\t\t\t\t\treturn this.failText;\n\t\t\t\t} else {\n\t\t\t\t\treturn '';\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\tmethods: {\n\t\t\tonClickMore() {\n\t\t\t\tthis.$emit('clickMore');\n\t\t\t}\n\t\t}\n\t}\n</script>\n\n<style scoped>\n\t.zpx-l-container {\n\t\theight: 80rpx;\n\t\tflex-direction: row;\n\t\talign-items: center;\n\t\tjustify-content: center;\n\t}\n\t\n\t.zpx-l-loading-text {\n\t\tcolor: #a4a4a4;\n\t\tmargin-left: 10rpx;\n\t\tfont-size: 28rpx;\n\t}\n\t\n\t.zpx-l-line {\n\t\tbackground-color: #eeeeee;\n\t\twidth: 100rpx;\n\t\theight: 1px;\n\t\tmargin: 0rpx 10rpx;\n\t}\n\n</style>\n"],"names":[],"mappings":";;;;;;;;;;;;;;AAYM;;;;;;;eAVL,IAKO,QAAA,IALD,WAAM,mBAAoB,aAAO,KAAA,WAAW;uBACrC,KAAA,QAAQ,GAApB;gBAAA,IAA2C,QAAA,gBAArB,WAAM;;;;;uBACJ,KAAA,SAAS,GAAjC;gBAAA,IAAqC,6BAAA,IAAA,SAAA,CAAA;YAAA;;;;YACrC,IAAsD,QAAA,IAAhD,WAAM,uBAAoB,IAAG,KAAA,UAAU,GAAA,CAAA;uBACjC,KAAA,QAAQ,GAApB;gBAAA,IAA2C,QAAA,gBAArB,WAAM;;;;;;;;IAW3B,SAAA,0BAGC;IAED,SAAA,+BAGC;IAED,SAAA,+BAGC;IAED,SAAA,8BAGC;IAED,SAAA,4BAGC;wBAQY,OAAM;wBAGN,OAAM;uBAGP,OAAM;qBAGR,OAAM;yBAGF,MAAK;;;2CAZN,OAAM,EAAnB,OAAa,OAAM,CAAA;YAClB,OAAO,IAAI,CAAC,MAAK,CAAA,GAAA,CAAM,UAAK,IAAI,CAAC,OAAO;QACzC;mCACa,OAAM,EAAnB,OAAa,OAAM,CAAA;YAClB,OAAO,IAAI,CAAC,MAAK,CAAA,GAAA,CAAM,UAAK,IAAI,CAAC,OAAO;QACzC;kCACY,OAAM,EAAlB,OAAY,OAAM,CAAA;YACjB,OAAO,IAAI,CAAC,MAAK,CAAA,GAAA,CAAM,UAAK,IAAI,CAAC,MAAM;QACxC;gCACU,OAAM,EAAhB,OAAU,OAAM,CAAA;YACf,OAAO,IAAI,CAAC,MAAK,CAAA,GAAA,CAAM,UAAK,IAAI,CAAC,IAAI;QACtC;oCACc,MAAK,EAAnB,OAAc,MAAK,CAAA;YAElB,IAAI,IAAI,CAAC,SAAS,EAAE;gBACnB,OAAO,IAAI,CAAC,WAAW;cACjB,IAQP,CARO,IAAI,IAAI,CAAC,SAAS,EAAE;gBAC1B,OAAO,IAAI,CAAC,WAAW;cACjB,IAMP,CANO,IAAI,IAAI,CAAC,QAAQ,EAAE;gBACzB,OAAO,IAAI,CAAC,UAAU;cAChB,IAIP,CAJO,IAAI,IAAI,CAAC,MAAM,EAAE;gBACvB,OAAO,IAAI,CAAC,QAAQ;cACd,IAEP,CAFO;gBACN,OAAO;;QAET;;;aAGA;aAAA,qBAAW;QACV,IAAI,CAAC,OAAK,CAAC;IACZ;;mBAjEK;;;;;;;;;;;;;4BAIL,YAAQ,IACD,UAAA,UACG,aAAA,UAAK,IAAI,CAAC,OAAO,GAG3B,iBAAa,IACN,UAAA,UACG,aAAA,WAGV,iBAAa,IACN,UAAA,UACG,aAAA,YAGV,gBAAY,IACL,UAAA,UACG,aAAA,UAGV,cAAU,IACH,UAAA,UACG,aAAA;;;;;;;;;;AAyCZ"}
\ No newline at end of file \ No newline at end of file
{"version":3,"sources":["uni_modules/z-paging-x/components/z-paging-x/components/z-paging-load-more.uvue"],"sourcesContent":["<!-- [z-paging-x]上拉加载更多view -->\n<template name=\"z-paging-load-more\">\n\t<view class=\"zpx-l-container\" @click=\"onClickMore\">\n\t\t<view v-if=\"isNoMore\" class=\"zpx-l-line\" />\n\t\t<z-paging-loading v-if=\"isLoading\" />\n\t\t<text class=\"zpx-l-loading-text\">{{statusText}}</text>\n\t\t<view v-if=\"isNoMore\" class=\"zpx-l-line\" />\n\t</view>\n</template>\n<script lang=\"uts\">\n\timport Enum from '../enums/index.uts'\n\timport zPagingLoading from '../components/z-paging-loading.uvue'\n\texport default {\n\t\tname: 'z-paging-load-more',\n\t\tcomponents: { zPagingLoading },\n\t\tprops: {\n\t\t\t// 下拉刷新状态\n\t\t\tstatus: {\n\t\t\t\ttype: String,\n\t\t\t\tdefault: Enum.More.Default,\n\t\t\t},\n\t\t\t// 滑动到底部\"默认\"文字,默认:点击加载更多\n\t\t\tdefaultText: {\n\t\t\t\ttype: String,\n\t\t\t\tdefault: '点击加载更多'\n\t\t\t},\n\t\t\t// 滑动到底部\"加载中\"文字,默认:正在加载...\n\t\t\tloadingText: {\n\t\t\t\ttype: String,\n\t\t\t\tdefault: '正在加载...'\n\t\t\t},\n\t\t\t// 滑动到底部\"没有更多\"文字,默认:没有更多了\n\t\t\tnoMoreText: {\n\t\t\t\ttype: String,\n\t\t\t\tdefault: '没有更多了'\n\t\t\t},\n\t\t\t// 滑动到底部\"加载失败\"文字,默认:加载失败,点击重新加载\n\t\t\tfailText: {\n\t\t\t\ttype: String,\n\t\t\t\tdefault: '加载失败,点击重新加载'\n\t\t\t},\n\t\t},\n\t\tdata() {\n\t\t\treturn {\n\t\t\t\t\n\t\t\t};\n\t\t},\n\t\tcomputed: {\n\t\t\tisDefault(): boolean {\n\t\t\t\treturn this.status === Enum.More.Default;\n\t\t\t},\n\t\t\tisLoading(): boolean {\n\t\t\t\treturn this.status === Enum.More.Loading;\n\t\t\t},\n\t\t\tisNoMore(): boolean {\n\t\t\t\treturn this.status === Enum.More.NoMore;\n\t\t\t},\n\t\t\tisFail(): boolean {\n\t\t\t\treturn this.status === Enum.More.Fail;\n\t\t\t},\n\t\t\tstatusText(): string {\n\t\t\t\t// 底部加载更多状态 default:默认状态 loading:加载中 no-more:没有更多数据 fail:加载失败\n\t\t\t\tif (this.isDefault) {\n\t\t\t\t\treturn this.defaultText;\n\t\t\t\t} else if (this.isLoading) {\n\t\t\t\t\treturn this.loadingText;\n\t\t\t\t} else if (this.isNoMore) {\n\t\t\t\t\treturn this.noMoreText;\n\t\t\t\t} else if (this.isFail) {\n\t\t\t\t\treturn this.failText;\n\t\t\t\t} else {\n\t\t\t\t\treturn '';\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\tmethods: {\n\t\t\tonClickMore() {\n\t\t\t\tthis.$emit('clickMore');\n\t\t\t}\n\t\t}\n\t}\n</script>\n\n<style scoped>\n\t.zpx-l-container {\n\t\theight: 80rpx;\n\t\tflex-direction: row;\n\t\talign-items: center;\n\t\tjustify-content: center;\n\t}\n\t\n\t.zpx-l-loading-text {\n\t\tcolor: #a4a4a4;\n\t\tmargin-left: 10rpx;\n\t\tfont-size: 28rpx;\n\t}\n\t\n\t.zpx-l-line {\n\t\tbackground-color: #eeeeee;\n\t\twidth: 100rpx;\n\t\theight: 1px;\n\t\tmargin: 0rpx 10rpx;\n\t}\n\n</style>\n"],"names":[],"mappings":";;;;;;;;;;;;;;AAYM;;;;;;;eAVL,IAKO,QAAA,IALD,WAAM,mBAAoB,aAAO,KAAA,WAAW;uBACrC,KAAA,QAAQ,GAApB;gBAAA,IAA2C,QAAA,gBAArB,WAAM;;;;;uBACJ,KAAA,SAAS,GAAjC;gBAAA,IAAqC,6BAAA,IAAA,SAAA,CAAA;YAAA;;;;YACrC,IAAsD,QAAA,IAAhD,WAAM,uBAAoB,IAAG,KAAA,UAAU,GAAA,CAAA;uBACjC,KAAA,QAAQ,GAApB;gBAAA,IAA2C,QAAA,gBAArB,WAAM;;;;;;;;IAW3B,SAAA,0BAGC;IAED,SAAA,+BAGC;IAED,SAAA,+BAGC;IAED,SAAA,8BAGC;IAED,SAAA,4BAGC;wBAQY,OAAM;wBAGN,OAAM;uBAGP,OAAM;qBAGR,OAAM;yBAGF,MAAK;;;2CAZN,OAAM,EAAnB,OAAa,OAAM,CAAA;YAClB,OAAO,IAAI,CAAC,MAAK,CAAA,GAAA,CAAM,WAAK,IAAI,CAAC,OAAO;QACzC;mCACa,OAAM,EAAnB,OAAa,OAAM,CAAA;YAClB,OAAO,IAAI,CAAC,MAAK,CAAA,GAAA,CAAM,WAAK,IAAI,CAAC,OAAO;QACzC;kCACY,OAAM,EAAlB,OAAY,OAAM,CAAA;YACjB,OAAO,IAAI,CAAC,MAAK,CAAA,GAAA,CAAM,WAAK,IAAI,CAAC,MAAM;QACxC;gCACU,OAAM,EAAhB,OAAU,OAAM,CAAA;YACf,OAAO,IAAI,CAAC,MAAK,CAAA,GAAA,CAAM,WAAK,IAAI,CAAC,IAAI;QACtC;oCACc,MAAK,EAAnB,OAAc,MAAK,CAAA;YAElB,IAAI,IAAI,CAAC,SAAS,EAAE;gBACnB,OAAO,IAAI,CAAC,WAAW;cACjB,IAQP,CARO,IAAI,IAAI,CAAC,SAAS,EAAE;gBAC1B,OAAO,IAAI,CAAC,WAAW;cACjB,IAMP,CANO,IAAI,IAAI,CAAC,QAAQ,EAAE;gBACzB,OAAO,IAAI,CAAC,UAAU;cAChB,IAIP,CAJO,IAAI,IAAI,CAAC,MAAM,EAAE;gBACvB,OAAO,IAAI,CAAC,QAAQ;cACd,IAEP,CAFO;gBACN,OAAO;;QAET;;;aAGA;aAAA,qBAAW;QACV,IAAI,CAAC,OAAK,CAAC;IACZ;;mBAjEK;;;;;;;;;;;;;4BAIL,YAAQ,IACD,UAAA,UACG,aAAA,WAAK,IAAI,CAAC,OAAO,GAG3B,iBAAa,IACN,UAAA,UACG,aAAA,WAGV,iBAAa,IACN,UAAA,UACG,aAAA,YAGV,gBAAY,IACL,UAAA,UACG,aAAA,UAGV,cAAU,IACH,UAAA,UACG,aAAA;;;;;;;;;;AAyCZ"}
\ No newline at end of file \ No newline at end of file
...@@ -4,97 +4,97 @@ ...@@ -4,97 +4,97 @@
"compiler_version": "4.87" "compiler_version": "4.87"
}, },
"files": { "files": {
"pages/index/index.kt": { "uni_modules/z-paging-x/components/z-paging-x/components/z-paging-refresher.kt": {
"class": "GenPagesIndexIndex", "md5": "d00deb8ec65ffe26f6731a99a0dbcfa11ea603f9",
"md5": "d8d028fdb9eab322150af58a90c2361ddfea3f18" "class": "GenUniModulesZPagingXComponentsZPagingXComponentsZPagingRefresher"
}, },
"index.kt": { "pages/demo/media/index.kt": {
"md5": "58f0fea201e4278f6bc39c939656ca440a4b8d98", "md5": "d76917918ad2397c0cd8429328b52ab77a83ff4f",
"class": "" "class": "GenPagesDemoMediaIndex"
}, },
"uni_modules/z-paging-x/components/z-paging-x/components/z-paging-loading.kt": { "pages/demo/old/index.kt": {
"class": "GenUniModulesZPagingXComponentsZPagingXComponentsZPagingLoading", "md5": "8b8d4a1b49e2ef7592d4e2f958b222392cf46fe8",
"md5": "bc2c0931a10ad4eea405d60556ee5e702cc28f62" "class": "GenPagesDemoOldIndex"
}, },
"pages/common/login/index.kt": { "pages/common/login/index.kt": {
"md5": "165659590e28e0663c371d8606710e0c7fd36859", "md5": "165659590e28e0663c371d8606710e0c7fd36859",
"class": "GenPagesCommonLoginIndex" "class": "GenPagesCommonLoginIndex"
}, },
"components/PublishPopup.kt": { "pages/common/components/NoData.kt": {
"md5": "b0c3be2d9836f013bc4b67bbf5fe08a456f6ce18", "class": "GenPagesCommonComponentsNoData",
"class": "GenComponentsPublishPopup" "md5": "0608111022dbb7da0f7c3e452b7409d1ec7f5735"
}, },
"pages/demo/record/index.kt": { "pages/index/index.kt": {
"class": "GenPagesDemoRecordIndex", "md5": "d8d028fdb9eab322150af58a90c2361ddfea3f18",
"md5": "84e76df7ed975ac1925322c2e8a598c39e5c84af" "class": "GenPagesIndexIndex"
}, },
"pages/demo/echarts/index.kt": { "pages/demo/echarts/index.kt": {
"md5": "e9c323efac81c50aa4eca12e75586263bacd95fb", "class": "GenPagesDemoEchartsIndex",
"class": "GenPagesDemoEchartsIndex" "md5": "e9c323efac81c50aa4eca12e75586263bacd95fb"
}, },
"pages/demo/local-store/index.kt": { "pages/common/components/AccountList.kt": {
"class": "GenPagesDemoLocalStoreIndex", "md5": "d78e30a9fd29b1bd3fc6451b74a39845095f79ee",
"md5": "6360b2df10619a70490f9f6f126d91728741e2c2" "class": "GenPagesCommonComponentsAccountList"
},
"uni_modules/lime-echart/components/l-echart/l-echart.kt": {
"md5": "23c5a52d57071d3771477b55f910fbe9ccac83fc",
"class": "GenUniModulesLimeEchartComponentsLEchartLEchart"
}, },
"pages/demo/media/index.kt": { "components/PublishPopup.kt": {
"class": "GenPagesDemoMediaIndex", "class": "GenComponentsPublishPopup",
"md5": "d76917918ad2397c0cd8429328b52ab77a83ff4f" "md5": "b0c3be2d9836f013bc4b67bbf5fe08a456f6ce18"
}, },
"uni_modules/z-paging-x/components/z-paging-x/components/z-paging-refresher.kt": { "uni_modules/uni-icons/components/uni-icons/uni-icons.kt": {
"md5": "16ff705042a40a87dd8d71d3fa16ad4a017d0301", "md5": "95aae1ef2b0e8906a602ca5d24eea964329fab31",
"class": "GenUniModulesZPagingXComponentsZPagingXComponentsZPagingRefresher" "class": "GenUniModulesUniIconsComponentsUniIconsUniIcons"
}, },
"pages/common/components/AccountList.kt": { "pages/demo/record/index.kt": {
"class": "GenPagesCommonComponentsAccountList", "class": "GenPagesDemoRecordIndex",
"md5": "d78e30a9fd29b1bd3fc6451b74a39845095f79ee" "md5": "46db702d44876c630d91abbce66cfca7cf3b20e9"
}, },
"uni_modules/z-paging-x/components/z-paging-x/z-paging-x.kt": { "uni_modules/z-paging-x/components/z-paging-x/z-paging-x.kt": {
"class": "GenUniModulesZPagingXComponentsZPagingXZPagingX", "class": "GenUniModulesZPagingXComponentsZPagingXZPagingX",
"md5": "4e08a9502eacce0a379370f55af65cc373be4d86" "md5": "4121973f93db5ff4294a93413e8c6e1f6413d356"
}, },
"uni_modules/uni-icons/components/uni-icons/uni-icons.kt": { "pages/demo/tailwindcss/index.kt": {
"class": "GenUniModulesUniIconsComponentsUniIconsUniIcons", "md5": "c427026081cb75ed3d462c5ebf8a3ac0750bfa34",
"md5": "95aae1ef2b0e8906a602ca5d24eea964329fab31" "class": "GenPagesDemoTailwindcssIndex"
},
"pages/demo/permission/index.kt": {
"class": "GenPagesDemoPermissionIndex",
"md5": "18cb329597e3254e8c67cefdc1f196e3a1260273"
}, },
"pages/common/accountItems/index.kt": { "pages/common/accountItems/index.kt": {
"class": "GenPagesCommonAccountItemsIndex", "md5": "ce7b7aebc25c812bc76446384be7b4ae423373da",
"md5": "ce7b7aebc25c812bc76446384be7b4ae423373da" "class": "GenPagesCommonAccountItemsIndex"
}, },
"pages/demo/gl-tape-demo/index.kt": { "pages/demo/local-store/index.kt": {
"class": "GenPagesDemoGlTapeDemoIndex", "md5": "6360b2df10619a70490f9f6f126d91728741e2c2",
"md5": "0aae13f9001ec4f53db18f232da3b9816d12d620" "class": "GenPagesDemoLocalStoreIndex"
}, },
"pages/demo/tailwindcss/index.kt": { "components/evaluationForm/TypeTabComponent.kt": {
"class": "GenPagesDemoTailwindcssIndex", "md5": "0c65870c54770c8dfebb843dc83b547ef7d25a50",
"md5": "c427026081cb75ed3d462c5ebf8a3ac0750bfa34" "class": "GenComponentsEvaluationFormTypeTabComponent"
}, },
"pages/common/components/NoData.kt": { "uni_modules/z-paging-x/components/z-paging-x/components/z-paging-loading.kt": {
"md5": "0608111022dbb7da0f7c3e452b7409d1ec7f5735", "md5": "bc2c0931a10ad4eea405d60556ee5e702cc28f62",
"class": "GenPagesCommonComponentsNoData" "class": "GenUniModulesZPagingXComponentsZPagingXComponentsZPagingLoading"
}, },
"components/evaluationForm/TypeTabComponent.kt": { "index.kt": {
"class": "GenComponentsEvaluationFormTypeTabComponent", "class": "",
"md5": "0c65870c54770c8dfebb843dc83b547ef7d25a50" "md5": "11de582aba43f97fbc5832ac2094c8bdd7584855"
}, },
"uni_modules/z-paging-x/components/z-paging-x/components/z-paging-load-more.kt": { "uni_modules/z-paging-x/components/z-paging-x/components/z-paging-load-more.kt": {
"class": "GenUniModulesZPagingXComponentsZPagingXComponentsZPagingLoadMore", "class": "GenUniModulesZPagingXComponentsZPagingXComponentsZPagingLoadMore",
"md5": "a09e63a3254f1a7fd1be3a47e1d27eccb876c289" "md5": "b477e65e495c0a7d8bebd037ce9b3929903fd834"
},
"pages/demo/gl-tape-demo/index.kt": {
"md5": "0aae13f9001ec4f53db18f232da3b9816d12d620",
"class": "GenPagesDemoGlTapeDemoIndex"
}, },
"uni_modules/z-paging-x/components/z-paging-x-empty/z-paging-x-empty.kt": { "uni_modules/z-paging-x/components/z-paging-x-empty/z-paging-x-empty.kt": {
"class": "GenUniModulesZPagingXComponentsZPagingXEmptyZPagingXEmpty", "class": "GenUniModulesZPagingXComponentsZPagingXEmptyZPagingXEmpty",
"md5": "e8fa2621d20e3d4183965c604b60282e40ce5932" "md5": "e8fa2621d20e3d4183965c604b60282e40ce5932"
}, },
"pages/demo/old/index.kt": { "uni_modules/lime-echart/components/l-echart/l-echart.kt": {
"class": "GenPagesDemoOldIndex", "md5": "23c5a52d57071d3771477b55f910fbe9ccac83fc",
"md5": "8b8d4a1b49e2ef7592d4e2f958b222392cf46fe8" "class": "GenUniModulesLimeEchartComponentsLEchartLEchart"
},
"pages/demo/permission/index.kt": {
"md5": "18cb329597e3254e8c67cefdc1f196e3a1260273",
"class": "GenPagesDemoPermissionIndex"
} }
} }
} }
\ No newline at end of file \ No newline at end of file
...@@ -13,8 +13,9 @@ import io.dcloud.uts.Set ...@@ -13,8 +13,9 @@ import io.dcloud.uts.Set
import io.dcloud.uts.UTSAndroid import io.dcloud.uts.UTSAndroid
import kotlin.properties.Delegates import kotlin.properties.Delegates
import uts.sdk.modules.permissionHandlerPlus.PermissionObject import uts.sdk.modules.permissionHandlerPlus.PermissionObject
import uts.sdk.modules.utsRecorder.StartRecordSuccess
import uts.sdk.modules.utsRecorder.StopRecordSuccess
import uts.sdk.modules.utsRecorder.StartRecordOptions import uts.sdk.modules.utsRecorder.StartRecordOptions
import uts.sdk.modules.utsRecorder.StopRecordOptions
import uts.sdk.modules.permissionHandlerPlus.checkPermission import uts.sdk.modules.permissionHandlerPlus.checkPermission
import uts.sdk.modules.permissionHandlerPlus.requestPermissions import uts.sdk.modules.permissionHandlerPlus.requestPermissions
import io.dcloud.uniapp.extapi.createInnerAudioContext as uni_createInnerAudioContext import io.dcloud.uniapp.extapi.createInnerAudioContext as uni_createInnerAudioContext
...@@ -22,6 +23,9 @@ import io.dcloud.uniapp.framework.onLoad ...@@ -22,6 +23,9 @@ import io.dcloud.uniapp.framework.onLoad
import io.dcloud.uniapp.extapi.showToast as uni_showToast import io.dcloud.uniapp.extapi.showToast as uni_showToast
import uts.sdk.modules.utsRecorder.startRecord as uniStartRecord import uts.sdk.modules.utsRecorder.startRecord as uniStartRecord
import uts.sdk.modules.utsRecorder.stopRecord as uniStopRecord import uts.sdk.modules.utsRecorder.stopRecord as uniStopRecord
import uts.sdk.modules.utsRecorder.startRecord
import uts.sdk.modules.utsRecorder.stopRecord
import uts.sdk.modules.utsRecorder.StopRecordOptions
open class GenPagesDemoRecordIndex : BasePage { open class GenPagesDemoRecordIndex : BasePage {
constructor(__ins: ComponentInternalInstance, __renderer: String?) : super(__ins, __renderer) { constructor(__ins: ComponentInternalInstance, __renderer: String?) : super(__ins, __renderer) {
onPageScroll(fun(e: OnPageScrollOptions) {}, __ins) onPageScroll(fun(e: OnPageScrollOptions) {}, __ins)
......
...@@ -55,16 +55,16 @@ open class GenUniModulesZPagingXComponentsZPagingXComponentsZPagingLoadMore : Vu ...@@ -55,16 +55,16 @@ open class GenUniModulesZPagingXComponentsZPagingXComponentsZPagingLoadMore : Vu
@Suppress("USELESS_CAST") @Suppress("USELESS_CAST")
override fun data(): Map<String, Any?> { override fun data(): Map<String, Any?> {
return _uM("isDefault" to computed<Boolean>(fun(): Boolean { return _uM("isDefault" to computed<Boolean>(fun(): Boolean {
return this.status === `default`.More.Default return this.status === default__1.More.Default
} }
), "isLoading" to computed<Boolean>(fun(): Boolean { ), "isLoading" to computed<Boolean>(fun(): Boolean {
return this.status === `default`.More.Loading return this.status === default__1.More.Loading
} }
), "isNoMore" to computed<Boolean>(fun(): Boolean { ), "isNoMore" to computed<Boolean>(fun(): Boolean {
return this.status === `default`.More.NoMore return this.status === default__1.More.NoMore
} }
), "isFail" to computed<Boolean>(fun(): Boolean { ), "isFail" to computed<Boolean>(fun(): Boolean {
return this.status === `default`.More.Fail return this.status === default__1.More.Fail
} }
), "statusText" to computed<String>(fun(): String { ), "statusText" to computed<String>(fun(): String {
if (this.isDefault) { if (this.isDefault) {
...@@ -99,7 +99,7 @@ open class GenUniModulesZPagingXComponentsZPagingXComponentsZPagingLoadMore : Vu ...@@ -99,7 +99,7 @@ open class GenUniModulesZPagingXComponentsZPagingXComponentsZPagingLoadMore : Vu
var inheritAttrs = true var inheritAttrs = true
var inject: Map<String, Map<String, Any?>> = _uM() var inject: Map<String, Map<String, Any?>> = _uM()
var emits: Map<String, Any?> = _uM() var emits: Map<String, Any?> = _uM()
var props = _nP(_uM("status" to _uM("type" to "String", "default" to `default`.More.Default), "defaultText" to _uM("type" to "String", "default" to "点击加载更多"), "loadingText" to _uM("type" to "String", "default" to "正在加载..."), "noMoreText" to _uM("type" to "String", "default" to "没有更多了"), "failText" to _uM("type" to "String", "default" to "加载失败,点击重新加载"))) var props = _nP(_uM("status" to _uM("type" to "String", "default" to default__1.More.Default), "defaultText" to _uM("type" to "String", "default" to "点击加载更多"), "loadingText" to _uM("type" to "String", "default" to "正在加载..."), "noMoreText" to _uM("type" to "String", "default" to "没有更多了"), "failText" to _uM("type" to "String", "default" to "加载失败,点击重新加载")))
var propsNeedCastKeys = _uA( var propsNeedCastKeys = _uA(
"status", "status",
"defaultText", "defaultText",
......
...@@ -69,13 +69,13 @@ open class GenUniModulesZPagingXComponentsZPagingXComponentsZPagingRefresher : V ...@@ -69,13 +69,13 @@ open class GenUniModulesZPagingXComponentsZPagingXComponentsZPagingRefresher : V
@Suppress("USELESS_CAST") @Suppress("USELESS_CAST")
override fun data(): Map<String, Any?> { override fun data(): Map<String, Any?> {
return _uM("times" to 0, "base64ArrowImg" to base64Arrow, "isDefault" to computed<Boolean>(fun(): Boolean { return _uM("times" to 0, "base64ArrowImg" to base64Arrow, "isDefault" to computed<Boolean>(fun(): Boolean {
return this.status === `default`.Refresher.Default return this.status === default__1.Refresher.Default
} }
), "isReleaseToRefresh" to computed<Boolean>(fun(): Boolean { ), "isReleaseToRefresh" to computed<Boolean>(fun(): Boolean {
return this.status === `default`.Refresher.ReleaseToRefresh return this.status === default__1.Refresher.ReleaseToRefresh
} }
), "isLoading" to computed<Boolean>(fun(): Boolean { ), "isLoading" to computed<Boolean>(fun(): Boolean {
return this.status === `default`.Refresher.Loading return this.status === default__1.Refresher.Loading
} }
), "statusText" to computed<String>(fun(): String { ), "statusText" to computed<String>(fun(): String {
if (this.isDefault) { if (this.isDefault) {
...@@ -111,7 +111,7 @@ open class GenUniModulesZPagingXComponentsZPagingXComponentsZPagingRefresher : V ...@@ -111,7 +111,7 @@ open class GenUniModulesZPagingXComponentsZPagingXComponentsZPagingRefresher : V
var inheritAttrs = true var inheritAttrs = true
var inject: Map<String, Map<String, Any?>> = _uM() var inject: Map<String, Map<String, Any?>> = _uM()
var emits: Map<String, Any?> = _uM() var emits: Map<String, Any?> = _uM()
var props = _nP(_uM("status" to _uM("type" to "String", "default" to `default`.Refresher.Default), "defaultText" to _uM("type" to "String", "default" to "继续下拉刷新"), "pullingText" to _uM("type" to "String", "default" to "松开立即刷新"), "refreshingText" to _uM("type" to "String", "default" to "正在刷新..."), "showUpdateTime" to _uM("type" to "Boolean", "default" to false), "updateTimeKey" to _uM("type" to "String", "default" to "default"), "timeTextTimestamp" to _uM("type" to "Number", "default" to 0))) var props = _nP(_uM("status" to _uM("type" to "String", "default" to default__1.Refresher.Default), "defaultText" to _uM("type" to "String", "default" to "继续下拉刷新"), "pullingText" to _uM("type" to "String", "default" to "松开立即刷新"), "refreshingText" to _uM("type" to "String", "default" to "正在刷新..."), "showUpdateTime" to _uM("type" to "Boolean", "default" to false), "updateTimeKey" to _uM("type" to "String", "default" to "default"), "timeTextTimestamp" to _uM("type" to "Number", "default" to 0)))
var propsNeedCastKeys = _uA( var propsNeedCastKeys = _uA(
"status", "status",
"defaultText", "defaultText",
......
...@@ -376,7 +376,7 @@ open class GenUniModulesZPagingXComponentsZPagingXZPagingX : VueComponent { ...@@ -376,7 +376,7 @@ open class GenUniModulesZPagingXComponentsZPagingXZPagingX : VueComponent {
open var listItemIs: String by `$data` open var listItemIs: String by `$data`
@Suppress("USELESS_CAST") @Suppress("USELESS_CAST")
override fun data(): Map<String, Any?> { override fun data(): Map<String, Any?> {
return _uM("\$zpxList" to null as UniElement?, "refresherStatus" to `default`.Refresher.Default, "refresherTriggered" to false, "refresherNodeHeight" to 0 as Number, "refresherTimeTextTimestamp" to 0, "loadMoreStatus" to `default`.More.Default, "queryFrom" to "", "isLoadFailed" to false, "customNoMore" to -1, "forceHideLoadMore" to false, "contentWidth" to 0, "isLoading" to true, "scrollTop" to 0, "oldScrollTop" to 0, "pageNo" to 1, "totalData" to _uA<Any>(), "base64BackToTopImg" to base64BackToTop, "backToTopClass" to "zpx-back-to-top zpx-back-to-top-hide", "lastBackToTopShowTime" to 0, "showBackToTopClass" to false, "privateScrollWithAnimation" to -1, "isFirstPage" to computed<Boolean>(fun(): Boolean { return _uM("\$zpxList" to null as UniElement?, "refresherStatus" to default__1.Refresher.Default, "refresherTriggered" to false, "refresherNodeHeight" to 0 as Number, "refresherTimeTextTimestamp" to 0, "loadMoreStatus" to default__1.More.Default, "queryFrom" to "", "isLoadFailed" to false, "customNoMore" to -1, "forceHideLoadMore" to false, "contentWidth" to 0, "isLoading" to true, "scrollTop" to 0, "oldScrollTop" to 0, "pageNo" to 1, "totalData" to _uA<Any>(), "base64BackToTopImg" to base64BackToTop, "backToTopClass" to "zpx-back-to-top zpx-back-to-top-hide", "lastBackToTopShowTime" to 0, "showBackToTopClass" to false, "privateScrollWithAnimation" to -1, "isFirstPage" to computed<Boolean>(fun(): Boolean {
return this.pageNo === this.defaultPageNo return this.pageNo === this.defaultPageNo
} }
), "finalRefresherThreshold" to computed<Number>(fun(): Number { ), "finalRefresherThreshold" to computed<Number>(fun(): Number {
...@@ -433,7 +433,7 @@ open class GenUniModulesZPagingXComponentsZPagingXZPagingX : VueComponent { ...@@ -433,7 +433,7 @@ open class GenUniModulesZPagingXComponentsZPagingXZPagingX : VueComponent {
if (this.scrollToTopWhenReload) { if (this.scrollToTopWhenReload) {
this.scrollToTop(false) this.scrollToTop(false)
} }
this.queryFrom = `default`.QueryFrom.Reload this.queryFrom = default__1.QueryFrom.Reload
this._emitQuery(this.pageNo, this.defaultPageSize) this._emitQuery(this.pageNo, this.defaultPageSize)
} }
open var complete = ::gen_complete_fn open var complete = ::gen_complete_fn
...@@ -448,13 +448,13 @@ open class GenUniModulesZPagingXComponentsZPagingXZPagingX : VueComponent { ...@@ -448,13 +448,13 @@ open class GenUniModulesZPagingXComponentsZPagingXZPagingX : VueComponent {
val currentData: UTSArray<Any> = finalData.slice() val currentData: UTSArray<Any> = finalData.slice()
if (this.customNoMore != -1) { if (this.customNoMore != -1) {
if (this.customNoMore == 1 || (this.customNoMore != 0 && finalData.length == 0)) { if (this.customNoMore == 1 || (this.customNoMore != 0 && finalData.length == 0)) {
this.loadMoreStatus = `default`.More.NoMore this.loadMoreStatus = default__1.More.NoMore
} }
} else { } else {
if (finalData.length == 0 || (finalData.length > 0 && finalData.length < this.defaultPageSize)) { if (finalData.length == 0 || (finalData.length > 0 && finalData.length < this.defaultPageSize)) {
this.loadMoreStatus = `default`.More.NoMore this.loadMoreStatus = default__1.More.NoMore
} else { } else {
this.loadMoreStatus = `default`.More.Default this.loadMoreStatus = default__1.More.Default
} }
} }
if (this.isFirstPage) { if (this.isFirstPage) {
...@@ -519,7 +519,7 @@ open class GenUniModulesZPagingXComponentsZPagingXZPagingX : VueComponent { ...@@ -519,7 +519,7 @@ open class GenUniModulesZPagingXComponentsZPagingXZPagingX : VueComponent {
open var endRefresh = ::gen_endRefresh_fn open var endRefresh = ::gen_endRefresh_fn
open fun gen_endRefresh_fn() { open fun gen_endRefresh_fn() {
this.refresherTriggered = false this.refresherTriggered = false
this.refresherStatus = `default`.Refresher.Default this.refresherStatus = default__1.Refresher.Default
this.isLoading = false this.isLoading = false
} }
open var scrollToTop = ::gen_scrollToTop_fn open var scrollToTop = ::gen_scrollToTop_fn
...@@ -559,9 +559,9 @@ open class GenUniModulesZPagingXComponentsZPagingXZPagingX : VueComponent { ...@@ -559,9 +559,9 @@ open class GenUniModulesZPagingXComponentsZPagingXZPagingX : VueComponent {
this.`$emit`("refresherpulling", e.detail.dy) this.`$emit`("refresherpulling", e.detail.dy)
if (!this.isLoading) { if (!this.isLoading) {
this.refresherStatus = if (e.detail.dy < this.finalRefresherThreshold) { this.refresherStatus = if (e.detail.dy < this.finalRefresherThreshold) {
`default`.Refresher.Default default__1.Refresher.Default
} else { } else {
`default`.Refresher.ReleaseToRefresh default__1.Refresher.ReleaseToRefresh
} }
} }
} }
...@@ -573,7 +573,7 @@ open class GenUniModulesZPagingXComponentsZPagingXZPagingX : VueComponent { ...@@ -573,7 +573,7 @@ open class GenUniModulesZPagingXComponentsZPagingXZPagingX : VueComponent {
open var _onRefresherrestore = ::gen__onRefresherrestore_fn open var _onRefresherrestore = ::gen__onRefresherrestore_fn
open fun gen__onRefresherrestore_fn(e: RefresherEvent) { open fun gen__onRefresherrestore_fn(e: RefresherEvent) {
this.`$emit`("refresherrestore", e) this.`$emit`("refresherrestore", e)
this.refresherStatus = `default`.Refresher.Default this.refresherStatus = default__1.Refresher.Default
} }
open var _onRefresherabort = ::gen__onRefresherabort_fn open var _onRefresherabort = ::gen__onRefresherabort_fn
open fun gen__onRefresherabort_fn(e: RefresherEvent) { open fun gen__onRefresherabort_fn(e: RefresherEvent) {
...@@ -596,20 +596,20 @@ open class GenUniModulesZPagingXComponentsZPagingXZPagingX : VueComponent { ...@@ -596,20 +596,20 @@ open class GenUniModulesZPagingXComponentsZPagingXZPagingX : VueComponent {
} }
open var _handleRefresh = ::gen__handleRefresh_fn open var _handleRefresh = ::gen__handleRefresh_fn
open fun gen__handleRefresh_fn() { open fun gen__handleRefresh_fn() {
this.refresherStatus = `default`.Refresher.Loading this.refresherStatus = default__1.Refresher.Loading
this.refresherTriggered = true this.refresherTriggered = true
this.pageNo = this.defaultPageNo this.pageNo = this.defaultPageNo
this.queryFrom = `default`.QueryFrom.UserPullDown this.queryFrom = default__1.QueryFrom.UserPullDown
this._emitQuery(this.pageNo, this.defaultPageSize) this._emitQuery(this.pageNo, this.defaultPageSize)
} }
open var _handleLoadMore = ::gen__handleLoadMore_fn open var _handleLoadMore = ::gen__handleLoadMore_fn
open fun gen__handleLoadMore_fn() { open fun gen__handleLoadMore_fn() {
if (!this.loadMoreEnabled || this.isLoading || this.loadMoreStatus === `default`.More.NoMore) { if (!this.loadMoreEnabled || this.isLoading || this.loadMoreStatus === default__1.More.NoMore) {
return return
} }
this.loadMoreStatus = `default`.More.Loading this.loadMoreStatus = default__1.More.Loading
this.pageNo++ this.pageNo++
this.queryFrom = `default`.QueryFrom.LoadMore this.queryFrom = default__1.QueryFrom.LoadMore
this._emitQuery(this.pageNo, this.defaultPageSize) this._emitQuery(this.pageNo, this.defaultPageSize)
} }
open var _emitQuery = ::gen__emitQuery_fn open var _emitQuery = ::gen__emitQuery_fn
......
...@@ -5,23 +5,23 @@ ...@@ -5,23 +5,23 @@
}, },
"files": { "files": {
"utssdk/app-android/index.uts": { "utssdk/app-android/index.uts": {
"md5": "b8d7047ab786009165b43ad180c008d5" "md5": "a9a4f6b699eb1cea81e748493d3ba888"
}, },
"utssdk/interface.uts": { "utssdk/interface.uts": {
"md5": "c3f1df6a5ce4db069e198bc8550a3fe6" "md5": "b8daf9671b1eb5a85e7bca7b196a3090"
}, },
"utssdk/unierror.uts": { "utssdk/unierror.uts": {
"md5": "2e94771aa7d3802e8966524c6a142eb2" "md5": "5b2797f29fe86ddfd69e3784308dfbff"
}, },
"package.json": { "package.json": {
"md5": "fc46605131f5f9ea232b00512485267c" "md5": "fc46605131f5f9ea232b00512485267c"
}, },
"utssdk/app-android/config.json": {
"md5": "e2b257eff8b98abf06058a732fc0be20"
},
"utssdk/app-android/PermissionHandlerKt.kt": { "utssdk/app-android/PermissionHandlerKt.kt": {
"md5": "cb21c56602c2216855449a50ef459221" "md5": "cb21c56602c2216855449a50ef459221"
}, },
"utssdk/app-android/config.json": {
"md5": "ab4a7dae37d696250958caf2a17d2e47"
},
"utssdk/app-android/libs/permission_handler_android.aar": { "utssdk/app-android/libs/permission_handler_android.aar": {
"md5": "44c97d7b3a2447bb7bd6d710d24d2de5" "md5": "44c97d7b3a2447bb7bd6d710d24d2de5"
} }
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
}, },
"files": { "files": {
"utssdk/app-android/index.uts": { "utssdk/app-android/index.uts": {
"md5": "55393a780411124ddd6d27d7739d0d78" "md5": "f5fc3cfa3c83d8527211190786e1f2eb"
}, },
"utssdk/interface.uts": { "utssdk/interface.uts": {
"md5": "df1924ab0087b4340b8e3e75129d1739" "md5": "df1924ab0087b4340b8e3e75129d1739"
......
@file:Suppress("UNCHECKED_CAST", "USELESS_CAST", "INAPPLICABLE_JVM_NAME", "UNUSED_ANONYMOUS_PARAMETER", "NAME_SHADOWING", "UNNECESSARY_NOT_NULL_ASSERTION")
package uts.sdk.modules.utsAlioss
import io.dcloud.uniapp.*
import io.dcloud.uniapp.extapi.*
import io.dcloud.uniapp.framework.*
import io.dcloud.uniapp.runtime.*
import io.dcloud.uniapp.vue.*
import io.dcloud.uniapp.vue.shared.*
import io.dcloud.unicloud.*
import io.dcloud.uts.*
import io.dcloud.uts.Map
import io.dcloud.uts.Set
import io.dcloud.uts.UTSAndroid
import kotlin.properties.Delegates
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Deferred
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.async
open class OSSConfig (
@JsonNotNull
open var endpoint: String,
@JsonNotNull
open var bucketName: String,
@JsonNotNull
open var accessKeyId: String,
@JsonNotNull
open var accessKeySecret: String,
open var securityToken: String? = null,
) : UTSObject(), IUTSSourceMap {
override fun `__$getOriginalPosition`(): UTSSourceMapPosition? {
return UTSSourceMapPosition("OSSConfig", "uni_modules/uts-alioss/utssdk/interface.uts", 1, 13)
}
}
open class UploadSuccessResult (
@JsonNotNull
open var url: String,
@JsonNotNull
open var objectKey: String,
) : UTSObject(), IUTSSourceMap {
override fun `__$getOriginalPosition`(): UTSSourceMapPosition? {
return UTSSourceMapPosition("UploadSuccessResult", "uni_modules/uts-alioss/utssdk/interface.uts", 8, 13)
}
}
open class UploadFailResult (
@JsonNotNull
open var errCode: Number,
@JsonNotNull
open var errMsg: String,
) : UTSObject(), IUTSSourceMap {
override fun `__$getOriginalPosition`(): UTSSourceMapPosition? {
return UTSSourceMapPosition("UploadFailResult", "uni_modules/uts-alioss/utssdk/interface.uts", 12, 13)
}
}
open class UploadOptions (
@JsonNotNull
open var filePath: String,
@JsonNotNull
open var objectKey: String,
open var useMultipart: Boolean? = null,
open var success: ((res: UploadSuccessResult) -> Unit)? = null,
open var fail: ((res: UploadFailResult) -> Unit)? = null,
open var complete: ((res: Any) -> Unit)? = null,
) : UTSObject(), IUTSSourceMap {
override fun `__$getOriginalPosition`(): UTSSourceMapPosition? {
return UTSSourceMapPosition("UploadOptions", "uni_modules/uts-alioss/utssdk/interface.uts", 16, 13)
}
}
interface AliOSS {
fun initConfig(config: OSSConfig)
fun upload(options: UploadOptions)
}
fun initConfig(config: Any) {}
fun upload(options: Any) {}
{"version":3,"sources":["uni_modules/uts-alioss/utssdk/interface.uts","uni_modules/uts-alioss/utssdk/app-android/index.uts"],"sourcesContent":["export type OSSConfig = {\n endpoint : string\n bucketName : string\n accessKeyId : string\n accessKeySecret : string\n securityToken? : string\n}\n\nexport type UploadSuccessResult = {\n url : string\n objectKey : string\n}\n\nexport type UploadFailResult = {\n errCode : number\n errMsg : string\n}\n\nexport type UploadOptions = {\n filePath : string\n objectKey : string\n useMultipart? : boolean\n success? : (res : UploadSuccessResult) => void\n fail? : (res : UploadFailResult) => void\n complete? : (res : any) => void\n}\n\nexport interface AliOSS {\n initConfig(config : OSSConfig) : void\n upload(options : UploadOptions) : void\n}\n","export * from '../interface.uts';\n// import { OSSConfig, UploadOptions, UploadSuccessResult, UploadFailResult } from '../interface.uts';\n// import Context from 'android.content.Context';\n// import OSS from 'com.alibaba.sdk.android.oss.OSS';\n// import OSSClient from 'com.alibaba.sdk.android.oss.OSSClient';\n// import OSSCredentialProvider from 'com.alibaba.sdk.android.oss.common.auth.OSSCredentialProvider';\n// import OSSStsTokenCredentialProvider from 'com.alibaba.sdk.android.oss.common.auth.OSSStsTokenCredentialProvider';\n// import OSSPlainTextAKSKCredentialProvider from 'com.alibaba.sdk.android.oss.common.auth.OSSPlainTextAKSKCredentialProvider';\n// import PutObjectRequest from 'com.alibaba.sdk.android.oss.model.PutObjectRequest';\n// import PutObjectResult from 'com.alibaba.sdk.android.oss.model.PutObjectResult';\n// import ResumableUploadRequest from 'com.alibaba.sdk.android.oss.model.ResumableUploadRequest';\n// import ResumableUploadResult from 'com.alibaba.sdk.android.oss.model.ResumableUploadResult';\n// import OSSCompletedCallback from 'com.alibaba.sdk.android.oss.callback.OSSCompletedCallback';\n// import ClientException from 'com.alibaba.sdk.android.oss.ClientException';\n// import ServiceException from 'com.alibaba.sdk.android.oss.ServiceException';\n// import File from 'java.io.File';\n// import { UTSAndroid } from \"dcloudio.uni-app.uts\";\n\nlet ossClient: any | null = null;\nlet currentConfig: any | null = null;\n\nexport function initConfig(config: any) {\n // currentConfig = config;\n // const context = UTSAndroid.getAppContext();\n // if (context != null) {\n // let credentialProvider: OSSCredentialProvider;\n // if (config.securityToken != null && config.securityToken != \"\") {\n // credentialProvider = new OSSStsTokenCredentialProvider(config.accessKeyId, config.accessKeySecret, config.securityToken!);\n // } else {\n // credentialProvider = new OSSPlainTextAKSKCredentialProvider(config.accessKeyId, config.accessKeySecret);\n // }\n // ossClient = new OSSClient(context, config.endpoint, credentialProvider);\n // }\n}\n\nexport function upload(options: any) {\n // if (ossClient == null) {\n // if (currentConfig != null) {\n // initConfig(currentConfig!);\n // } else {\n // const res = { errCode: -1, errMsg: \"OSSClient not initialized\" } as UploadFailResult;\n // options.fail?.(res);\n // return;\n // }\n // }\n\n // if (currentConfig == null) {\n // const res = { errCode: -1, errMsg: \"Configuration missing\" } as UploadFailResult;\n // options.fail?.(res);\n // return;\n // }\n\n // const bucketName = currentConfig!.bucketName;\n // const objectKey = options.objectKey;\n // const filePath = options.filePath;\n\n // if (options.useMultipart == true) {\n // const context = UTSAndroid.getAppContext();\n // let recordDir = \"\";\n // if (context != null) {\n // // 优先使用外部缓存目录\n // const cacheDir = context.getExternalCacheDir();\n // if (cacheDir != null) {\n // recordDir = cacheDir.getAbsolutePath() + \"/oss_record/\";\n // } else {\n // recordDir = context.getCacheDir().getAbsolutePath() + \"/oss_record/\";\n // }\n // const dirFile = new File(recordDir);\n // if (!dirFile.exists()) {\n // dirFile.mkdirs();\n // }\n // }\n\n // const request = new ResumableUploadRequest(bucketName, objectKey, filePath, recordDir);\n \n // ossClient!.asyncResumableUpload(request, new OSSCompletedCallback<ResumableUploadRequest, ResumableUploadResult>({\n // onSuccess: (request: ResumableUploadRequest, result: ResumableUploadResult) => {\n // let endpoint = currentConfig!.endpoint;\n // if (!endpoint.startsWith(\"http\")) {\n // endpoint = \"https://\" + endpoint;\n // }\n \n // let url = \"\";\n // if (endpoint.includes(\"://\")) {\n // const parts = endpoint.split(\"://\");\n // url = parts[0] + \"://\" + bucketName + \".\" + parts[1] + \"/\" + objectKey;\n // } else {\n // url = \"https://\" + bucketName + \".\" + endpoint + \"/\" + objectKey;\n // }\n\n // const successRes = {\n // url: url,\n // objectKey: objectKey\n // } as UploadSuccessResult;\n \n // options.success?.(successRes);\n // options.complete?.(successRes);\n // },\n // onFailure: (request: ResumableUploadRequest, clientException: ClientException | null, serviceException: ServiceException | null) => {\n // let errMsg = \"\";\n // if (clientException != null) {\n\n // errMsg += clientException.getMessage();\n // }\n // if (serviceException != null) {\n // errMsg += \" \" + serviceException.getErrorCode() + \" \" + serviceException.getRequestId() + \" \" + serviceException.getHostId() + \" \" + serviceException.getRawMessage();\n // }\n \n // const failRes = {\n // errCode: -2,\n // errMsg: errMsg\n // } as UploadFailResult;\n \n // options.fail?.(failRes);\n // options.complete?.(failRes);\n // }\n // }));\n // return;\n // }\n\n // const put = new PutObjectRequest(bucketName, objectKey, filePath);\n\n // ossClient!.asyncPutObject(put, new OSSCompletedCallback<PutObjectRequest, PutObjectResult>({\n // onSuccess: (request: PutObjectRequest, result: PutObjectResult) => {\n // let endpoint = currentConfig!.endpoint;\n // if (!endpoint.startsWith(\"http\")) {\n // endpoint = \"https://\" + endpoint;\n // }\n \n // let url = \"\";\n // if (endpoint.includes(\"://\")) {\n // const parts = endpoint.split(\"://\");\n // // Assuming standard OSS endpoint format: http(s)://region.aliyuncs.com\n // // The bucket domain is bucket.region.aliyuncs.com\n // url = parts[0] + \"://\" + bucketName + \".\" + parts[1] + \"/\" + objectKey;\n // } else {\n // url = \"https://\" + bucketName + \".\" + endpoint + \"/\" + objectKey;\n // }\n\n // const successRes = {\n // url: url,\n // objectKey: objectKey\n // } as UploadSuccessResult;\n \n // options.success?.(successRes);\n // options.complete?.(successRes);\n // },\n // onFailure: (request: PutObjectRequest, clientException: ClientException | null, serviceException: ServiceException | null) => {\n // let errMsg = \"\";\n // if (clientException != null) {\n // errMsg += clientException.getMessage();\n // }\n // if (serviceException != null) {\n // errMsg += \" \" + serviceException.getErrorCode() + \" \" + serviceException.getRequestId() + \" \" + serviceException.getHostId() + \" \" + serviceException.getRawMessage();\n // }\n \n // const failRes = {\n // errCode: -2,\n // errMsg: errMsg\n // } as UploadFailResult;\n \n // options.fail?.(failRes);\n // options.complete?.(failRes);\n // }\n // }));\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAwB,WAAZ;IACR;uBAAW,MAAM,CAAA;IACjB;yBAAa,MAAM,CAAA;IACnB;0BAAc,MAAM,CAAA;IACpB;8BAAkB,MAAM,CAAA;IACxB,wBAAiB,MAAM,SAAA;;;;;;AAGO,WAAtB;IACR;kBAAM,MAAM,CAAA;IACZ;wBAAY,MAAM,CAAA;;;;;;AAGS,WAAnB;IACR;sBAAU,MAAM,CAAA;IAChB;qBAAS,MAAM,CAAA;;;;;;AAGS,WAAhB;IACR;uBAAW,MAAM,CAAA;IACjB;wBAAY,MAAM,CAAA;IAClB,uBAAgB,OAAO,SAAA;IACvB,oBAAY,KAAM,wBAAwB,IAAI,UAAA;IAC9C,iBAAS,KAAM,qBAAqB,IAAI,UAAA;IACxC,qBAAa,KAAM,GAAG,KAAK,IAAI,UAAA;;;;;;UAGlB;QACb,WAAW,QAAS;QACpB,OAAO,SAAU;;ACRf,IAAU,WAAW,QAAQ,GAAG,EAAA,CAYtC;AAEM,IAAU,OAAO,SAAS,GAAG,EAAA,CAkInC"}
\ No newline at end of file \ No newline at end of file
{
"version": "1",
"env": {
"compilerVersion": "4.87"
},
"files": {
"utssdk/app-android/index.uts": {
"md5": "7702ee53c2669e07b8bf16a7880023f1"
},
"utssdk/index.uts": {
"md5": "01104f37b0e6512bad0c3b39b302c93d"
},
"utssdk/interface.uts": {
"md5": "eeb3679b137b90826b6b0f8e397bb718"
},
"package.json": {
"md5": "6af7d52cbb668b71fe21975b58a66d73"
},
"utssdk/app-android/config.json": {
"md5": "dcda16688e0c4e71db5ef077e5fa6fb4"
}
}
}
\ No newline at end of file \ No newline at end of file
...@@ -5,10 +5,10 @@ ...@@ -5,10 +5,10 @@
}, },
"files": { "files": {
"utssdk/app-android/index.uts": { "utssdk/app-android/index.uts": {
"md5": "8cdabedbcc648fdbbe3f4c18c42c45f9" "md5": "62f1766476919e0e0621094336cbb99e"
}, },
"utssdk/interface.uts": { "utssdk/interface.uts": {
"md5": "6688e38e61f6eca9240da7450e8c2975" "md5": "dc62a22614c37e0b72a783f66b3e6cf4"
}, },
"package.json": { "package.json": {
"md5": "6f06381a2dea5e2d824cf2b44e875ed7" "md5": "6f06381a2dea5e2d824cf2b44e875ed7"
......
...@@ -8,13 +8,13 @@ ...@@ -8,13 +8,13 @@
"md5": "50a5c2c1bc75cb73d1f42200484fa0fb" "md5": "50a5c2c1bc75cb73d1f42200484fa0fb"
}, },
"utssdk/app-android/index.uts": { "utssdk/app-android/index.uts": {
"md5": "e15698bf671f186c36fa5a62bb967816" "md5": "7b25e4a14ea8ef398083fe98eeca8876"
}, },
"utssdk/index.uts": { "utssdk/index.uts": {
"md5": "2a72ac7645c68b6be4d52267edeb1d1d" "md5": "2a72ac7645c68b6be4d52267edeb1d1d"
}, },
"utssdk/interface.uts": { "utssdk/interface.uts": {
"md5": "e752ab8bf299c45b2f7f892d0f0eee1f" "md5": "e215f354eaf163d253081e63956c90e5"
}, },
"utssdk/unierror.uts": { "utssdk/unierror.uts": {
"md5": "a73277502f7e1d5e6e9b3273f85a2766" "md5": "a73277502f7e1d5e6e9b3273f85a2766"
...@@ -25,6 +25,12 @@ ...@@ -25,6 +25,12 @@
"HARMONY_TODO.md": { "HARMONY_TODO.md": {
"md5": "983c8c4abe15f05ba196dc3d97cdb1e4" "md5": "983c8c4abe15f05ba196dc3d97cdb1e4"
}, },
"NativeRecorder.js": {
"md5": "b0a7bb39fdd1da6bb2675d5568e9d780"
},
"package.json": {
"md5": "2de57a5dd7425c2e53120b39c1dc81ee"
},
"TEST.md": { "TEST.md": {
"md5": "c6f935b78a4fca01dca2d0206486afd7" "md5": "c6f935b78a4fca01dca2d0206486afd7"
}, },
...@@ -37,8 +43,11 @@ ...@@ -37,8 +43,11 @@
"USAGE.md": { "USAGE.md": {
"md5": "9d01fc031eacc4eb17f59af06e56e1f5" "md5": "9d01fc031eacc4eb17f59af06e56e1f5"
}, },
"package.json": { "utssdk/app-android/AndroidManifest.xml": {
"md5": "2de57a5dd7425c2e53120b39c1dc81ee" "md5": "a86c214fd7004bd1bba482a2507eb0e9"
},
"utssdk/app-android/config.json": {
"md5": "058540efb76e2ef2f4c07c8aa732472e"
} }
} }
} }
\ No newline at end of file \ No newline at end of file
{"duts":["uni-actionSheet","uni-theme","uni-getSystemInfo","uni-base64ToArrayBuffer","uni-arrayBufferToBase64","uni-crash","uni-storage","uni-dialogPage","uni-event","uni-exit","uni-form","uni-getAccessibilityInfo","uni-getAppAuthorizeSetting","uni-getAppBaseInfo","uni-getDeviceInfo","uni-getElementById","uni-getSystemSetting","uni-modal","uni-openAppAuthorizeSetting","uni-privacy","uni-progress","uni-prompt","uni-rpx2px","uni-rich-text","uni-barcode-scanning","uni-camera","uni-media","permission-handler-plus","uni-location","uni-location-system","lime-sqlite","uts-recorder","uni-createInnerAudioContext","uni-clipboard","uni-getNetworkType","uni-previewImage","uni-network","uni-fileSystemManager","uni-video"]}
\ No newline at end of file \ No newline at end of file
{"duts":["uni-actionSheet","uni-theme","uni-getSystemInfo","uni-base64ToArrayBuffer","uni-arrayBufferToBase64","uni-crash","uni-storage","uni-dialogPage","uni-event","uni-exit","uni-form","uni-getAccessibilityInfo","uni-getAppAuthorizeSetting","uni-getAppBaseInfo","uni-getDeviceInfo","uni-getElementById","uni-getSystemSetting","uni-modal","uni-openAppAuthorizeSetting","uni-privacy","uni-progress","uni-prompt","uni-rpx2px","uni-rich-text","uni-barcode-scanning","uni-camera","uni-media","permission-handler-plus","uni-location","uni-location-system","lime-sqlite","uts-recorder","uni-getNetworkType","uni-createInnerAudioContext","uni-fileSystemManager","uni-clipboard","uni-previewImage","uni-network","uni-video"]}
\ No newline at end of file \ No newline at end of file
export default class Queue<T> {
items: T[]
constructor(items: T[] = []) {
this.items = items
}
enqueue(element: T) {
this.items.push(element)
}
dequeue(): T | null {
if (this.isEmpty()) {
return null
}
return this.items.shift()
}
front(): T | null {
if (this.isEmpty()) {
return null
}
return this.items[0]
}
isEmpty(): boolean {
return this.items.length == 0
}
get size(): number {
return this.items.length
}
clear() {
this.items = []
}
}
...@@ -93,9 +93,44 @@ export function isEmpty(value: any): boolean { ...@@ -93,9 +93,44 @@ export function isEmpty(value: any): boolean {
* 返回对象的所有键名 * 返回对象的所有键名
* @example keys({a: 1, b: 2}) // ['a', 'b'] * @example keys({a: 1, b: 2}) // ['a', 'b']
*/ */
export function keys(value: any): string[] { export const nullValues = [null, ""]
// @ts-ignore
return UTSJSONObject.keys(value as UTSJSONObject); /**
* 格式化日期时间
*/
export function convertDateTimeFormat(date: Date, separator: string): string {
const year = date.getFullYear()
const month = (date.getMonth() + 1).toString().padStart(2, '0')
const day = date.getDate().toString().padStart(2, '0')
const hours = date.getHours().toString().padStart(2, '0')
const minutes = date.getMinutes().toString().padStart(2, '0')
const seconds = date.getSeconds().toString().padStart(2, '0')
return `${year}${separator}${month}${separator}${day} ${hours}:${minutes}:${seconds}`
}
/**
* 生成 UUID
* @example getUUID() // "123e4567-e89b-12d3-a456-426614174000"
*/
export function getUUID(): string {
let uuidStr = "";
let i: number;
let random: number;
for (i = 0; i < 36; i++) {
if (i == 8 || i == 13 || i == 18 || i == 23) {
uuidStr += "-";
} else if (i == 14) {
uuidStr += "4";
} else if (i == 19) {
random = (Math.random() * 16) | 0;
uuidStr += ((random & 0x3) | 0x8).toString(16);
} else {
random = (Math.random() * 16) | 0;
uuidStr += random.toString(16);
}
}
return uuidStr;
} }
/** /**
...@@ -486,31 +521,6 @@ export function toArray<T>(data: any, iteratee: (value: any, key: string) => T): ...@@ -486,31 +521,6 @@ export function toArray<T>(data: any, iteratee: (value: any, key: string) => T):
} }
/** /**
* 生成UUID
* @example uuid() // "123e4567-e89b-12d3-a456-426614174000"
*/
export function uuid(): string {
let uuid = "";
let i: number;
let random: number;
for (i = 0; i < 36; i++) {
if (i == 8 || i == 13 || i == 18 || i == 23) {
uuid += "-";
} else if (i == 14) {
uuid += "4";
} else if (i == 19) {
random = (Math.random() * 16) | 0;
uuid += ((random & 0x3) | 0x8).toString(16);
} else {
random = (Math.random() * 16) | 0;
uuid += random.toString(16);
}
}
return uuid;
}
/**
* 创建一个防抖函数,在指定延迟后执行函数,如果在延迟期间再次调用则重新计时 * 创建一个防抖函数,在指定延迟后执行函数,如果在延迟期间再次调用则重新计时
* @example debounce(() => console.log('执行'), 300) * @example debounce(() => console.log('执行'), 300)
*/ */
......
export class PathUtils {
static _basePath: string | null = null
// 默认保存文件夹名称
static SAVE_DIR_NAME = 'uniapp_save'
// 默认文件保存路径 (相对于 _doc/)
static DEFAULT_SAVE_PATH = "_doc/" + PathUtils.SAVE_DIR_NAME + "/"
static CACHED_ROOT_PATH: string | null = null
// 本地缓存键名
static ROOT_PATH_CACHE_KEY = 'sqlite_root_path_cache'
/**
* 路径拼接工具
* @param args 路径片段
* @returns
*/
static join(...args: string[]): string {
if (args.length == 0) return ''
const parts = args.map((part): string => {
if (part == "") return ''
let str = part
// 简单的去斜杠处理,UTS中正则可能需要注意
// 这里简化处理,假设输入相对规范
return str.trim()
}).filter((p: string): boolean => p.length > 0)
// 简单拼接,实际可能需要更复杂的逻辑处理 / 分隔符
return parts.join('/')
}
/**
* 获取基础保存路径 (带缓存)
*/
static async getBasePath(): Promise<string> {
if (PathUtils._basePath != null) return PathUtils._basePath!
PathUtils._basePath = await PathUtils.getFileSaveFolderOnClient()
return PathUtils._basePath!
}
/**
* 获取文件系统根目录的完整路径
* @returns {Promise<string>}
*/
static getFilePath(): Promise<string> {
// 1. 优先使用内存缓存,性能最高
if (PathUtils.CACHED_ROOT_PATH != null) {
// uni.$logger?.local?.info(`[PathUtils] 命中内存缓存,根路径: ${PathUtils.CACHED_ROOT_PATH}`);
return Promise.resolve(PathUtils.CACHED_ROOT_PATH!);
}
// 2. 尝试读取持久化缓存
const storageCache = uni.getStorageSync(PathUtils.ROOT_PATH_CACHE_KEY);
if (storageCache != null && storageCache != "") {
// uni.$logger?.local?.info(`[PathUtils] 命中本地缓存,根路径: ${storageCache}`);
// 同步到内存缓存
PathUtils.CACHED_ROOT_PATH = storageCache as string;
return Promise.resolve(PathUtils.CACHED_ROOT_PATH!);
}
// 3. 无缓存,请求原生文件系统API
return new Promise((resolve, reject) => {
// UTS 环境下优先使用 uni.env.USER_DATA_PATH
const userDataPath = uni.env.USER_DATA_PATH
PathUtils.CACHED_ROOT_PATH = userDataPath
uni.setStorageSync(PathUtils.ROOT_PATH_CACHE_KEY, userDataPath)
resolve(userDataPath)
});
}
/**
* 获取客户端文件保存基础路径
*/
static async getFileSaveFolderOnClient(): Promise<string> {
// 简单实现,直接调用 getFilePath
return await PathUtils.getFilePath()
}
}
export default class TaskQueue {
name: string
queue: Promise<any | null>
constructor(name: string = 'TaskQueue') {
this.name = name
this.queue = Promise.resolve(null)
}
/**
* 将任务加入队列
* @param {Function} task - 返回 Promise 的任务函数
* @param {number} timeout - 超时时间(ms),默认 20000
* @returns {Promise<any>}
*/
enqueue(task: () => Promise<any>, timeout: number = 20000): Promise<any | null> {
const taskWithTimeout = (): Promise<any | null> => this.withTimeout(task, timeout)
// 将任务追加到队列末尾
// 注意:在UTS中,Promise的类型需要明确,这里假设所有任务返回 Promise<any>
const next = this.queue.then((_: any | null): Promise<any | null> => {
return taskWithTimeout()
})
// 更新队列指针,确保队列始终指向最新的 Promise,且永远是 resolved 状态(catch 了错误)
this.queue = next.then((res: any | null): any | null => { return null }, (_: any): any | null => { return null })
return next
}
/**
* 带超时控制的任务执行器
*/
private withTimeout(task: () => Promise<any>, timeout: number): Promise<any | null> {
return new Promise((resolve, reject) => {
const timeoutId = setTimeout(() => {
const error = new Error(`${this.name}操作超时(${timeout}ms)`)
// uni.$logger?.local?.error(error.message)
console.error(error.message)
reject(error)
}, timeout)
task().then((res: any | null) => {
clearTimeout(timeoutId)
resolve(res)
}, (err: any) => {
clearTimeout(timeoutId)
reject(err)
})
})
}
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!