cosey 0.10.0 → 0.10.2
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 +1 -2
- package/components/editor/contents/content-code-block.d.ts +3 -3
- package/components/editor/contents/content-code-block.js +11 -7
- package/components/editor/editor.style.js +1 -0
- package/components/editor/plugins/code-block.js +9 -1
- package/components/highlight/highlight.api.js +1 -1
- package/components/highlight/highlight.js +3 -2
- package/components/highlight/highlight.style.d.ts +1 -0
- package/components/highlight/highlight.style.js +10 -11
- 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.js +1 -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 +12 -2
- package/locale/index.js +58 -2
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -68,7 +68,6 @@ Cosey 基于 element-plus 并补充了众多组件,意在使开发者更加专
|
|
|
68
68
|
- 打包案例 `npm run build`
|
|
69
69
|
- 打包文档 `npm run docs:build`
|
|
70
70
|
- 部署案例和文档 `npm run cosey:deploy`
|
|
71
|
-
- 更新 `create-cosey` 中 `cosey` 包的版本
|
|
72
71
|
|
|
73
72
|
## 推送代码流程
|
|
74
73
|
|
|
@@ -76,4 +75,4 @@ Cosey 基于 element-plus 并补充了众多组件,意在使开发者更加专
|
|
|
76
75
|
- 打标签 `npm run tag`
|
|
77
76
|
- 生成更新日志 `npm run changelog`
|
|
78
77
|
- 暂存、提交 changelog `git commit -a -m 'chore: changelog'`
|
|
79
|
-
- 推送
|
|
78
|
+
- 推送 `npm run push`
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
declare const _default: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
2
|
-
|
|
2
|
+
language: {
|
|
3
3
|
type: StringConstructor;
|
|
4
4
|
default: string;
|
|
5
5
|
};
|
|
6
6
|
}>, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
7
7
|
'update:value': (value: string) => boolean;
|
|
8
8
|
}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
9
|
-
|
|
9
|
+
language: {
|
|
10
10
|
type: StringConstructor;
|
|
11
11
|
default: string;
|
|
12
12
|
};
|
|
13
13
|
}>> & Readonly<{
|
|
14
14
|
"onUpdate:value"?: ((value: string) => any) | undefined;
|
|
15
15
|
}>, {
|
|
16
|
-
|
|
16
|
+
language: string;
|
|
17
17
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
18
18
|
export default _default;
|
|
@@ -2,12 +2,13 @@ import { defineComponent, useModel, createVNode } from 'vue';
|
|
|
2
2
|
import { useEditor, useElement } from 'slate-vue3';
|
|
3
3
|
import { DOMEditor } from 'slate-vue3/dom';
|
|
4
4
|
import { languageOptions } from '../plugins/code-block.js';
|
|
5
|
+
import { useGlobalHighlightStyle } from '../../highlight/highlight.style.js';
|
|
5
6
|
import { isString } from '../../../utils/is.js';
|
|
6
7
|
|
|
7
8
|
var stdin_default = defineComponent({
|
|
8
9
|
name: "CoEditorContentCodeBlock",
|
|
9
10
|
props: {
|
|
10
|
-
|
|
11
|
+
language: {
|
|
11
12
|
type: String,
|
|
12
13
|
default: "text"
|
|
13
14
|
}
|
|
@@ -18,28 +19,31 @@ var stdin_default = defineComponent({
|
|
|
18
19
|
setup(props, {
|
|
19
20
|
slots
|
|
20
21
|
}) {
|
|
21
|
-
|
|
22
|
+
useGlobalHighlightStyle();
|
|
23
|
+
const language = useModel(props, "language");
|
|
22
24
|
const editor = useEditor();
|
|
23
25
|
const element = useElement();
|
|
24
26
|
const onChange = e => {
|
|
25
|
-
|
|
27
|
+
language.value = e.target.value;
|
|
26
28
|
const path = DOMEditor.findPath(editor, element.value);
|
|
27
29
|
editor.setNodes({
|
|
28
|
-
language:
|
|
30
|
+
language: language.value
|
|
29
31
|
}, {
|
|
30
32
|
at: path
|
|
31
33
|
});
|
|
32
34
|
};
|
|
33
35
|
return () => {
|
|
34
36
|
return createVNode("pre", {
|
|
35
|
-
"class": `language-${
|
|
37
|
+
"class": `language-${language.value}`
|
|
38
|
+
}, [createVNode("code", {
|
|
39
|
+
"class": `language-${language.value}`
|
|
36
40
|
}, [createVNode("select", {
|
|
37
|
-
"value":
|
|
41
|
+
"value": language.value,
|
|
38
42
|
"contenteditable": false,
|
|
39
43
|
"onChange": onChange
|
|
40
44
|
}, [languageOptions.map(option => createVNode("option", {
|
|
41
45
|
"value": option.value
|
|
42
|
-
}, [option.label]))]), createVNode("div", null, [slots.default?.()])]);
|
|
46
|
+
}, [option.label]))]), createVNode("div", null, [slots.default?.()])])]);
|
|
43
47
|
};
|
|
44
48
|
}
|
|
45
49
|
});
|
|
@@ -19,6 +19,7 @@ const languageOptions = [
|
|
|
19
19
|
{ value: "json", label: "JSON" },
|
|
20
20
|
{ value: "markdown", label: "Markdown" },
|
|
21
21
|
{ value: "php", label: "PHP" },
|
|
22
|
+
{ value: "bash", label: "Bash" },
|
|
22
23
|
{ value: "java", label: "Java" },
|
|
23
24
|
{ value: "python", label: "Python" },
|
|
24
25
|
{ value: "sql", label: "SQL" }
|
|
@@ -318,7 +319,14 @@ function withCodeBlock(editor) {
|
|
|
318
319
|
editor.renderElement = (props) => {
|
|
319
320
|
const { attributes, children, element } = props;
|
|
320
321
|
if (element.type === "code-block") {
|
|
321
|
-
return h(
|
|
322
|
+
return h(
|
|
323
|
+
stdin_default,
|
|
324
|
+
{
|
|
325
|
+
...useInheritRef(attributes),
|
|
326
|
+
language: element.language
|
|
327
|
+
},
|
|
328
|
+
() => children
|
|
329
|
+
);
|
|
322
330
|
}
|
|
323
331
|
if (element.type === "code-line") {
|
|
324
332
|
return h("div", { ...attributes, style: { position: "relative" } }, children);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { defineComponent, computed, createVNode } from 'vue';
|
|
2
2
|
import { ElScrollbar } from 'element-plus';
|
|
3
3
|
import { highlightSlots, highlightProps } from './highlight.api.js';
|
|
4
|
-
import stdin_default$1 from './highlight.style.js';
|
|
4
|
+
import stdin_default$1, { useGlobalHighlightStyle } from './highlight.style.js';
|
|
5
5
|
import stdin_default$2 from '../copy/copy.js';
|
|
6
6
|
import { useComponentConfig } from '../config-provider/config-provider.api.js';
|
|
7
7
|
import Prism from 'prismjs';
|
|
@@ -17,7 +17,8 @@ var stdin_default = defineComponent({
|
|
|
17
17
|
const {
|
|
18
18
|
hashId
|
|
19
19
|
} = stdin_default$1(prefixCls);
|
|
20
|
-
|
|
20
|
+
useGlobalHighlightStyle();
|
|
21
|
+
const highlightedCode = computed(() => Prism.highlight(props.code || "", Prism.languages[props.lang] || Prism.languages["text"], props.lang));
|
|
21
22
|
return () => {
|
|
22
23
|
return createVNode("div", {
|
|
23
24
|
"class": [hashId.value, prefixCls.value]
|
|
@@ -5,3 +5,4 @@ declare const _default: (_prefixCls?: import("vue").ComputedRef<string> | string
|
|
|
5
5
|
hashId: import("vue").Ref<string, string>;
|
|
6
6
|
};
|
|
7
7
|
export default _default;
|
|
8
|
+
export declare const useGlobalHighlightStyle: (themeManager?: import("../theme/theme-context").ThemeManager) => void;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import { getGlobalStyleHook } from '../theme/getGlobalStyleHook.js';
|
|
1
2
|
import { getSimpleStyleHook } from '../theme/getSimpleStyleHook.js';
|
|
2
3
|
|
|
3
4
|
function getHljsDark() {
|
|
4
5
|
return {
|
|
5
6
|
'pre[class*="language-"], code[class*="language-"]': {
|
|
7
|
+
display: "block",
|
|
6
8
|
color: "#d4d4d4",
|
|
7
9
|
fontSize: "13px",
|
|
8
10
|
textShadow: "none",
|
|
@@ -32,12 +34,10 @@ function getHljsDark() {
|
|
|
32
34
|
},
|
|
33
35
|
'pre[class*="language-"]': {
|
|
34
36
|
padding: "1em",
|
|
35
|
-
margin: ".5em 0",
|
|
36
37
|
overflow: "auto",
|
|
37
38
|
background: "#1e1e1e"
|
|
38
39
|
},
|
|
39
40
|
':not(pre) > code[class*="language-"]': {
|
|
40
|
-
padding: ".1em .3em",
|
|
41
41
|
borderRadius: ".3em",
|
|
42
42
|
color: "#db4c69",
|
|
43
43
|
background: "#1e1e1e"
|
|
@@ -188,6 +188,7 @@ function getHljsDark() {
|
|
|
188
188
|
function getHljsLight() {
|
|
189
189
|
return {
|
|
190
190
|
'code[class*="language-"], pre[class*="language-"]': {
|
|
191
|
+
display: "block",
|
|
191
192
|
background: "hsl(230, 1%, 98%)",
|
|
192
193
|
color: "hsl(230, 8%, 24%)",
|
|
193
194
|
fontFamily: '"Fira Code", "Fira Mono", Menlo, Consolas, "DejaVu Sans Mono", monospace',
|
|
@@ -215,12 +216,10 @@ function getHljsLight() {
|
|
|
215
216
|
},
|
|
216
217
|
'pre[class*="language-"]': {
|
|
217
218
|
padding: "1em",
|
|
218
|
-
margin: "0.5em 0",
|
|
219
219
|
overflow: "auto",
|
|
220
220
|
borderRadius: "0.3em"
|
|
221
221
|
},
|
|
222
222
|
':not(pre) > code[class*="language-"]': {
|
|
223
|
-
padding: "0.2em 0.3em",
|
|
224
223
|
borderRadius: "0.3em",
|
|
225
224
|
whiteSpace: "normal"
|
|
226
225
|
},
|
|
@@ -335,15 +334,15 @@ var stdin_default = getSimpleStyleHook("CoHighlight", (token) => {
|
|
|
335
334
|
insetBlockStart: token.sizeXXS,
|
|
336
335
|
insetInlineEnd: token.sizeXXS,
|
|
337
336
|
zIndex: 10
|
|
338
|
-
},
|
|
339
|
-
":root.dark &": {
|
|
340
|
-
...getHljsDark()
|
|
341
|
-
},
|
|
342
|
-
":root:not(.dark) &": {
|
|
343
|
-
...getHljsLight()
|
|
344
337
|
}
|
|
345
338
|
}
|
|
346
339
|
};
|
|
347
340
|
});
|
|
341
|
+
const useGlobalHighlightStyle = getGlobalStyleHook("CoGlobalHighlight", () => {
|
|
342
|
+
return {
|
|
343
|
+
":root.dark": getHljsDark(),
|
|
344
|
+
":root:not(.dark)": getHljsLight()
|
|
345
|
+
};
|
|
346
|
+
});
|
|
348
347
|
|
|
349
|
-
export { stdin_default as default, getHljsDark, getHljsLight };
|
|
348
|
+
export { stdin_default as default, getHljsDark, getHljsLight, useGlobalHighlightStyle };
|
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.js
CHANGED
|
@@ -56,6 +56,7 @@ export { default as MergedLayoutForbidden } from './layout/merged/layout-forbidd
|
|
|
56
56
|
export { default as MergedLayoutHeader } from './layout/merged/layout-header.js';
|
|
57
57
|
export { default as MergedLayoutIframe } from './layout/merged/layout-iframe.js';
|
|
58
58
|
export { default as MergedLayoutInternalServerError } from './layout/merged/layout-internal-server-error.js';
|
|
59
|
+
export { default as MergedLayoutLocale } from './layout/merged/layout-locale.js';
|
|
59
60
|
export { default as MergedLayoutLogin } from './layout/merged/layout-login.js';
|
|
60
61
|
export { default as MergedLayoutMain } from './layout/merged/layout-main.js';
|
|
61
62
|
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,12 @@ export type Language = {
|
|
|
8
9
|
el: TranslatePair;
|
|
9
10
|
co: TranslatePair;
|
|
10
11
|
};
|
|
12
|
+
export declare function setupLocale(app: App, config: I18nConfig | undefined, persist: Persist): void;
|
|
13
|
+
export declare function useCoseyLocale(): Record<string, any>;
|
|
14
|
+
export declare function useLocaleMessages(): {
|
|
15
|
+
value: string;
|
|
16
|
+
label: string;
|
|
17
|
+
dayjs: Record<string, any>;
|
|
18
|
+
cosey: Record<string, any>;
|
|
19
|
+
app: Record<string, any>;
|
|
20
|
+
}[];
|
package/locale/index.js
CHANGED
|
@@ -1,2 +1,58 @@
|
|
|
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
|
+
function setupLocale(app, config = {}, persist) {
|
|
19
|
+
const mergedConfig = defaultsDeep(config, defaultI18nConfig);
|
|
20
|
+
const appMessages = getMessages(mergedConfig, "app");
|
|
21
|
+
const coesyMessages = getMessages(mergedConfig, "cosey");
|
|
22
|
+
const dayjsMessages = getMessages(mergedConfig, "dayjs");
|
|
23
|
+
const locale = persist.get(langKey) || mergedConfig.locale;
|
|
24
|
+
const coseyLocale = shallowRef({});
|
|
25
|
+
const i18n = createI18n({
|
|
26
|
+
legacy: false,
|
|
27
|
+
locale,
|
|
28
|
+
fallbackLocale: locale,
|
|
29
|
+
messages: appMessages,
|
|
30
|
+
silentTranslationWarn: true,
|
|
31
|
+
silentFallbackWarn: true,
|
|
32
|
+
missingWarn: false,
|
|
33
|
+
fallbackWarn: false
|
|
34
|
+
});
|
|
35
|
+
watch(
|
|
36
|
+
i18n.global.locale,
|
|
37
|
+
(locale2) => {
|
|
38
|
+
coseyLocale.value = coesyMessages[locale2];
|
|
39
|
+
dayjs.locale(dayjsMessages[locale2]);
|
|
40
|
+
persist.set(langKey, locale2);
|
|
41
|
+
document.documentElement.setAttribute("dir", rtlLangs.includes(locale2) ? "rtl" : "ltr");
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
immediate: true
|
|
45
|
+
}
|
|
46
|
+
);
|
|
47
|
+
app.use(i18n);
|
|
48
|
+
app.provide(coseyLocaleKey, coseyLocale);
|
|
49
|
+
app.provide(localeMessagesKey, mergedConfig.messages);
|
|
50
|
+
}
|
|
51
|
+
function useCoseyLocale() {
|
|
52
|
+
return inject(coseyLocaleKey, {});
|
|
53
|
+
}
|
|
54
|
+
function useLocaleMessages() {
|
|
55
|
+
return inject(localeMessagesKey, []);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export { 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.2",
|
|
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",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"nprogress": "^0.2.0",
|
|
39
39
|
"pinia": "^3.0.2",
|
|
40
40
|
"prismjs": "^1.30.0",
|
|
41
|
-
"slate-vue3": "^0.
|
|
41
|
+
"slate-vue3": "^0.10.0",
|
|
42
42
|
"stylis": "^4.3.6",
|
|
43
43
|
"svga": "^2.1.1",
|
|
44
44
|
"vue": "^3.5.21",
|
|
@@ -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",
|
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
"nprogress": "^0.2.0",
|
|
73
73
|
"pinia": "^3.0.2",
|
|
74
74
|
"prismjs": "^1.30.0",
|
|
75
|
-
"slate-vue3": "^0.
|
|
75
|
+
"slate-vue3": "^0.10.0",
|
|
76
76
|
"stylis": "^4.3.6",
|
|
77
77
|
"svga": "^2.1.1",
|
|
78
78
|
"vue": "^3.5.21",
|