@done-coding/forge-core 0.0.0-placeholder.0 → 0.100.0-alpha.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.
- package/LICENSE +21 -0
- package/README.md +49 -0
- package/es/_virtual/_plugin-vue_export-helper.mjs +10 -0
- package/es/bridge/badge.mjs +37 -0
- package/es/bridge/config-hook.mjs +58 -0
- package/es/bridge/contracts/event.mjs +102 -0
- package/es/bridge/contracts/index.mjs +5 -0
- package/es/bridge/event.mjs +87 -0
- package/es/bridge/index.mjs +331 -0
- package/es/bridge/layout.mjs +100 -0
- package/es/bridge/permission.mjs +91 -0
- package/es/bridge/plugin.mjs +39 -0
- package/es/bridge/route.mjs +78 -0
- package/es/bridge/state.mjs +61 -0
- package/es/bridge/storage.mjs +26 -0
- package/es/bridge/theme/index.mjs +233 -0
- package/es/bridge/theme/persist.mjs +18 -0
- package/es/bridge/theme/system-dark.mjs +18 -0
- package/es/components/basic/AppCollapseToggle.vue.mjs +7 -0
- package/es/components/basic/AppCollapseToggle.vue2.mjs +63 -0
- package/es/components/basic/action-btn/ActionBtn.vue.mjs +200 -0
- package/es/components/basic/action-btn/ActionBtn.vue2.mjs +4 -0
- package/es/components/basic/action-btn/index.mjs +4 -0
- package/es/components/basic/action-btn/use-action-btn-report.mjs +54 -0
- package/es/components/basic/action-btn-group/ActionBtnGroup.vue.mjs +69 -0
- package/es/components/basic/action-btn-group/ActionBtnGroup.vue2.mjs +4 -0
- package/es/components/basic/action-btn-group/index.mjs +4 -0
- package/es/components/basic/action-btn-group/use-action-btn-group-report.mjs +30 -0
- package/es/components/basic/display-contracts/index.mjs +1 -0
- package/es/components/basic/drag-float/DragFloat.vue.mjs +7 -0
- package/es/components/basic/drag-float/DragFloat.vue2.mjs +109 -0
- package/es/components/basic/drag-float/index.mjs +4 -0
- package/es/components/basic/height-provider/HeightProvider.vue.mjs +62 -0
- package/es/components/basic/height-provider/HeightProvider.vue2.mjs +4 -0
- package/es/components/basic/height-provider/index.mjs +4 -0
- package/es/components/basic/index.mjs +4 -0
- package/es/components/basic/shadow-clone/ShadowClone.vue.mjs +32 -0
- package/es/components/basic/shadow-clone/ShadowClone.vue2.mjs +4 -0
- package/es/components/basic/shadow-clone/index.mjs +4 -0
- package/es/components/basic/shadow-clone/use-shadow-target.mjs +76 -0
- package/es/components/basic/slot-layout-flow-aside/SlotLayoutFlowAside.vue.mjs +7 -0
- package/es/components/basic/slot-layout-flow-aside/SlotLayoutFlowAside.vue2.mjs +68 -0
- package/es/components/basic/slot-layout-flow-aside/index.mjs +4 -0
- package/es/components/basic/slot-layout-template/SlotLayoutTemplate.vue.mjs +30 -0
- package/es/components/basic/slot-layout-template/SlotLayoutTemplate.vue2.mjs +4 -0
- package/es/components/basic/slot-layout-template/index.mjs +4 -0
- package/es/components/basic/watch-size/WatchSize.vue.mjs +73 -0
- package/es/components/basic/watch-size/WatchSize.vue2.mjs +4 -0
- package/es/components/basic/watch-size/index.mjs +4 -0
- package/es/components/config/app-theme/AppTheme.vue.mjs +7 -0
- package/es/components/config/app-theme/AppTheme.vue2.mjs +82 -0
- package/es/components/config/app-theme/index.mjs +4 -0
- package/es/components/data/badge-mark/BadgeMark.vue.mjs +7 -0
- package/es/components/data/badge-mark/BadgeMark.vue2.mjs +80 -0
- package/es/components/data/badge-mark/index.mjs +4 -0
- package/es/components/data/badge-mark/use-badge-mask.mjs +82 -0
- package/es/components/data/badge-mark/use-badge.mjs +106 -0
- package/es/components/data/boolean-tag/BooleanTag.vue.mjs +36 -0
- package/es/components/data/boolean-tag/BooleanTag.vue2.mjs +4 -0
- package/es/components/data/boolean-tag/index.mjs +4 -0
- package/es/components/data/image-preview-trigger/ImagePreviewTrigger.vue.mjs +38 -0
- package/es/components/data/image-preview-trigger/ImagePreviewTrigger.vue2.mjs +4 -0
- package/es/components/data/image-preview-trigger/index.mjs +4 -0
- package/es/components/data/modal-image-preview/ModalImagePreview.vue.mjs +52 -0
- package/es/components/data/modal-image-preview/ModalImagePreview.vue2.mjs +4 -0
- package/es/components/data/modal-image-preview/index.mjs +4 -0
- package/es/components/feedback/action-confirm/ActionConfirm.vue.mjs +7 -0
- package/es/components/feedback/action-confirm/ActionConfirm.vue2.mjs +143 -0
- package/es/components/feedback/action-confirm/index.mjs +4 -0
- package/es/components/feedback/modal-confirm/ModalConfirm.vue.mjs +8 -0
- package/es/components/feedback/modal-confirm/ModalConfirm.vue2.mjs +243 -0
- package/es/components/feedback/modal-confirm/index.mjs +4 -0
- package/es/components/feedback/modal-video-preview/ModalVideoPreview.vue.mjs +8 -0
- package/es/components/feedback/modal-video-preview/ModalVideoPreview.vue2.mjs +93 -0
- package/es/components/feedback/modal-video-preview/index.mjs +4 -0
- package/es/components/feedback/preview-keys/index.mjs +7 -0
- package/es/components/feedback/preview-keys/keys.mjs +7 -0
- package/es/components/feedback/shelf-contracts/index.mjs +1 -0
- package/es/components/feedback/video-preview-trigger/VideoPreviewTrigger.vue.mjs +7 -0
- package/es/components/feedback/video-preview-trigger/VideoPreviewTrigger.vue2.mjs +133 -0
- package/es/components/feedback/video-preview-trigger/index.mjs +4 -0
- package/es/components/other/TriggerAutoImport.vue.mjs +12 -0
- package/es/components/other/TriggerAutoImport.vue2.mjs +4 -0
- package/es/components/other/auto-refresh/AutoRefresh.vue.mjs +7 -0
- package/es/components/other/auto-refresh/AutoRefresh.vue2.mjs +96 -0
- package/es/components/other/auto-refresh/index.mjs +4 -0
- package/es/components/other/auto-refresh/use-auto-refresh-report.mjs +31 -0
- package/es/components/other/auto-refresh-contracts/index.mjs +1 -0
- package/es/components/other/auto-refresh-group/AutoRefreshGroup.vue.mjs +7 -0
- package/es/components/other/auto-refresh-group/AutoRefreshGroup.vue2.mjs +69 -0
- package/es/components/other/auto-refresh-group/index.mjs +4 -0
- package/es/components/other/auto-refresh-group/use-auto-refresh-group-report.mjs +12 -0
- package/es/components/other/index.mjs +4 -0
- package/es/config/badge-attr.mjs +6 -0
- package/es/config/index.mjs +19 -0
- package/es/config/list-model.mjs +13 -0
- package/es/config/modal-keys.mjs +6 -0
- package/es/config/route.mjs +6 -0
- package/es/config/slot-region.mjs +45 -0
- package/es/helpers/form.mjs +25 -0
- package/es/helpers/index.mjs +10 -0
- package/es/helpers/list-helper.mjs +77 -0
- package/es/hooks/activated.mjs +64 -0
- package/es/hooks/feel-size.mjs +46 -0
- package/es/hooks/index.mjs +31 -0
- package/es/hooks/menus-dispatch.mjs +85 -0
- package/es/hooks/timeout.mjs +36 -0
- package/es/hooks/use-active-record.mjs +104 -0
- package/es/hooks/use-breakpoint.mjs +48 -0
- package/es/hooks/use-bridge-report.mjs +12 -0
- package/es/hooks/use-channel-viewport-height.mjs +43 -0
- package/es/hooks/use-context-defaults.mjs +44 -0
- package/es/hooks/use-custom-breakpoint.mjs +69 -0
- package/es/hooks/use-is-dev.mjs +16 -0
- package/es/hooks/use-observe-size.mjs +43 -0
- package/es/hooks/use-permission.mjs +12 -0
- package/es/hooks/use-surface.mjs +35 -0
- package/es/hooks/use-theme-apply.mjs +496 -0
- package/es/hooks/use-viewport-apply.mjs +52 -0
- package/es/index.mjs +179 -0
- package/es/inject/index.mjs +19 -0
- package/es/inject/key.mjs +70 -0
- package/es/injection-namespace.mjs +4 -0
- package/es/internals/index.mjs +16 -0
- package/es/router/group-redirect.mjs +26 -0
- package/es/router/guard/index.mjs +36 -0
- package/es/router/guard/login.mjs +6 -0
- package/es/router/guard/permission.mjs +6 -0
- package/es/router/index.mjs +10 -0
- package/es/store/app.mjs +306 -0
- package/es/store/index.mjs +8 -0
- package/es/store/router-permission.mjs +94 -0
- package/es/store/user.mjs +128 -0
- package/es/style.css +339 -0
- package/es/types/index.mjs +1 -0
- package/es/utils/dom.mjs +42 -0
- package/es/utils/export.mjs +39 -0
- package/es/utils/gap-scale.mjs +25 -0
- package/es/utils/id.mjs +7 -0
- package/es/utils/index.mjs +37 -0
- package/es/utils/permission.mjs +31 -0
- package/es/utils/router.mjs +42 -0
- package/es/utils/theme-scale.mjs +86 -0
- package/es/utils/time.mjs +24 -0
- package/package.json +232 -1
- package/types/bridge/badge.d.ts +215 -0
- package/types/bridge/config-hook.d.ts +12 -0
- package/types/bridge/contracts/bridge.d.ts +339 -0
- package/types/bridge/contracts/config.d.ts +519 -0
- package/types/bridge/contracts/event.d.ts +546 -0
- package/types/bridge/contracts/index.d.ts +3 -0
- package/types/bridge/event.d.ts +3 -0
- package/types/bridge/index.d.ts +28 -0
- package/types/bridge/layout.d.ts +102 -0
- package/types/bridge/permission.d.ts +31 -0
- package/types/bridge/plugin.d.ts +11 -0
- package/types/bridge/route.d.ts +36 -0
- package/types/bridge/state.d.ts +26 -0
- package/types/bridge/storage.d.ts +10 -0
- package/types/bridge/theme/index.d.ts +10 -0
- package/types/bridge/theme/persist.d.ts +23 -0
- package/types/bridge/theme/system-dark.d.ts +14 -0
- package/types/bridge/theme/types.d.ts +346 -0
- package/types/components/basic/AppCollapseToggle.vue.d.ts +14 -0
- package/types/components/basic/action-btn/ActionBtn.vue.d.ts +19 -0
- package/types/components/basic/action-btn/index.d.ts +1 -0
- package/types/components/basic/action-btn/use-action-btn-report.d.ts +12 -0
- package/types/components/basic/action-btn-group/ActionBtnGroup.vue.d.ts +18 -0
- package/types/components/basic/action-btn-group/index.d.ts +1 -0
- package/types/components/basic/action-btn-group/use-action-btn-group-report.d.ts +6 -0
- package/types/components/basic/display-contracts/index.d.ts +1 -0
- package/types/components/basic/display-contracts/types.d.ts +280 -0
- package/types/components/basic/drag-float/DragFloat.vue.d.ts +35 -0
- package/types/components/basic/drag-float/index.d.ts +1 -0
- package/types/components/basic/height-provider/HeightProvider.vue.d.ts +28 -0
- package/types/components/basic/height-provider/index.d.ts +1 -0
- package/types/components/basic/index.d.ts +1 -0
- package/types/components/basic/shadow-clone/ShadowClone.vue.d.ts +20 -0
- package/types/components/basic/shadow-clone/index.d.ts +1 -0
- package/types/components/basic/shadow-clone/use-shadow-target.d.ts +9 -0
- package/types/components/basic/slot-layout-flow-aside/SlotLayoutFlowAside.vue.d.ts +32 -0
- package/types/components/basic/slot-layout-flow-aside/index.d.ts +2 -0
- package/types/components/basic/slot-layout-flow-aside/types.d.ts +10 -0
- package/types/components/basic/slot-layout-template/SlotLayoutTemplate.vue.d.ts +48 -0
- package/types/components/basic/slot-layout-template/index.d.ts +1 -0
- package/types/components/basic/watch-size/WatchSize.vue.d.ts +45 -0
- package/types/components/basic/watch-size/index.d.ts +1 -0
- package/types/components/config/app-theme/AppTheme.vue.d.ts +2 -0
- package/types/components/config/app-theme/index.d.ts +1 -0
- package/types/components/data/badge-mark/BadgeMark.vue.d.ts +212 -0
- package/types/components/data/badge-mark/index.d.ts +1 -0
- package/types/components/data/badge-mark/use-badge-mask.d.ts +8 -0
- package/types/components/data/badge-mark/use-badge.d.ts +78 -0
- package/types/components/data/boolean-tag/BooleanTag.vue.d.ts +8 -0
- package/types/components/data/boolean-tag/index.d.ts +1 -0
- package/types/components/data/image-preview-trigger/ImagePreviewTrigger.vue.d.ts +41 -0
- package/types/components/data/image-preview-trigger/index.d.ts +1 -0
- package/types/components/data/modal-image-preview/ModalImagePreview.vue.d.ts +31 -0
- package/types/components/data/modal-image-preview/index.d.ts +1 -0
- package/types/components/feedback/action-confirm/ActionConfirm.vue.d.ts +33 -0
- package/types/components/feedback/action-confirm/index.d.ts +1 -0
- package/types/components/feedback/modal-confirm/ModalConfirm.vue.d.ts +120 -0
- package/types/components/feedback/modal-confirm/index.d.ts +2 -0
- package/types/components/feedback/modal-confirm/types.d.ts +4 -0
- package/types/components/feedback/modal-video-preview/ModalVideoPreview.vue.d.ts +40 -0
- package/types/components/feedback/modal-video-preview/index.d.ts +1 -0
- package/types/components/feedback/preview-keys/index.d.ts +2 -0
- package/types/components/feedback/preview-keys/keys.d.ts +14 -0
- package/types/components/feedback/shelf-contracts/index.d.ts +1 -0
- package/types/components/feedback/shelf-contracts/types.d.ts +1 -0
- package/types/components/feedback/video-preview-trigger/VideoPreviewTrigger.vue.d.ts +46 -0
- package/types/components/feedback/video-preview-trigger/index.d.ts +1 -0
- package/types/components/other/TriggerAutoImport.vue.d.ts +17 -0
- package/types/components/other/auto-refresh/AutoRefresh.vue.d.ts +14 -0
- package/types/components/other/auto-refresh/index.d.ts +1 -0
- package/types/components/other/auto-refresh/use-auto-refresh-report.d.ts +1 -0
- package/types/components/other/auto-refresh-contracts/index.d.ts +1 -0
- package/types/components/other/auto-refresh-contracts/types.d.ts +17 -0
- package/types/components/other/auto-refresh-group/AutoRefreshGroup.vue.d.ts +18 -0
- package/types/components/other/auto-refresh-group/index.d.ts +1 -0
- package/types/components/other/auto-refresh-group/use-auto-refresh-group-report.d.ts +3 -0
- package/types/components/other/index.d.ts +1 -0
- package/types/config/badge-attr.d.ts +26 -0
- package/types/config/index.d.ts +5 -0
- package/types/config/list-model.d.ts +49 -0
- package/types/config/modal-keys.d.ts +12 -0
- package/types/config/route.d.ts +4 -0
- package/types/config/slot-region.d.ts +72 -0
- package/types/helpers/form.d.ts +8 -0
- package/types/helpers/index.d.ts +3 -0
- package/types/helpers/list-helper.d.ts +35 -0
- package/types/helpers/types.d.ts +15 -0
- package/types/hooks/activated.d.ts +36 -0
- package/types/hooks/feel-size.d.ts +10 -0
- package/types/hooks/index.d.ts +12 -0
- package/types/hooks/menus-dispatch.d.ts +35 -0
- package/types/hooks/timeout.d.ts +7 -0
- package/types/hooks/use-active-record.d.ts +64 -0
- package/types/hooks/use-breakpoint.d.ts +4 -0
- package/types/hooks/use-bridge-report.d.ts +3 -0
- package/types/hooks/use-channel-viewport-height.d.ts +22 -0
- package/types/hooks/use-context-defaults.d.ts +39 -0
- package/types/hooks/use-custom-breakpoint.d.ts +17 -0
- package/types/hooks/use-is-dev.d.ts +24 -0
- package/types/hooks/use-observe-size.d.ts +36 -0
- package/types/hooks/use-permission.d.ts +14 -0
- package/types/hooks/use-surface.d.ts +45 -0
- package/types/hooks/use-theme-apply.d.ts +34 -0
- package/types/hooks/use-viewport-apply.d.ts +20 -0
- package/types/index.d.ts +33 -0
- package/types/inject/index.d.ts +1 -0
- package/types/inject/key.d.ts +247 -0
- package/types/injection-namespace.d.ts +4 -0
- package/types/internals/index.d.ts +6 -0
- package/types/router/group-redirect.d.ts +14 -0
- package/types/router/guard/index.d.ts +20 -0
- package/types/router/guard/login.d.ts +4 -0
- package/types/router/guard/permission.d.ts +4 -0
- package/types/router/guard/types.d.ts +14 -0
- package/types/router/index.d.ts +2 -0
- package/types/store/app.d.ts +219 -0
- package/types/store/index.d.ts +3 -0
- package/types/store/router-permission.d.ts +79 -0
- package/types/store/user.d.ts +64 -0
- package/types/types/app-layout.d.ts +42 -0
- package/types/types/dc-path.d.ts +2 -0
- package/types/types/dot-path.d.ts +13 -0
- package/types/types/index.d.ts +9 -0
- package/types/types/list-api.d.ts +17 -0
- package/types/types/modal-shelf.d.ts +123 -0
- package/types/types/nest-form.d.ts +8 -0
- package/types/types/permission.d.ts +31 -0
- package/types/types/route.d.ts +141 -0
- package/types/types/utility-types.d.ts +25 -0
- package/types/utils/dom.d.ts +61 -0
- package/types/utils/export.d.ts +35 -0
- package/types/utils/gap-scale.d.ts +46 -0
- package/types/utils/id.d.ts +2 -0
- package/types/utils/index.d.ts +8 -0
- package/types/utils/permission.d.ts +16 -0
- package/types/utils/router.d.ts +18 -0
- package/types/utils/theme-scale.d.ts +78 -0
- package/types/utils/time.d.ts +2 -0
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { ref, computed, watch, reactive } from "vue";
|
|
2
|
+
import _cloneDeep from "lodash/cloneDeep.js";
|
|
3
|
+
const createUseState = (factoryNamespace) => {
|
|
4
|
+
return (initState, { debug, moduleKey, cache, storage = localStorage } = {
|
|
5
|
+
debug: false,
|
|
6
|
+
moduleKey: ""
|
|
7
|
+
}) => {
|
|
8
|
+
const cacheKey = `${factoryNamespace}/useState/${moduleKey}`;
|
|
9
|
+
let cacheState;
|
|
10
|
+
if (cache) {
|
|
11
|
+
const str = storage.getItem(cacheKey);
|
|
12
|
+
try {
|
|
13
|
+
cacheState = JSON.parse(str ?? "");
|
|
14
|
+
} catch (e) {
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
const stateInit = typeof initState === "function" ? initState() : initState;
|
|
18
|
+
const getStateInit = () => _cloneDeep(stateInit);
|
|
19
|
+
const stateBase = ref(cacheState ? cacheState : getStateInit());
|
|
20
|
+
const state = computed(() => stateBase.value);
|
|
21
|
+
const resetState = () => {
|
|
22
|
+
stateBase.value = getStateInit();
|
|
23
|
+
debug && console.log(`[useState]
|
|
24
|
+
重置 ${moduleKey} store 状态属性
|
|
25
|
+
`);
|
|
26
|
+
};
|
|
27
|
+
const updateState = (newStateObj = {}) => {
|
|
28
|
+
Object.entries(newStateObj).forEach(([key, newState]) => {
|
|
29
|
+
const currentState = stateBase.value;
|
|
30
|
+
const oldState = currentState[key];
|
|
31
|
+
if (oldState !== newState) {
|
|
32
|
+
debug && console.log(`[useState]
|
|
33
|
+
${moduleKey} ${key} 变化更新: ${oldState} => ${newState}
|
|
34
|
+
`);
|
|
35
|
+
currentState[key] = newState;
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
if (cache) {
|
|
40
|
+
watch(
|
|
41
|
+
stateBase,
|
|
42
|
+
(n) => {
|
|
43
|
+
storage == null ? void 0 : storage.setItem(cacheKey, JSON.stringify(n));
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
deep: true,
|
|
47
|
+
immediate: true
|
|
48
|
+
}
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
return reactive({
|
|
52
|
+
state,
|
|
53
|
+
getStateInit,
|
|
54
|
+
resetState,
|
|
55
|
+
updateState
|
|
56
|
+
});
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
export {
|
|
60
|
+
createUseState
|
|
61
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
const createStorageWithNamespace = (namespace) => {
|
|
2
|
+
const getKeyFinal = (key) => `${namespace}/${key}`;
|
|
3
|
+
return {
|
|
4
|
+
setItem: (key, value) => {
|
|
5
|
+
return localStorage.setItem(getKeyFinal(key), value);
|
|
6
|
+
},
|
|
7
|
+
getItem: (key) => {
|
|
8
|
+
return localStorage.getItem(getKeyFinal(key));
|
|
9
|
+
},
|
|
10
|
+
removeItem: (key) => {
|
|
11
|
+
return localStorage.removeItem(getKeyFinal(key));
|
|
12
|
+
},
|
|
13
|
+
clear: () => {
|
|
14
|
+
return localStorage.clear();
|
|
15
|
+
},
|
|
16
|
+
key: (index) => {
|
|
17
|
+
return localStorage.key(index);
|
|
18
|
+
},
|
|
19
|
+
get length() {
|
|
20
|
+
return localStorage.length;
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
export {
|
|
25
|
+
createStorageWithNamespace
|
|
26
|
+
};
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
import { ref, computed, readonly, markRaw } from "vue";
|
|
2
|
+
import { DEFAULT_STORAGE_KEY, readPersist } from "./persist.mjs";
|
|
3
|
+
import { readSystemPrefersDark, watchSystemPrefersDark } from "./system-dark.mjs";
|
|
4
|
+
const DEFAULT_STYLE = "default";
|
|
5
|
+
const DEFAULT_MODE = "light";
|
|
6
|
+
const DEFAULT_LABEL = "默认";
|
|
7
|
+
const DEFAULT_DENSITY = "cozy";
|
|
8
|
+
const DEFAULT_MOTION = "standard";
|
|
9
|
+
const snapshotConfig = (config) => ({
|
|
10
|
+
light: { ...config.light },
|
|
11
|
+
dark: { ...config.dark }
|
|
12
|
+
});
|
|
13
|
+
function createBridgeThemeHook(init) {
|
|
14
|
+
var _a;
|
|
15
|
+
const storageKey = init.storageKey ?? DEFAULT_STORAGE_KEY;
|
|
16
|
+
const styleMap = /* @__PURE__ */ new Map();
|
|
17
|
+
const layoutMap = /* @__PURE__ */ new Map();
|
|
18
|
+
const hookMap = /* @__PURE__ */ new Map();
|
|
19
|
+
const rhythmMap = /* @__PURE__ */ new Map();
|
|
20
|
+
const themeStyle = ref(DEFAULT_STYLE);
|
|
21
|
+
const themeMode = ref(init.defaultMode ?? DEFAULT_MODE);
|
|
22
|
+
const systemPrefersDark = ref(readSystemPrefersDark());
|
|
23
|
+
const themeDarkOverride = ref(void 0);
|
|
24
|
+
const themeIsDark = computed(
|
|
25
|
+
() => themeDarkOverride.value ?? (themeMode.value === "system" ? systemPrefersDark.value : themeMode.value === "dark")
|
|
26
|
+
);
|
|
27
|
+
watchSystemPrefersDark((isDark) => {
|
|
28
|
+
systemPrefersDark.value = isDark;
|
|
29
|
+
});
|
|
30
|
+
const themeLayout = ref({
|
|
31
|
+
shell: void 0,
|
|
32
|
+
extractLevel1ToHeader: false
|
|
33
|
+
});
|
|
34
|
+
const themeDensity = ref(DEFAULT_DENSITY);
|
|
35
|
+
const themeMotion = ref(DEFAULT_MOTION);
|
|
36
|
+
const themeList = ref([]);
|
|
37
|
+
const themeLabels = ref({});
|
|
38
|
+
const themeDescriptions = ref({});
|
|
39
|
+
let desiredStyle = DEFAULT_STYLE;
|
|
40
|
+
const persisted = readPersist(init.storage, storageKey);
|
|
41
|
+
if (persisted) {
|
|
42
|
+
if (typeof persisted.themeStyle === "string" && persisted.themeStyle) {
|
|
43
|
+
desiredStyle = persisted.themeStyle;
|
|
44
|
+
}
|
|
45
|
+
if (persisted.themeMode === "light" || persisted.themeMode === "dark" || persisted.themeMode === "system") {
|
|
46
|
+
themeMode.value = persisted.themeMode;
|
|
47
|
+
} else if (typeof persisted.themeIsDark === "boolean") {
|
|
48
|
+
themeMode.value = persisted.themeIsDark ? "dark" : "light";
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
const persist = () => {
|
|
52
|
+
init.storage.setItem(
|
|
53
|
+
storageKey,
|
|
54
|
+
JSON.stringify({
|
|
55
|
+
themeStyle: themeStyle.value,
|
|
56
|
+
themeMode: themeMode.value
|
|
57
|
+
})
|
|
58
|
+
);
|
|
59
|
+
};
|
|
60
|
+
const refreshList = () => {
|
|
61
|
+
themeList.value = Array.from(styleMap.keys());
|
|
62
|
+
};
|
|
63
|
+
const applyConfig = (config) => {
|
|
64
|
+
init.update("APP_THEME_CONFIG", { light: config.light, dark: config.dark });
|
|
65
|
+
};
|
|
66
|
+
const applyLayout = (layout, presetId = "") => {
|
|
67
|
+
const baseline = init.layoutBaseline;
|
|
68
|
+
if (baseline) {
|
|
69
|
+
init.update("APP_LAYOUT_HEADER_CONFIG", { ...baseline.header });
|
|
70
|
+
init.update("APP_LAYOUT_FOOTER_CONFIG", { ...baseline.footer });
|
|
71
|
+
init.update("APP_LAYOUT_SIDEBAR_CONFIG", { ...baseline.sidebar });
|
|
72
|
+
init.update("APP_LAYOUT_ASIDE_CONFIG", { ...baseline.aside });
|
|
73
|
+
init.update("APP_LAYOUT_BREADCRUMB_CONFIG", { ...baseline.breadcrumb });
|
|
74
|
+
init.update("APP_LAYOUT_BODY_CONFIG", { ...baseline.body });
|
|
75
|
+
init.update("APP_LAYOUT_VIEWPORT_CONFIG", { ...baseline.viewport });
|
|
76
|
+
init.update("APP_LAYOUT_GAP_CONFIG", { ...baseline.gap });
|
|
77
|
+
}
|
|
78
|
+
if (layout) {
|
|
79
|
+
if (layout.header) init.update("APP_LAYOUT_HEADER_CONFIG", layout.header);
|
|
80
|
+
if (layout.footer) init.update("APP_LAYOUT_FOOTER_CONFIG", layout.footer);
|
|
81
|
+
if (layout.sidebar)
|
|
82
|
+
init.update("APP_LAYOUT_SIDEBAR_CONFIG", layout.sidebar);
|
|
83
|
+
if (layout.aside) init.update("APP_LAYOUT_ASIDE_CONFIG", layout.aside);
|
|
84
|
+
if (layout.breadcrumb)
|
|
85
|
+
init.update("APP_LAYOUT_BREADCRUMB_CONFIG", layout.breadcrumb);
|
|
86
|
+
if (layout.body) {
|
|
87
|
+
const { shimPadding, ...bodyRest } = layout.body;
|
|
88
|
+
if (shimPadding) {
|
|
89
|
+
console.warn(
|
|
90
|
+
`[dc-layout] 主题预设「${presetId}」的 layout.body.shimPadding(${shimPadding})已废弃且**不再影响任何渲染**,已忽略。内容四周留白改由间距阶梯的外圈档(gap × 2)给出 —— 预设要调留白请改自己的 layout.gap.size。本字段将在下一个版本移除。`
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
init.update("APP_LAYOUT_BODY_CONFIG", bodyRest);
|
|
94
|
+
}
|
|
95
|
+
if (layout.viewport)
|
|
96
|
+
init.update("APP_LAYOUT_VIEWPORT_CONFIG", layout.viewport);
|
|
97
|
+
if (layout.gap) init.update("APP_LAYOUT_GAP_CONFIG", layout.gap);
|
|
98
|
+
}
|
|
99
|
+
themeLayout.value = {
|
|
100
|
+
shell: (layout == null ? void 0 : layout.shell) ? markRaw(layout.shell) : void 0,
|
|
101
|
+
extractLevel1ToHeader: (layout == null ? void 0 : layout.extractLevel1ToHeader) ?? false
|
|
102
|
+
};
|
|
103
|
+
};
|
|
104
|
+
const fireHook = (fn, id) => {
|
|
105
|
+
if (!fn) return;
|
|
106
|
+
try {
|
|
107
|
+
fn({ id });
|
|
108
|
+
} catch (e) {
|
|
109
|
+
console.warn("[dc-theme] lifecycle hook error", e);
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
const setStyle = (name) => {
|
|
113
|
+
var _a2, _b;
|
|
114
|
+
const config = styleMap.get(name);
|
|
115
|
+
const target = config ? name : DEFAULT_STYLE;
|
|
116
|
+
const targetConfig = config ?? styleMap.get(DEFAULT_STYLE);
|
|
117
|
+
if (!targetConfig) return;
|
|
118
|
+
const prev = themeStyle.value;
|
|
119
|
+
if (prev === target) return;
|
|
120
|
+
fireHook((_a2 = hookMap.get(prev)) == null ? void 0 : _a2.onDeactivate, prev);
|
|
121
|
+
applyConfig(targetConfig);
|
|
122
|
+
applyLayout(layoutMap.get(target), target);
|
|
123
|
+
const rhythm = rhythmMap.get(target);
|
|
124
|
+
themeDensity.value = (rhythm == null ? void 0 : rhythm.density) ?? DEFAULT_DENSITY;
|
|
125
|
+
themeMotion.value = (rhythm == null ? void 0 : rhythm.motion) ?? DEFAULT_MOTION;
|
|
126
|
+
themeStyle.value = target;
|
|
127
|
+
fireHook((_b = hookMap.get(target)) == null ? void 0 : _b.onActivate, target);
|
|
128
|
+
persist();
|
|
129
|
+
};
|
|
130
|
+
const setMode = (mode) => {
|
|
131
|
+
themeMode.value = mode;
|
|
132
|
+
persist();
|
|
133
|
+
};
|
|
134
|
+
const setDark = (isDark) => {
|
|
135
|
+
setMode(isDark ? "dark" : "light");
|
|
136
|
+
};
|
|
137
|
+
const setDarkOverride = (isDark) => {
|
|
138
|
+
themeDarkOverride.value = isDark;
|
|
139
|
+
};
|
|
140
|
+
const setDensity = (density) => {
|
|
141
|
+
themeDensity.value = density;
|
|
142
|
+
};
|
|
143
|
+
const setMotion = (motion) => {
|
|
144
|
+
themeMotion.value = motion;
|
|
145
|
+
};
|
|
146
|
+
const add = (name, preset) => {
|
|
147
|
+
styleMap.set(name, snapshotConfig(preset.config));
|
|
148
|
+
if (preset.layout) {
|
|
149
|
+
layoutMap.set(name, preset.layout);
|
|
150
|
+
} else {
|
|
151
|
+
layoutMap.delete(name);
|
|
152
|
+
}
|
|
153
|
+
if (preset.onActivate || preset.onDeactivate) {
|
|
154
|
+
hookMap.set(name, {
|
|
155
|
+
onActivate: preset.onActivate,
|
|
156
|
+
onDeactivate: preset.onDeactivate
|
|
157
|
+
});
|
|
158
|
+
} else {
|
|
159
|
+
hookMap.delete(name);
|
|
160
|
+
}
|
|
161
|
+
if (preset.density || preset.motion) {
|
|
162
|
+
rhythmMap.set(name, {
|
|
163
|
+
density: preset.density,
|
|
164
|
+
motion: preset.motion
|
|
165
|
+
});
|
|
166
|
+
} else {
|
|
167
|
+
rhythmMap.delete(name);
|
|
168
|
+
}
|
|
169
|
+
themeLabels.value = { ...themeLabels.value, [name]: preset.label ?? name };
|
|
170
|
+
if (preset.description !== void 0) {
|
|
171
|
+
themeDescriptions.value = {
|
|
172
|
+
...themeDescriptions.value,
|
|
173
|
+
[name]: preset.description
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
refreshList();
|
|
177
|
+
if (name === desiredStyle && themeStyle.value !== desiredStyle) {
|
|
178
|
+
setStyle(name);
|
|
179
|
+
}
|
|
180
|
+
};
|
|
181
|
+
const remove = (name) => {
|
|
182
|
+
if (name === DEFAULT_STYLE) return;
|
|
183
|
+
if (!styleMap.delete(name)) return;
|
|
184
|
+
layoutMap.delete(name);
|
|
185
|
+
rhythmMap.delete(name);
|
|
186
|
+
const nextLabels = { ...themeLabels.value };
|
|
187
|
+
delete nextLabels[name];
|
|
188
|
+
themeLabels.value = nextLabels;
|
|
189
|
+
const nextDescriptions = { ...themeDescriptions.value };
|
|
190
|
+
delete nextDescriptions[name];
|
|
191
|
+
themeDescriptions.value = nextDescriptions;
|
|
192
|
+
refreshList();
|
|
193
|
+
if (themeStyle.value === name) setStyle(DEFAULT_STYLE);
|
|
194
|
+
hookMap.delete(name);
|
|
195
|
+
};
|
|
196
|
+
const labelOf = (name) => themeLabels.value[name] ?? name;
|
|
197
|
+
const descriptionOf = (name) => themeDescriptions.value[name];
|
|
198
|
+
add(DEFAULT_STYLE, {
|
|
199
|
+
config: init.initConfig,
|
|
200
|
+
label: DEFAULT_LABEL,
|
|
201
|
+
description: {
|
|
202
|
+
suitable: "常规中后台:左 sidebar 主导航 + 顶 header,表单 / 列表密集型管理应用。",
|
|
203
|
+
unsuitable: "需沉浸式边框 / 右侧上下文面板 / 一级模块横向切换的应用(宜用带布局变更的 preset)。"
|
|
204
|
+
}
|
|
205
|
+
});
|
|
206
|
+
const initialStyle = themeStyle.value;
|
|
207
|
+
fireHook((_a = hookMap.get(initialStyle)) == null ? void 0 : _a.onActivate, initialStyle);
|
|
208
|
+
return {
|
|
209
|
+
theme: {
|
|
210
|
+
add,
|
|
211
|
+
remove,
|
|
212
|
+
setStyle,
|
|
213
|
+
setMode,
|
|
214
|
+
setDark,
|
|
215
|
+
setDarkOverride,
|
|
216
|
+
setDensity,
|
|
217
|
+
setMotion,
|
|
218
|
+
list: readonly(themeList),
|
|
219
|
+
labelOf,
|
|
220
|
+
descriptionOf
|
|
221
|
+
},
|
|
222
|
+
themeStyle: readonly(themeStyle),
|
|
223
|
+
themeMode: readonly(themeMode),
|
|
224
|
+
// themeIsDark 为 computed(已只读),直接返回;与 DeepReadonly<Ref<boolean>> 契约相容。
|
|
225
|
+
themeIsDark,
|
|
226
|
+
themeLayout: readonly(themeLayout),
|
|
227
|
+
themeDensity: readonly(themeDensity),
|
|
228
|
+
themeMotion: readonly(themeMotion)
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
export {
|
|
232
|
+
createBridgeThemeHook
|
|
233
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
const DEFAULT_STORAGE_KEY = "dc-core-theme";
|
|
2
|
+
const readPersist = (storage, key) => {
|
|
3
|
+
const raw = storage.getItem(key);
|
|
4
|
+
if (!raw) return null;
|
|
5
|
+
try {
|
|
6
|
+
const parsed = JSON.parse(raw);
|
|
7
|
+
if (parsed && typeof parsed === "object") {
|
|
8
|
+
return parsed;
|
|
9
|
+
}
|
|
10
|
+
return null;
|
|
11
|
+
} catch {
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
export {
|
|
16
|
+
DEFAULT_STORAGE_KEY,
|
|
17
|
+
readPersist
|
|
18
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
const readSystemPrefersDark = () => {
|
|
2
|
+
if (typeof window === "undefined" || typeof window.matchMedia !== "function")
|
|
3
|
+
return false;
|
|
4
|
+
return window.matchMedia("(prefers-color-scheme: dark)").matches;
|
|
5
|
+
};
|
|
6
|
+
const watchSystemPrefersDark = (cb) => {
|
|
7
|
+
if (typeof window === "undefined" || typeof window.matchMedia !== "function")
|
|
8
|
+
return () => {
|
|
9
|
+
};
|
|
10
|
+
const mql = window.matchMedia("(prefers-color-scheme: dark)");
|
|
11
|
+
const handler = (e) => cb(e.matches);
|
|
12
|
+
mql.addEventListener("change", handler);
|
|
13
|
+
return () => mql.removeEventListener("change", handler);
|
|
14
|
+
};
|
|
15
|
+
export {
|
|
16
|
+
readSystemPrefersDark,
|
|
17
|
+
watchSystemPrefersDark
|
|
18
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import _sfc_main from "./AppCollapseToggle.vue2.mjs";
|
|
2
|
+
/* empty css */
|
|
3
|
+
import _export_sfc from "../../_virtual/_plugin-vue_export-helper.mjs";
|
|
4
|
+
const AppCollapseToggle = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-eb97134e"]]);
|
|
5
|
+
export {
|
|
6
|
+
AppCollapseToggle as default
|
|
7
|
+
};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { defineComponent, computed, openBlock, createBlock, unref, withCtx, createElementVNode, withKeys, withModifiers, normalizeClass, createVNode, normalizeStyle, createCommentVNode } from "vue";
|
|
2
|
+
import { ElTooltip, ElIcon } from "element-plus";
|
|
3
|
+
import { ArrowRightBold } from "@element-plus/icons-vue";
|
|
4
|
+
const _hoisted_1 = ["aria-label"];
|
|
5
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
6
|
+
__name: "AppCollapseToggle",
|
|
7
|
+
props: {
|
|
8
|
+
side: {},
|
|
9
|
+
collapse: { type: Boolean },
|
|
10
|
+
show: { type: Boolean }
|
|
11
|
+
},
|
|
12
|
+
emits: ["toggle"],
|
|
13
|
+
setup(__props, { emit: __emit }) {
|
|
14
|
+
const props = __props;
|
|
15
|
+
const emit = __emit;
|
|
16
|
+
const placement = computed(() => props.side === "sidebar" ? "right" : "left");
|
|
17
|
+
const iconStyle = computed(() => {
|
|
18
|
+
const deg = props.side === "sidebar" ? props.collapse ? 0 : 180 : props.collapse ? 180 : 0;
|
|
19
|
+
return { transform: `rotate(${deg}deg)` };
|
|
20
|
+
});
|
|
21
|
+
return (_ctx, _cache) => {
|
|
22
|
+
return __props.show ? (openBlock(), createBlock(unref(ElTooltip), {
|
|
23
|
+
key: 0,
|
|
24
|
+
content: __props.collapse ? "展开" : "收起",
|
|
25
|
+
placement: placement.value,
|
|
26
|
+
"show-after": 200
|
|
27
|
+
}, {
|
|
28
|
+
default: withCtx(() => [
|
|
29
|
+
createElementVNode("div", {
|
|
30
|
+
class: normalizeClass([
|
|
31
|
+
"dc-collapse-toggle",
|
|
32
|
+
`dc-collapse-toggle--${__props.side}`,
|
|
33
|
+
"app-collapse-toggle",
|
|
34
|
+
`app-collapse-toggle--${__props.side}`
|
|
35
|
+
]),
|
|
36
|
+
role: "button",
|
|
37
|
+
tabindex: "0",
|
|
38
|
+
"aria-label": __props.collapse ? "展开" : "收起",
|
|
39
|
+
onClick: _cache[0] || (_cache[0] = ($event) => emit("toggle")),
|
|
40
|
+
onKeydown: [
|
|
41
|
+
_cache[1] || (_cache[1] = withKeys(withModifiers(($event) => emit("toggle"), ["prevent"]), ["enter"])),
|
|
42
|
+
_cache[2] || (_cache[2] = withKeys(withModifiers(($event) => emit("toggle"), ["prevent"]), ["space"]))
|
|
43
|
+
]
|
|
44
|
+
}, [
|
|
45
|
+
createVNode(unref(ElIcon), null, {
|
|
46
|
+
default: withCtx(() => [
|
|
47
|
+
createVNode(unref(ArrowRightBold), {
|
|
48
|
+
class: "app-collapse-toggle__icon",
|
|
49
|
+
style: normalizeStyle(iconStyle.value)
|
|
50
|
+
}, null, 8, ["style"])
|
|
51
|
+
]),
|
|
52
|
+
_: 1
|
|
53
|
+
})
|
|
54
|
+
], 42, _hoisted_1)
|
|
55
|
+
]),
|
|
56
|
+
_: 1
|
|
57
|
+
}, 8, ["content", "placement"])) : createCommentVNode("", true);
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
export {
|
|
62
|
+
_sfc_main as default
|
|
63
|
+
};
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import { defineComponent, toRefs, getCurrentInstance, ref, computed, openBlock, createBlock, unref, withCtx, createVNode, mergeProps, renderSlot } from "vue";
|
|
2
|
+
import { useActionBtnReport } from "./use-action-btn-report.mjs";
|
|
3
|
+
import { ElButton } from "element-plus";
|
|
4
|
+
import ActionConfirm from "../../feedback/action-confirm/ActionConfirm.vue.mjs";
|
|
5
|
+
import BadgeMark from "../../data/badge-mark/BadgeMark.vue.mjs";
|
|
6
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
7
|
+
...{ inheritAttrs: false },
|
|
8
|
+
__name: "ActionBtn",
|
|
9
|
+
props: {
|
|
10
|
+
size: {},
|
|
11
|
+
disabled: { type: Boolean },
|
|
12
|
+
type: { default: "default" },
|
|
13
|
+
icon: {},
|
|
14
|
+
nativeType: {},
|
|
15
|
+
loadingIcon: {},
|
|
16
|
+
plain: { type: Boolean },
|
|
17
|
+
text: { type: Boolean },
|
|
18
|
+
link: { type: Boolean },
|
|
19
|
+
bg: { type: Boolean },
|
|
20
|
+
autofocus: { type: Boolean },
|
|
21
|
+
round: { type: Boolean },
|
|
22
|
+
circle: { type: Boolean },
|
|
23
|
+
dashed: { type: Boolean },
|
|
24
|
+
color: {},
|
|
25
|
+
dark: { type: Boolean },
|
|
26
|
+
autoInsertSpace: { type: Boolean },
|
|
27
|
+
tag: {},
|
|
28
|
+
groupMeta: {},
|
|
29
|
+
confirmMode: {},
|
|
30
|
+
confirmConfig: {},
|
|
31
|
+
beforeOpen: {},
|
|
32
|
+
badgeKey: {}
|
|
33
|
+
},
|
|
34
|
+
emits: ["click"],
|
|
35
|
+
setup(__props) {
|
|
36
|
+
const props = __props;
|
|
37
|
+
const { confirmConfig, confirmMode, beforeOpen } = toRefs(props);
|
|
38
|
+
const instance = getCurrentInstance();
|
|
39
|
+
const innerLoading = ref(false);
|
|
40
|
+
const confirmVisible = ref(false);
|
|
41
|
+
const resolvedConfig = ref();
|
|
42
|
+
const {
|
|
43
|
+
reportActionClick,
|
|
44
|
+
reportConfirmOpen,
|
|
45
|
+
reportConfirmClose,
|
|
46
|
+
runConfirmSubmit
|
|
47
|
+
} = useActionBtnReport(() => ({
|
|
48
|
+
type: props.type,
|
|
49
|
+
groupMeta: props.groupMeta,
|
|
50
|
+
config: resolvedConfig.value
|
|
51
|
+
}));
|
|
52
|
+
let lastEvt;
|
|
53
|
+
const shouldRenderConfirm = computed(
|
|
54
|
+
() => Boolean(confirmConfig.value) || Boolean(beforeOpen.value)
|
|
55
|
+
);
|
|
56
|
+
const passthrough = computed(() => {
|
|
57
|
+
const p = props;
|
|
58
|
+
const picked = {};
|
|
59
|
+
const keys = [
|
|
60
|
+
"type",
|
|
61
|
+
"size",
|
|
62
|
+
"plain",
|
|
63
|
+
"text",
|
|
64
|
+
"bg",
|
|
65
|
+
"link",
|
|
66
|
+
"round",
|
|
67
|
+
"circle",
|
|
68
|
+
"color",
|
|
69
|
+
"dark",
|
|
70
|
+
"disabled",
|
|
71
|
+
"autofocus",
|
|
72
|
+
"nativeType",
|
|
73
|
+
"autoInsertSpace",
|
|
74
|
+
"tag",
|
|
75
|
+
"icon",
|
|
76
|
+
"loadingIcon"
|
|
77
|
+
];
|
|
78
|
+
for (const k of keys) if (p[k] !== void 0) picked[k] = p[k];
|
|
79
|
+
return { ...instance == null ? void 0 : instance.attrs, ...picked };
|
|
80
|
+
});
|
|
81
|
+
const isPromise = (v) => !!v && typeof v.then === "function";
|
|
82
|
+
const getListeners = () => {
|
|
83
|
+
var _a;
|
|
84
|
+
const raw = (_a = instance == null ? void 0 : instance.vnode.props) == null ? void 0 : _a.onClick;
|
|
85
|
+
if (!raw) return [];
|
|
86
|
+
return Array.isArray(raw) ? raw : [raw];
|
|
87
|
+
};
|
|
88
|
+
const invokeListeners = () => {
|
|
89
|
+
const listeners = getListeners();
|
|
90
|
+
if (!listeners.length) return;
|
|
91
|
+
const evt = lastEvt;
|
|
92
|
+
let rets;
|
|
93
|
+
try {
|
|
94
|
+
rets = listeners.map((fn) => fn(evt));
|
|
95
|
+
} catch (e) {
|
|
96
|
+
innerLoading.value = false;
|
|
97
|
+
throw e;
|
|
98
|
+
}
|
|
99
|
+
const proms = rets.filter(isPromise);
|
|
100
|
+
if (!proms.length) return;
|
|
101
|
+
innerLoading.value = true;
|
|
102
|
+
return Promise.all(proms).finally(() => {
|
|
103
|
+
innerLoading.value = false;
|
|
104
|
+
});
|
|
105
|
+
};
|
|
106
|
+
const submitFnAdapter = () => runConfirmSubmit(() => invokeListeners());
|
|
107
|
+
const onInnerClick = async (evt) => {
|
|
108
|
+
if (innerLoading.value || confirmVisible.value) return;
|
|
109
|
+
reportActionClick();
|
|
110
|
+
lastEvt = evt;
|
|
111
|
+
let data;
|
|
112
|
+
if (beforeOpen.value) {
|
|
113
|
+
innerLoading.value = true;
|
|
114
|
+
try {
|
|
115
|
+
data = await beforeOpen.value();
|
|
116
|
+
} catch {
|
|
117
|
+
innerLoading.value = false;
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
innerLoading.value = false;
|
|
121
|
+
} else {
|
|
122
|
+
data = void 0;
|
|
123
|
+
}
|
|
124
|
+
if (confirmConfig.value) {
|
|
125
|
+
resolvedConfig.value = typeof confirmConfig.value === "function" ? confirmConfig.value(data) : confirmConfig.value;
|
|
126
|
+
confirmVisible.value = true;
|
|
127
|
+
reportConfirmOpen();
|
|
128
|
+
} else {
|
|
129
|
+
invokeListeners();
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
const onConfirmClose = (confirmed) => {
|
|
133
|
+
reportConfirmClose(confirmed);
|
|
134
|
+
resolvedConfig.value = void 0;
|
|
135
|
+
};
|
|
136
|
+
return (_ctx, _cache) => {
|
|
137
|
+
var _a, _b, _c, _d, _e;
|
|
138
|
+
return shouldRenderConfirm.value ? (openBlock(), createBlock(unref(ActionConfirm), {
|
|
139
|
+
key: 0,
|
|
140
|
+
show: confirmVisible.value,
|
|
141
|
+
"onUpdate:show": _cache[0] || (_cache[0] = ($event) => confirmVisible.value = $event),
|
|
142
|
+
mode: unref(confirmMode) || "popconfirm",
|
|
143
|
+
title: (_a = resolvedConfig.value) == null ? void 0 : _a.title,
|
|
144
|
+
content: (_b = resolvedConfig.value) == null ? void 0 : _b.content,
|
|
145
|
+
"confirm-text": (_c = resolvedConfig.value) == null ? void 0 : _c.confirmText,
|
|
146
|
+
"cancel-text": (_d = resolvedConfig.value) == null ? void 0 : _d.cancelText,
|
|
147
|
+
type: ((_e = resolvedConfig.value) == null ? void 0 : _e.type) ?? __props.type,
|
|
148
|
+
"submit-fn": submitFnAdapter,
|
|
149
|
+
onClose: onConfirmClose
|
|
150
|
+
}, {
|
|
151
|
+
default: withCtx(() => [
|
|
152
|
+
createVNode(unref(ElButton), mergeProps({
|
|
153
|
+
class: "dc-action-btn",
|
|
154
|
+
"data-dc-badge-host": ""
|
|
155
|
+
}, passthrough.value, {
|
|
156
|
+
loading: innerLoading.value,
|
|
157
|
+
onClick: onInnerClick
|
|
158
|
+
}), {
|
|
159
|
+
default: withCtx(() => [
|
|
160
|
+
createVNode(unref(BadgeMark), {
|
|
161
|
+
align: "corner",
|
|
162
|
+
badgeKey: __props.badgeKey
|
|
163
|
+
}, {
|
|
164
|
+
default: withCtx(() => [
|
|
165
|
+
renderSlot(_ctx.$slots, "default")
|
|
166
|
+
]),
|
|
167
|
+
_: 3
|
|
168
|
+
}, 8, ["badgeKey"])
|
|
169
|
+
]),
|
|
170
|
+
_: 3
|
|
171
|
+
}, 16, ["loading"])
|
|
172
|
+
]),
|
|
173
|
+
_: 3
|
|
174
|
+
}, 8, ["show", "mode", "title", "content", "confirm-text", "cancel-text", "type"])) : (openBlock(), createBlock(unref(ElButton), mergeProps({
|
|
175
|
+
key: 1,
|
|
176
|
+
class: "dc-action-btn",
|
|
177
|
+
"data-dc-badge-host": ""
|
|
178
|
+
}, passthrough.value, {
|
|
179
|
+
loading: innerLoading.value,
|
|
180
|
+
onClick: onInnerClick
|
|
181
|
+
}), {
|
|
182
|
+
default: withCtx(() => [
|
|
183
|
+
createVNode(unref(BadgeMark), {
|
|
184
|
+
align: "corner",
|
|
185
|
+
badgeKey: __props.badgeKey
|
|
186
|
+
}, {
|
|
187
|
+
default: withCtx(() => [
|
|
188
|
+
renderSlot(_ctx.$slots, "default")
|
|
189
|
+
]),
|
|
190
|
+
_: 3
|
|
191
|
+
}, 8, ["badgeKey"])
|
|
192
|
+
]),
|
|
193
|
+
_: 3
|
|
194
|
+
}, 16, ["loading"]));
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
});
|
|
198
|
+
export {
|
|
199
|
+
_sfc_main as default
|
|
200
|
+
};
|