SToggleLanguage.js 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. import { ref as r, onMounted as E, resolveComponent as T, openBlock as n, createElementBlock as l, normalizeClass as z, createBlock as s, withCtx as o, createElementVNode as w, toDisplayString as i, createVNode as u, Fragment as L, renderList as D, createTextVNode as _, createCommentVNode as N } from "vue";
  2. import { n as B, de as V, cG as $, cH as G, B as P } from "./index2.js";
  3. const b = "data:image/svg+xml,%3c?xml%20version='1.0'%20standalone='no'?%3e%3c!DOCTYPE%20svg%20PUBLIC%20'-//W3C//DTD%20SVG%201.1//EN'%20'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'%3e%3csvg%20t='1732167226097'%20class='icon'%20viewBox='0%200%201024%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20p-id='9067'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20width='200'%20height='200'%3e%3cpath%20d='M554.666667%20849.066667c-12.8%200-29.866667%204.266667-42.666667%204.266666-187.733333%200-341.333333-153.6-341.333333-341.333333%200-64%2017.066667-123.733333%2051.2-179.2l8.533333-12.8c25.6-42.666667%2059.733333-76.8%20102.4-102.4%2042.666667-25.6%2089.6-42.666667%20140.8-46.933333h38.4c187.733333%200%20341.333333%20153.6%20341.333333%20341.333333%200%2076.8-25.6%20145.066667-64%20200.533333l-4.266666%204.266667c-25.6%2034.133333-59.733333%2064-98.133334%2089.6-42.666667%2025.6-89.6%2038.4-132.266666%2042.666667zM507.733333%20768v-85.333333l-64-93.866667%20106.666667-106.666667%2064%2076.8h102.4l34.133333%2034.133334c8.533333-25.6%2012.8-51.2%2012.8-81.066667%200-140.8-115.2-256-256-256-12.8%200-25.6%200-38.4%204.266667l-29.866666%2029.866666L494.933333%20341.333333l17.066667%20115.2-85.333333%2085.333334-145.066667-140.8C264.533333%20435.2%20256%20469.333333%20256%20512c0%20140.8%20110.933333%20256%20251.733333%20256z'%20fill='%23444444'%20p-id='9068'%3e%3c/path%3e%3c/svg%3e", S = "data:image/svg+xml,%3c?xml%20version='1.0'%20standalone='no'?%3e%3c!DOCTYPE%20svg%20PUBLIC%20'-//W3C//DTD%20SVG%201.1//EN'%20'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'%3e%3csvg%20t='1732167226097'%20class='icon'%20viewBox='0%200%201024%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20p-id='9067'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20width='200'%20height='200'%3e%3cpath%20d='M554.666667%20849.066667c-12.8%200-29.866667%204.266667-42.666667%204.266666-187.733333%200-341.333333-153.6-341.333333-341.333333%200-64%2017.066667-123.733333%2051.2-179.2l8.533333-12.8c25.6-42.666667%2059.733333-76.8%20102.4-102.4%2042.666667-25.6%2089.6-42.666667%20140.8-46.933333h38.4c187.733333%200%20341.333333%20153.6%20341.333333%20341.333333%200%2076.8-25.6%20145.066667-64%20200.533333l-4.266666%204.266667c-25.6%2034.133333-59.733333%2064-98.133334%2089.6-42.666667%2025.6-89.6%2038.4-132.266666%2042.666667zM507.733333%20768v-85.333333l-64-93.866667%20106.666667-106.666667%2064%2076.8h102.4l34.133333%2034.133334c8.533333-25.6%2012.8-51.2%2012.8-81.066667%200-140.8-115.2-256-256-256-12.8%200-25.6%200-38.4%204.266667l-29.866666%2029.866666L494.933333%20341.333333l17.066667%20115.2-85.333333%2085.333334-145.066667-140.8C264.533333%20435.2%20256%20469.333333%20256%20512c0%20140.8%20110.933333%20256%20251.733333%20256z'%20fill='%231677FF'%20p-id='9068'%3e%3c/path%3e%3c/svg%3e", A = { class: "locale-select" }, O = { class: "label" }, I = {
  4. key: 0,
  5. src: b,
  6. class: "icon"
  7. }, M = {
  8. key: 1,
  9. src: S,
  10. class: "icon"
  11. }, F = /* @__PURE__ */ Object.assign({ name: "SToggleLanguage" }, {
  12. __name: "SToggleLanguage",
  13. props: {
  14. // 展示形态:button 按钮 / dropdown 下拉 / 其它为块状
  15. blockType: {
  16. type: String,
  17. default: "button"
  18. }
  19. },
  20. setup(g) {
  21. const t = r(""), a = r(!1), p = [
  22. {
  23. key: "zh",
  24. name: window.$l("中文")
  25. },
  26. {
  27. key: "en",
  28. name: "English"
  29. }
  30. ];
  31. function h(e) {
  32. a.value = e;
  33. }
  34. function v(e) {
  35. t.value = e.key, window.$utils.ls.set("lang", e.key), window.location.reload();
  36. }
  37. function m() {
  38. t.value === "zh" ? (t.value = "en", window.$utils.ls.set("lang", "en")) : (t.value = "zh", window.$utils.ls.set("lang", "zh")), window.location.reload();
  39. }
  40. function k() {
  41. const e = window.$utils.ls.get("lang");
  42. (!e || e === "undefined") && window.$utils.ls.set("lang", window.$utils.env.VITE_APP_LANG), t.value = window.$utils.env.VITE_APP_LANG_ENABLE ? window.$utils.ls.get("lang") : "zh";
  43. }
  44. return E(() => {
  45. k();
  46. }), (e, U) => {
  47. const d = T("s-icon"), f = G, x = $, y = V, C = P;
  48. return e.$utils.env.VITE_APP_LANG_ENABLE ? (n(), l("div", {
  49. key: 0,
  50. class: z(["s-toggle-language", g.blockType === "button" ? "flex-right" : ""])
  51. }, [
  52. g.blockType === "dropdown" ? (n(), s(y, {
  53. key: 0,
  54. trigger: ["click"],
  55. onOpenChange: h
  56. }, {
  57. overlay: o(() => [
  58. u(x, null, {
  59. default: o(() => [
  60. (n(), l(L, null, D(p, (c) => u(f, {
  61. key: c.key,
  62. onClick: (W) => v(c)
  63. }, {
  64. default: o(() => [
  65. _(i(c.name), 1)
  66. ]),
  67. _: 2
  68. }, 1032, ["onClick"])), 64))
  69. ]),
  70. _: 1
  71. })
  72. ]),
  73. default: o(() => [
  74. w("div", A, [
  75. w("div", O, i(t.value === "zh" ? "中文" : "English"), 1),
  76. a.value ? (n(), l("img", M)) : (n(), l("img", I)),
  77. a.value ? (n(), s(d, {
  78. key: 3,
  79. name: "CaretUpOutlined",
  80. class: "s-theme-color",
  81. style: { "font-size": "12px" }
  82. })) : (n(), s(d, {
  83. key: 2,
  84. name: "CaretDownOutlined",
  85. style: { color: "var(--s-text-color)", "font-size": "12px" }
  86. }))
  87. ])
  88. ]),
  89. _: 1
  90. })) : (n(), s(C, {
  91. key: 1,
  92. class: "custom-btn",
  93. onClick: m
  94. }, {
  95. default: o(() => [
  96. _(i(t.value === "zh" ? "中" : "EN"), 1)
  97. ]),
  98. _: 1
  99. }))
  100. ], 2)) : N("", !0);
  101. };
  102. }
  103. }), H = /* @__PURE__ */ B(F, [["__scopeId", "data-v-8e47e553"]]);
  104. export {
  105. H as default
  106. };