config Unstable
Introduction:
Configuration plugin, can be used to set the current language of Dweb App
, or to switch entry points.
This plugin works with defaultConfig.lang
in plaoc.json
to switch the entire basic file routing.
Reference
Method
setLang
Switch current language (entry)
Assuming you have two language entries, you can switch the entry after configuring in plaoc.json
.
ts
import { configPlugin } from "@plaoc/plugins";
await configPlugin.setLang("en", true);
// my-app
// ├── en
// └── zh
getLang
Get current language (entry)
ts
import { configPlugin } from "@plaoc/plugins";
await configPlugin.getLang();
Usage Plugins
vue
<script setup lang="ts">
import { configPlugin } from "@plaoc/plugins";
async function setLang() {
await configPlugin.setLang("en", true);
}
async function getLang() {
const res = await configPlugin.getLang();
}
</script>
Usage WebComponent
vue
<script setup lang="ts">
import { onMounted, ref } from "vue";
import { HTMLDwebConfigElement } from "@plaoc/plugins";
const $configPlugin = ref<HTMLDwebConfigElement>();
let config: HTMLDwebConfigElement;
onMounted(async () => {
config = $configPlugin.value!;
});
async function setLang() {
await config.setLang("en", true);
}
async function getLang() {
const res = await config.getLang();
}
</script>
<template>
<dweb-config ref="$configPlugin"></dweb-config>
</template>