补充组件描述, 起草 lay-config-provider 全局配置

This commit is contained in:
就眠儀式
2022-02-08 11:36:36 +08:00
parent dc03f2a65b
commit 3787e80ff0
12 changed files with 135 additions and 83 deletions

View File

@@ -8,7 +8,7 @@ export default {
import "./index.less";
const props = defineProps<{
nm?: boolean;
nm?: boolean | string;
}>();
</script>

View File

@@ -5,4 +5,4 @@ Component.install = (app: App) => {
app.component(Component.name, Component);
};
export default Component;
export default Component;

View File

@@ -1,19 +1,44 @@
<script lang="ts">
import { watch } from '@vue/runtime-core';
export default {
name: "lay-config-provider"
}
name: "lay-config-provider",
};
</script>
<script setup lang="ts">
// 切换主题 (通过 less 特性提供的 api 更改变量)
export interface LayConfigProviderProps {
theme?: object;
}
// 切换语言 (通过 i18n 框架切换内置的语言包)
const props = withDefaults(defineProps<LayConfigProviderProps>(),
{
}
);
const changeTheme = (vars: any) => {
// @ts-ignore
if (!window.less || !window.less.modifyVars) {
return;
}
// @ts-ignore
window.less.modifyVars(vars).then((res) => {
console.log(res);
}).catch((res: any) => {
console.log(res);
});
};
watch(() => props.theme, (vars) => {
changeTheme(vars);
},{immediate: true})
</script>
<template>
<div class="lay-config-provider">
<slot></slot>
</div>
<div class="lay-config-provider">
<slot></slot>
</div>
</template>