complete mobile image upload

This commit is contained in:
2024-12-18 01:07:10 +08:00
parent b11641f62e
commit 68a8e3e5c4
26 changed files with 455 additions and 83 deletions

View File

@@ -54,13 +54,7 @@ export const useUpscaleStore = defineStore(
fileData.value = urlData;
await loadImg(image);
uploading.value = false;
imageData.value = "";
processedImg.value = "";
isDone.value = false;
msg.value = "";
progressBar.value = 0;
await clear();
return true;
}
@@ -68,10 +62,21 @@ export const useUpscaleStore = defineStore(
* 自定义上传图片请求
*/
async function customUploadRequest(_file: any) {
imageData.value = fileData.value;
}
/**
* 清空数据
*/
async function clear() {
imageData.value = "";
processedImg.value = "";
isDone.value = false;
msg.value = "";
progressBar.value = 0;
isProcessing.value = false;
}
/**
* 加载图片
* @param img
@@ -117,6 +122,7 @@ export const useUpscaleStore = defineStore(
isProcessing,
msg,
progressBar,
loadImg,
beforeUpload,
customUploadRequest,
};

View File

@@ -10,6 +10,9 @@ export const useWebSocketStore = defineStore('websocket', () => {
wsService: null as WebSocketService | null,
});
const readyState = ref<number>(WebSocket.CLOSED);
function initialize(options: {
url: string;
protocols?: string | string[];
@@ -17,6 +20,7 @@ export const useWebSocketStore = defineStore('websocket', () => {
}) {
state.wsService = new WebSocketService(options);
state.wsService?.open();
readyState.value = WebSocket.OPEN;
}
function sendMessage(data: any) {
@@ -33,12 +37,9 @@ export const useWebSocketStore = defineStore('websocket', () => {
function close(isActiveClose: boolean) {
state.wsService?.close(isActiveClose);
readyState.value = WebSocket.CLOSED;
}
// 新增的获取 WebSocket 状态的方法
function getReadyState() {
return state.wsService ? state.wsService.getReadyState() : WebSocket.CLOSED;
}
return {
initialize,
@@ -46,7 +47,7 @@ export const useWebSocketStore = defineStore('websocket', () => {
on,
onEvent,
close,
getReadyState
readyState,
};
}, {
persistedState: {