主题开发
从工作室示例制作 ObliviousMic WebUI 主题并安装试用。
ObliviousMic WebUI 的主题由 ZIP 中的 CSS、配置声明和静态素材组成。可从本体的 examples/themes/studio 复制示例,先修改强调色,确认能安装,再调整侧栏、字号和其他布局。
-
在本体源码根目录打开 PowerShell。复制主题到新目录,并给它分配独有 ID。
obmic-前缀由内置主题使用。终端窗口 $omThemeSource = (Resolve-Path -LiteralPath '.\examples\themes\studio').Path$omThemeWork = Join-Path $env:LOCALAPPDATA 'ObliviousMicExamples\studio-1.0.0'if (Test-Path -LiteralPath $omThemeWork) { throw '示例目录已存在,请换一个目录名。' }$omThemeDir = Join-Path $omThemeWork 'package'New-Item -ItemType Directory -Path $omThemeDir | Out-Null$omThemeFiles = 'obliviousmic.theme.json', 'style.css', 'settings.json', 'LICENSE'foreach ($omName in $omThemeFiles) {Copy-Item -LiteralPath (Join-Path $omThemeSource $omName) -Destination $omThemeDir}$omThemeManifestPath = Join-Path $omThemeDir 'obliviousmic.theme.json'$omThemeManifest = Get-Content -LiteralPath $omThemeManifestPath -Encoding UTF8 -Raw | ConvertFrom-Json$omThemeManifest.id = 'my-studio-theme'$omThemeManifest.name = 'My Studio'$omThemeManifest.author = 'Your name'$omThemeManifest.display_names.'zh-CN' = '我的工作室'$omThemeManifest.display_names.en = 'My Studio'$omThemeJson = $omThemeManifest | ConvertTo-Json -Depth 30[IO.File]::WriteAllText($omThemeManifestPath, $omThemeJson, [Text.UTF8Encoding]::new($false))Get-Item -LiteralPath (Join-Path $omThemeDir 'style.css') -
用文本编辑器打开命令输出的
style.css,在末尾追加下面的颜色并保存为 UTF-8。已有主题变量包括--om-background、--om-foreground、--om-sidebar、--om-surface和--om-border。控制页面布局时优先用[data-ui="sidebar"]、[data-ui="graph-canvas"]等已有属性。图片或字体使用与声明相符的本地assets/文件。:root {--om-accent: #5753a8;--om-accent-hover: #443f96;--om-on-accent: #ffffff;} -
描述可编辑选项时,用 manifest 的
settings指向settings.json。示例给出了groups和字段,每个字段用variable写到指定--om-*变量,可用颜色、数值、选项、开关、图片或文本。新增字段先给自定义变量一个合理默认值,再让 CSS 使用它。清单还包括theme_api: 1、主题 ID、版本、兼容范围、样式文件、亮暗模式和许可。 -
压缩文件到 ZIP 根目录。若加了
assets/,也把该目录一起打进去。将生成的 ZIP 拿到「设置与支持」,点「安装主题包」,选择自己的主题。回到「处理图」检查节点和连线,回到「设置与支持」改一项外观,点「预览修改」「保存外观」,刷新页面确认已保存。终端窗口 $omThemeZip = Join-Path $omThemeWork 'my-studio-theme-1.0.0.zip'$omThemePaths = $omThemeFiles | ForEach-Object { Join-Path $omThemeDir $_ }Compress-Archive -LiteralPath $omThemePaths -DestinationPath $omThemeZipGet-Item -LiteralPath $omThemeZip
如果准备让别人搜索,按分发声明步骤发布主题 ZIP。Topic 使用 obliviousmic-theme,外部文件用 obliviousmic.theme.json,包内仓库、版本和分发信息按实际主题附件填写。用户在「设置与支持 → 安装新主题」搜索。详细字段和素材约束可查本体源码的 docs/spec/WEBUI_THEMES_V1.md 与 src/obliviousmic/schemas/obliviousmic-theme-v1.json。