Files
srdb/webui/static/js/components/field-icon.js
bourdon 4aade1cff1 前端:重构 Web UI 代码结构
- 添加 Import Map 支持 Lit 和本地模块的简洁导入
- 创建统一的 API 管理模块 (common/api.js)
- 重命名 styles/ 为 common/ 目录
- 修复分页时列选择被重置的问题
- 将 app.js 重命名为 main.js
- 所有导入路径使用 ~ 别名映射
2025-10-09 19:30:20 +08:00

59 lines
1.3 KiB
JavaScript

import { LitElement, html, css } from 'lit';
export class FieldIcon extends LitElement {
static properties = {
indexed: { type: Boolean }
};
static styles = css`
:host {
display: inline-flex;
align-items: center;
justify-content: center;
width: 20px;
height: 20px;
}
svg {
width: 16px;
height: 16px;
}
.indexed {
fill: var(--success);
color: var(--success);
opacity: 1;
}
.not-indexed {
fill: var(--text-secondary);
color: var(--text-secondary);
opacity: 0.6;
}
`;
constructor() {
super();
this.indexed = false;
}
render() {
if (this.indexed) {
// 闪电图标 - 已索引(快速)
return html`
<svg viewBox="0 0 24 24" class="indexed" xmlns="http://www.w3.org/2000/svg" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<polygon points="13 2 3 14 12 14 11 22 21 10 12 10 13 2" fill="currentColor" stroke="none"/>
</svg>
`;
} else {
// 圆点图标 - 未索引
return html`
<svg viewBox="0 0 24 24" class="not-indexed" xmlns="http://www.w3.org/2000/svg">
<circle cx="12" cy="12" r="4" fill="currentColor"/>
</svg>
`;
}
}
}
customElements.define('srdb-field-icon', FieldIcon);