|
30 | 30 | </template> |
31 | 31 |
|
32 | 32 | <script lang="ts"> |
33 | | - import { computed, defineComponent, ExtractPropTypes, PropType, reactive, ref } from "vue"; |
| 33 | + import { |
| 34 | + computed, |
| 35 | + defineComponent, |
| 36 | + ExtractPropTypes, |
| 37 | + PropType, |
| 38 | + provide, |
| 39 | + reactive, |
| 40 | + ref, |
| 41 | + } from "vue"; |
34 | 42 | import FkColorPicker from "./fk/FkColorPicker.vue"; |
35 | 43 | import ChromeColorPicker from "./chrome/ChromeColorPicker.vue"; |
36 | 44 | import GradientColorPicker from "./gradient/GradientColorPicker.vue"; |
|
41 | 49 | import { onClickOutside, tryOnMounted, whenever } from "@vueuse/core"; |
42 | 50 | import { createPopper } from "@popperjs/core"; |
43 | 51 | import { GradientNode, parse, stringify } from "gradient-parser"; |
| 52 | + import { ColorPickerProvider, ColorPickerProviderKey, SupportLang } from "./utils/type"; |
44 | 53 |
|
45 | 54 | const colorPickerProps = { |
46 | 55 | isWidget: propTypes.bool.def(false), |
|
60 | 69 | roundHistory: propTypes.bool.def(false), |
61 | 70 | useType: propTypes.oneOf(["single", "gradient", "both"]).def("single"), |
62 | 71 | activeKey: propTypes.oneOf(["single", "gradient"]).def("single"), |
| 72 | + lang: { |
| 73 | + type: String as PropType<SupportLang>, |
| 74 | + default: "ZH-cn", |
| 75 | + }, |
63 | 76 | }; |
64 | 77 |
|
65 | 78 | export type ColorPickerProps = Partial<ExtractPropTypes<typeof colorPickerProps>>; |
|
84 | 97 | isAdvanceMode: false, |
85 | 98 | }); |
86 | 99 |
|
| 100 | + provide<ColorPickerProvider>(ColorPickerProviderKey, { |
| 101 | + lang: computed(() => props.lang || "ZH-cn"), |
| 102 | + }); |
| 103 | +
|
87 | 104 | const instance = new Color(state.pureColor); |
88 | 105 | const colorInstance = ref(instance); |
89 | 106 |
|
|
0 commit comments