cosey 0.10.1 → 0.10.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -1
- package/config/i18n.d.ts +16 -0
- package/config/i18n.js +6 -0
- package/config/index.d.ts +24 -7
- package/config/index.js +16 -9
- package/config/root-config-provider.js +9 -6
- package/index.d.ts +1 -0
- package/index.js +2 -0
- package/layout/index.js +1 -0
- package/layout/layout-auth/layout-auth.vue.js +3 -2
- package/layout/layout-base/layout-base.vue.js +18 -17
- package/layout/layout-locale/index.d.ts +1 -0
- package/layout/layout-locale/index.js +1 -0
- package/layout/layout-locale/layout-locale.vue.d.ts +2 -0
- package/layout/layout-locale/layout-locale.vue.js +73 -0
- package/layout/merged/index.d.ts +1 -0
- package/layout/merged/index.js +1 -0
- package/layout/merged/layout-locale.d.ts +4 -0
- package/layout/merged/layout-locale.js +6 -0
- package/locale/index.d.ts +13 -2
- package/locale/index.js +61 -2
- package/package.json +3 -3
package/README.md
CHANGED
package/config/i18n.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { DeepPartial } from '../types/helper';
|
|
2
|
+
/**
|
|
3
|
+
* 国际化相关配置
|
|
4
|
+
*/
|
|
5
|
+
export declare const defaultI18nConfig: {
|
|
6
|
+
locale: string;
|
|
7
|
+
messages: {
|
|
8
|
+
value: string;
|
|
9
|
+
label: string;
|
|
10
|
+
dayjs: Record<string, any>;
|
|
11
|
+
cosey: Record<string, any>;
|
|
12
|
+
app: Record<string, any>;
|
|
13
|
+
}[];
|
|
14
|
+
};
|
|
15
|
+
export type I18nConfig = DeepPartial<typeof defaultI18nConfig>;
|
|
16
|
+
export type RequiredI18nConfig = typeof defaultI18nConfig;
|
package/config/i18n.js
ADDED
package/config/index.d.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
import { type
|
|
1
|
+
import { type App, type Component, type VNodeChild } from 'vue';
|
|
2
|
+
import { type RouterConfig, type RequiredRouterConfig } from './router';
|
|
3
3
|
import { type LayoutConfig, type RequiredLayoutConfig } from './layout';
|
|
4
4
|
import { type SiteConfig, type RequiredSiteConfig } from './site';
|
|
5
|
-
import { type
|
|
6
|
-
import { type
|
|
7
|
-
import { type
|
|
8
|
-
import {
|
|
5
|
+
import { type HttpConfig, type RequiredHttpConfig } from './http';
|
|
6
|
+
import { type ApiConfig, type RequiredApiConfig } from './api';
|
|
7
|
+
import { type PersistConfig } from './persist';
|
|
8
|
+
import { I18nConfig } from './i18n';
|
|
9
9
|
import { type RouteRecordRaw } from 'vue-router';
|
|
10
|
+
import { type CoseyRouterOptions } from '../router';
|
|
10
11
|
export interface LayoutComponents {
|
|
11
12
|
base?: string | Component;
|
|
12
13
|
sidebar?: string | Component;
|
|
@@ -63,6 +64,7 @@ export type CoseyOptions = {
|
|
|
63
64
|
} | DefineAuthorityHandler;
|
|
64
65
|
components?: LayoutComponents;
|
|
65
66
|
slots?: LayoutSlots;
|
|
67
|
+
i18n?: I18nConfig;
|
|
66
68
|
};
|
|
67
69
|
export interface GlobalConfig {
|
|
68
70
|
router: RequiredRouterConfig;
|
|
@@ -75,6 +77,21 @@ export interface GlobalConfig {
|
|
|
75
77
|
components: NonNullable<CoseyOptions['components']>;
|
|
76
78
|
slots: NonNullable<CoseyOptions['slots']>;
|
|
77
79
|
}
|
|
78
|
-
export declare function provideGlobalConfig(app: App, options: CoseyOptions):
|
|
80
|
+
export declare function provideGlobalConfig(app: App, options: CoseyOptions): {
|
|
81
|
+
router: any;
|
|
82
|
+
http: any;
|
|
83
|
+
layout: any;
|
|
84
|
+
site: any;
|
|
85
|
+
api: any;
|
|
86
|
+
filterRoute: FilterRouteHandler | {
|
|
87
|
+
hook: () => FilterRouteHandler;
|
|
88
|
+
};
|
|
89
|
+
defineAuthority: DefineAuthorityHandler | {
|
|
90
|
+
hook: () => DefineAuthorityHandler;
|
|
91
|
+
};
|
|
92
|
+
components: LayoutComponents;
|
|
93
|
+
slots: LayoutSlots;
|
|
94
|
+
persist: import("@gunny/persist").default;
|
|
95
|
+
};
|
|
79
96
|
export declare function useGlobalConfig(): GlobalConfig;
|
|
80
97
|
export {};
|
package/config/index.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
|
+
import { inject } from 'vue';
|
|
2
|
+
import { defaultsDeep } from 'lodash-es';
|
|
1
3
|
import { defaultRouterConfig } from './router.js';
|
|
2
|
-
import { defaultPersistConfig } from './persist.js';
|
|
3
4
|
import { defaultLayoutConfig } from './layout.js';
|
|
4
5
|
import { defaultSiteConfig } from './site.js';
|
|
5
6
|
import { defaultHttpConfig } from './http.js';
|
|
6
7
|
import { defaultApiConfig } from './api.js';
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
8
|
+
import { defaultPersistConfig } from './persist.js';
|
|
9
|
+
import { setupLocale } from '../locale/index.js';
|
|
10
|
+
import { createPersist, persistContextKey } from '../hooks/usePersist.js';
|
|
10
11
|
|
|
11
12
|
const globalConfigContextKey = Symbol("globalConfigContext");
|
|
12
13
|
function provideGlobalConfig(app, options) {
|
|
@@ -20,11 +21,14 @@ function provideGlobalConfig(app, options) {
|
|
|
20
21
|
filterRoute = () => true,
|
|
21
22
|
defineAuthority = () => void 0,
|
|
22
23
|
components = {},
|
|
23
|
-
slots = {}
|
|
24
|
+
slots = {},
|
|
25
|
+
i18n = {}
|
|
24
26
|
} = options;
|
|
25
27
|
const persistConfig = defaultsDeep(persist, defaultPersistConfig);
|
|
26
|
-
|
|
27
|
-
app
|
|
28
|
+
const persistIns = createPersist(persistConfig.name, persistConfig.type);
|
|
29
|
+
setupLocale(app, i18n, persistIns);
|
|
30
|
+
app.provide(persistContextKey, persistIns);
|
|
31
|
+
const globalConfig = {
|
|
28
32
|
router: defaultsDeep({ homePath, loginPath, changePasswordPath }, defaultRouterConfig),
|
|
29
33
|
http: defaultsDeep(http, defaultHttpConfig),
|
|
30
34
|
layout: defaultsDeep(layout, defaultLayoutConfig),
|
|
@@ -33,8 +37,11 @@ function provideGlobalConfig(app, options) {
|
|
|
33
37
|
filterRoute,
|
|
34
38
|
defineAuthority,
|
|
35
39
|
components,
|
|
36
|
-
slots
|
|
37
|
-
|
|
40
|
+
slots,
|
|
41
|
+
persist: persistIns
|
|
42
|
+
};
|
|
43
|
+
app.provide(globalConfigContextKey, globalConfig);
|
|
44
|
+
return globalConfig;
|
|
38
45
|
}
|
|
39
46
|
function useGlobalConfig() {
|
|
40
47
|
return inject(globalConfigContextKey, {});
|
|
@@ -7,6 +7,7 @@ import 'element-plus/dist/index.css';
|
|
|
7
7
|
import 'element-plus/theme-chalk/dark/css-vars.css';
|
|
8
8
|
import { ElConfigProvider } from 'element-plus';
|
|
9
9
|
import { provideUploadConfig } from './upload.js';
|
|
10
|
+
import { useCoseyLocale } from '../locale/index.js';
|
|
10
11
|
import { useColorSchemeProvide } from '../hooks/useColorScheme.js';
|
|
11
12
|
import { containerContextKey } from '../components/container/container.api.js';
|
|
12
13
|
import { useStackDialogProvide } from '../components/stack-dialog/stack-dialog.api.js';
|
|
@@ -28,12 +29,7 @@ var stdin_default = defineComponent({
|
|
|
28
29
|
algorithm: props.theme?.algorithm || getAlgorithm([... /* @__PURE__ */new Set([appliedColorScheme.value])])
|
|
29
30
|
};
|
|
30
31
|
});
|
|
31
|
-
const
|
|
32
|
-
return {
|
|
33
|
-
...props,
|
|
34
|
-
theme: themeConfig.value
|
|
35
|
-
};
|
|
36
|
-
});
|
|
32
|
+
const coseyLocale = useCoseyLocale();
|
|
37
33
|
const apiConfig = useGlobalConfig()?.api;
|
|
38
34
|
if (apiConfig) {
|
|
39
35
|
const uploadApi = apiConfig.upload?.();
|
|
@@ -46,6 +42,13 @@ var stdin_default = defineComponent({
|
|
|
46
42
|
height: computed(() => `calc(100vh - ${layoutStore.headerHeight}px)`)
|
|
47
43
|
}));
|
|
48
44
|
useStackDialogProvide();
|
|
45
|
+
const mergedConfigProviderProps = computed(() => {
|
|
46
|
+
return {
|
|
47
|
+
...props,
|
|
48
|
+
locale: coseyLocale.value,
|
|
49
|
+
theme: themeConfig.value
|
|
50
|
+
};
|
|
51
|
+
});
|
|
49
52
|
return () => {
|
|
50
53
|
return createVNode(_ConfigProvider, mergedConfigProviderProps.value, {
|
|
51
54
|
default: () => [createVNode(ElConfigProvider, {
|
package/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { type CoseyOptions } from './config';
|
|
|
3
3
|
export * from './request';
|
|
4
4
|
export * from './layout';
|
|
5
5
|
export * from './router';
|
|
6
|
+
export { i18n } from './locale';
|
|
6
7
|
export { useUserStore, useAppearanceStore, useLayoutStore } from './store';
|
|
7
8
|
export * from './config';
|
|
8
9
|
export * from './config/root-config-provider.api';
|
package/index.js
CHANGED
|
@@ -5,6 +5,7 @@ import { provideGlobalConfig } from './config/index.js';
|
|
|
5
5
|
export { useGlobalConfig } from './config/index.js';
|
|
6
6
|
import { registerGlobalComponents } from './layout/index.js';
|
|
7
7
|
import { createPiniaStore } from './store/index.js';
|
|
8
|
+
export { i18n } from './locale/index.js';
|
|
8
9
|
export { getAlgorithm, rootConfigProviderProps } from './config/root-config-provider.api.js';
|
|
9
10
|
export { default as RootConfigProvider } from './config/root-config-provider.js';
|
|
10
11
|
export { useAppearanceStore } from './store/appearance.js';
|
|
@@ -56,6 +57,7 @@ export { default as MergedLayoutForbidden } from './layout/merged/layout-forbidd
|
|
|
56
57
|
export { default as MergedLayoutHeader } from './layout/merged/layout-header.js';
|
|
57
58
|
export { default as MergedLayoutIframe } from './layout/merged/layout-iframe.js';
|
|
58
59
|
export { default as MergedLayoutInternalServerError } from './layout/merged/layout-internal-server-error.js';
|
|
60
|
+
export { default as MergedLayoutLocale } from './layout/merged/layout-locale.js';
|
|
59
61
|
export { default as MergedLayoutLogin } from './layout/merged/layout-login.js';
|
|
60
62
|
export { default as MergedLayoutMain } from './layout/merged/layout-main.js';
|
|
61
63
|
export { default as MergedLayoutMask } from './layout/merged/layout-mask.js';
|
package/layout/index.js
CHANGED
|
@@ -43,6 +43,7 @@ export { default as MergedLayoutForbidden } from './merged/layout-forbidden.js';
|
|
|
43
43
|
export { default as MergedLayoutHeader } from './merged/layout-header.js';
|
|
44
44
|
export { default as MergedLayoutIframe } from './merged/layout-iframe.js';
|
|
45
45
|
export { default as MergedLayoutInternalServerError } from './merged/layout-internal-server-error.js';
|
|
46
|
+
export { default as MergedLayoutLocale } from './merged/layout-locale.js';
|
|
46
47
|
export { default as MergedLayoutLogin } from './merged/layout-login.js';
|
|
47
48
|
export { default as MergedLayoutMain } from './merged/layout-main.js';
|
|
48
49
|
export { default as MergedLayoutMask } from './merged/layout-mask.js';
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { defineComponent, resolveComponent, createElementBlock, openBlock, normalizeClass, unref, createElementVNode, createVNode, createBlock, resolveDynamicComponent } from 'vue';
|
|
2
|
-
import stdin_default$
|
|
2
|
+
import stdin_default$4 from '../merged/layout-color-scheme.js';
|
|
3
3
|
import stdin_default$2 from '../merged/layout-brand.js';
|
|
4
|
+
import stdin_default$3 from '../merged/layout-locale.js';
|
|
4
5
|
import stdin_default$1 from './style/index.js';
|
|
5
6
|
import { useGlobalConfig } from '../../config/index.js';
|
|
6
7
|
import { useComponentConfig } from '../../components/config-provider/config-provider.api.js';
|
|
@@ -35,7 +36,7 @@ var stdin_default = /* @__PURE__ */defineComponent({
|
|
|
35
36
|
}, [createVNode(unref(stdin_default$2))], 2
|
|
36
37
|
/* CLASS */), createElementVNode("div", {
|
|
37
38
|
class: normalizeClass(`${unref(prefixCls)}-widget`)
|
|
38
|
-
}, [(openBlock(), createBlock(resolveDynamicComponent(unref(AuthWidget)))), createVNode(unref(stdin_default$3))], 2
|
|
39
|
+
}, [(openBlock(), createBlock(resolveDynamicComponent(unref(AuthWidget)))), createVNode(unref(stdin_default$3)), createVNode(unref(stdin_default$4))], 2
|
|
39
40
|
/* CLASS */)], 2
|
|
40
41
|
/* CLASS */);
|
|
41
42
|
};
|
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
import { defineComponent, createElementBlock, openBlock, normalizeClass, unref, createBlock, createCommentVNode, createVNode, withCtx, resolveDynamicComponent } from 'vue';
|
|
2
2
|
import stdin_default$4 from '../merged/layout-aside.js';
|
|
3
|
-
import stdin_default$
|
|
4
|
-
import stdin_default$
|
|
3
|
+
import stdin_default$d from '../merged/layout-brand.js';
|
|
4
|
+
import stdin_default$f from '../merged/layout-breadcrumb.js';
|
|
5
5
|
import stdin_default$6 from '../merged/layout-content.js';
|
|
6
6
|
import stdin_default$7 from '../merged/layout-header.js';
|
|
7
|
-
import stdin_default$
|
|
7
|
+
import stdin_default$a from '../merged/layout-locale.js';
|
|
8
|
+
import stdin_default$j from '../merged/layout-main.js';
|
|
8
9
|
import stdin_default$5 from '../merged/layout-mask.js';
|
|
9
|
-
import stdin_default$
|
|
10
|
+
import stdin_default$h from '../merged/layout-menu.js';
|
|
10
11
|
import stdin_default$2 from '../merged/layout-sidebar.js';
|
|
11
12
|
import stdin_default$3 from '../merged/layout-snug-aside.js';
|
|
12
|
-
import stdin_default$
|
|
13
|
-
import stdin_default$
|
|
14
|
-
import stdin_default$
|
|
13
|
+
import stdin_default$i from '../merged/layout-tabbar.js';
|
|
14
|
+
import stdin_default$e from '../merged/layout-toggle.js';
|
|
15
|
+
import stdin_default$g from '../merged/layout-top-snug-menu.js';
|
|
15
16
|
import stdin_default$8 from '../merged/layout-topbar.js';
|
|
16
|
-
import stdin_default$
|
|
17
|
+
import stdin_default$b from '../merged/layout-color-scheme.js';
|
|
17
18
|
import stdin_default$9 from '../merged/layout-search.js';
|
|
18
|
-
import stdin_default$
|
|
19
|
+
import stdin_default$c from '../merged/layout-user-menu.js';
|
|
19
20
|
import stdin_default$1 from './style/index.js';
|
|
20
21
|
import { useLayoutStore } from '../../store/layout.js';
|
|
21
22
|
import { useGlobalConfig } from '../../config/index.js';
|
|
@@ -57,29 +58,29 @@ var stdin_default = /* @__PURE__ */defineComponent({
|
|
|
57
58
|
})) : createCommentVNode("v-if", true), createVNode(unref(stdin_default$6), null, {
|
|
58
59
|
default: withCtx(() => [createVNode(unref(stdin_default$7), null, {
|
|
59
60
|
default: withCtx(() => [createVNode(unref(stdin_default$8), null, {
|
|
60
|
-
left: withCtx(() => [!unref(layoutStore).isMobile && (unref(layoutStore).isHorizontal || unref(layoutStore).isHorizontalVertical || unref(layoutStore).isHorizontalBiserial) ? (openBlock(), createBlock(unref(stdin_default$
|
|
61
|
+
left: withCtx(() => [!unref(layoutStore).isMobile && (unref(layoutStore).isHorizontal || unref(layoutStore).isHorizontalVertical || unref(layoutStore).isHorizontalBiserial) ? (openBlock(), createBlock(unref(stdin_default$d), {
|
|
61
62
|
key: 0,
|
|
62
63
|
"is-horizontal": ""
|
|
63
|
-
})) : createCommentVNode("v-if", true), unref(layoutStore).isMobile || unref(layoutStore).isVertical || unref(layoutStore).isBiserial ? (openBlock(), createBlock(unref(stdin_default$
|
|
64
|
+
})) : createCommentVNode("v-if", true), unref(layoutStore).isMobile || unref(layoutStore).isVertical || unref(layoutStore).isBiserial ? (openBlock(), createBlock(unref(stdin_default$e), {
|
|
64
65
|
key: 1
|
|
65
|
-
})) : createCommentVNode("v-if", true), (openBlock(), createBlock(resolveDynamicComponent(unref(AfterToggle)))), !unref(layoutStore).isMobile && (unref(layoutStore).isVertical || unref(layoutStore).isBiserial) ? (openBlock(), createBlock(unref(stdin_default$
|
|
66
|
+
})) : createCommentVNode("v-if", true), (openBlock(), createBlock(resolveDynamicComponent(unref(AfterToggle)))), !unref(layoutStore).isMobile && (unref(layoutStore).isVertical || unref(layoutStore).isBiserial) ? (openBlock(), createBlock(unref(stdin_default$f), {
|
|
66
67
|
key: 2
|
|
67
|
-
})) : createCommentVNode("v-if", true), !unref(layoutStore).isMobile && (unref(layoutStore).isHorizontalVertical || unref(layoutStore).isHorizontalBiserial) ? (openBlock(), createBlock(unref(stdin_default$
|
|
68
|
+
})) : createCommentVNode("v-if", true), !unref(layoutStore).isMobile && (unref(layoutStore).isHorizontalVertical || unref(layoutStore).isHorizontalBiserial) ? (openBlock(), createBlock(unref(stdin_default$g), {
|
|
68
69
|
key: 3
|
|
69
|
-
})) : createCommentVNode("v-if", true), !unref(layoutStore).isMobile && unref(layoutStore).isHorizontal ? (openBlock(), createBlock(unref(stdin_default$
|
|
70
|
+
})) : createCommentVNode("v-if", true), !unref(layoutStore).isMobile && unref(layoutStore).isHorizontal ? (openBlock(), createBlock(unref(stdin_default$h), {
|
|
70
71
|
key: 4,
|
|
71
72
|
mode: "horizontal",
|
|
72
73
|
style: {
|
|
73
74
|
"flex": "1"
|
|
74
75
|
}
|
|
75
76
|
})) : createCommentVNode("v-if", true)]),
|
|
76
|
-
right: withCtx(() => [createVNode(unref(stdin_default$9)), (openBlock(), createBlock(resolveDynamicComponent(unref(TopbarWidget)))), createVNode(unref(stdin_default$a)), createVNode(unref(stdin_default$b)), (openBlock(), createBlock(resolveDynamicComponent(unref(TopbarRight))))]),
|
|
77
|
+
right: withCtx(() => [createVNode(unref(stdin_default$9)), (openBlock(), createBlock(resolveDynamicComponent(unref(TopbarWidget)))), createVNode(unref(stdin_default$a)), createVNode(unref(stdin_default$b)), createVNode(unref(stdin_default$c)), (openBlock(), createBlock(resolveDynamicComponent(unref(TopbarRight))))]),
|
|
77
78
|
_: 1
|
|
78
79
|
/* STABLE */
|
|
79
|
-
}), createVNode(unref(stdin_default$
|
|
80
|
+
}), createVNode(unref(stdin_default$i))]),
|
|
80
81
|
_: 1
|
|
81
82
|
/* STABLE */
|
|
82
|
-
}), createVNode(unref(stdin_default$
|
|
83
|
+
}), createVNode(unref(stdin_default$j))]),
|
|
83
84
|
_: 1
|
|
84
85
|
/* STABLE */
|
|
85
86
|
})], 2
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './layout-locale.vue';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './layout-locale.vue.js';
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
declare const _default: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
2
|
+
export default _default;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { defineComponent, resolveComponent, createBlock, createCommentVNode, unref, openBlock, withCtx, createVNode, createElementBlock, Fragment, renderList, createElementVNode, createTextVNode, toDisplayString } from 'vue';
|
|
2
|
+
import { Icon } from 'cosey/components';
|
|
3
|
+
import { useLocaleMessages } from '../../locale/index.js';
|
|
4
|
+
import { useI18n } from 'vue-i18n';
|
|
5
|
+
|
|
6
|
+
const _hoisted_1 = {
|
|
7
|
+
style: {
|
|
8
|
+
"width": "24px"
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
var stdin_default = /* @__PURE__ */defineComponent({
|
|
12
|
+
...{
|
|
13
|
+
name: "CoLayoutLocale"
|
|
14
|
+
},
|
|
15
|
+
__name: "layout-locale",
|
|
16
|
+
setup(__props) {
|
|
17
|
+
const messages = useLocaleMessages();
|
|
18
|
+
const {
|
|
19
|
+
locale
|
|
20
|
+
} = useI18n();
|
|
21
|
+
const onCommand = lang => {
|
|
22
|
+
locale.value = lang;
|
|
23
|
+
};
|
|
24
|
+
return (_ctx, _cache) => {
|
|
25
|
+
const _component_el_button = resolveComponent("el-button");
|
|
26
|
+
const _component_el_dropdown_item = resolveComponent("el-dropdown-item");
|
|
27
|
+
const _component_el_dropdown_menu = resolveComponent("el-dropdown-menu");
|
|
28
|
+
const _component_el_dropdown = resolveComponent("el-dropdown");
|
|
29
|
+
return unref(messages).length > 1 ? (openBlock(), createBlock(_component_el_dropdown, {
|
|
30
|
+
key: 0,
|
|
31
|
+
placement: "bottom",
|
|
32
|
+
trigger: "click",
|
|
33
|
+
onCommand
|
|
34
|
+
}, {
|
|
35
|
+
dropdown: withCtx(() => [createVNode(_component_el_dropdown_menu, null, {
|
|
36
|
+
default: withCtx(() => [(openBlock(true), createElementBlock(Fragment, null, renderList(unref(messages), option => {
|
|
37
|
+
return openBlock(), createBlock(_component_el_dropdown_item, {
|
|
38
|
+
key: option.value,
|
|
39
|
+
command: option.value
|
|
40
|
+
}, {
|
|
41
|
+
default: withCtx(() => [createElementVNode("div", _hoisted_1, [option.value === unref(locale) ? (openBlock(), createBlock(unref(Icon), {
|
|
42
|
+
key: 0,
|
|
43
|
+
name: "co:checkmark",
|
|
44
|
+
size: "lg"
|
|
45
|
+
})) : createCommentVNode("v-if", true)]), createTextVNode(" " + toDisplayString(option.label), 1
|
|
46
|
+
/* TEXT */)]),
|
|
47
|
+
_: 2
|
|
48
|
+
/* DYNAMIC */
|
|
49
|
+
}, 1032, ["command"]);
|
|
50
|
+
}), 128
|
|
51
|
+
/* KEYED_FRAGMENT */))]),
|
|
52
|
+
_: 1
|
|
53
|
+
/* STABLE */
|
|
54
|
+
})]),
|
|
55
|
+
default: withCtx(() => [createVNode(_component_el_button, {
|
|
56
|
+
link: "",
|
|
57
|
+
size: "large"
|
|
58
|
+
}, {
|
|
59
|
+
default: withCtx(() => [createVNode(unref(Icon), {
|
|
60
|
+
name: "co:ibm-watson-language-translator",
|
|
61
|
+
size: "lg"
|
|
62
|
+
})]),
|
|
63
|
+
_: 1
|
|
64
|
+
/* STABLE */
|
|
65
|
+
})]),
|
|
66
|
+
_: 1
|
|
67
|
+
/* STABLE */
|
|
68
|
+
})) : createCommentVNode("v-if", true);
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
export { stdin_default as default };
|
package/layout/merged/index.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ export { default as MergedLayoutForbidden } from './layout-forbidden';
|
|
|
12
12
|
export { default as MergedLayoutHeader } from './layout-header';
|
|
13
13
|
export { default as MergedLayoutIframe } from './layout-iframe';
|
|
14
14
|
export { default as MergedLayoutInternalServerError } from './layout-internal-server-error';
|
|
15
|
+
export { default as MergedLayoutLocale } from './layout-locale';
|
|
15
16
|
export { default as MergedLayoutLogin } from './layout-login';
|
|
16
17
|
export { default as MergedLayoutMain } from './layout-main';
|
|
17
18
|
export { default as MergedLayoutMask } from './layout-mask';
|
package/layout/merged/index.js
CHANGED
|
@@ -12,6 +12,7 @@ export { default as MergedLayoutForbidden } from './layout-forbidden.js';
|
|
|
12
12
|
export { default as MergedLayoutHeader } from './layout-header.js';
|
|
13
13
|
export { default as MergedLayoutIframe } from './layout-iframe.js';
|
|
14
14
|
export { default as MergedLayoutInternalServerError } from './layout-internal-server-error.js';
|
|
15
|
+
export { default as MergedLayoutLocale } from './layout-locale.js';
|
|
15
16
|
export { default as MergedLayoutLogin } from './layout-login.js';
|
|
16
17
|
export { default as MergedLayoutMain } from './layout-main.js';
|
|
17
18
|
export { default as MergedLayoutMask } from './layout-mask.js';
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
declare const _default: import("vue").DefineComponent<{}, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
2
|
+
[key: string]: any;
|
|
3
|
+
}>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
4
|
+
export default _default;
|
package/locale/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { type App } from 'vue';
|
|
2
|
+
import { type I18nConfig } from '../config/i18n';
|
|
3
|
+
import Persist from '@gunny/persist';
|
|
3
4
|
export type TranslatePair = {
|
|
4
5
|
[key: string]: string | string[] | TranslatePair;
|
|
5
6
|
};
|
|
@@ -8,3 +9,13 @@ export type Language = {
|
|
|
8
9
|
el: TranslatePair;
|
|
9
10
|
co: TranslatePair;
|
|
10
11
|
};
|
|
12
|
+
export declare let i18n: import("vue-i18n").I18n<{}, {}, {}, string, false>;
|
|
13
|
+
export declare function setupLocale(app: App, config: I18nConfig | undefined, persist: Persist): void;
|
|
14
|
+
export declare function useCoseyLocale(): Record<string, any>;
|
|
15
|
+
export declare function useLocaleMessages(): {
|
|
16
|
+
value: string;
|
|
17
|
+
label: string;
|
|
18
|
+
dayjs: Record<string, any>;
|
|
19
|
+
cosey: Record<string, any>;
|
|
20
|
+
app: Record<string, any>;
|
|
21
|
+
}[];
|
package/locale/index.js
CHANGED
|
@@ -1,2 +1,61 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { inject, shallowRef, watch } from 'vue';
|
|
2
|
+
import { createI18n } from 'vue-i18n';
|
|
3
|
+
import { defaultsDeep } from 'lodash-es';
|
|
4
|
+
import dayjs from 'dayjs';
|
|
5
|
+
import { defaultI18nConfig } from '../config/i18n.js';
|
|
6
|
+
|
|
7
|
+
const langKey = "Cosey:lang";
|
|
8
|
+
const rtlLangs = ["ar"];
|
|
9
|
+
function getMessages(config, type) {
|
|
10
|
+
const langs = {};
|
|
11
|
+
config.messages.forEach((item) => {
|
|
12
|
+
langs[item.value] = item[type];
|
|
13
|
+
});
|
|
14
|
+
return langs;
|
|
15
|
+
}
|
|
16
|
+
const coseyLocaleKey = Symbol("coseyLocale");
|
|
17
|
+
const localeMessagesKey = Symbol("localeMessages");
|
|
18
|
+
let i18n = createI18n({
|
|
19
|
+
legacy: false
|
|
20
|
+
});
|
|
21
|
+
function setupLocale(app, config = {}, persist) {
|
|
22
|
+
const mergedConfig = defaultsDeep(config, defaultI18nConfig);
|
|
23
|
+
const appMessages = getMessages(mergedConfig, "app");
|
|
24
|
+
const coesyMessages = getMessages(mergedConfig, "cosey");
|
|
25
|
+
const dayjsMessages = getMessages(mergedConfig, "dayjs");
|
|
26
|
+
const locale = persist.get(langKey) || mergedConfig.locale;
|
|
27
|
+
const coseyLocale = shallowRef({});
|
|
28
|
+
i18n = createI18n({
|
|
29
|
+
legacy: false,
|
|
30
|
+
locale,
|
|
31
|
+
fallbackLocale: locale,
|
|
32
|
+
messages: appMessages,
|
|
33
|
+
silentTranslationWarn: true,
|
|
34
|
+
silentFallbackWarn: true,
|
|
35
|
+
missingWarn: false,
|
|
36
|
+
fallbackWarn: false
|
|
37
|
+
});
|
|
38
|
+
watch(
|
|
39
|
+
i18n.global.locale,
|
|
40
|
+
(locale2) => {
|
|
41
|
+
coseyLocale.value = coesyMessages[locale2];
|
|
42
|
+
dayjs.locale(dayjsMessages[locale2]);
|
|
43
|
+
persist.set(langKey, locale2);
|
|
44
|
+
document.documentElement.setAttribute("dir", rtlLangs.includes(locale2) ? "rtl" : "ltr");
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
immediate: true
|
|
48
|
+
}
|
|
49
|
+
);
|
|
50
|
+
app.use(i18n);
|
|
51
|
+
app.provide(coseyLocaleKey, coseyLocale);
|
|
52
|
+
app.provide(localeMessagesKey, mergedConfig.messages);
|
|
53
|
+
}
|
|
54
|
+
function useCoseyLocale() {
|
|
55
|
+
return inject(coseyLocaleKey, {});
|
|
56
|
+
}
|
|
57
|
+
function useLocaleMessages() {
|
|
58
|
+
return inject(localeMessagesKey, []);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export { i18n, setupLocale, useCoseyLocale, useLocaleMessages };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cosey",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.3",
|
|
4
4
|
"description": "基于 Vue3 + vite 的后台管理系统框架",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.js",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
},
|
|
11
11
|
"devDependencies": {
|
|
12
12
|
"@casl/ability": "^6.7.3",
|
|
13
|
-
"@cosey/icons": "^0.1.
|
|
13
|
+
"@cosey/icons": "^0.1.8",
|
|
14
14
|
"@ctrl/tinycolor": "^4.1.0",
|
|
15
15
|
"@element-plus/icons-vue": "^2.3.1",
|
|
16
16
|
"@emotion/hash": "^0.9.2",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
},
|
|
48
48
|
"peerDependencies": {
|
|
49
49
|
"@casl/ability": "^6.7.3",
|
|
50
|
-
"@cosey/icons": "^0.1.
|
|
50
|
+
"@cosey/icons": "^0.1.8",
|
|
51
51
|
"@ctrl/tinycolor": "^4.1.0",
|
|
52
52
|
"@element-plus/icons-vue": "^2.3.1",
|
|
53
53
|
"@emotion/hash": "^0.9.2",
|