Compare commits

...

3 Commits

Author SHA1 Message Date
hypercross 3cd8cc54b7 fix: mini icons 2026-03-25 17:36:19 +08:00
hypercross 64ac6c4516 fix: card layer assets 2026-03-25 17:29:56 +08:00
hypercross 8af559fe1c refactor: invert dice interaction 2026-03-25 14:08:29 +08:00
4 changed files with 13 additions and 9 deletions

View File

@ -23,7 +23,7 @@ export function CardLayer(props: CardLayerProps) {
const showBounds = () => props.store.state.isEditing;
function renderLayerContent(content: string) {
const iconPath = resolvePath(props.store.state.cards.sourcePath, props.cardData.iconPath);
const iconPath = resolvePath(props.store.state.cards.sourcePath, props.cardData.iconPath ?? "./assets");
return parseMarkdown(processVariables(content, props.cardData, props.store.state.cards), iconPath) as string;
}
return (

View File

@ -54,7 +54,8 @@ customElement("md-dice", { key: "" }, (props, { element }) => {
}
});
const handleRoll = () => {
const handleRoll = (e: MouseEvent) => {
e.preventDefault();
// 点击骰子图标:总是重 roll
const rollResult = rollFormula(formula).result;
setResult(rollResult.total);
@ -65,7 +66,8 @@ customElement("md-dice", { key: "" }, (props, { element }) => {
}
};
const handleTextClick = () => {
const handleTextClick = (e: MouseEvent) => {
e.preventDefault();
// 点击文本:总是重置为公式
setResult(null);
setIsRolled(false);
@ -80,17 +82,14 @@ customElement("md-dice", { key: "" }, (props, { element }) => {
return (
<span class="inline-flex items-center px-1">
<span
onClick={(e) => {
e.preventDefault();
handleRoll();
}}
onClick={handleTextClick}
class="text-blue-600 hover:text-blue-800 cursor-pointer"
title={rollDetail() || "掷骰子"}
>
🎲
</span>
<a
onClick={handleTextClick}
onClick={handleRoll}
class="cursor-pointer text-gray-700 hover:text-gray-900"
title={isRolled() ? "点击重置为公式" : formula}
>

View File

@ -40,7 +40,7 @@ const marked = new Marked()
renderer(token) {
if (!token.meta.name) {
const style = globalIconPrefix ? `style="--icon-src: url('${globalIconPrefix}/${token.text}.png')"` : '';
return `<icon ${style} class="icon-${token.text}"></icon>`;
return `<icon ${style} class="icon-${token.text} ${token.attrs?.class || ""}"></icon>`;
}
return false;
}

View File

@ -13,6 +13,11 @@ icon, pull{
background-position: center;
background-repeat: no-repeat;
}
icon.mini{
width: 1em;
height: 1em;
vertical-align: bottom;
}
pull{
margin-right: -.5em;
width: 0;