26 lines
1.4 KiB
JavaScript
26 lines
1.4 KiB
JavaScript
import { defineComponent, ref, computed, mergeProps } from "vue";
|
|
import { ssrRenderAttrs, ssrInterpolate, ssrRenderClass } from "vue/server-renderer";
|
|
import { useI18n } from "vue-i18n";
|
|
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
__name: "LanguageSwitcher",
|
|
__ssrInlineRender: true,
|
|
setup(__props) {
|
|
const i18n = useI18n();
|
|
const dropdownOpen = ref(false);
|
|
const currentLocale = computed(() => i18n.locale.value);
|
|
return (_ctx, _push, _parent, _attrs) => {
|
|
_push(`<div${ssrRenderAttrs(mergeProps({ class: "relative" }, _attrs))}><button class="flex items-center text-white/85 hover:text-secondary transition-colors duration-300"><span class="mr-1">${ssrInterpolate(currentLocale.value === "zh" ? "EN" : "中")}</span><i class="fas fa-chevron-down text-xs"></i></button>`);
|
|
if (dropdownOpen.value) {
|
|
_push(`<div class="absolute right-0 mt-2 bg-white rounded-md shadow-lg py-1 min-w-[100px] z-50"><button class="${ssrRenderClass([{ "bg-gray-100": currentLocale.value === "zh" }, "block w-full text-left px-4 py-2 text-gray-800 hover:bg-gray-100"])}"> 中文 </button><button class="${ssrRenderClass([{ "bg-gray-100": currentLocale.value === "en" }, "block w-full text-left px-4 py-2 text-gray-800 hover:bg-gray-100"])}"> English </button></div>`);
|
|
} else {
|
|
_push(`<!---->`);
|
|
}
|
|
_push(`</div>`);
|
|
};
|
|
}
|
|
});
|
|
export {
|
|
_sfc_main as default
|
|
};
|
|
//# sourceMappingURL=LanguageSwitcher.vue2.mjs.map
|