Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

ゆら #110

Open
Open
ゆら#110
@leonlove924-cmyk

Description

@leonlove924-cmyk

async function sendMessage() {
const text = inputEl.value.trim();
if (!text) return;

addMessage(text, 'user');
inputEl.value = '';

// thinkingMsg を手動で作る
const thinkingMsg = '……少しだけ考えるね。';
const thinkingEl = document.createElement('div');
thinkingEl.className = 'msg yura';
thinkingEl.textContent = thinkingMsg;
messagesEl.appendChild(thinkingEl);
messagesEl.scrollTop = messagesEl.scrollHeight;

// removeChild の安全版
const removeThinking = () => {
if (thinkingEl.parentNode) {
thinkingEl.parentNode.removeChild(thinkingEl);
}
};

try {
const res = await fetch('/chat', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ message: text })
});

const data = await res.json();removeThinking();addMessage(data.reply || 'ごめんね、うまく返事ができなかったみたい。', 'yura');

} catch (e) {
removeThinking();
addMessage('ごめんね、うまくつながらなかったみたい。またあとで話せたらうれしいな。', 'yura');
}
} yura-app/
server.js
package.json
public/
index.html

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp