File size: 1,443 Bytes
ef987bb | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | <!doctype html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<title>Prompt Response API Fixture</title>
<style>body { font-family: Arial, sans-serif; padding: 24px; } textarea { width: 520px; height: 80px; display: block; } output { display: block; margin-top: 12px; white-space: pre-wrap; }</style>
<script src="config.js"></script>
</head>
<body>
<main>
<label>Prompt<textarea data-testid="prompt-input"></textarea></label>
<button data-testid="send-button">Generate</button>
<h1 data-testid="generated-title">Build a todo app</h1>
<output data-testid="generated-content">Develop a cross-platform mobile app with fake content.</output>
<p data-testid="generation-status">idle</p>
</main>
<script>
async function fakeGenerate(prompt) {
return { title: 'Build a todo app', content: 'Develop a cross-platform mobile app with fake content.' };
}
document.querySelector('[data-testid="send-button"]').addEventListener('click', async () => {
document.querySelector('[data-testid="generation-status"]').textContent = 'complete';
const result = await fakeGenerate(document.querySelector('[data-testid="prompt-input"]').value);
document.querySelector('[data-testid="generated-title"]').textContent = result.title;
document.querySelector('[data-testid="generated-content"]').textContent = result.content;
});
</script>
</body>
</html>
|