From 4df6165fa93c7caeea86385312415e312de4d11f Mon Sep 17 00:00:00 2001
From: Moli <13026959681@163.com>
Date: 星期二, 05 五月 2026 01:10:39 +0800
Subject: [PATCH] 暂存
---
samples/plugins/sample.llm-command-palette/demo.html | 491 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 491 insertions(+), 0 deletions(-)
diff --git a/samples/plugins/sample.llm-command-palette/demo.html b/samples/plugins/sample.llm-command-palette/demo.html
new file mode 100644
index 0000000..f86d004
--- /dev/null
+++ b/samples/plugins/sample.llm-command-palette/demo.html
@@ -0,0 +1,491 @@
+<!doctype html>
+<html lang="en">
+<head>
+ <meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>LLM Command Palette Demo</title>
+ <style>
+ :root {
+ color-scheme: dark;
+ font-family: "Segoe UI", system-ui, sans-serif;
+ background: #11100f;
+ }
+
+ * {
+ box-sizing: border-box;
+ }
+
+ html,
+ body {
+ width: 100%;
+ min-height: 100%;
+ margin: 0;
+ background:
+ radial-gradient(circle at 18% 18%, rgba(255, 130, 88, 0.16), transparent 28%),
+ linear-gradient(135deg, #151312 0%, #23201f 52%, #11100f 100%);
+ overflow: hidden;
+ }
+
+ body {
+ padding: 8px;
+ }
+
+ .shell {
+ width: 100%;
+ color: rgba(255, 255, 255, 0.92);
+ }
+
+ .bar,
+ .output,
+ .memory {
+ width: 100%;
+ border: 1px solid rgba(255, 255, 255, 0.14);
+ background: rgba(28, 26, 25, 0.72);
+ box-shadow: 0 12px 30px rgba(0, 0, 0, 0.18);
+ backdrop-filter: blur(18px);
+ }
+
+ .bar {
+ display: grid;
+ grid-template-columns: minmax(90px, 112px) 22px minmax(0, 1fr) 30px minmax(112px, 128px);
+ align-items: center;
+ gap: 14px;
+ min-height: 56px;
+ padding: 0 20px;
+ border-radius: 20px;
+ }
+
+ .mark {
+ width: 18px;
+ height: 18px;
+ color: #ff8258;
+ display: grid;
+ place-items: center;
+ font-size: 20px;
+ line-height: 1;
+ transform-origin: center;
+ }
+
+ .mark.busy {
+ animation: spin 1.1s linear infinite;
+ }
+
+ @keyframes spin {
+ to { transform: rotate(360deg); }
+ }
+
+ textarea {
+ width: 100%;
+ min-height: 24px;
+ max-height: 78px;
+ resize: none;
+ border: 0;
+ outline: none;
+ color: rgba(255, 255, 255, 0.94);
+ background: transparent;
+ font: 600 16px/1.35 "Segoe UI", system-ui, sans-serif;
+ letter-spacing: 0;
+ overflow-y: auto;
+ }
+
+ textarea::placeholder {
+ color: rgba(255, 255, 255, 0.46);
+ }
+
+ input {
+ width: 100%;
+ height: 34px;
+ border: 1px solid rgba(255, 255, 255, 0.13);
+ outline: none;
+ color: rgba(255, 255, 255, 0.88);
+ background: rgba(255, 255, 255, 0.07);
+ border-radius: 8px;
+ padding: 0 30px 0 10px;
+ font: 600 13px/1 "Segoe UI", system-ui, sans-serif;
+ letter-spacing: 0;
+ transition: background 120ms ease;
+ }
+
+ .combo {
+ position: relative;
+ width: 100%;
+ min-width: 0;
+ }
+
+ .combo-input {
+ display: none;
+ }
+
+ .combo-trigger {
+ width: 100%;
+ height: 34px;
+ border: 0;
+ border-radius: 8px;
+ color: rgba(255, 255, 255, 0.82);
+ background: transparent;
+ padding: 0 28px 0 10px;
+ text-align: left;
+ font: 600 13px/1 "Segoe UI", system-ui, sans-serif;
+ letter-spacing: 0;
+ cursor: pointer;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ position: relative;
+ transition: background 120ms ease;
+ }
+
+ .combo-trigger::after {
+ content: "";
+ position: absolute;
+ right: 11px;
+ top: 13px;
+ width: 7px;
+ height: 7px;
+ border-right: 2px solid rgba(255, 255, 255, 0.72);
+ border-bottom: 2px solid rgba(255, 255, 255, 0.72);
+ transform: rotate(45deg);
+ }
+
+ input:hover,
+ input:focus,
+ .combo.open .combo-trigger,
+ .combo-trigger:hover,
+ .combo-trigger:focus {
+ background-color: rgba(255, 255, 255, 0.08);
+ box-shadow: none;
+ }
+
+ .combo-menu {
+ position: absolute;
+ left: 0;
+ right: 0;
+ top: calc(100% + 6px);
+ z-index: 10;
+ display: none;
+ max-height: 184px;
+ overflow-y: auto;
+ padding: 6px;
+ border: 1px solid rgba(255, 255, 255, 0.13);
+ border-radius: 10px;
+ background: rgba(28, 26, 25, 0.92);
+ box-shadow: 0 12px 28px rgba(0, 0, 0, 0.26);
+ backdrop-filter: blur(16px);
+ }
+
+ .combo.open .combo-menu {
+ display: block;
+ }
+
+ .combo-option {
+ min-height: 36px;
+ display: flex;
+ align-items: center;
+ border-radius: 7px;
+ padding: 0 10px;
+ color: rgba(255, 255, 255, 0.86);
+ font: 600 13px/1.2 "Segoe UI", system-ui, sans-serif;
+ cursor: pointer;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ }
+
+ .combo-option:hover,
+ .combo-option.selected {
+ background: rgba(255, 130, 88, 0.16);
+ color: rgba(255, 255, 255, 0.96);
+ }
+
+ .output,
+ .memory {
+ display: none;
+ margin-top: 8px;
+ max-height: 50vh;
+ overflow: auto;
+ border-radius: 16px;
+ padding: 16px 18px 14px;
+ font-size: 14px;
+ line-height: 1.55;
+ white-space: pre-wrap;
+ }
+
+ .output.open,
+ .memory.open {
+ display: block;
+ animation: panelIn 160ms ease-out;
+ }
+
+ @keyframes panelIn {
+ from { opacity: 0; transform: translateY(-3px); }
+ to { opacity: 1; transform: translateY(0); }
+ }
+
+ .actions,
+ .memory-actions {
+ display: flex;
+ justify-content: flex-end;
+ gap: 8px;
+ margin-top: 12px;
+ }
+
+ .memory-row {
+ display: grid;
+ grid-template-columns: minmax(0, 1fr) 32px;
+ gap: 8px;
+ align-items: start;
+ padding: 8px 0;
+ border-top: 1px solid rgba(255, 255, 255, 0.08);
+ white-space: normal;
+ }
+
+ .memory-row:first-child {
+ border-top: 0;
+ }
+
+ .memory-content {
+ color: rgba(255, 255, 255, 0.86);
+ overflow-wrap: anywhere;
+ }
+
+ button {
+ width: 30px;
+ height: 30px;
+ border: 0;
+ border-radius: 8px;
+ color: rgba(255, 255, 255, 0.84);
+ background: rgba(255, 255, 255, 0.08);
+ cursor: pointer;
+ font: 700 13px/1 "Segoe UI", system-ui, sans-serif;
+ }
+
+ button:disabled,
+ input:disabled {
+ cursor: not-allowed;
+ opacity: 0.52;
+ }
+
+ .error {
+ color: #ffad9b;
+ }
+ </style>
+</head>
+<body>
+ <main class="shell">
+ <section class="bar">
+ <div class="combo" id="projectCombo">
+ <input id="project" class="combo-input" aria-hidden="true">
+ <button id="projectButton" class="combo-trigger" type="button" title="AiChat project">Project</button>
+ <div id="projectMenu" class="combo-menu" role="listbox"></div>
+ </div>
+ <div id="mark" class="mark" aria-hidden="true">*</div>
+ <textarea id="prompt" rows="1" placeholder="What can I help you with today?">Summarize today's desktop notes</textarea>
+ <button id="memoryToggle" title="Memory">M</button>
+ <div class="combo" id="modelCombo">
+ <input id="model" class="combo-input" aria-hidden="true">
+ <button id="modelButton" class="combo-trigger" type="button" title="Model">Model</button>
+ <div id="modelMenu" class="combo-menu" role="listbox"></div>
+ </div>
+ </section>
+ <section id="output" class="output open" aria-live="polite">
+ <div id="text">Static preview response. This demo.html has no host bridge, no network calls, and no LLM dependency. Press Enter in the prompt to preview the loading and response states.</div>
+ <div class="actions">
+ <button id="copy" title="Copy">C</button>
+ <button id="collapse" title="Collapse">-</button>
+ </div>
+ </section>
+ <section id="memory" class="memory" aria-live="polite">
+ <div id="memoryList"></div>
+ <div class="memory-actions">
+ <input id="memoryInput" placeholder="Save memory">
+ <button id="saveMemory" title="Save memory">+</button>
+ <button id="refreshMemory" title="Refresh memory">R</button>
+ </div>
+ </section>
+ </main>
+
+ <script>
+ const demoProjects = [
+ { value: "desktop", label: "Desktop", title: "CHAT / PROJECT" },
+ { value: "design", label: "Design pass", title: "CHAT / PROJECT" },
+ { value: "ops", label: "Ops notes", title: "CHAT / PROJECT" }
+ ];
+ const demoModels = [
+ { value: "deepseek-v4-flash", label: "deepseek-v4-flash", title: "deepseek / deepseek-v4-flash" },
+ { value: "kimi-k2.6", label: "kimi-k2.6", title: "kimi / kimi-k2.6" },
+ { value: "glm-4.7-flash", label: "glm-4.7-flash", title: "bigmodel / glm-4.7-flash" },
+ { value: "qwen3.6-plus", label: "qwen3.6-plus", title: "qwen / qwen3.6-plus" }
+ ];
+ let demoMemories = [
+ { id: "m1", content: "Keep the command palette compact enough for a desktop widget." },
+ { id: "m2", content: "Prefer plain static demo files for visual iteration." }
+ ];
+
+ const promptInput = document.getElementById("prompt");
+ const projectSelect = document.getElementById("project");
+ const projectCombo = document.getElementById("projectCombo");
+ const projectButton = document.getElementById("projectButton");
+ const projectMenu = document.getElementById("projectMenu");
+ const modelSelect = document.getElementById("model");
+ const modelCombo = document.getElementById("modelCombo");
+ const modelButton = document.getElementById("modelButton");
+ const modelMenu = document.getElementById("modelMenu");
+ const output = document.getElementById("output");
+ const text = document.getElementById("text");
+ const mark = document.getElementById("mark");
+ const copy = document.getElementById("copy");
+ const collapse = document.getElementById("collapse");
+ const memoryToggle = document.getElementById("memoryToggle");
+ const memoryPanel = document.getElementById("memory");
+ const memoryList = document.getElementById("memoryList");
+ const memoryInput = document.getElementById("memoryInput");
+ const saveMemory = document.getElementById("saveMemory");
+ const refreshMemory = document.getElementById("refreshMemory");
+
+ let currentText = text.textContent;
+ const projectDropdown = { input: projectSelect, root: projectCombo, button: projectButton, menu: projectMenu };
+ const modelDropdown = { input: modelSelect, root: modelCombo, button: modelButton, menu: modelMenu };
+
+ function setupDropdown(dropdown) {
+ dropdown.button.addEventListener("click", () => {
+ const willOpen = !dropdown.root.classList.contains("open");
+ closeDropdowns();
+ dropdown.root.classList.toggle("open", willOpen);
+ });
+ }
+
+ function closeDropdowns() {
+ projectCombo.classList.remove("open");
+ modelCombo.classList.remove("open");
+ }
+
+ function setDropdownOptions(dropdown, items, preferredValue) {
+ dropdown.menu.innerHTML = "";
+ const selected = items.find((item) => item.value === preferredValue) || items[0];
+ for (const item of items) {
+ const option = document.createElement("div");
+ option.className = `combo-option${item.value === selected.value ? " selected" : ""}`;
+ option.textContent = item.label;
+ option.title = item.title || item.label;
+ option.dataset.value = item.value;
+ option.addEventListener("click", () => {
+ setDropdownValue(dropdown, item);
+ closeDropdowns();
+ });
+ dropdown.menu.appendChild(option);
+ }
+ setDropdownValue(dropdown, selected, false);
+ }
+
+ function setDropdownValue(dropdown, item, notify = true) {
+ dropdown.input.value = item.value;
+ dropdown.button.textContent = item.label;
+ dropdown.button.title = item.title || item.label;
+ for (const option of dropdown.menu.children) {
+ option.classList.toggle("selected", option.dataset.value === item.value);
+ }
+ if (notify) {
+ dropdown.input.dispatchEvent(new Event("change"));
+ }
+ }
+
+ function setBusy(busy) {
+ mark.classList.toggle("busy", busy);
+ }
+
+ function openOutput() {
+ output.classList.add("open");
+ }
+
+ function submitPrompt() {
+ const content = promptInput.value.trim();
+ if (!content) return;
+
+ currentText = "";
+ text.className = "";
+ text.textContent = "";
+ openOutput();
+ setBusy(true);
+
+ setTimeout(() => {
+ currentText = `Preview only\n\nProject: ${projectButton.textContent}\nModel: ${modelButton.textContent}\nPrompt: ${content}\n\nThis static demo mimics the result panel so the visual style can be edited without running Moli.Desktop.`;
+ text.textContent = currentText;
+ setBusy(false);
+ }, 380);
+ }
+
+ function renderMemories() {
+ memoryList.innerHTML = "";
+ if (!demoMemories.length) {
+ memoryList.textContent = "No memory";
+ return;
+ }
+
+ for (const item of demoMemories) {
+ const row = document.createElement("div");
+ row.className = "memory-row";
+ const content = document.createElement("div");
+ content.className = "memory-content";
+ content.textContent = item.content;
+ row.appendChild(content);
+ const remove = document.createElement("button");
+ remove.textContent = "x";
+ remove.title = "Delete memory";
+ remove.addEventListener("click", () => {
+ demoMemories = demoMemories.filter((memory) => memory.id !== item.id);
+ renderMemories();
+ });
+ row.appendChild(remove);
+ memoryList.appendChild(row);
+ }
+ }
+
+ promptInput.addEventListener("keydown", (event) => {
+ if (event.key === "Enter" && !event.shiftKey) {
+ event.preventDefault();
+ submitPrompt();
+ }
+
+ if (event.key === "Escape") {
+ output.classList.remove("open");
+ memoryPanel.classList.remove("open");
+ }
+ });
+
+ promptInput.addEventListener("input", () => {
+ promptInput.style.height = "0";
+ promptInput.style.height = `${Math.min(promptInput.scrollHeight, 78)}px`;
+ });
+
+ memoryToggle.addEventListener("click", () => {
+ memoryPanel.classList.toggle("open");
+ if (memoryPanel.classList.contains("open")) {
+ renderMemories();
+ }
+ });
+
+ refreshMemory.addEventListener("click", renderMemories);
+ saveMemory.addEventListener("click", () => {
+ const content = memoryInput.value.trim();
+ if (!content) return;
+ demoMemories.unshift({ id: `m${Date.now()}`, content });
+ memoryInput.value = "";
+ renderMemories();
+ });
+
+ collapse.addEventListener("click", () => output.classList.remove("open"));
+ copy.addEventListener("click", () => navigator.clipboard?.writeText(currentText).catch(() => {}));
+ document.addEventListener("click", (event) => {
+ if (!projectCombo.contains(event.target) && !modelCombo.contains(event.target)) {
+ closeDropdowns();
+ }
+ });
+
+ setupDropdown(projectDropdown);
+ setupDropdown(modelDropdown);
+ setDropdownOptions(projectDropdown, demoProjects, "desktop");
+ setDropdownOptions(modelDropdown, demoModels, "deepseek-v4-flash");
+ renderMemories();
+ </script>
+</body>
+</html>
--
Gitblit v1.9.1