xtaw / LiteLoaderQQNT-Audio-Sender

一个用于直接以语音形式发送音频文件的插件
58 stars 3 forks source link

​ 1.04 Uncaught TypeError: e.dataTransfer.files.forEach is not a function #20

Open ShikieikiC opened 5 months ago

ShikieikiC commented 5 months ago

把音频拖拽到语音框后,没有任何反应

232131232131231

ShikieikiC commented 5 months ago

好像解决了,把renderer.js中

    if (document.querySelector(".audio-msg-input") != undefined) {
        e.dataTransfer.files.forEach(async file => {

这两行改为

    if (document.querySelector(".audio-msg-input") != undefined) {
        const files = Array.from(e.dataTransfer.files);
        for (const file of files) {

这对我是有效的

devil233-ui commented 3 months ago

卧槽用这方法直接整个llnt加载不了了,差点重装

3058132083 commented 3 months ago

解决renderer.js完整改动:

 import { Contact, Audio } from '../LiteLoaderQQNT-Euphony/src/index.js';
 document.addEventListener('drop', async e => {
     if (document.querySelector(".audio-msg-input") != undefined) {
         const files = Array.from(e.dataTransfer.files);
         for (const file of files) {
             if (await audio_sender.isFileSilk(file.path)) {
                 Contact.getCurrentContact().sendMessage(new Audio(file.path));
                 return;
             }
             const getSampleRateResult = await audio_sender.getSampleRate(file.path);
             if (getSampleRateResult.error) {
                 console.error(getSampleRateResult.error);
                 return;
             }
             const convertToPcmResult = await audio_sender.convertToPcm(file.path);
             if (convertToPcmResult.error) {
                 console.error(convertToPcmResult.error);
                 return;
             }
             const convertToSilkResult = await audio_sender.convertToSilk(convertToPcmResult.data, getSampleRateResult.data);
             if (convertToSilkResult.error) {
                 console.error(convertToSilkResult.error);
                 return;
             }
             const silkPath = `${ file.path }.silk`;
             const writeFileError = await audio_sender.writeFile(silkPath, convertToSilkResult.data.data);
             if (writeFileError) {
                 console.error(writeFileError);
                 return;
             }
             await Contact.getCurrentContact().sendMessage(new Audio(silkPath, convertToSilkResult.data.duration / 1000));
             const deleteFileError = await audio_sender.deleteFile(silkPath);
             if (deleteFileError) {
                 console.error(deleteFileError);
                 return;
             }
         };
     }
 });
devil233-ui commented 2 months ago

解决renderer.js完整改动:

    import { Contact, Audio } from '../LiteLoaderQQNT-Euphony/src/index.js';
    document.addEventListener('drop', async e => {
        if (document.querySelector(".audio-msg-input") != undefined) {
            const files = Array.from(e.dataTransfer.files);
            for (const file of files) {
                if (await audio_sender.isFileSilk(file.path)) {
                    Contact.getCurrentContact().sendMessage(new Audio(file.path));
                    return;
                }
                const getSampleRateResult = await audio_sender.getSampleRate(file.path);
                if (getSampleRateResult.error) {
                    console.error(getSampleRateResult.error);
                    return;
                }
                const convertToPcmResult = await audio_sender.convertToPcm(file.path);
                if (convertToPcmResult.error) {
                    console.error(convertToPcmResult.error);
                    return;
                }
                const convertToSilkResult = await audio_sender.convertToSilk(convertToPcmResult.data, getSampleRateResult.data);
                if (convertToSilkResult.error) {
                    console.error(convertToSilkResult.error);
                    return;
                }
                const silkPath = `${ file.path }.silk`;
                const writeFileError = await audio_sender.writeFile(silkPath, convertToSilkResult.data.data);
                if (writeFileError) {
                    console.error(writeFileError);
                    return;
                }
                await Contact.getCurrentContact().sendMessage(new Audio(silkPath, convertToSilkResult.data.duration / 1000));
                const deleteFileError = await audio_sender.deleteFile(silkPath);
                if (deleteFileError) {
                    console.error(deleteFileError);
                    return;
                }
            };
        }
    });

audio报错 能问下为啥我改完报错么

3058132083 commented 2 months ago

renderer.zip 试试直接用这个改好的? 我这边没啥问题可以正常使用。

dgwqc commented 2 months ago

renderer.zip 直接尝试用这个改好了吗? 我的香料没啥问题可以正常使用。

感谢,可以使用了