Commit 4783975d by yixinjj

完善上传机制

1 parent e87507e2
......@@ -117,6 +117,11 @@
<!-- 设置弹框 -->
<setting-box ref="settingRef" @stopAudio="stopAudio" />
<slot name="content" />
<web-view
@message="handlerMessage"
ref="webview"
src="/hybrid/html/index.html"
></web-view>
</view>
</template>
<script>
......@@ -124,8 +129,9 @@ import KfBox from "./components/KfBox";
import SettingBox from "./components/SettingBox";
import RecordList from "./components/RecordList.vue";
import myClick from "@/mixin/click";
import uploader from "@/mixin/uploader.js";
export default {
mixins: [myClick],
mixins: [myClick,uploader],
components: { KfBox, SettingBox, RecordList },
props: {
id: [String, Number],
......
......@@ -5,6 +5,7 @@
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>file upload oss</title>
Lorem ipsum, dolor sit amet consectetur adipisicing elit. Dolorum in saepe quia, amet quis, at id aperiam nesciunt incidunt, rerum aut modi facilis culpa expedita repellat cupiditate vero dicta ut.
</head>
<body>
......@@ -39,7 +40,8 @@
data: {
...result,
fileName,
recordId
recordId,
filePath
}
});
// 调用 destroy 方法,这将重置上传器的状态,释放资源
......@@ -54,6 +56,7 @@
code: 1,
fileName,
recordId,
filePath,
error: e.message
}
});
......
......@@ -23,7 +23,8 @@ export default {
// // #endif
},
mounted() {
var currentWebview = this.$scope.$getAppWebview(); //此对象相当于html5plus里的plus.webview.currentWebview()。在uni-app里vue页面直接使用plus.webview.currentWebview()无效
// console.log(JSON.stringify(this))
var currentWebview = this.$parent.$scope.$getAppWebview(); //此对象相当于html5plus里的plus.webview.currentWebview()。在uni-app里vue页面直接使用plus.webview.currentWebview()无效
setTimeout(function () {
wv = currentWebview.children()[0];
wv.setStyle({ top: "100%", height: 300 });
......
......@@ -47,14 +47,14 @@
<novice-guide @nextStep="nextStep" @back="back" />
</template>
</home-frame>
<!--
<cover-view class="webview-container">
<web-view
@message="handlerMessage"
ref="webview"
src="/hybrid/html/index.html"
></web-view>
</cover-view>
</cover-view> -->
</view>
</template>
<script>
......@@ -62,9 +62,9 @@ import detail from "./detail/detail";
import { mapMutations } from "vuex";
import NoviceGuide from "@/components/NoviceGuide.vue";
import HomeFrame from "@/components/HomeFrame/index.vue";
import storge from "@/mixin/storge";
// import storge from "@/mixin/storge";
export default {
mixins: [storge],
// mixins: [storge],
components: { HomeFrame, detail, NoviceGuide },
data() {
return {
......
class Queue {
_items = [];
constructor(items = []) {
this._items = items;
}
enqueue(item) {
this._items.push(item);
}
dequeue() {
return this._items.shift();
}
get head() {
return this._items[0];
}
get tail() {
return this._items[this._items.length - 1];
}
get items() {
return this._items;
}
get isEmpty() {
return !this._items.length;
}
get size() {
return this._items.length;
}
clear() {
this._items = [];
}
}
import { storageApi } from "./cache";
/**
* 记录管理器类
* 用于管理记录列表
*/
class RecordManager {
/**
* RecordManager 类的构造函数
* 用于初始化 RecordManager 实例
*/
constructor() {}
// 单例模式
static instance = null;
// 读写锁
locker = false;
/**
* 获取 RecordManager 的单例实例
* 如果 instance 不存在,则创建一个新实例并赋值给 instance
* @return {RecordManager} RecordManager 的单例实例
*/
static getInstance() {
if (!RecordManager.instance) {
RecordManager.instance = new RecordManager();
}
return RecordManager.instance;
}
/**
* 异步获取锁
* 如果锁已被占用,则在一段时间后重新尝试获取锁
* 如果成功获取锁,将返回一个 Promise,该 Promise 包含一个解锁函数。
* @return {Promise} 一个 Promise,在锁可用时兑现,并返回一个解锁函数
*/
async lock() {
return new Promise((resolve) => {
if (this.locker) {
setTimeout(() => {
this.lock();
}, 100);
} else {
this.locker = true;
resolve(this.unlock);
}
});
}
/**
* 释放本地存储的读写锁
*/
unlock() {
this.locker = false;
}
/**
* 将一条新记录添加到当前对象的记录列表中
*
* @param {Object} record - 要添加的新记录对象
* @returns {Array} - 包含新记录的更新后的记录列表
*/
async addRecord(record) {
const records = this.getRecords();
records.push(record);
this.setRecords(records);
return records;
}
/**
* 移除一个ID对应的记录
*
* @param {number} id - 要移除的记录的ID
* @returns {Array} - 移除记录后的更新后的记录列表
*/
async removeRecord(id) {
let records = this.getRecords();
records = records.filter((i) => i.id !== id);
this.setRecords(records);
return records;
}
/**
* 获取并移除当前对象记录列表中的最后一条记录
*
* @returns {Object} - 被移除的最后一条记录对象,如果记录列表为空,则返回 undefined
*/
getRecord() {
const records = this.getRecords();
return records.pop();
}
/**
* 根据给定的 ID 获取一条记录
*
* @param {number} id - 要获取的记录的 ID
* @returns {Object} - 具有给定 ID 的记录对象,如果没有找到符合条件的记录,则返回 undefined
*/
getRecordById(id) {
const records = this.getRecords();
return records.find((i) => i.id === id);
}
/**
* 获取记录列表
*
* @returns {Array} - 从 storageApi 获取的记录列表
*/
getRecords() {
return storageApi.getRecords();
}
/**
* 设置记录列表
*
* @param {Array} records - 要设置的记录列表
* @returns {void} - 此函数不返回任何值
*/
setRecords(records) {
storageApi.setRecords(records);
}
updateRecord(record) {
const records = this.getRecords();
const index = records.findIndex((i) => i.id === record.id);
if (index!== -1) {
records[index] = record;
this.setRecords(records);
}
}
/**
* 清除所有记录
*
* @returns {void} - 此函数不返回任何值
*/
clearRecords() {
storageApi.removeRecords();
}
}
export default RecordManager
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!