@pubinfo/core 2.0.15 → 2.1.1
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/dist/{AppSetting-CF0Y36Kx.js → AppSetting-CmT5_15W.js} +17 -17
- package/dist/{HCheckList.vue_vue_type_script_setup_true_lang-B7ZyR4n6.js → HCheckList.vue_vue_type_script_setup_true_lang-CHzkJth7.js} +1 -1
- package/dist/{HToggle-Dap0xf8L.js → HToggle-DpDYLh8y.js} +1 -1
- package/dist/HeaderThinMenu-D6jF8yl1.js +4 -0
- package/dist/{PreferencesContent-DWHQ2EOo.js → PreferencesContent-AXqWatOF.js} +6 -6
- package/dist/{SettingBreadcrumb-P-C21e5U.js → SettingBreadcrumb-CBWdS_nO.js} +3 -3
- package/dist/{SettingCopyright-XUQuMUND.js → SettingCopyright-D5Jhdu1J.js} +2 -2
- package/dist/{SettingEnableTransition-hJTXOtuP.js → SettingEnableTransition-DQJozSZH.js} +2 -2
- package/dist/{SettingHome-1C9Ph1Dl.js → SettingHome-DAwn9Ypx.js} +3 -3
- package/dist/{SettingMenu-B2h4e61Z.js → SettingMenu-DEQRAtWl.js} +4 -4
- package/dist/{SettingMode-bStWvnHg.js → SettingMode-bh3I8UBZ.js} +1 -1
- package/dist/{SettingNavSearch-BvTlahqj.js → SettingNavSearch-iYc-eRzY.js} +3 -3
- package/dist/{SettingOther-ihHycIPn.js → SettingOther-C2TS6okv.js} +3 -3
- package/dist/{SettingPage-d8HGOfhZ.js → SettingPage-B2_SNyn5.js} +2 -2
- package/dist/{SettingTabbar-YLshyP8G.js → SettingTabbar-BETdKJxz.js} +6 -6
- package/dist/{SettingThemes-Do-SwCzx.js → SettingThemes-ComNCP3P.js} +16 -15
- package/dist/{SettingToolbar-DHbr1d6B.js → SettingToolbar-D0DTBbbb.js} +3 -3
- package/dist/{SettingTopbar-QwqH9maD.js → SettingTopbar-BcO5Hcxm.js} +4 -4
- package/dist/{SettingWidthMode-CGmv4JQk.js → SettingWidthMode-wzTMq96A.js} +2 -2
- package/dist/built-in/devtools/index.d.ts +13 -0
- package/dist/built-in/index.d.ts +1 -0
- package/dist/built-in/layout-component/Layout.vue.d.ts +7 -1
- package/dist/built-in/layout-component/components/Topbar/index.vue.d.ts +1 -1
- package/dist/built-in/layout-component/composables/useLayoutVisible.d.ts +8 -0
- package/dist/built-in/layout-component/interface.d.ts +22 -0
- package/dist/built-in/pinia-plugin/plugins/persist.d.ts +2 -2
- package/dist/built-in/pinia-plugin/plugins/persistedstate/index.d.ts +3 -0
- package/dist/built-in/pinia-plugin/plugins/persistedstate/persistedstate.d.ts +15 -0
- package/dist/built-in/pinia-plugin/plugins/persistedstate/types.d.ts +150 -0
- package/dist/built-in/pinia-plugin/plugins/persistedstate/utils.d.ts +17 -0
- package/dist/core/ctx.d.ts +1 -0
- package/dist/core/interface.d.ts +26 -1
- package/dist/core/utils/index.d.ts +2 -0
- package/dist/features/composables/index.d.ts +1 -0
- package/dist/features/composables/partyLogin.d.ts +7 -1
- package/dist/features/stores/modules/settings.d.ts +6 -6
- package/dist/features/stores/modules/user.d.ts +14 -2
- package/dist/{index-WLA0JU4Y.js → index-6W8u4oWQ.js} +1 -1
- package/dist/{index-CEodMjIg.js → index-B9i7R1pn.js} +4 -5
- package/dist/{index-Ctu3_aXu.js → index-BXLF9xfN.js} +17666 -17025
- package/dist/{index-egA-td8O.js → index-C5X0cH7a.js} +3 -3
- package/dist/{index-Da79wYQP.js → index-CMSPnrUx.js} +1 -1
- package/dist/index-DSKHePRb.js +4 -0
- package/dist/{index-B8wbywmR.js → index-FATjHAwl.js} +1 -1
- package/dist/{index-B69sIuLj.js → index-_VKoUSGo.js} +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +13 -12
- package/dist/{pick-BS5wr8z9.js → pick-BvMRfqim.js} +1 -1
- package/dist/{question-line-CfkciTFq.js → question-line-DCMVyZ3e.js} +2 -2
- package/dist/{right-Bfe2p1o0.js → right-aIVrXLnr.js} +4 -4
- package/dist/style.css +1 -1
- package/dist/utils/index.d.ts +0 -1
- package/package.json +10 -9
- package/src/built-in/devtools/index.ts +292 -0
- package/src/built-in/index.ts +1 -0
- package/src/built-in/layout-component/Layout.vue +93 -9
- package/src/built-in/layout-component/components/Header/index.vue +4 -11
- package/src/built-in/layout-component/components/Sidebar/MainSidebar.vue +3 -1
- package/src/built-in/layout-component/components/Sidebar/SubSidebar.vue +4 -21
- package/src/built-in/layout-component/components/Topbar/index.vue +4 -105
- package/src/built-in/layout-component/composables/useLayoutVisible.ts +87 -0
- package/src/built-in/layout-component/interface.ts +25 -0
- package/src/built-in/pinia-plugin/index.ts +2 -2
- package/src/built-in/pinia-plugin/plugins/persist.ts +15 -4
- package/src/built-in/pinia-plugin/plugins/persistedstate/README.md +551 -0
- package/src/built-in/pinia-plugin/plugins/persistedstate/index.ts +3 -0
- package/src/built-in/pinia-plugin/plugins/persistedstate/persistedstate.ts +575 -0
- package/src/built-in/pinia-plugin/plugins/persistedstate/types.ts +162 -0
- package/src/built-in/pinia-plugin/plugins/persistedstate/utils.ts +46 -0
- package/src/core/create.ts +1 -3
- package/src/core/ctx.ts +24 -1
- package/src/core/interface.ts +31 -1
- package/src/core/request.ts +0 -1
- package/src/core/resolver/icon.ts +1 -1
- package/src/core/utils/index.ts +2 -0
- package/src/features/assets/styles/globals.css +2 -1
- package/src/features/composables/index.ts +1 -0
- package/src/features/composables/log.ts +3 -5
- package/src/features/composables/partyLogin.ts +180 -38
- package/src/features/context/index.ts +1 -1
- package/src/features/stores/modules/keepAlive.ts +10 -14
- package/src/features/stores/modules/settings.ts +2 -7
- package/src/features/stores/modules/user.ts +57 -2
- package/src/index.ts +9 -5
- package/src/utils/index.ts +0 -1
- package/src/utils/proxy.ts +1 -1
- package/types/index.d.ts +1 -0
- package/types/pinia.d.ts +94 -0
- package/types/vue-router.d.ts +7 -0
- package/dist/HeaderThinMenu-Bu4X2-vs.js +0 -4
- package/dist/index-ondkWqUz.js +0 -4
- /package/dist/{utils → core/utils}/global.d.ts +0 -0
- /package/dist/core/{utils.d.ts → utils/utils.d.ts} +0 -0
- /package/src/{utils → core/utils}/global.ts +0 -0
- /package/src/core/{utils.ts → utils/utils.ts} +0 -0
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import {
|
|
3
|
-
import { useContext } from '../../composables/useContext';
|
|
2
|
+
import { useLayoutVisible } from '../../composables/useLayoutVisible';
|
|
4
3
|
import Tabbar from './Tabbar/index.vue';
|
|
5
4
|
import Toolbar from './Toolbar/index.vue';
|
|
6
5
|
|
|
@@ -8,110 +7,10 @@ defineOptions({
|
|
|
8
7
|
name: 'Topbar',
|
|
9
8
|
});
|
|
10
9
|
|
|
11
|
-
const {
|
|
12
|
-
const route = useRoute();
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* 计算属性:是否开启工具栏
|
|
16
|
-
*
|
|
17
|
-
* @return {boolean}
|
|
18
|
-
*/
|
|
19
|
-
const enableToolbar = computed(() => {
|
|
20
|
-
return !(
|
|
21
|
-
(
|
|
22
|
-
settingsStore.settings.menu.menuMode === 'head'
|
|
23
|
-
&& !settingsStore.settings.menu.enableSubMenuCollapseButton
|
|
24
|
-
&& !settingsStore.settings.favorites.enable
|
|
25
|
-
&& !settingsStore.settings.breadcrumb.enable
|
|
26
|
-
) || (
|
|
27
|
-
settingsStore.settings.menu.menuMode === 'only-head'
|
|
28
|
-
&& !settingsStore.settings.favorites.enable
|
|
29
|
-
&& !settingsStore.settings.breadcrumb.enable
|
|
30
|
-
)
|
|
31
|
-
);
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
// 统一在 Topbar 内控制是否渲染 Tabbar/Toolbar(结合全局设置与路由 meta)
|
|
35
|
-
const showTabbar = computed(() => {
|
|
36
|
-
// 路由可通过 meta.layout.tabs 显隐,默认显示
|
|
37
|
-
const routeAllow = (routeStore.getRemoteAppRouteById(route)?.meta as any)?.layout?.tabs ?? true;
|
|
38
|
-
return settingsStore.settings.tabbar.enable && routeAllow;
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
const showToolbar = computed(() => {
|
|
42
|
-
// 路由可通过 meta.layout.toolbar 显隐,默认显示
|
|
43
|
-
const routeAllow = (routeStore.getRemoteAppRouteById(route)?.meta as any)?.layout?.toolbar ?? true;
|
|
44
|
-
return enableToolbar.value && routeAllow;
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
const scrollTop = ref(0);
|
|
48
|
-
const scrollOnHide = ref(false);
|
|
49
|
-
const globalTabbarHeight = useCssVar('--g-tabbar-height', document.documentElement || document.body);
|
|
50
|
-
const globalToolBarHeight = useCssVar('--g-toolbar-height', document.documentElement || document.body);
|
|
51
|
-
|
|
52
|
-
const topbarHeight = computed(() => {
|
|
53
|
-
const tabbarHeight = showTabbar.value
|
|
54
|
-
? Number.parseInt(globalTabbarHeight.value!)
|
|
55
|
-
: 0;
|
|
56
|
-
const toolbarHeight = showToolbar.value
|
|
57
|
-
? Number.parseInt(globalToolBarHeight.value!)
|
|
58
|
-
: 0;
|
|
59
|
-
return tabbarHeight + toolbarHeight;
|
|
60
|
-
});
|
|
61
|
-
onMounted(() => {
|
|
62
|
-
window.addEventListener('scroll', onScroll);
|
|
63
|
-
});
|
|
64
|
-
onUnmounted(() => {
|
|
65
|
-
window.removeEventListener('scroll', onScroll);
|
|
66
|
-
});
|
|
67
|
-
function onScroll() {
|
|
68
|
-
scrollTop.value = (document.documentElement || document.body).scrollTop;
|
|
69
|
-
}
|
|
70
|
-
watch(scrollTop, (val, oldVal) => {
|
|
71
|
-
scrollOnHide.value = settingsStore.settings.topbar.mode === 'sticky' && val > oldVal && val > topbarHeight.value;
|
|
72
|
-
});
|
|
10
|
+
const { show } = useLayoutVisible();
|
|
73
11
|
</script>
|
|
74
12
|
|
|
75
13
|
<template>
|
|
76
|
-
<
|
|
77
|
-
|
|
78
|
-
:class="{
|
|
79
|
-
'has-tabbar': showTabbar,
|
|
80
|
-
'has-toolbar': showToolbar,
|
|
81
|
-
[`topbar-${settingsStore.settings.topbar.mode}`]: true,
|
|
82
|
-
'shadow': !settingsStore.settings.topbar.switchTabbarAndToolbar && scrollTop,
|
|
83
|
-
'hide': scrollOnHide,
|
|
84
|
-
'switch-tabbar-toolbar': settingsStore.settings.topbar.switchTabbarAndToolbar,
|
|
85
|
-
}"
|
|
86
|
-
data-fixed-calc-width
|
|
87
|
-
>
|
|
88
|
-
<Tabbar v-if="showTabbar" />
|
|
89
|
-
<Toolbar v-if="showToolbar" />
|
|
90
|
-
</div>
|
|
14
|
+
<Tabbar v-if="show.tabbar" />
|
|
15
|
+
<Toolbar v-if="show.toolbar" />
|
|
91
16
|
</template>
|
|
92
|
-
|
|
93
|
-
<style scoped>
|
|
94
|
-
.topbar-container {
|
|
95
|
-
--at-apply: absolute top-0 z-100 flex flex-col;
|
|
96
|
-
box-shadow: 0 1px 0 0 var(--g-border-color);
|
|
97
|
-
transition: width 0.3s, top 0.3s, transform 0.3s, box-shadow 0.3s;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
.topbar-container.topbar-fixed,
|
|
101
|
-
.topbar-container.topbar-sticky {
|
|
102
|
-
--at-apply: fixed;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
.topbar-container.topbar-fixed.shadow,
|
|
106
|
-
.topbar-container.topbar-sticky.shadow {
|
|
107
|
-
box-shadow: 0 10px 10px -10px var(--g-box-shadow-color);
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
.topbar-container.topbar-sticky.hide {
|
|
111
|
-
top: calc((var(--g-tabbar-height) + var(--g-toolbar-height)) * -1) !important;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
.topbar-container.switch-tabbar-toolbar {
|
|
115
|
-
flex-direction: column-reverse;
|
|
116
|
-
}
|
|
117
|
-
</style>
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import type { RouterMetaRawBaseOptions } from '#/vue-router';
|
|
2
|
+
import type { RequiredDeep } from 'type-fest';
|
|
3
|
+
import type { LayoutProps } from '../interface';
|
|
4
|
+
import { useContext } from './useContext';
|
|
5
|
+
|
|
6
|
+
const visibleInjectionKey = Symbol.for('pubinfo.layout.visible') as InjectionKey<LayoutProps>;
|
|
7
|
+
|
|
8
|
+
export function createLayoutVisible(props: LayoutProps) {
|
|
9
|
+
provide(visibleInjectionKey, props);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* 判断布局组件内各个部分的展示
|
|
14
|
+
*/
|
|
15
|
+
export function useLayoutVisible(_props?: LayoutProps) {
|
|
16
|
+
const { routeStore, settingsStore, menuStore } = useContext();
|
|
17
|
+
const props = inject(visibleInjectionKey, _props);
|
|
18
|
+
|
|
19
|
+
const route = useRoute();
|
|
20
|
+
|
|
21
|
+
const show = computed(() => {
|
|
22
|
+
// 应用级 meta.layout 配置
|
|
23
|
+
const appMetaData: RequiredDeep<RouterMetaRawBaseOptions['layout']> = {
|
|
24
|
+
header: true,
|
|
25
|
+
sidebar: true,
|
|
26
|
+
tabs: true,
|
|
27
|
+
toolbar: true,
|
|
28
|
+
...routeStore.getRemoteAppRouteById(route)?.meta?.layout,
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
// 侧边栏菜单的菜单数据
|
|
32
|
+
const sidebarMenus = menuStore.sidebarMenus;
|
|
33
|
+
|
|
34
|
+
// 菜单模式
|
|
35
|
+
const { menuMode, subMenuOnlyOneHide, enableSubMenuCollapseButton } = settingsStore.settings.menu;
|
|
36
|
+
|
|
37
|
+
const mode = settingsStore.mode;
|
|
38
|
+
const tabbarEnable = settingsStore.settings.tabbar.enable;
|
|
39
|
+
const favoritesEnable = settingsStore.settings.favorites.enable;
|
|
40
|
+
const breadcrumbEnable = settingsStore.settings.breadcrumb.enable;
|
|
41
|
+
|
|
42
|
+
return {
|
|
43
|
+
/** 顶部栏 */
|
|
44
|
+
header: mode === 'pc' && ['head', 'only-head'].includes(menuMode) && appMetaData.header && props?.showHeader,
|
|
45
|
+
|
|
46
|
+
/** 主侧边栏 */
|
|
47
|
+
mainSidebar: ((mode === 'mobile' && menuMode !== 'single') || ['side', 'only-side'].includes(menuMode)) && props?.showSidebar,
|
|
48
|
+
|
|
49
|
+
/** 副侧边栏 */
|
|
50
|
+
subSidebar: (
|
|
51
|
+
mode === 'mobile' || (
|
|
52
|
+
['side', 'head', 'single'].includes(menuMode)
|
|
53
|
+
&& sidebarMenus.length > 0
|
|
54
|
+
&& !(
|
|
55
|
+
subMenuOnlyOneHide
|
|
56
|
+
&& sidebarMenus.length === 1
|
|
57
|
+
&& (
|
|
58
|
+
!sidebarMenus[0].children
|
|
59
|
+
|| sidebarMenus[0]?.children.every(item => item.meta?.sidebar === false)
|
|
60
|
+
)
|
|
61
|
+
)
|
|
62
|
+
)
|
|
63
|
+
) && appMetaData.sidebar && props?.showSidebar,
|
|
64
|
+
|
|
65
|
+
/** 标签栏 */
|
|
66
|
+
tabbar: tabbarEnable && appMetaData.tabs && props?.showTabbar,
|
|
67
|
+
|
|
68
|
+
/** 工具栏 */
|
|
69
|
+
toolbar: !(
|
|
70
|
+
(
|
|
71
|
+
menuMode === 'head'
|
|
72
|
+
&& !enableSubMenuCollapseButton
|
|
73
|
+
&& !favoritesEnable
|
|
74
|
+
&& !breadcrumbEnable
|
|
75
|
+
) || (
|
|
76
|
+
menuMode === 'only-head'
|
|
77
|
+
&& !favoritesEnable
|
|
78
|
+
&& !breadcrumbEnable
|
|
79
|
+
)
|
|
80
|
+
) && appMetaData.toolbar && props?.showToolbar,
|
|
81
|
+
};
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
return {
|
|
85
|
+
show,
|
|
86
|
+
};
|
|
87
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export interface LayoutProps {
|
|
2
|
+
/**
|
|
3
|
+
* 是否展示头部
|
|
4
|
+
* @default true
|
|
5
|
+
*/
|
|
6
|
+
showHeader?: boolean
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* 是否展示侧边栏
|
|
10
|
+
* @default true
|
|
11
|
+
*/
|
|
12
|
+
showSidebar?: boolean
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* 是否展示标签栏
|
|
16
|
+
* @default true
|
|
17
|
+
*/
|
|
18
|
+
showTabbar?: boolean
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* 是否展示工具栏
|
|
22
|
+
* @default true
|
|
23
|
+
*/
|
|
24
|
+
showToolbar?: boolean
|
|
25
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { ModuleOptions } from '@/core';
|
|
2
|
-
import { createPersistedState } from 'pinia-plugin-persistedstate';
|
|
3
2
|
import { createCleanupPlugin } from './plugins/cleanup';
|
|
4
3
|
import { createFavoritesStoragePlugin } from './plugins/favoritesStorage';
|
|
5
4
|
import { createIframeCachePlugin } from './plugins/iframeCache';
|
|
6
5
|
import { createPersistedStateOptions } from './plugins/persist';
|
|
6
|
+
import { createSyncedPersistedState } from './plugins/persistedstate';
|
|
7
7
|
import { createTabbarStoragePlugin } from './plugins/tabbarStorage';
|
|
8
8
|
/**
|
|
9
9
|
* pinia 统一注册插件
|
|
@@ -15,7 +15,7 @@ export function PiniaPlugin(): ModuleOptions {
|
|
|
15
15
|
const { store } = ctx;
|
|
16
16
|
|
|
17
17
|
// 持久化
|
|
18
|
-
store.use(
|
|
18
|
+
store.use(createSyncedPersistedState(createPersistedStateOptions()));
|
|
19
19
|
|
|
20
20
|
// 各个store的副作用
|
|
21
21
|
store.use(createCleanupPlugin);
|
|
@@ -1,10 +1,20 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import {
|
|
1
|
+
import type { StateTree } from 'pinia';
|
|
2
|
+
import type { Serializer, SyncedPersistedStateOptions } from './persistedstate';
|
|
3
|
+
import { destr } from 'destr';
|
|
4
|
+
import { storage } from '../../../utils/storage';
|
|
3
5
|
|
|
4
6
|
export function customSerializer(): Serializer {
|
|
5
7
|
return {
|
|
6
8
|
deserialize: (value) => {
|
|
7
|
-
|
|
9
|
+
if (!value) {
|
|
10
|
+
return {};
|
|
11
|
+
}
|
|
12
|
+
const parsed = destr<StateTree | null>(value);
|
|
13
|
+
if (parsed && typeof parsed === 'object') {
|
|
14
|
+
return parsed;
|
|
15
|
+
}
|
|
16
|
+
console.warn('[pinia:persist] invalid persisted state detected, fallback to empty state');
|
|
17
|
+
return {};
|
|
8
18
|
},
|
|
9
19
|
serialize: (value) => {
|
|
10
20
|
return JSON.stringify(value);
|
|
@@ -12,10 +22,11 @@ export function customSerializer(): Serializer {
|
|
|
12
22
|
};
|
|
13
23
|
}
|
|
14
24
|
|
|
15
|
-
export function createPersistedStateOptions():
|
|
25
|
+
export function createPersistedStateOptions(): SyncedPersistedStateOptions {
|
|
16
26
|
return {
|
|
17
27
|
storage: storage.local,
|
|
18
28
|
key: id => `_${id}`,
|
|
19
29
|
serializer: customSerializer(),
|
|
30
|
+
storageArea: 'local',
|
|
20
31
|
};
|
|
21
32
|
}
|