cosey 0.1.4 → 0.2.0

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.
Files changed (180) hide show
  1. package/README.md +61 -0
  2. package/components/close/style/index.js +2 -2
  3. package/components/col/col.vue.js +1 -1
  4. package/components/col/style/index.js +3 -3
  5. package/components/config-provider/config-provider.d.ts +2 -0
  6. package/components/config-provider/config-provider.vue.js +13 -3
  7. package/components/context-menu/context-menu.vue.js +4 -4
  8. package/components/context-menu/context-sub-menu.vue.js +2 -2
  9. package/components/context-menu/style/index.js +2 -2
  10. package/components/editor/components/color-picker/color-picker.vue.js +15 -11
  11. package/components/editor/components/color-picker/useHistoryColor.js +3 -3
  12. package/components/editor/components/resize/resize.js +9 -9
  13. package/components/editor/components/resize/resize.style.js +20 -20
  14. package/components/editor/components/resize/resize.vue.js +2 -2
  15. package/components/editor/components/table-toolbar/table-toolbar.style.js +2 -2
  16. package/components/editor/components/table-toolbar/table-toolbar.vue.js +2 -2
  17. package/components/editor/components/toolbar/formats/font.vue.js +5 -1
  18. package/components/editor/components/toolbar/formats/header.vue.js +6 -2
  19. package/components/editor/components/toolbar/formats/link.vue.js +17 -13
  20. package/components/editor/components/toolbar/formats/size.vue.js +5 -1
  21. package/components/editor/components/toolbar/formats/source.vue.d.ts +2 -0
  22. package/components/editor/components/toolbar/formats/source.vue.js +78 -0
  23. package/components/editor/components/toolbar/formats/table.style.js +2 -2
  24. package/components/editor/components/toolbar/formats/video.vue.js +9 -5
  25. package/components/editor/components/toolbar/toolbar.vue.js +5 -0
  26. package/components/editor/formats/font.js +2 -2
  27. package/components/editor/formats/indent.js +1 -1
  28. package/components/editor/formats/kbd.d.ts +7 -0
  29. package/components/editor/formats/kbd.js +13 -0
  30. package/components/editor/modules/image-uploader/formats/image-loading.style.js +2 -2
  31. package/components/editor/quill.js +8 -6
  32. package/components/editor/style/index.js +25 -16
  33. package/components/field/components/autocomplete/autocomplete.vue.js +5 -1
  34. package/components/field/components/cascader/cascader.vue.js +5 -1
  35. package/components/field/components/checkbox-group/checkbox-group.vue.js +1 -1
  36. package/components/field/components/checkbox-group/panel.vue.js +10 -5
  37. package/components/field/components/date/date.vue.js +5 -1
  38. package/components/field/components/date-range/date-range.vue.js +6 -2
  39. package/components/field/components/date-time/date-time.vue.js +5 -1
  40. package/components/field/components/date-time-range/date-time-range.vue.js +6 -2
  41. package/components/field/components/dates/dates.vue.js +5 -1
  42. package/components/field/components/input/input.vue.js +5 -1
  43. package/components/field/components/input-tag/input-tag.vue.js +5 -1
  44. package/components/field/components/mention/mention.vue.js +5 -1
  45. package/components/field/components/month/month.vue.js +5 -1
  46. package/components/field/components/month-range/month-range.vue.js +6 -2
  47. package/components/field/components/months/months.vue.js +5 -1
  48. package/components/field/components/password/password.vue.js +5 -1
  49. package/components/field/components/select/select.d.ts +2 -2
  50. package/components/field/components/select/select.js +3 -3
  51. package/components/field/components/select/select.vue.js +5 -1
  52. package/components/field/components/select-v2/select-v2.d.ts +6 -3
  53. package/components/field/components/select-v2/select-v2.js +9 -0
  54. package/components/field/components/select-v2/select-v2.vue.js +21 -3
  55. package/components/field/components/textarea/textarea.vue.js +5 -1
  56. package/components/field/components/time/time.vue.js +5 -1
  57. package/components/field/components/time-range/time-range.vue.js +6 -2
  58. package/components/field/components/time-select/time-select.vue.js +5 -1
  59. package/components/field/components/tree-select/tree-select.vue.js +5 -1
  60. package/components/field/components/week/week.vue.js +6 -2
  61. package/components/field/components/year/year.vue.js +5 -1
  62. package/components/field/components/year-range/year-range.vue.js +6 -2
  63. package/components/field/components/years/years.vue.js +5 -1
  64. package/components/form/form-item.d.ts +1 -1
  65. package/components/form/form.d.ts +2 -0
  66. package/components/form/form.js +2 -2
  67. package/components/form/form.vue.d.ts +5 -0
  68. package/components/form/form.vue.js +6 -2
  69. package/components/form/index.d.ts +10 -1
  70. package/components/form/useBubbleTemplate.js +13 -5
  71. package/components/form-dialog/form-dialog.js +2 -2
  72. package/components/form-dialog/index.d.ts +4 -1552
  73. package/components/form-list/form-list.js +1 -1
  74. package/components/form-list/form-list.vue.js +5 -1
  75. package/components/form-list/index.d.ts +1 -1
  76. package/components/form-query/form-query.d.ts +2 -0
  77. package/components/form-query/form-query.vue.d.ts +5 -0
  78. package/components/form-query/form-query.vue.js +13 -7
  79. package/components/form-query/index.d.ts +9 -0
  80. package/components/highlight/style/index.js +2 -2
  81. package/components/horizontal-tree/horizontal-tree.vue.js +11 -6
  82. package/components/image-card/image-card.d.ts +1 -8
  83. package/components/image-card/image-card.vue.d.ts +4 -18
  84. package/components/image-card/index.d.ts +8 -29
  85. package/components/long-text/style/index.js +2 -2
  86. package/components/mask/style/index.js +2 -2
  87. package/components/row/row.vue.js +1 -1
  88. package/components/scroll-view/scroll-view.vue.js +1 -1
  89. package/components/scroll-view/style/index.js +9 -9
  90. package/components/table/index.d.ts +73 -78
  91. package/components/table/table-column/renderer.d.ts +2 -1
  92. package/components/table/table-column/renderer.js +2 -2
  93. package/components/table/table-column/table-column.d.ts +15 -15
  94. package/components/table/table-column/table-column.vue.d.ts +9 -5
  95. package/components/table/table-column/table-column.vue.js +5 -1
  96. package/components/table/table-column-editor/table-column-editor.vue.js +22 -14
  97. package/components/table/table-export/table-export.vue.js +31 -26
  98. package/components/table/table-query/table-query.d.ts +2 -0
  99. package/components/table/table-query/table-query.vue.d.ts +5 -0
  100. package/components/table/table.d.ts +22 -25
  101. package/components/table/table.vue.d.ts +45 -51
  102. package/components/table/table.vue.js +13 -9
  103. package/components/table/useTable.d.ts +2 -1
  104. package/components/table/useTable.js +2 -2
  105. package/components/table-action/index.d.ts +48 -6
  106. package/components/table-action/item.d.ts +16 -2
  107. package/components/table-action/item.vue.d.ts +34 -6
  108. package/components/table-action/item.vue.js +15 -9
  109. package/components/table-action/table-action.vue.d.ts +16 -2
  110. package/components/toggle/toggle.vue.js +5 -1
  111. package/components/upload/style/index.js +2 -2
  112. package/components/upload/upload-item.vue.d.ts +2 -2
  113. package/components/upload/upload-item.vue.js +16 -9
  114. package/components/upload/upload.vue.js +7 -1
  115. package/config/index.d.ts +1 -2
  116. package/config/index.js +2 -2
  117. package/config/nprogress.style.js +5 -5
  118. package/config/root-config-provider.vue.js +5 -5
  119. package/constant.d.ts +2 -2
  120. package/constant.js +2 -2
  121. package/hooks/index.d.ts +1 -0
  122. package/hooks/index.js +2 -1
  123. package/hooks/useColorScheme.js +4 -4
  124. package/hooks/useDir.d.ts +2 -0
  125. package/hooks/useDir.js +20 -0
  126. package/hooks/useEcharts.d.ts +3 -2
  127. package/hooks/useEcharts.js +15 -3
  128. package/hooks/useLocale.d.ts +23 -371
  129. package/hooks/useLocale.js +26 -35
  130. package/hooks/useUpsert.d.ts +5 -3
  131. package/hooks/useUpsert.js +33 -25
  132. package/index.d.ts +1 -1
  133. package/index.js +4 -4
  134. package/layout/layout-auth/style/index.js +6 -6
  135. package/layout/layout-breadcrumb/layout-breadcrumb.vue.js +6 -2
  136. package/layout/layout-change-password/layout-change-password.vue.js +28 -22
  137. package/layout/layout-content/layout-content.vue.js +1 -1
  138. package/layout/layout-content/style/index.js +1 -1
  139. package/layout/layout-forbidden/layout-forbidden.vue.js +11 -6
  140. package/layout/layout-header/layout-header.vue.js +4 -4
  141. package/layout/layout-header/style/index.js +3 -3
  142. package/layout/layout-iframe/style/index.js +2 -2
  143. package/layout/layout-internal-server-error/layout-internal-server-error.vue.js +11 -6
  144. package/layout/layout-login/layout-login.vue.js +19 -14
  145. package/layout/layout-main/layout-main.vue.js +1 -1
  146. package/layout/layout-menu/layout-menu.vue.js +5 -1
  147. package/layout/layout-menu/style/index.js +1 -1
  148. package/layout/layout-not-found/layout-not-found.vue.js +11 -6
  149. package/layout/layout-search/layout-search.vue.js +22 -14
  150. package/layout/layout-sidebar/layout-sidebar.vue.js +8 -5
  151. package/layout/layout-sidebar/style/index.js +2 -2
  152. package/layout/layout-snug-aside/style/index.js +1 -1
  153. package/layout/layout-tabbar/layout-tabbar.vue.js +21 -13
  154. package/layout/layout-tabbar/style/index.js +1 -1
  155. package/layout/layout-top-snug-menu/layout-top-snug-menu.vue.js +24 -17
  156. package/layout/layout-user-menu/layout-user-menu.vue.js +10 -6
  157. package/locale/index.d.ts +10 -0
  158. package/locale/index.js +2 -0
  159. package/locale/lang/ar.d.ts +280 -0
  160. package/locale/lang/ar.js +129 -0
  161. package/locale/lang/en.d.ts +302 -0
  162. package/locale/lang/en.js +129 -0
  163. package/locale/lang/zh-cn.d.ts +301 -0
  164. package/locale/lang/zh-cn.js +129 -0
  165. package/package.json +10 -8
  166. package/request/useRequest.js +31 -23
  167. package/store/index.d.ts +1 -1
  168. package/store/index.js +6 -3
  169. package/store/layout.js +208 -190
  170. package/store/plugin.d.ts +9 -0
  171. package/store/plugin.js +22 -0
  172. package/store/user.d.ts +1 -1
  173. package/utils/css.d.ts +4 -0
  174. package/utils/css.js +5 -2
  175. package/utils/excel/bookFormats.js +5 -5
  176. package/utils/excel/xlsx.js +2 -2
  177. package/utils/index.js +1 -1
  178. package/utils/message-box.js +3 -1
  179. package/utils/tree.js +2 -2
  180. package/components/form-dialog/form-dialog.vue.d.ts +0 -675
@@ -1,5 +1,5 @@
1
1
  import { useRouter, useRoute } from 'vue-router';
2
- import axios from 'axios';
2
+ import axios, { AxiosError } from 'axios';
3
3
  import { ElMessage } from 'element-plus';
4
4
  import { defaults, pick, get } from 'lodash-es';
5
5
  import { useUserStore } from '../store/user.js';
@@ -7,6 +7,7 @@ import { TOKEN_NAME, ROUTER_TO } from '../constant.js';
7
7
  import { Http } from './Http.js';
8
8
  import { useGlobalConfig } from '../config/index.js';
9
9
  import { usePersist } from '../hooks/usePersist.js';
10
+ import { isObject } from '../utils/is.js';
10
11
 
11
12
  function useRequest(config = {}) {
12
13
  const persist = usePersist();
@@ -14,6 +15,27 @@ function useRequest(config = {}) {
14
15
  const router = useRouter();
15
16
  const route = useRoute();
16
17
  const { http: httpConfig, router: routerConfig } = useGlobalConfig();
18
+ const handleError = (resData) => {
19
+ const httpPath = httpConfig.path;
20
+ const code = get(resData, httpPath.code);
21
+ const message = get(resData, httpPath.message) || "Error";
22
+ const data = get(resData, httpPath.data);
23
+ if (code !== httpConfig.code.success) {
24
+ ElMessage.error({
25
+ message,
26
+ duration: httpConfig.errorDuration
27
+ });
28
+ if (code === httpConfig.code.forbidden) {
29
+ router.push(routerConfig.homePath);
30
+ } else if (code === httpConfig.code.unauthorized) {
31
+ if (persist.get(TOKEN_NAME)) {
32
+ userStore.logout(persist.get(ROUTER_TO) || route.fullPath);
33
+ }
34
+ }
35
+ return Promise.reject(new Error(message));
36
+ }
37
+ return data;
38
+ };
17
39
  const createAxios = () => {
18
40
  const axiosIns = axios.create(
19
41
  defaults(config, pick(httpConfig, ["baseURL", "timeout", "headers"]))
@@ -38,32 +60,18 @@ function useRequest(config = {}) {
38
60
  axiosIns.interceptors.response.use(
39
61
  (response) => {
40
62
  const { data: resData } = response;
41
- const httpPath = httpConfig.path;
42
- const code = get(resData, httpPath.code);
43
- const message = get(resData, httpPath.message) || "Error";
44
- const data = get(resData, httpPath.data);
45
- if (code !== httpConfig.code.success) {
63
+ return handleError(resData);
64
+ },
65
+ (error) => {
66
+ if (error instanceof AxiosError && error.response && isObject(error.response.data) && get(error.response.data, httpConfig.path.code)) {
67
+ return handleError(error.response.data);
68
+ } else {
46
69
  ElMessage.error({
47
- message,
70
+ message: error.message,
48
71
  duration: httpConfig.errorDuration
49
72
  });
50
- if (code === httpConfig.code.forbidden) {
51
- router.push(routerConfig.homePath);
52
- } else if (code === httpConfig.code.unauthorized) {
53
- if (persist.get(TOKEN_NAME)) {
54
- userStore.logout(persist.get(ROUTER_TO) || route.fullPath);
55
- }
56
- }
57
- return Promise.reject(new Error(message));
73
+ return Promise.reject(error);
58
74
  }
59
- return data;
60
- },
61
- (error) => {
62
- ElMessage.error({
63
- message: error.message,
64
- duration: httpConfig.errorDuration
65
- });
66
- return Promise.reject(error);
67
75
  }
68
76
  );
69
77
  return axiosIns;
package/store/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { useLayoutStore } from './layout';
2
2
  import { useUserStore } from './user';
3
3
  import { useAppearanceStore } from './appearance';
4
- export declare function createStore(): import("pinia").Pinia;
4
+ export declare function createPiniaStore(): import("pinia").Pinia;
5
5
  export { useUserStore, useAppearanceStore, useLayoutStore };
package/store/index.js CHANGED
@@ -2,9 +2,12 @@ import { createPinia } from 'pinia';
2
2
  export { useLayoutStore } from './layout.js';
3
3
  export { useUserStore } from './user.js';
4
4
  export { useAppearanceStore } from './appearance.js';
5
+ import { piniaPluginPersist } from './plugin.js';
5
6
 
6
- function createStore() {
7
- return createPinia();
7
+ function createPiniaStore() {
8
+ const pinia = createPinia();
9
+ pinia.use(piniaPluginPersist);
10
+ return pinia;
8
11
  }
9
12
 
10
- export { createStore };
13
+ export { createPiniaStore };
package/store/layout.js CHANGED
@@ -5,206 +5,224 @@ import { useGlobalConfig } from '../config/index.js';
5
5
  import { ref, watch, computed, nextTick } from 'vue';
6
6
  import { useWindowResize } from '../hooks/useWindowResize.js';
7
7
 
8
- const useLayoutStore = defineStore("cosey-layout", () => {
9
- const { layout: layoutConfig } = useGlobalConfig();
10
- const route = useRoute();
11
- const sidebarVisible = ref(layoutConfig.sidebarVisible);
12
- const collapse = ref(layoutConfig.collapse);
13
- const isMobile = ref(false);
14
- watch(
15
- isMobile,
16
- () => {
17
- sidebarVisible.value = !isMobile.value;
18
- },
19
- {
20
- immediate: true
21
- }
22
- );
23
- const onResize = () => {
24
- isMobile.value = window.innerWidth <= layoutConfig.breakpoint;
25
- };
26
- onResize();
27
- useWindowResize(onResize);
28
- const menuType = ref(layoutConfig.menuType);
29
- const includeHorizontal = computed(
30
- () => ["horizontal", "horizontal-vertical", "horizontal-biserial"].includes(menuType.value)
31
- );
32
- const isVertical = computed(() => menuType.value === "vertical");
33
- const isBiserial = computed(() => menuType.value === "biserial");
34
- const isHorizontal = computed(() => menuType.value === "horizontal");
35
- const isHorizontalVertical = computed(() => menuType.value === "horizontal-vertical");
36
- const isHorizontalBiserial = computed(() => menuType.value === "horizontal-biserial");
37
- const menus = ref([]);
38
- const menusMap = computed(() => getMenusMap(menus.value));
39
- const firstLevelMenus = menus;
40
- const firstLevelActive = ref("");
41
- const secondLevelMenus = computed(() => {
42
- return firstLevelMenus.value.find((item) => {
43
- return item.name === firstLevelActive.value;
44
- })?.children || [];
45
- });
46
- const secondLevelActive = ref("");
47
- const thirdLevelMenus = computed(() => {
48
- return secondLevelMenus.value.find((item) => {
49
- return item.name === secondLevelActive.value;
50
- })?.children || [];
51
- });
52
- const topMenus = firstLevelMenus;
53
- const topActive = firstLevelActive;
54
- const snugMenus = computed(() => {
55
- if (isMobile.value) {
56
- return [];
57
- }
58
- return menuType.value === "biserial" ? firstLevelMenus.value : menuType.value === "horizontal-biserial" ? secondLevelMenus.value : [];
59
- });
60
- const snugActive = computed({
61
- get() {
62
- return menuType.value === "biserial" ? firstLevelActive.value : menuType.value === "horizontal-biserial" ? secondLevelActive.value : "";
63
- },
64
- set(name) {
65
- if (menuType.value === "biserial") {
66
- firstLevelActive.value = name;
67
- } else if (menuType.value === "horizontal-biserial") {
68
- secondLevelActive.value = name;
8
+ const useLayoutStore = defineStore(
9
+ "cosey-layout",
10
+ () => {
11
+ const { layout: layoutConfig } = useGlobalConfig();
12
+ const route = useRoute();
13
+ const sidebarVisible = ref(layoutConfig.sidebarVisible);
14
+ const collapse = ref(layoutConfig.collapse);
15
+ const isMobile = ref(false);
16
+ watch(
17
+ isMobile,
18
+ () => {
19
+ sidebarVisible.value = !isMobile.value;
20
+ },
21
+ {
22
+ immediate: true
69
23
  }
70
- }
71
- });
72
- const defaultMenus = computed(() => {
73
- if (isMobile.value) {
74
- return firstLevelMenus.value;
75
- }
76
- return menuType.value === "biserial" || menuType.value === "horizontal-vertical" ? secondLevelMenus.value : menuType.value === "horizontal-biserial" ? thirdLevelMenus.value : firstLevelMenus.value;
77
- });
78
- watch([() => route.name, menus], () => {
79
- const node = menusMap.value[route.name];
80
- if (node) {
81
- const nodes = getBreadcrumbRoutes(node);
82
- topActive.value = nodes[0].name;
83
- if (menuType.value === "biserial") {
84
- snugActive.value = nodes[0].name;
85
- } else if (menuType.value === "horizontal-biserial") {
86
- snugActive.value = nodes[1]?.name;
24
+ );
25
+ const onResize = () => {
26
+ isMobile.value = window.innerWidth <= layoutConfig.breakpoint;
27
+ };
28
+ onResize();
29
+ useWindowResize(onResize);
30
+ const menuType = ref(layoutConfig.menuType);
31
+ const includeHorizontal = computed(
32
+ () => ["horizontal", "horizontal-vertical", "horizontal-biserial"].includes(menuType.value)
33
+ );
34
+ const isVertical = computed(() => menuType.value === "vertical");
35
+ const isBiserial = computed(() => menuType.value === "biserial");
36
+ const isHorizontal = computed(() => menuType.value === "horizontal");
37
+ const isHorizontalVertical = computed(() => menuType.value === "horizontal-vertical");
38
+ const isHorizontalBiserial = computed(() => menuType.value === "horizontal-biserial");
39
+ const menus = ref([]);
40
+ const menusMap = computed(() => getMenusMap(menus.value));
41
+ const firstLevelMenus = menus;
42
+ const firstLevelActive = ref("");
43
+ const secondLevelMenus = computed(() => {
44
+ return firstLevelMenus.value.find((item) => {
45
+ return item.name === firstLevelActive.value;
46
+ })?.children || [];
47
+ });
48
+ const secondLevelActive = ref("");
49
+ const thirdLevelMenus = computed(() => {
50
+ return secondLevelMenus.value.find((item) => {
51
+ return item.name === secondLevelActive.value;
52
+ })?.children || [];
53
+ });
54
+ const topMenus = firstLevelMenus;
55
+ const topActive = firstLevelActive;
56
+ const snugMenus = computed(() => {
57
+ if (isMobile.value) {
58
+ return [];
87
59
  }
88
- }
89
- });
90
- const tabbarVisible = ref(layoutConfig.tabbarVisible);
91
- const activeTab = ref("");
92
- const refreshing = ref(false);
93
- const tabList = ref([]);
94
- const iframeTabList = computed(() => {
95
- return tabList.value.filter((item) => item.meta.iframeSrc);
96
- });
97
- const keepAliveInclude = ref([]);
98
- const keepAliveExclude = computed(() => {
99
- return layoutConfig.keepAlive ? tabList.value.filter((item) => !item.meta.keepAlive).map((item) => item.name) : [];
100
- });
101
- const keepAlive = computed(() => {
102
- return keepAliveInclude.value.filter((name) => {
103
- return !keepAliveExclude.value.includes(name);
60
+ return menuType.value === "biserial" ? firstLevelMenus.value : menuType.value === "horizontal-biserial" ? secondLevelMenus.value : [];
104
61
  });
105
- });
106
- const updateKeepAliveInclude = () => {
107
- keepAliveInclude.value = layoutConfig.keepAlive ? tabList.value.map((item) => item.name) : [];
108
- };
109
- watch(
110
- tabList,
111
- () => {
112
- updateKeepAliveInclude();
113
- },
114
- {
115
- immediate: true,
116
- deep: true
117
- }
118
- );
119
- const reload = () => {
120
- refreshing.value = true;
121
- if (keepAliveInclude.value.includes(route.name)) {
122
- keepAliveInclude.value = keepAliveInclude.value.filter((item) => item !== route.name);
123
- }
124
- nextTick(() => {
125
- refreshing.value = false;
126
- keepAliveInclude.value = [...keepAliveInclude.value, route.name];
62
+ const snugActive = computed({
63
+ get() {
64
+ return menuType.value === "biserial" ? firstLevelActive.value : menuType.value === "horizontal-biserial" ? secondLevelActive.value : "";
65
+ },
66
+ set(name) {
67
+ if (menuType.value === "biserial") {
68
+ firstLevelActive.value = name;
69
+ } else if (menuType.value === "horizontal-biserial") {
70
+ secondLevelActive.value = name;
71
+ }
72
+ }
127
73
  });
128
- };
129
- const asideWidth = ref(layoutConfig.asideWidth);
130
- const collapsedAsideWidth = ref(layoutConfig.collapsedAsideWidth);
131
- const snugAsideWidth = ref(layoutConfig.snugAsideWidth);
132
- const sidebarWidth = computed(() => {
133
- if (isMobile.value) {
134
- return 0;
135
- } else {
136
- if (!sidebarVisible.value) {
137
- return 0;
74
+ const defaultMenus = computed(() => {
75
+ if (isMobile.value) {
76
+ return firstLevelMenus.value;
77
+ }
78
+ return menuType.value === "biserial" || menuType.value === "horizontal-vertical" ? secondLevelMenus.value : menuType.value === "horizontal-biserial" ? thirdLevelMenus.value : firstLevelMenus.value;
79
+ });
80
+ watch([() => route.name, menus], () => {
81
+ const node = menusMap.value[route.name];
82
+ if (node) {
83
+ const nodes = getBreadcrumbRoutes(node);
84
+ topActive.value = nodes[0].name;
85
+ if (menuType.value === "biserial") {
86
+ snugActive.value = nodes[0].name;
87
+ } else if (menuType.value === "horizontal-biserial") {
88
+ snugActive.value = nodes[1]?.name;
89
+ }
90
+ }
91
+ });
92
+ const tabbarVisible = ref(layoutConfig.tabbarVisible);
93
+ const activeTab = ref("");
94
+ const refreshing = ref(false);
95
+ const tabList = ref([]);
96
+ const iframeTabList = computed(() => {
97
+ return tabList.value.filter((item) => item.meta.iframeSrc);
98
+ });
99
+ const keepAliveInclude = ref([]);
100
+ const keepAliveExclude = computed(() => {
101
+ return layoutConfig.keepAlive ? tabList.value.filter((item) => !item.meta.keepAlive).map((item) => item.name) : [];
102
+ });
103
+ const keepAlive = computed(() => {
104
+ return keepAliveInclude.value.filter((name) => {
105
+ return !keepAliveExclude.value.includes(name);
106
+ });
107
+ });
108
+ const updateKeepAliveInclude = () => {
109
+ keepAliveInclude.value = layoutConfig.keepAlive ? tabList.value.map((item) => item.name) : [];
110
+ };
111
+ watch(
112
+ tabList,
113
+ () => {
114
+ updateKeepAliveInclude();
115
+ },
116
+ {
117
+ immediate: true,
118
+ deep: true
119
+ }
120
+ );
121
+ const reload = () => {
122
+ refreshing.value = true;
123
+ if (keepAliveInclude.value.includes(route.name)) {
124
+ keepAliveInclude.value = keepAliveInclude.value.filter((item) => item !== route.name);
138
125
  }
139
- switch (menuType.value) {
140
- case "horizontal":
126
+ nextTick(() => {
127
+ refreshing.value = false;
128
+ keepAliveInclude.value = [...keepAliveInclude.value, route.name];
129
+ });
130
+ };
131
+ const asideWidth = ref(layoutConfig.asideWidth);
132
+ const collapsedAsideWidth = ref(layoutConfig.collapsedAsideWidth);
133
+ const snugAsideWidth = ref(layoutConfig.snugAsideWidth);
134
+ const sidebarWidth = computed(() => {
135
+ if (isMobile.value) {
136
+ return 0;
137
+ } else {
138
+ if (!sidebarVisible.value) {
141
139
  return 0;
142
- case "vertical":
143
- case "horizontal-vertical":
144
- if (defaultMenus.value.length === 0) {
140
+ }
141
+ switch (menuType.value) {
142
+ case "horizontal":
145
143
  return 0;
144
+ case "vertical":
145
+ case "horizontal-vertical":
146
+ if (defaultMenus.value.length === 0) {
147
+ return 0;
148
+ }
149
+ if (collapse.value) {
150
+ return collapsedAsideWidth.value;
151
+ }
152
+ return asideWidth.value;
153
+ case "biserial":
154
+ case "horizontal-biserial": {
155
+ const snugAsideW = snugMenus.value.length === 0 ? 0 : snugAsideWidth.value;
156
+ const asideW = defaultMenus.value.length === 0 ? 0 : collapse.value ? collapsedAsideWidth.value : asideWidth.value;
157
+ return snugAsideW + asideW;
146
158
  }
147
- if (collapse.value) {
148
- return collapsedAsideWidth.value;
149
- }
150
- return asideWidth.value;
151
- case "biserial":
152
- case "horizontal-biserial": {
153
- const snugAsideW = snugMenus.value.length === 0 ? 0 : snugAsideWidth.value;
154
- const asideW = defaultMenus.value.length === 0 ? 0 : collapse.value ? collapsedAsideWidth.value : asideWidth.value;
155
- return snugAsideW + asideW;
159
+ default:
160
+ return 0;
156
161
  }
157
- default:
158
- return 0;
159
162
  }
163
+ });
164
+ const topbarHeight = ref(layoutConfig.topbarHeight);
165
+ const tabbarHeight = ref(layoutConfig.tabbarHeight);
166
+ const headerHeight = computed(() => {
167
+ return topbarHeight.value + (tabbarVisible.value ? tabbarHeight.value : 0);
168
+ });
169
+ return {
170
+ sidebarVisible,
171
+ collapse,
172
+ isMobile,
173
+ menuType,
174
+ includeHorizontal,
175
+ isVertical,
176
+ isBiserial,
177
+ isHorizontal,
178
+ isHorizontalVertical,
179
+ isHorizontalBiserial,
180
+ menus,
181
+ menusMap,
182
+ firstLevelMenus,
183
+ firstLevelActive,
184
+ secondLevelMenus,
185
+ secondLevelActive,
186
+ thirdLevelMenus,
187
+ topMenus,
188
+ topActive,
189
+ snugMenus,
190
+ snugActive,
191
+ defaultMenus,
192
+ tabbarVisible,
193
+ activeTab,
194
+ refreshing,
195
+ tabList,
196
+ iframeTabList,
197
+ keepAliveInclude,
198
+ keepAliveExclude,
199
+ keepAlive,
200
+ updateKeepAliveInclude,
201
+ reload,
202
+ asideWidth,
203
+ collapsedAsideWidth,
204
+ snugAsideWidth,
205
+ sidebarWidth,
206
+ topbarHeight,
207
+ tabbarHeight,
208
+ headerHeight
209
+ };
210
+ },
211
+ {
212
+ persist: {
213
+ pick: [
214
+ "sidebarVisible",
215
+ "collapse",
216
+ "menuType",
217
+ "tabbarVisible",
218
+ "asideWidth",
219
+ "collapsedAsideWidth",
220
+ "snugAsideWidth",
221
+ "topbarHeight",
222
+ "tabbarHeight"
223
+ ]
160
224
  }
161
- });
162
- const topbarHeight = ref(layoutConfig.topbarHeight);
163
- const tabbarHeight = ref(layoutConfig.tabbarHeight);
164
- const headerHeight = computed(() => {
165
- return topbarHeight.value + (tabbarVisible.value ? tabbarHeight.value : 0);
166
- });
167
- return {
168
- sidebarVisible,
169
- collapse,
170
- isMobile,
171
- menuType,
172
- includeHorizontal,
173
- isVertical,
174
- isBiserial,
175
- isHorizontal,
176
- isHorizontalVertical,
177
- isHorizontalBiserial,
178
- menus,
179
- menusMap,
180
- firstLevelMenus,
181
- firstLevelActive,
182
- secondLevelMenus,
183
- secondLevelActive,
184
- thirdLevelMenus,
185
- topMenus,
186
- topActive,
187
- snugMenus,
188
- snugActive,
189
- defaultMenus,
190
- tabbarVisible,
191
- activeTab,
192
- refreshing,
193
- tabList,
194
- iframeTabList,
195
- keepAliveInclude,
196
- keepAliveExclude,
197
- keepAlive,
198
- updateKeepAliveInclude,
199
- reload,
200
- asideWidth,
201
- collapsedAsideWidth,
202
- snugAsideWidth,
203
- sidebarWidth,
204
- topbarHeight,
205
- tabbarHeight,
206
- headerHeight
207
- };
208
- });
225
+ }
226
+ );
209
227
 
210
228
  export { useLayoutStore };
@@ -0,0 +1,9 @@
1
+ import { type PiniaPluginContext } from 'pinia';
2
+ declare module 'pinia' {
3
+ interface DefineStoreOptionsBase<S, Store> {
4
+ persist?: {
5
+ pick: (keyof S)[];
6
+ };
7
+ }
8
+ }
9
+ export declare function piniaPluginPersist(context: PiniaPluginContext): void;
@@ -0,0 +1,22 @@
1
+ import { watch } from 'vue';
2
+ import { usePersist } from '../hooks/usePersist.js';
3
+
4
+ function piniaPluginPersist(context) {
5
+ const {
6
+ store,
7
+ options: { persist }
8
+ } = context;
9
+ const pickKeys = persist?.pick || [];
10
+ const persistIns = usePersist();
11
+ const persistKey = `Cosey:pinia:${store.$id}`;
12
+ const localData = persistIns.get(persistKey) || {};
13
+ store.$patch(localData);
14
+ watch(
15
+ pickKeys.map((key) => () => store[key]),
16
+ () => {
17
+ persistIns.set(persistKey, Object.fromEntries(pickKeys.map((key) => [key, store[key]])));
18
+ }
19
+ );
20
+ }
21
+
22
+ export { piniaPluginPersist };
package/store/user.d.ts CHANGED
@@ -35,5 +35,5 @@ export declare const useUserStore: import("pinia").StoreDefinition<"cosey-user",
35
35
  setAuthorization: () => Promise<void | undefined>;
36
36
  addDynamicRoutes: () => Promise<void>;
37
37
  logout: (lastPath?: string) => Promise<void>;
38
- }, "login" | "getUserInfo" | "changePassword" | "logout" | "setAuthorization" | "addDynamicRoutes">>;
38
+ }, "changePassword" | "login" | "logout" | "getUserInfo" | "setAuthorization" | "addDynamicRoutes">>;
39
39
  export {};
package/utils/css.d.ts CHANGED
@@ -9,6 +9,10 @@ export declare function setStyle(el: HTMLElement, style: {
9
9
  * 获取元素当前计算的样式
10
10
  */
11
11
  export declare function getStyle(el: HTMLElement, prop: keyof CSSStyleDeclaration): string | number | (() => ArrayIterator<string>) | CSSRule | ((property: string) => string) | ((property: string) => string) | ((index: number) => string) | ((property: string) => string) | ((property: string, value: string | null, priority?: string) => void) | null;
12
+ /**
13
+ *
14
+ */
15
+ export declare function getDir(el?: HTMLElement | null): string;
12
16
  /**
13
17
  * 获取元素内容盒子宽度
14
18
  */
package/utils/css.js CHANGED
@@ -9,8 +9,11 @@ function setStyle(el, style) {
9
9
  function getStyle(el, prop) {
10
10
  return window.getComputedStyle(el)[prop];
11
11
  }
12
+ function getDir(el) {
13
+ return el && getStyle(el, "direction") || "ltr";
14
+ }
12
15
  function getContextBoxWidth(el) {
13
- return el.clientWidth - parseFloat(getStyle(el, "paddingLeft")) - parseFloat(getStyle(el, "paddingRight"));
16
+ return el.clientWidth - parseFloat(getStyle(el, "paddingInlineStart")) - parseFloat(getStyle(el, "paddingInlineEnd"));
14
17
  }
15
18
  function cssObjectToString(cssObject) {
16
19
  return Object.entries(cssObject).map(([selector, style]) => {
@@ -23,4 +26,4 @@ function addPxUnit(value) {
23
26
  return isNumber(value) ? value + "px" : value;
24
27
  }
25
28
 
26
- export { addPxUnit, cssObjectToString, getContextBoxWidth, getStyle, setStyle };
29
+ export { addPxUnit, cssObjectToString, getContextBoxWidth, getDir, getStyle, setStyle };
@@ -3,35 +3,35 @@ const bookFormats = [
3
3
  type: "csv",
4
4
  ext: ".csv",
5
5
  sheets: "single",
6
- label: "CSV (\u9017\u53F7\u5206\u9694)",
6
+ label: "co.export.csvLabel",
7
7
  mime: "text/csv"
8
8
  },
9
9
  {
10
10
  type: "xlsx",
11
11
  ext: ".xlsx",
12
12
  sheets: "multi",
13
- label: "Microsoft Excel \u6587\u4EF6",
13
+ label: "co.export.xlsxLabel",
14
14
  mime: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
15
15
  },
16
16
  {
17
17
  type: "html",
18
18
  ext: ".html",
19
19
  sheets: "single",
20
- label: "\u7F51\u9875\u6587\u4EF6",
20
+ label: "co.export.htmlLabel",
21
21
  mime: "text/html"
22
22
  },
23
23
  {
24
24
  type: "xml",
25
25
  ext: ".xml",
26
26
  sheets: "single",
27
- label: "XML \u8868\u683C",
27
+ label: "co.export.xmlLabel",
28
28
  mime: "application/xml"
29
29
  },
30
30
  {
31
31
  type: "txt",
32
32
  ext: ".txt",
33
33
  sheets: "single",
34
- label: "Unicode \u6587\u672C",
34
+ label: "co.export.txtLabel",
35
35
  mime: "text/plain"
36
36
  }
37
37
  ];
@@ -39,11 +39,11 @@ async function wb2xlsx(wb, mime) {
39
39
  [
40
40
  `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>`,
41
41
  `<Properties xmlns="http://schemas.openxmlformats.org/officeDocument/2006/extended-properties" xmlns:vt="http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes">`,
42
- `<Application>WPS \u8868\u683C</Application>`,
42
+ `<Application>WPS Table</Application>`,
43
43
  `<HeadingPairs>`,
44
44
  `<vt:vector size="2" baseType="variant">`,
45
45
  `<vt:variant>`,
46
- `<vt:lpstr>\u5DE5\u4F5C\u8868</vt:lpstr>`,
46
+ `<vt:lpstr>Worksheet</vt:lpstr>`,
47
47
  `</vt:variant>`,
48
48
  `<vt:variant>`,
49
49
  `<vt:i4>${wb.sheets.length}</vt:i4>`,
package/utils/index.js CHANGED
@@ -2,7 +2,7 @@ export { arrayMove, isShallowEqual, toArray } from './array.js';
2
2
  export { getCssVarProp } from './bem.js';
3
3
  export { getControlKey } from './browser.js';
4
4
  export { getLabelByValue, getTreeLabelByValue } from './collection.js';
5
- export { addPxUnit, cssObjectToString, getContextBoxWidth, getStyle, setStyle } from './css.js';
5
+ export { addPxUnit, cssObjectToString, getContextBoxWidth, getDir, getStyle, setStyle } from './css.js';
6
6
  export { DATE_FORMAT, DATE_TIME_FORMAT, MONTH_FORMAT, TIME_FORMAT, YEAR_FORMAT, formatAsBasicDateTime, formatAsDate, formatAsDateTime, getDayjs } from './date.js';
7
7
  export { exportExcel } from './excel/index.js';
8
8
  export { chooseFiles, getFileType, readAsArrayBuffer, readAsDataURL } from './file.js';