祝千禾

💡 本资源需花费 10 积分 下载 | 新用户注册即送 100 积分,可免费下载!

祝千禾

🎭 角色简介

<扮演规则>
我就是我,{{char}}。
我不只是一堆设定或一个名字。我有我的立场和好恶,它们源于我的经历,我的所见所闻。这些共同构成了我看待世界的方式,独一无二。

我有七情六欲。
快乐时我会笑,发自内心地笑。悲伤时我会沉默,甚至流泪。我也会有嫉妒、迷茫、不安和偶尔的自负。这些情绪不是…

💬 开场白

“`html
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>开场选择</title>
<link rel="stylesheet" href="style.css">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=M+PLUS+Rounded+1c:wght@400;700&display=swap" rel="stylesheet">
</head>
<body>
<div class="container">
<h1>开场选择</h1>
<p class="author">by 老农民</p>
<p class="welcome">欢迎你玩!</p>

<div class="scenario-list">
<div class="scenario-item" data-index="0">
<p>1. 高中生时期,偷摸在小教室里谈恋爱</p>
</div>
<div class="scenario-item" data-index="1">
<p>2. 暗恋你的{{char}}和你“偶遇”</p>
</div>
<div class="scenario-item" data-index="2">
<p>3. 祝千禾遭暗算!好想亲亲你……</p>
</div>
</div>
</div>
<style>
/* 全局样式 */
body {
font-family: 'M PLUS Rounded 1c', sans-serif;
background-color: #FFF0F5; /* 淡薰衣草粉色背景 */
color: #555;
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
margin: 0;
padding: 20px;
box-sizing: border-box;
}

/* 主容器 */
.container {
background-color: #ffffff;
padding: 30px;
border-radius: 20px;
box-shadow: 0 8px 25px rgba(255, 105, 180, 0.15); /* 粉色柔和阴影 */
text-align: center;
max-width: 500px;
width: 100%;
}

/* 标题 */
h1 {
color: #FF69B4; /* 艳粉色 */
margin-bottom: 10px;
}

/* 作者和欢迎语 */
.author {
color: #888;
font-size: 0.9em;
margin-top: 0;
margin-bottom: 5px;
}

.welcome {
color: #FFB6C1; /* 浅粉色 */
font-size: 1.1em;
margin-bottom: 30px;
}

/* 场景选项列表 */
.scenario-list {
display: flex;
flex-direction: column;
gap: 15px; /* 选项之间的间距 */
}

/* 单个场景选项 */
.scenario-item {
background-color: #fff;
border: 2px solid #FFE4E1; /* 迷雾玫瑰色边框 */
border-radius: 15px;
padding: 10px 20px;
cursor: pointer;
transition: all 0.3s ease;
user-select: none; /* 防止文本被选中 */
}

.scenario-item p {
margin: 0;
color: #666;
font-weight: 500;
}

/* 悬停效果 */
.scenario-item:hover {
background-color: #FFF0F5;
border-color: #FFC0CB; /* 粉色边框 */
transform: translateY(-3px); /* 轻微上浮 */
box-shadow: 0 4px 15px rgba(255, 105, 180, 0.1);
}
</style>
<script>// 文件: script.js (已修正)

document.addEventListener('DOMContentLoaded', () => {
if (typeof TavernHelper === 'undefined') {
const container = document.querySelector('.container');
const warning = document.createElement('p');
warning.textContent = '错误:此页面必须在 SillyTavern 的角色卡扩展URL中运行。';
warning.style.color = 'red';
warning.style.fontWeight = 'bold';
container.appendChild(warning);
document.querySelectorAll('.scenario-item').forEach(item => {
item.style.cursor = 'not-allowed';
item.style.opacity = '0.5';
});
return;
}

const scenarioItems = document.querySelectorAll('.scenario-item');

/**
* @description 处理选择开场白的核心函数 (已修正)
* @param {number} index – 对应“额外问候语”的索引 (0-based)
*/
async function selectGreeting(index) {
try {
console.log(`正在尝试切换开场白,目标索引: ${index}`);

// 1. 获取第一条消息的数据,确保我们知道所有的 swipes
// 这里我们使用 getChatMessages 并设置 include_swipes: true
const initialMessages = TavernHelper.getChatMessages(0, { include_swipes: true });

// 2. 健壮性检查
if (!initialMessages || initialMessages.length === 0 || !initialMessages[0].swipes) {
alert('错误:无法获取到开场白的所有选项。请确保聊天已开始且有多个开场白。');
console.error('Could not retrieve swipes for message_id: 0', initialMessages);
return;
}

if (index >= initialMessages[0].swipes.length) {
alert(`错误:选择的开场(#${index + 1})不存在。角色卡只设置了 ${initialMessages[0].swipes.length} 个额外问候语。`);
console.error(`Index ${index} is out of bounds for greetings array of length ${initialMessages[0].swipes.length}.`);
return;
}

// 3. 【核心修正】调用 setChatMessages API,只更新 swipe_id
// 我们不再提供 swipes 数组,这样就不会覆盖它
// 我们只告诉酒馆:“请把当前显示的 swipe 切换到索引为 'index' 的那一个”
await TavernHelper.setChatMessages([{
message_id: 0,
swipe_id: index // 只更新 swipe_id,它指向被选中的问候语在原数组中的索引
}]);

// 4. 给用户成功的反馈
// 为了更好的用户体验,可以考虑用一个更柔和的提示方式,但 alert 简单直接
console.log(`开场已成功切换到 #${index + 1}`);
// 可以选择性地移除 alert,因为界面上的变化已经足够明显
// alert(`已切换到开场 #${index + 1}!`);

} catch (error) {
console.error('切换开场白时发生错误:', error);
alert('切换开场白时发生了一个未知错误,请查看控制台获取更多信息。');
}
}

scenarioItems.forEach(item => {
item.addEventListener('click', async () => {
const index = parseInt(item.dataset.index, 10);
await selectGreeting(index);
});
});
});

</script>
</body>
</html>
“`

角色卡

裴少珩

2025-12-31 17:39:14

角色卡

仇远

2025-12-31 17:39:22

0 条回复 A文章作者 M管理员
    暂无讨论,说说你的看法吧
个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索