feat(models): show Civitai model/version ids in model modal, always-on hash/id search

- Model modal hash footnote now shows Civitai model id and version id
  (right-aligned, quick-copy buttons); hidden for non-Civitai models
- Hash/id exact search (sha256/autov2/autov3/civitai ids) is now always
  on: the search-options "hash" toggle is removed and the search_hash
  query param is silently ignored for API compatibility
- Footnote render condition relaxed so autov3-only and id-only models
  still show the line
- i18n: 4 new keys translated in all 9 locales; filters.hash key removed
This commit is contained in:
Will Miao
2026-10-03 09:46:46 +08:00
parent 515469054c
commit f8aba393fe
22 changed files with 254 additions and 167 deletions
-1
View File
@@ -387,7 +387,6 @@ class ModelListingHandler:
== "true",
"tags": request.query.get("search_tags", "false").lower() == "true",
"creator": request.query.get("search_creator", "false").lower() == "true",
"hash": request.query.get("search_hash", "false").lower() == "true",
"recursive": request.query.get("recursive", "true").lower() == "true",
}
+20 -8
View File
@@ -432,7 +432,6 @@ class SearchStrategy:
"tags": False,
"recursive": True,
"creator": False,
"hash": False,
}
def __init__(
@@ -495,13 +494,14 @@ class SearchStrategy:
results.append(item)
continue
# Hash search is always exact (never fuzzy): match the full
# sha256, its autov2 prefix (first 10 chars), or the autov3 hash.
if options.get("hash", False):
hash_query = search_lower.strip()
if hash_query and self._matches_hash(item, hash_query):
results.append(item)
continue
# Hash/id search is always exact (never fuzzy) and always on: it
# matches the full sha256, its autov2 prefix (first 10 chars),
# the autov3 hash, or the Civitai model/version ids. Exact-match
# semantics mean it adds no noise to ordinary keyword searches.
hash_query = search_lower.strip()
if hash_query and self._matches_hash(item, hash_query):
results.append(item)
continue
return results
@@ -515,6 +515,18 @@ class SearchStrategy:
autov3 = item.get("autov3")
if isinstance(autov3, str) and autov3 and hash_query == autov3.lower():
return True
civitai = item.get("civitai")
if isinstance(civitai, dict):
# A model card corresponds to one Civitai version: `modelId` is
# the model id (may match several cards when the library holds
# multiple versions), `id` is the version id (unique per card).
for key in ("modelId", "model_id", "id"):
value = civitai.get(key)
if value is None:
continue
value_str = str(value).strip()
if value_str and value_str != "0" and hash_query == value_str:
return True
return False
def _matches(