diff --git a/app/renderer/src/main/src/components/MilkdownEditor/Block/Block.tsx b/app/renderer/src/main/src/components/MilkdownEditor/Block/Block.tsx index b5e523c30f..634416c469 100644 --- a/app/renderer/src/main/src/components/MilkdownEditor/Block/Block.tsx +++ b/app/renderer/src/main/src/components/MilkdownEditor/Block/Block.tsx @@ -150,49 +150,49 @@ export const BlockView: React.FC = (props) => { command(state, dispatch) }) break - case "上传文件": - ipcRenderer - .invoke("openDialog", { - title: "请选择文件", - properties: ["openFile"] - }) - .then((data: {filePaths: string[]}) => { - const filesLength = data.filePaths.length - if (filesLength) { - const path = data.filePaths[0].replace(/\\/g, "\\") - getLocalFileLinkInfo(path).then((res) => { - if (res.size > FileMaxSize) { - yakitNotify("error", "文件大小不能超过1G") - return - } - const index = path.lastIndexOf(".") - const fileType = path.substring(index, path.length) - if (imgTypes.includes(fileType)) { - if (res.size > ImgMaxSize) { - yakitNotify("error", "图片大小不能超过1M") - return - } - httpUploadImgPath({path, type, filedHash: notepadHash}) - .then((src) => { - action( - callCommand(insertImageBlockCommand.key, { - src, - alt: path, - title: "" - }) - ) - }) - .catch((e) => { - yakitNotify("error", `上传图片失败:${e}`) - }) - } else { - action(callCommand(fileCommand.key, {id: "0", path, notepadHash})) - } - }) - } - }) + // case "上传文件": + // ipcRenderer + // .invoke("openDialog", { + // title: "请选择文件", + // properties: ["openFile"] + // }) + // .then((data: {filePaths: string[]}) => { + // const filesLength = data.filePaths.length + // if (filesLength) { + // const path = data.filePaths[0].replace(/\\/g, "\\") + // getLocalFileLinkInfo(path).then((res) => { + // if (res.size > FileMaxSize) { + // yakitNotify("error", "文件大小不能超过1G") + // return + // } + // const index = path.lastIndexOf(".") + // const fileType = path.substring(index, path.length) + // if (imgTypes.includes(fileType)) { + // if (res.size > ImgMaxSize) { + // yakitNotify("error", "图片大小不能超过1M") + // return + // } + // httpUploadImgPath({path, type, filedHash: notepadHash}) + // .then((src) => { + // action( + // callCommand(insertImageBlockCommand.key, { + // src, + // alt: path, + // title: "" + // }) + // ) + // }) + // .catch((e) => { + // yakitNotify("error", `上传图片失败:${e}`) + // }) + // } else { + // action(callCommand(fileCommand.key, {id: "0", path, notepadHash})) + // } + // }) + // } + // }) - break + // break case "分割线": action((ctx) => { const command = clearContentAndAddBlockType(hrSchema.type(ctx)) diff --git a/app/renderer/src/main/src/components/MilkdownEditor/CollabManager.tsx b/app/renderer/src/main/src/components/MilkdownEditor/CollabManager.tsx index 8285b83780..0eb427ebc8 100644 --- a/app/renderer/src/main/src/components/MilkdownEditor/CollabManager.tsx +++ b/app/renderer/src/main/src/components/MilkdownEditor/CollabManager.tsx @@ -131,6 +131,7 @@ export class CollabManager extends ObservableV2 { }) this.wsProvider.once("online-user-count", (onlineUserCount: number) => { + console.log("wsProvider-online-user-count", onlineUserCount) if (onlineUserCount < 2 && this.collabStatus.isSynced) { this.collabService.applyTemplate(template).connect() } else if (this.collabStatus.isSynced) { @@ -139,12 +140,14 @@ export class CollabManager extends ObservableV2 { }) this.wsProvider.on("saveStatus", ({saveStatus}) => { + console.log("wsProvider-saveStatus", saveStatus) this.setCollabStatus({...this.collabStatus, saveStatus}) }) // 监听在线用户数据 this.wsProvider?.awareness?.on("change", (payload) => { // 获取当前所有用户的状态 const users = this.getOnlineUser() + console.log("wsProvider-awareness-change", users) this.setOnlineUsers([...users]) }) } @@ -212,7 +215,9 @@ export class CollabManager extends ObservableV2 { token: this.wsRequest.token } if (this.wsProvider && this.wsProvider?.ws && this.wsProvider.ws?.readyState === WebSocket.OPEN) { - this.wsProvider?.ws?.send(Buffer.from(JSON.stringify(v))) + const sendValueString = JSON.stringify(v) + console.log("sendContent-valueString", sendValueString) + this.wsProvider?.ws?.send(Buffer.from(sendValueString)) } } diff --git a/app/renderer/src/main/src/components/MilkdownEditor/CustomFile/CustomFile.tsx b/app/renderer/src/main/src/components/MilkdownEditor/CustomFile/CustomFile.tsx index 472259d93e..19c94de746 100644 --- a/app/renderer/src/main/src/components/MilkdownEditor/CustomFile/CustomFile.tsx +++ b/app/renderer/src/main/src/components/MilkdownEditor/CustomFile/CustomFile.tsx @@ -77,7 +77,6 @@ export const CustomFile: React.FC = () => { const [loading, setLoading] = useState(false) const [errorReason, setErrorReason] = useState("") const [downFileInfo, setDownFileInfo] = useState() - const [visibleDownFiles, setVisibleDownFiles] = useState(false) const [queryFileErrorInfo, setQueryFileErrorInfo] = useState("") const [loadingRefresh, setLoadingRefresh] = useState(false) @@ -198,7 +197,6 @@ export const CustomFile: React.FC = () => { saveDialogAndGetLocalFileInfo(fileId).then((v) => { setDownFileInfo(v) setFileInfo({...fileInfo, path: v.path}) - setVisibleDownFiles(true) }) } const onCopyLink = useMemoizedFn((e) => { @@ -252,7 +250,6 @@ export const CustomFile: React.FC = () => { }) const onCancelDownload = useMemoizedFn(() => { setFileInfo({...fileInfo, path: ""}) - setVisibleDownFiles(false) setDownFileInfo(undefined) }) const onRefreshFileInfo = useMemoizedFn((e) => { diff --git a/app/renderer/src/main/src/components/MilkdownEditor/MilkdownEditor.tsx b/app/renderer/src/main/src/components/MilkdownEditor/MilkdownEditor.tsx index f76fe0dc17..84970b8e5c 100644 --- a/app/renderer/src/main/src/components/MilkdownEditor/MilkdownEditor.tsx +++ b/app/renderer/src/main/src/components/MilkdownEditor/MilkdownEditor.tsx @@ -71,7 +71,6 @@ import {useStore} from "@/store" import {CollabManager, CollabUserInfo} from "./CollabManager" import emiter from "@/utils/eventBus/eventBus" -import {YakitButton} from "../yakitUI/YakitButton/YakitButton" import {collab, collabServiceCtx} from "@milkdown/plugin-collab" import {showYakitModal} from "../yakitUI/YakitModal/YakitModalConfirm" import {tokenOverdue} from "@/services/fetch" @@ -88,8 +87,6 @@ const markdown1 = ` #ggg -:file[]{fileId="https://yakit-online.oss-accelerate.aliyuncs.com/notepade/2e80f8894f904134fb795f0731bed428-1732088835089&*&app.zip"} - ![1.00]( Maybe more? ![]() @@ -192,6 +189,7 @@ const CustomMilkdown: React.FC = React.memo((props) => { images.map(async (image) => { const alt = image.name try { + console.log("uploadConfig-image", image) const src = await uploadImg(image) return schema.nodes["image-block"].createAndFill({ src, @@ -232,6 +230,7 @@ const CustomMilkdown: React.FC = React.memo((props) => { `, onUpload: async (image: File) => { + console.log("imageBlockConfig-image", image) const url = uploadImg(image) return url } @@ -258,6 +257,7 @@ const CustomMilkdown: React.FC = React.memo((props) => { `, onUpload: async (image: File) => { + console.log("inlineImageConfig-image", image) const url = uploadImg(image) return url } @@ -356,7 +356,8 @@ const CustomMilkdown: React.FC = React.memo((props) => { filename: image.name || "image.png", contentType: image.type || "image/png" }, - type: "notepad" + type: collabParams.enableCollab ? "notepad" : "img", + filedHash: collabParams.milkdownHash }) return src } catch (error) { @@ -490,6 +491,7 @@ const CustomMilkdown: React.FC = React.memo((props) => { useMemoizedFn((ctx) => { // 获取 trackDeletePlugin 插件共享的值 const urls = ctx.get(deletedFileUrlsCtx) + console.log("onDeleteFiles", urls) if (urls.length > 0) { setInterval(1000) } else { @@ -519,8 +521,10 @@ const CustomMilkdown: React.FC = React.memo((props) => { newDeletedFiles.push(element) } } + console.log("onDeleteFiles-deletedFiles", deletedFiles) if (fileName.length > 0) { setInterval(undefined) + console.log("onDeleteFiles-fileName", fileName) httpDeleteOSSResource({file_name: fileName}, true).finally(() => { // 暂不考虑删除失败的情况 get()?.action((ctx) => ctx.update(deletedFileUrlsCtx, () => [...newDeletedFiles])) diff --git a/app/renderer/src/main/src/components/MilkdownEditor/WebsocketProvider/WebsocketProvider.ts b/app/renderer/src/main/src/components/MilkdownEditor/WebsocketProvider/WebsocketProvider.ts index 02447be7b4..36270b667c 100644 --- a/app/renderer/src/main/src/components/MilkdownEditor/WebsocketProvider/WebsocketProvider.ts +++ b/app/renderer/src/main/src/components/MilkdownEditor/WebsocketProvider/WebsocketProvider.ts @@ -114,6 +114,7 @@ const setupWS = (provider: WebsocketProvider) => { const bytes = Buffer.from(event.data).toString() const data: NotepadWsRequest = JSON.parse(bytes) const yjsParams = Buffer.from(data.yjsParams, "base64") + console.log("websocket.onmessage-data", data) if (!!data.params.userCount && data.params.docType === notepadActions.join) { // 目前加入类型的消息会修改在线人数,用来做连接文档的初始化内容 provider.onlineUserCount = data.params.userCount @@ -136,12 +137,15 @@ const setupWS = (provider: WebsocketProvider) => { } catch (error) {} } websocket.onerror = (event) => { + console.log("websocket.onerror-event", event) provider.emit("connection-error", [event, provider]) } websocket.onclose = (event) => { + console.log("websocket.onclose-event", event) closeWebsocketConnection(provider, websocket, event) } websocket.onopen = () => { + console.log("websocket.onopen") provider.wsLastMessageReceived = time.getUnixTime() provider.wsconnecting = false provider.wsconnected = true @@ -189,7 +193,9 @@ const setupWS = (provider: WebsocketProvider) => { * @param {CloseEvent} event */ const closeWebsocketConnection = (provider: WebsocketProvider, ws: WebSocket, event?: CloseEvent) => { + console.log("closeWebsocketConnection------1", ws, provider.ws) if (ws === provider.ws) { + console.log("closeWebsocketConnection------2", event) if (event) provider.emit("connection-close", [event, provider]) provider.ws = null ws.close() @@ -375,6 +381,7 @@ export class WebsocketProvider extends ObservableV2 { if (resyncInterval > 0) { this._resyncInterval = setInterval(() => { if (this.ws && this.ws.readyState === WebSocket.OPEN) { + console.log("_resyncInterval") // resend sync step 1 const encoder = encoding.createEncoder() encoding.writeVarUint(encoder, messageSync) @@ -408,6 +415,7 @@ export class WebsocketProvider extends ObservableV2 { token } const jsonString = JSON.stringify(value) + console.log("getSendData", jsonString) const finalArrayBuffer = Buffer.from(jsonString) return finalArrayBuffer } catch (error) { diff --git a/app/renderer/src/main/src/components/MilkdownEditor/constants.tsx b/app/renderer/src/main/src/components/MilkdownEditor/constants.tsx index 182a752dd4..72fc49d691 100644 --- a/app/renderer/src/main/src/components/MilkdownEditor/constants.tsx +++ b/app/renderer/src/main/src/components/MilkdownEditor/constants.tsx @@ -68,12 +68,12 @@ export const defaultBlockList: BlockListProps[] = [ label: "高亮", description: "高亮: :::success空格" }, - { - id: 10, - icon: , - label: "上传文件", - description: "上传文件" - }, + // { + // id: 10, + // icon: , + // label: "上传文件", + // description: "上传文件" + // }, { id: 11, icon: , diff --git a/app/renderer/src/main/src/components/MilkdownEditor/utils/uploadPlugin.ts b/app/renderer/src/main/src/components/MilkdownEditor/utils/uploadPlugin.ts index 5760db9bec..ac4295cd42 100644 --- a/app/renderer/src/main/src/components/MilkdownEditor/utils/uploadPlugin.ts +++ b/app/renderer/src/main/src/components/MilkdownEditor/utils/uploadPlugin.ts @@ -1,6 +1,10 @@ import {$command, $nodeSchema, $nodeAttr} from "@milkdown/utils" import {Attrs} from "@milkdown/kit/prose/model" import {TextSelection} from "@milkdown/kit/prose/state" +import { getTypeAndNameByPath } from "../CustomFile/CustomFile" +import { getLocalFileLinkInfo } from "../CustomFile/utils" +import { UploadOSSStartProps } from "@/hook/useUploadOSS/useUploadOSS" +import { uploadBigFileType } from "@/hook/useUploadOSS/constants" export const fileCustomId = "file-custom" export const fileCustomAttr = $nodeAttr("file-custom", () => ({ @@ -77,12 +81,25 @@ export const fileCustomSchema = $nodeSchema(fileCustomId, (ctx) => ({ } })) -export const fileCommand = $command(`command-${fileCustomId}`, (ctx) => (props) => (state, dispatch) => { +export const fileCommand = $command(`command-${fileCustomId}`, (ctx) => (props: any) => (state, dispatch) => { const {selection, tr} = state if (!(selection instanceof TextSelection)) return false const {from, to} = selection const fragment = state.doc.slice(from, to).content // 获取 Fragment + + const path = props.path.replace(/\\/g, "\\") + + // if (props.path) { + // getLocalFileLinkInfo(path).then((fileInfo) => { + // const value: UploadOSSStartProps = { + // filePath:path, + // filedHash: props?.notepadHash || "", + // type: uploadBigFileType.notepad + // } + // // onStartUpload(value) + // }) + // } dispatch?.( tr .setMeta(fileCustomId, true) diff --git a/app/renderer/src/main/src/pages/EnterpriseJudgeLogin.tsx b/app/renderer/src/main/src/pages/EnterpriseJudgeLogin.tsx index 6549ef63db..f4b471b21a 100644 --- a/app/renderer/src/main/src/pages/EnterpriseJudgeLogin.tsx +++ b/app/renderer/src/main/src/pages/EnterpriseJudgeLogin.tsx @@ -118,7 +118,7 @@ const EnterpriseJudgeLogin: React.FC = (props) => { ) : ( <> - {activateLicense ? ( + {true ? (
= (query) => { return new Promise((resolve, reject) => { + console.log("apiSetNotepadPermission-query", query) try { NetWorkApi({ method: "post", diff --git a/app/renderer/src/main/src/pages/notepadManage/notepadManage/utils.ts b/app/renderer/src/main/src/pages/notepadManage/notepadManage/utils.ts index 80cc8b8f76..a871997af1 100644 --- a/app/renderer/src/main/src/pages/notepadManage/notepadManage/utils.ts +++ b/app/renderer/src/main/src/pages/notepadManage/notepadManage/utils.ts @@ -71,6 +71,7 @@ export const apiGetNotepadList: APIFunc = (params, hiddenError) => { return new Promise((resolve, reject) => { + console.log("apiSaveNotepadList", params) NetWorkApi({ method: "post", url: "notepad", @@ -159,8 +160,10 @@ export const onBaseNotepadDown: APIFunc { + console.log("onBaseNotepadDown-res", res) saveDialogAndGetLocalFileInfo((res as string) || "") .then(resolve) .catch(reject) diff --git a/app/renderer/src/main/src/routes/newRoute.tsx b/app/renderer/src/main/src/routes/newRoute.tsx index 887facfac4..49ed7241c0 100644 --- a/app/renderer/src/main/src/routes/newRoute.tsx +++ b/app/renderer/src/main/src/routes/newRoute.tsx @@ -424,7 +424,8 @@ export const RouteToPage: (props: PageItemProps) => ReactNode = (props) => { const {routeKey, yakScriptId, params} = props switch (routeKey) { case YakitRoute.NewHome: - return + // return + return case YakitRoute.HTTPHacker: return ( }> diff --git a/app/renderer/src/main/src/utils/webSocket/webSocket.tsx b/app/renderer/src/main/src/utils/webSocket/webSocket.tsx index 891262cc1e..e934351165 100644 --- a/app/renderer/src/main/src/utils/webSocket/webSocket.tsx +++ b/app/renderer/src/main/src/utils/webSocket/webSocket.tsx @@ -1,23 +1,22 @@ import emiter from "../eventBus/eventBus" import {failed} from "@/utils/notification" -import { Uint8ArrayToString } from "../str" -import { API } from "@/services/swagger/resposeType" +import {Uint8ArrayToString} from "../str" +import {API} from "@/services/swagger/resposeType" const {ipcRenderer} = window.require("electron") - /**@name webSocket是否开启 */ export let webSocketStatus = false export const startWebSocket = () => { - ipcRenderer.on("client-socket-message", (e, data:Uint8Array) => { + ipcRenderer.on("client-socket-message", (e, data: Uint8Array) => { try { const obj = JSON.parse(Uint8ArrayToString(data)) + console.log("client-socket-message", obj) switch (obj.messageType) { case "messageLog": emiter.emit("onRefreshMessageSocket", JSON.stringify(obj.params)) - break; - } - + break + } } catch (error) {} }) @@ -34,7 +33,7 @@ export const startWebSocket = () => { webSocketStatus = false }) - ipcRenderer.on("client-socket-error", (e, error:any) => { + ipcRenderer.on("client-socket-error", (e, error: any) => { // console.log("webSocket错误",error); }) } @@ -47,6 +46,6 @@ export const closeWebSocket = () => { ipcRenderer.removeAllListeners("client-socket-error") } -export const sendWebSocket = (data:API.WsRequest) => { - ipcRenderer.invoke("socket-send",data) -} \ No newline at end of file +export const sendWebSocket = (data: API.WsRequest) => { + ipcRenderer.invoke("socket-send", data) +}