mirror of
https://github.com/jasonxu114514/opencode2api.git
synced 2026-12-05 08:02:53 +00:00
feat(webui): show flag-only language selector aligned with toolbar
This commit is contained in:
1 parent
6833a5d7a8
commit
86ea7dae74
2 files changed
+11
-3
No files matched your search
+4
-2
@@ -13,6 +13,7 @@
|
||||
window.O2I18N = (() => {
|
||||
const STORAGE_KEY = "opencode2api.ui.lang";
|
||||
const DEFAULT_LOCALE = "zh-CN";
|
||||
const FLAGS = { "zh-CN": "🇨🇳", en: "🇺🇸", vi: "🇻🇳" };
|
||||
const SUPPORTED = ["zh-CN", "en", "vi"];
|
||||
const LABELS = { "zh-CN": "简体中文", en: "English", vi: "Tiếng Việt" };
|
||||
const DATE_LOCALES = { "zh-CN": "zh-CN", en: "en-US", vi: "vi-VN" };
|
||||
@@ -1097,7 +1098,7 @@ window.O2I18N = (() => {
|
||||
const syncSelectors = () => {
|
||||
document.querySelectorAll("[data-lang-switch]").forEach((node) => {
|
||||
node.value = locale;
|
||||
node.setAttribute("aria-label", t("语言", "lang.label"));
|
||||
node.setAttribute("aria-label", LABELS[locale] || t("语言", "lang.label"));
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1135,7 +1136,8 @@ window.O2I18N = (() => {
|
||||
...SUPPORTED.map((code) => {
|
||||
const option = document.createElement("option");
|
||||
option.value = code;
|
||||
option.textContent = LABELS[code];
|
||||
option.textContent = FLAGS[code];
|
||||
option.setAttribute('aria-label', LABELS[code]);
|
||||
return option;
|
||||
}),
|
||||
);
|
||||
|
||||
+7
-1
@@ -315,8 +315,14 @@ pre,
|
||||
max-width: 680px;
|
||||
}
|
||||
.lang-switch {
|
||||
padding: 8px 10px;
|
||||
width: auto;
|
||||
min-width: 34px;
|
||||
height: 38px;
|
||||
padding: 0 4px;
|
||||
border: 1px solid var(--ink);
|
||||
font-size: 18px;
|
||||
line-height: 1;
|
||||
text-align: center;
|
||||
background: transparent;
|
||||
color: var(--ink);
|
||||
font-weight: 700;
|
||||
|
||||
Reference in new issue
Block a user