config Unstable
introduction:
Configuration plug-in can be used to set the current language of Dweb App
, or to switch the entrance.
This plug-in works with defaultConfig.lang
in plaoc.json
to switch the entire basic file routing.
Reference
Method
setLang
Switching current language (entry)
Assuming you have two language entry points, after configuring in plaoc.json
, you can switch between them.
ts
import { configPlugin } from "@plaoc/plugins";
await configPlugin.setLang("en", true);
// my-app
// ├── en
// └── zh
getLang
Retrieving current language (entry)
ts
import { configPlugin } from "@plaoc/plugins";
await configPlugin.getLang();
Plugin Usage
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>
WebComponent Usage
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>