Data Dictionary
The Data Dictionary module provides centralized, localized lookup data for dropdowns, tags, and labels across the platform. Dictionaries are JSON files loaded at runtime and exposed to both backend and frontend.
Interface Screenshot

Captured from the live Smart Site system with the English UI. See the
zh-CNcounterpart for the Chinese-UI screenshot.
1. Dictionary Categories
Dictionaries live under ss-run/ss/data/dicts/{lang}/ in three categories:
| Category | Purpose | Examples |
|---|---|---|
basic-data |
Foundational lookup values | device-types, protocol-types, byte-order, measurement-units, tag-data-types, time-units, collection-priority, industry |
business-config |
Operational configuration enums | conversion-types, deadband-modes, template-status, variable-categories |
system-enums |
System state enums | alarm-status, data-quality, quality-status |
Each file is a JSON array of { label, value, ... } entries. The DictLoaderService scans the directory on startup and indexes them by code.
2. Dictionary CRUD
- Dictionaries are primarily file-based for version control
- The
DictControllerexposes read endpoints for the frontend:GET /api/v1/dict/:category/:code— fetch one dictionaryGET /api/v1/dict/:category— fetch all dictionaries in a category
- Some dictionaries can be extended at runtime via the API; changes are written back to the JSON file
3. Frontend Components
Three reusable Vue components render dictionary data:
3.1 DictSelector
A dropdown that populates from a dictionary:
<DictSelector dict-key="basic-data/protocol-types" v-model="protocol" />
Supports filtering, lazy loading, and automatic label resolution.
3.2 DictLabel
Renders the human-readable label for a stored value:
<DictLabel dict-key="basic-data/device-types" :value="device.type" />
Useful in tables where you store the code but want to show the label.
3.3 DictTag
Renders a colored tag/pill based on the dictionary entry's color or level:
<DictTag dict-key="system-enums/alarm-status" :value="alarm.status" />
4. useDict Composable
For non-template access, use the useDict composable:
const { loadDict, getLabel, getOptions } = useDict()
// Load once, cached thereafter
await loadDict('basic-data/protocol-types')
// Resolve a label
const label = getLabel('basic-data/protocol-types', 'modbus')
// Get all options for a select
const options = getOptions('basic-data/protocol-types')
The composable caches loaded dictionaries in a Pinia store, so repeated calls do not refetch.
5. Localization
Each dictionary exists in both en-US and zh-CN folders with the same value codes but translated label strings. The DictLoaderService picks the folder based on the request's Accept-Language header or the user's language preference.
Example (en-US/basic-data/protocol-types.json):
[
{ "label": "Modbus TCP/RTU", "value": "modbus" },
{ "label": "OPC UA", "value": "opcua" }
]
Example (zh-CN/basic-data/protocol-types.json):
[
{ "label": "Modbus TCP/RTU", "value": "modbus" },
{ "label": "OPC UA", "value": "opcua" }
]
6. Operational Guidance
6.1 Adding a New Dictionary Entry
- Stop the backend (or rely on the file watcher if enabled)
- Edit the JSON file in both
en-US/andzh-CN/folders - Add
{ "label": "...", "value": "..." }to the array - Restart — the
DictLoaderServicereloads on startup
6.2 Adding a New Dictionary
- Create the JSON file under the appropriate category folder in both languages
- Reference it by
category/code(e.g.basic-data/my-new-dict) - Use
<DictSelector dict-key="basic-data/my-new-dict" />in the frontend
7. FAQ
Q: The dropdown shows raw codes instead of labels.
A: The dict-key prop may be wrong, or the dictionary failed to load. Check the network panel for the /api/v1/dict/... call and verify the file exists under both language folders.
Q: Can I override a dictionary at runtime? A: Yes, through the DictController write endpoints (if enabled). The change is persisted to the JSON file and broadcast to other instances via the EventBus.
Q: Dictionary labels are not translated.
A: Confirm the entry exists in the current language folder. The DictLoaderService falls back to the value code if no label is found, which is what you are seeing.
Q: How do I reference a dictionary in a script? A: Scripts do not have direct dictionary access. Pass the needed labels as script parameters, or expose them through a custom ScriptAPI extension.
8. Related Links
../../15-i18n/README.md../../04-template/README.md../../08-protocol/README.md- Dictionaries Directory