qy-better-lib 0.0.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/.vscode/extensions.json +3 -0
- package/LICENSE +24 -0
- package/README.md +2 -0
- package/index.html +13 -0
- package/package.json +37 -0
- package/packages/core/DOCUMENTATION.md +2681 -0
- package/packages/core/LICENSE +24 -0
- package/packages/core/package.json +67 -0
- package/packages/core/types/index.d.ts +39 -0
- package/packages/core/types/json.d.ts +4 -0
- package/packages/core/types/vue.shim.d.ts +5 -0
- package/packages/core/vitest.config.ts +15 -0
- package/packages/core/yarn.lock +1233 -0
- package/packages/hooks/DOCUMENTATION.md +634 -0
- package/packages/hooks/LICENSE +24 -0
- package/packages/hooks/__tests__/use-chart/index.test.ts +287 -0
- package/packages/hooks/__tests__/use-emit/index.test.ts +248 -0
- package/packages/hooks/__tests__/use-fullscreen/index.test.ts +162 -0
- package/packages/hooks/__tests__/use-image/index.test.ts +230 -0
- package/packages/hooks/__tests__/use-layout-flow/index.test.ts +382 -0
- package/packages/hooks/__tests__/use-mqtt/index.test.ts +392 -0
- package/packages/hooks/__tests__/use-print/index.test.ts +378 -0
- package/packages/hooks/__tests__/use-watermark/index.test.ts +277 -0
- package/packages/hooks/__tests__/use-websocket/index.test.ts +402 -0
- package/packages/hooks/package.json +104 -0
- package/packages/hooks/types/index.d.ts +1 -0
- package/packages/hooks/types/json.d.ts +4 -0
- package/packages/hooks/types/vue.shim.d.ts +5 -0
- package/packages/hooks/yarn.lock +1832 -0
- package/packages/lowcode/core/package.json +60 -0
- package/packages/lowcode/core/types/index.d.ts +1 -0
- package/packages/lowcode/core/types/json.d.ts +4 -0
- package/packages/lowcode/core/types/vue.shim.d.ts +5 -0
- package/packages/lowcode/core/vite.dist.min.config.js +40 -0
- package/packages/lowcode/core/vite.dist.min.config.js.map +1 -0
- package/packages/lowcode/core/vite.lib.config.js +74 -0
- package/packages/lowcode/core/vite.lib.config.js.map +1 -0
- package/packages/lowcode/core/yarn.lock +1132 -0
- package/packages/lowcode/mobile/package.json +63 -0
- package/packages/lowcode/mobile/types/index.d.ts +1 -0
- package/packages/lowcode/mobile/types/json.d.ts +4 -0
- package/packages/lowcode/mobile/types/vue.shim.d.ts +77 -0
- package/packages/lowcode/mobile/vite.config.js +11 -0
- package/packages/lowcode/mobile/vite.config.js.map +1 -0
- package/packages/lowcode/mobile/vite.dist.min.config.js +71 -0
- package/packages/lowcode/mobile/vite.dist.min.config.js.map +1 -0
- package/packages/lowcode/mobile/vite.lib.config.js +137 -0
- package/packages/lowcode/mobile/vite.lib.config.js.map +1 -0
- package/packages/lowcode/mobile/yarn.lock +3888 -0
- package/packages/lowcode/pc/package.json +64 -0
- package/packages/lowcode/pc/vite.config.js +11 -0
- package/packages/lowcode/pc/vite.config.js.map +1 -0
- package/packages/lowcode/pc/vite.dist.min.config.js +71 -0
- package/packages/lowcode/pc/vite.dist.min.config.js.map +1 -0
- package/packages/lowcode/pc/vite.lib.config.js +137 -0
- package/packages/lowcode/pc/vite.lib.config.js.map +1 -0
- package/packages/lowcode/pc/yarn.lock +4026 -0
- package/packages/pc_components/DOCUMENTATION.md +566 -0
- package/packages/pc_components/LICENSE +24 -0
- package/packages/pc_components/lib/commDialog/index.d.ts +3 -0
- package/packages/pc_components/lib/commDialog/index.js +8 -0
- package/packages/pc_components/lib/commDialog/src/index.vue.d.ts +102 -0
- package/packages/pc_components/lib/commDialog/src/index.vue.js +43 -0
- package/packages/pc_components/lib/commDialog/src/index.vue2.js +4 -0
- package/packages/pc_components/lib/commDialog/src/props.d.ts +49 -0
- package/packages/pc_components/lib/commDialog/src/props.js +48 -0
- package/packages/pc_components/lib/commDialog/src/type.d.ts +39 -0
- package/packages/pc_components/lib/commForm/index.d.ts +3 -0
- package/packages/pc_components/lib/commForm/index.js +8 -0
- package/packages/pc_components/lib/commForm/src/index.vue.d.ts +95 -0
- package/packages/pc_components/lib/commForm/src/index.vue.js +50 -0
- package/packages/pc_components/lib/commForm/src/index.vue2.js +4 -0
- package/packages/pc_components/lib/commForm/src/props.d.ts +49 -0
- package/packages/pc_components/lib/commForm/src/props.js +47 -0
- package/packages/pc_components/lib/commForm/src/type.d.ts +8 -0
- package/packages/pc_components/lib/contextMenu/index.d.ts +5 -0
- package/packages/pc_components/lib/contextMenu/index.js +8 -0
- package/packages/pc_components/lib/contextMenu/src/index.vue.d.ts +91 -0
- package/packages/pc_components/lib/contextMenu/src/index.vue.js +153 -0
- package/packages/pc_components/lib/contextMenu/src/index.vue2.js +4 -0
- package/packages/pc_components/lib/contextMenu/src/props.d.ts +32 -0
- package/packages/pc_components/lib/contextMenu/src/props.js +27 -0
- package/packages/pc_components/lib/contextMenu/src/type.d.ts +11 -0
- package/packages/pc_components/lib/describeView/index.d.ts +2 -0
- package/packages/pc_components/lib/describeView/index.js +7 -0
- package/packages/pc_components/lib/describeView/src/index.vue.d.ts +61 -0
- package/packages/pc_components/lib/describeView/src/index.vue.js +84 -0
- package/packages/pc_components/lib/describeView/src/index.vue2.js +4 -0
- package/packages/pc_components/lib/describeView/src/props.d.ts +35 -0
- package/packages/pc_components/lib/describeView/src/props.js +33 -0
- package/packages/pc_components/lib/describeView/src/type.d.ts +10 -0
- package/packages/pc_components/lib/index.d.ts +18 -0
- package/packages/pc_components/lib/index.js +40 -0
- package/packages/pc_components/lib/simpleVirtualList/index.d.ts +2 -0
- package/packages/pc_components/lib/simpleVirtualList/index.js +7 -0
- package/packages/pc_components/lib/simpleVirtualList/src/index.vue.d.ts +28 -0
- package/packages/pc_components/lib/simpleVirtualList/src/index.vue.js +101 -0
- package/packages/pc_components/lib/simpleVirtualList/src/index.vue2.js +4 -0
- package/packages/pc_components/lib/simpleVirtualList/src/type.d.ts +12 -0
- package/packages/pc_components/lib/styles/comm-form.scss +4 -0
- package/packages/pc_components/lib/styles/context-menu.scss +47 -0
- package/packages/pc_components/lib/styles/describe-view.scss +25 -0
- package/packages/pc_components/lib/styles/index.scss +6 -0
- package/packages/pc_components/lib/styles/simple-virtual-list.scss +25 -0
- package/packages/pc_components/lib/styles/table-extend.scss +100 -0
- package/packages/pc_components/lib/styles/text-button.scss +71 -0
- package/packages/pc_components/lib/tableExtend/index.d.ts +3 -0
- package/packages/pc_components/lib/tableExtend/index.js +7 -0
- package/packages/pc_components/lib/tableExtend/props.d.ts +130 -0
- package/packages/pc_components/lib/tableExtend/props.js +128 -0
- package/packages/pc_components/lib/tableExtend/src/colVisible.vue.d.ts +3 -0
- package/packages/pc_components/lib/tableExtend/src/colVisible.vue.js +128 -0
- package/packages/pc_components/lib/tableExtend/src/colVisible.vue2.js +4 -0
- package/packages/pc_components/lib/tableExtend/src/index.vue.d.ts +186 -0
- package/packages/pc_components/lib/tableExtend/src/index.vue.js +234 -0
- package/packages/pc_components/lib/tableExtend/src/index.vue2.js +4 -0
- package/packages/pc_components/lib/tableExtend/src/valueCol.vue.d.ts +24 -0
- package/packages/pc_components/lib/tableExtend/src/valueCol.vue.js +29 -0
- package/packages/pc_components/lib/tableExtend/src/valueCol.vue2.js +4 -0
- package/packages/pc_components/lib/tableExtend/type.d.ts +165 -0
- package/packages/pc_components/lib/tableExtend/type.js +9 -0
- package/packages/pc_components/lib/tableExtend/useTable.d.ts +27 -0
- package/packages/pc_components/lib/tableExtend/useTable.js +115 -0
- package/packages/pc_components/lib/textButton/index.d.ts +2 -0
- package/packages/pc_components/lib/textButton/index.js +7 -0
- package/packages/pc_components/lib/textButton/src/index.vue.d.ts +42 -0
- package/packages/pc_components/lib/textButton/src/index.vue.js +44 -0
- package/packages/pc_components/lib/textButton/src/index.vue2.js +4 -0
- package/packages/pc_components/lib/textButton/src/props.d.ts +23 -0
- package/packages/pc_components/lib/textButton/src/props.js +30 -0
- package/packages/pc_components/lib/textButton/src/type.d.ts +30 -0
- package/packages/pc_components/lib/utils/index.d.ts +77 -0
- package/packages/pc_components/lib/utils/index.js +124 -0
- package/packages/pc_components/package.json +73 -0
- package/packages/pc_components/types/index.d.ts +9 -0
- package/packages/pc_components/types/json.d.ts +4 -0
- package/packages/pc_components/types/vue.shim.d.ts +5 -0
- package/packages/pc_components/yarn.lock +1641 -0
- package/postcss.config.js +19 -0
- package/public/vite.svg +1 -0
- package/src/App.vue +37 -0
- package/src/api/index.ts +42 -0
- package/src/assets/vue.svg +1 -0
- package/src/document/core.md +2680 -0
- package/src/document/hooks.md +632 -0
- package/src/document/pc_components.md +566 -0
- package/src/locales/en.json +1 -0
- package/src/locales/zh-cn.json +1 -0
- package/src/main.ts +13 -0
- package/src/plugins/element-plus.ts +16 -0
- package/src/plugins/i18n.ts +17 -0
- package/src/plugins/index.ts +13 -0
- package/src/plugins/store.ts +12 -0
- package/src/router/index.ts +20 -0
- package/src/shared/chartType.ts +279 -0
- package/src/shared/const.ts +160 -0
- package/src/shared/lib.ts +129 -0
- package/src/shared/request.ts +255 -0
- package/src/shared/type.ts +48 -0
- package/src/shared/utils/date.ts +83 -0
- package/src/shared/utils/utils.ts +85 -0
- package/src/store/index.ts +22 -0
- package/src/store/modules/app.ts +17 -0
- package/src/store/modules/shared.ts +21 -0
- package/src/styles/index.scss +169 -0
- package/src/types/app.d.ts +23 -0
- package/src/types/echarts.d.ts +5 -0
- package/src/types/index.d.ts +1 -0
- package/src/types/json.d.ts +4 -0
- package/src/types/scss.d.ts +9 -0
- package/src/types/vue.shim.d.ts +5 -0
- package/src/views/docs/docs-content.vue +379 -0
- package/src/views/docs/docs-header.vue +130 -0
- package/src/views/docs/docs-sidebar.vue +76 -0
- package/src/views/docs/hooks.ts +600 -0
- package/src/views/docs/index.vue +30 -0
- package/src/views/docs/styles/docs-content.scss +106 -0
- package/src/views/docs/styles/docs-header.scss +20 -0
- package/src/views/docs/styles/docs-sidebar.scss +182 -0
- package/src/views/docs/styles/index.scss +14 -0
- package/src/views/docs/type.ts +101 -0
- package/src/views/index.vue +34 -0
- package/tsconfig.json +37 -0
- package/tsconfig.node.json +8 -0
- package/vite.config.ts +54 -0
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { auto_size } from "@qy_better_lib/core";
|
|
2
|
+
import { getCurrentInstance, computed, reactive, toRef, shallowReactive } from "vue";
|
|
3
|
+
import { FileType } from "./type.js";
|
|
4
|
+
function use_table(i18n_instance) {
|
|
5
|
+
const base_w = 1920;
|
|
6
|
+
const current_instance = getCurrentInstance();
|
|
7
|
+
const props = current_instance?.props;
|
|
8
|
+
const default_table_attr = {
|
|
9
|
+
rowKey: "id",
|
|
10
|
+
"element-loading-text": "加载中…",
|
|
11
|
+
"element-loading-background": "rgba(0, 0, 0, 0.2)",
|
|
12
|
+
highlightCurrentRow: true,
|
|
13
|
+
stripe: true,
|
|
14
|
+
border: false
|
|
15
|
+
};
|
|
16
|
+
const default_col_setting = {
|
|
17
|
+
headerAlign: void 0,
|
|
18
|
+
align: void 0,
|
|
19
|
+
prop: void 0,
|
|
20
|
+
label: void 0,
|
|
21
|
+
init: true,
|
|
22
|
+
width: void 0,
|
|
23
|
+
showOverflowTooltip: false,
|
|
24
|
+
sortable: void 0,
|
|
25
|
+
fixed: void 0
|
|
26
|
+
};
|
|
27
|
+
const table_attribute = computed(() => {
|
|
28
|
+
return {
|
|
29
|
+
...default_table_attr,
|
|
30
|
+
...Object.keys(props.options).length > 0 ? props.options : {}
|
|
31
|
+
};
|
|
32
|
+
});
|
|
33
|
+
const selection_options = reactive({
|
|
34
|
+
count: 0,
|
|
35
|
+
rows: []
|
|
36
|
+
});
|
|
37
|
+
const pagination = reactive({
|
|
38
|
+
page_index: props?.paging?.pageIndex ? toRef(props.paging, "pageIndex") : 1,
|
|
39
|
+
page_size: props?.paging?.pageSize ? toRef(props.paging, "pageSize") : 10
|
|
40
|
+
});
|
|
41
|
+
const has_pagination = computed(() => {
|
|
42
|
+
const has = props?.paging?.pageIndex > 0 && props?.paging?.pageSize > 0;
|
|
43
|
+
if (!props.autoPagination) {
|
|
44
|
+
return has;
|
|
45
|
+
}
|
|
46
|
+
const total = props.tableData.length > (props.total || 0) ? props.tableData.length : props.total || 0;
|
|
47
|
+
return has && total > pagination.page_size;
|
|
48
|
+
});
|
|
49
|
+
const image_viewer = reactive({
|
|
50
|
+
/** 是否显示图片预览 */
|
|
51
|
+
show: false,
|
|
52
|
+
/** 图片路径列表 */
|
|
53
|
+
file_path_list: [],
|
|
54
|
+
/** 当前显示图片的索引 */
|
|
55
|
+
index: 0
|
|
56
|
+
});
|
|
57
|
+
const column_config = shallowReactive({
|
|
58
|
+
show_column: [],
|
|
59
|
+
hidden_column: []
|
|
60
|
+
});
|
|
61
|
+
const col_setting_list = computed(() => {
|
|
62
|
+
if (!column_config.show_column || column_config.show_column.length === 0) {
|
|
63
|
+
return [{ prop: "default-prop", init: true, label: "" }];
|
|
64
|
+
}
|
|
65
|
+
const col_list = column_config.show_column.map((item) => {
|
|
66
|
+
const clonedItem = { ...item };
|
|
67
|
+
i18n_instance && clonedItem.langue && (clonedItem.label = i18n_instance(clonedItem.langue));
|
|
68
|
+
if (props.autoSize) {
|
|
69
|
+
if (clonedItem.width) {
|
|
70
|
+
clonedItem.width = auto_size(clonedItem.width || 0, base_w);
|
|
71
|
+
} else if (clonedItem.minWidth) {
|
|
72
|
+
clonedItem.minWidth = auto_size(clonedItem.minWidth || 0, base_w);
|
|
73
|
+
}
|
|
74
|
+
} else {
|
|
75
|
+
clonedItem.minWidth = auto_size(clonedItem.minWidth || 0, base_w);
|
|
76
|
+
}
|
|
77
|
+
return { ...default_col_setting, ...clonedItem };
|
|
78
|
+
});
|
|
79
|
+
return col_list;
|
|
80
|
+
});
|
|
81
|
+
const show_tool_panel = computed(() => {
|
|
82
|
+
return (current_instance?.slots["tool-left"]?.()?.length || 0) > 0 || (current_instance?.slots["tool-right"]?.()?.length || 0) > 0;
|
|
83
|
+
});
|
|
84
|
+
const show_bottom_panel = computed(() => (current_instance?.slots["tool-left"]?.()?.length || 0) > 0);
|
|
85
|
+
const has_image_viewer = computed(() => col_setting_list.value.some(
|
|
86
|
+
(f) => f.fileType && f.fileType == FileType.PICTURE
|
|
87
|
+
));
|
|
88
|
+
return {
|
|
89
|
+
def_col_setting: default_col_setting,
|
|
90
|
+
// 默认列配置
|
|
91
|
+
selection_options,
|
|
92
|
+
// 选中行状态
|
|
93
|
+
table_attribute,
|
|
94
|
+
// 表格属性
|
|
95
|
+
pagination,
|
|
96
|
+
// 分页配置
|
|
97
|
+
has_pagination,
|
|
98
|
+
// 是否显示分页
|
|
99
|
+
image_viewer,
|
|
100
|
+
// 图片预览配置
|
|
101
|
+
column_config,
|
|
102
|
+
// 列显示/隐藏配置
|
|
103
|
+
col_setting_list,
|
|
104
|
+
// 表格显示列
|
|
105
|
+
show_tool_panel,
|
|
106
|
+
// 是否显示工具栏
|
|
107
|
+
show_bottom_panel,
|
|
108
|
+
// 是否显示底部面板
|
|
109
|
+
has_image_viewer
|
|
110
|
+
// 是否包含图片预览功能
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
export {
|
|
114
|
+
use_table as default
|
|
115
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { DefineComponent, ExtractPropTypes, PropType, ComponentOptionsMixin, PublicProps, ComponentProvideOptions } from 'vue';
|
|
2
|
+
import { TextButtonType } from './type';
|
|
3
|
+
declare function __VLS_template(): {
|
|
4
|
+
attrs: Partial<{}>;
|
|
5
|
+
slots: {
|
|
6
|
+
default?(_: {}): any;
|
|
7
|
+
};
|
|
8
|
+
refs: {};
|
|
9
|
+
rootEl: HTMLDivElement;
|
|
10
|
+
};
|
|
11
|
+
type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
|
|
12
|
+
declare const __VLS_component: DefineComponent<ExtractPropTypes<{
|
|
13
|
+
type: {
|
|
14
|
+
type: PropType<TextButtonType>;
|
|
15
|
+
default: string;
|
|
16
|
+
validator: (val: string) => boolean;
|
|
17
|
+
};
|
|
18
|
+
icon: StringConstructor;
|
|
19
|
+
disabled: BooleanConstructor;
|
|
20
|
+
}>, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {
|
|
21
|
+
click: (event: MouseEvent) => any;
|
|
22
|
+
}, string, PublicProps, Readonly< ExtractPropTypes<{
|
|
23
|
+
type: {
|
|
24
|
+
type: PropType<TextButtonType>;
|
|
25
|
+
default: string;
|
|
26
|
+
validator: (val: string) => boolean;
|
|
27
|
+
};
|
|
28
|
+
icon: StringConstructor;
|
|
29
|
+
disabled: BooleanConstructor;
|
|
30
|
+
}>> & Readonly<{
|
|
31
|
+
onClick?: ((event: MouseEvent) => any) | undefined;
|
|
32
|
+
}>, {
|
|
33
|
+
type: TextButtonType;
|
|
34
|
+
disabled: boolean;
|
|
35
|
+
}, {}, {}, {}, string, ComponentProvideOptions, true, {}, HTMLDivElement>;
|
|
36
|
+
declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
|
|
37
|
+
export default _default;
|
|
38
|
+
type __VLS_WithTemplateSlots<T, S> = T & {
|
|
39
|
+
new (): {
|
|
40
|
+
$slots: S;
|
|
41
|
+
};
|
|
42
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { defineComponent, resolveComponent, openBlock, createElementBlock, normalizeClass, createBlock, withCtx, resolveDynamicComponent, createCommentVNode, createElementVNode, withModifiers, renderSlot } from "vue";
|
|
2
|
+
import { props } from "./props.js";
|
|
3
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
4
|
+
...{ name: "TextButton" },
|
|
5
|
+
__name: "index",
|
|
6
|
+
props: props(),
|
|
7
|
+
emits: ["click"],
|
|
8
|
+
setup(__props, { emit: __emit }) {
|
|
9
|
+
const props2 = __props;
|
|
10
|
+
const emit = __emit;
|
|
11
|
+
function onClick(e) {
|
|
12
|
+
if (props2.disabled) return;
|
|
13
|
+
emit("click", e);
|
|
14
|
+
}
|
|
15
|
+
return (_ctx, _cache) => {
|
|
16
|
+
const _component_el_icon = resolveComponent("el-icon");
|
|
17
|
+
return openBlock(), createElementBlock("div", {
|
|
18
|
+
class: normalizeClass(["text-button", [
|
|
19
|
+
`text-button-${_ctx.type}`,
|
|
20
|
+
_ctx.disabled && "is-disabled"
|
|
21
|
+
]])
|
|
22
|
+
}, [
|
|
23
|
+
_ctx.icon ? (openBlock(), createBlock(_component_el_icon, {
|
|
24
|
+
key: 0,
|
|
25
|
+
class: "text-button-icon"
|
|
26
|
+
}, {
|
|
27
|
+
default: withCtx(() => [
|
|
28
|
+
(openBlock(), createBlock(resolveDynamicComponent(_ctx.icon)))
|
|
29
|
+
]),
|
|
30
|
+
_: 1
|
|
31
|
+
})) : createCommentVNode("", true),
|
|
32
|
+
createElementVNode("div", {
|
|
33
|
+
class: "text-button-inner",
|
|
34
|
+
onClick: withModifiers(onClick, ["prevent"])
|
|
35
|
+
}, [
|
|
36
|
+
renderSlot(_ctx.$slots, "default")
|
|
37
|
+
])
|
|
38
|
+
], 2);
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
export {
|
|
43
|
+
_sfc_main as default
|
|
44
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { PropType } from 'vue';
|
|
2
|
+
import { TextButtonType } from './type';
|
|
3
|
+
/**
|
|
4
|
+
* 文本按钮组件属性定义
|
|
5
|
+
*/
|
|
6
|
+
export declare const props: () => {
|
|
7
|
+
/**
|
|
8
|
+
* 按钮类型
|
|
9
|
+
*/
|
|
10
|
+
type: {
|
|
11
|
+
type: PropType<TextButtonType>;
|
|
12
|
+
default: string;
|
|
13
|
+
validator: (val: string) => boolean;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* 图标组件
|
|
17
|
+
*/
|
|
18
|
+
icon: StringConstructor;
|
|
19
|
+
/**
|
|
20
|
+
* 是否禁用
|
|
21
|
+
*/
|
|
22
|
+
disabled: BooleanConstructor;
|
|
23
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
const props = () => ({
|
|
2
|
+
/**
|
|
3
|
+
* 按钮类型
|
|
4
|
+
*/
|
|
5
|
+
type: {
|
|
6
|
+
type: String,
|
|
7
|
+
default: "primary",
|
|
8
|
+
validator: (val) => {
|
|
9
|
+
return [
|
|
10
|
+
"default",
|
|
11
|
+
"primary",
|
|
12
|
+
"success",
|
|
13
|
+
"warning",
|
|
14
|
+
"info",
|
|
15
|
+
"danger"
|
|
16
|
+
].includes(val);
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
/**
|
|
20
|
+
* 图标组件
|
|
21
|
+
*/
|
|
22
|
+
icon: String,
|
|
23
|
+
/**
|
|
24
|
+
* 是否禁用
|
|
25
|
+
*/
|
|
26
|
+
disabled: Boolean
|
|
27
|
+
});
|
|
28
|
+
export {
|
|
29
|
+
props
|
|
30
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 文本按钮类型
|
|
3
|
+
*/
|
|
4
|
+
export type TextButtonType = 'default' | 'primary' | 'success' | 'warning' | 'info' | 'danger';
|
|
5
|
+
/**
|
|
6
|
+
* 文本按钮组件属性
|
|
7
|
+
*/
|
|
8
|
+
export interface TextButtonProps {
|
|
9
|
+
/**
|
|
10
|
+
* 按钮类型
|
|
11
|
+
*/
|
|
12
|
+
type: TextButtonType;
|
|
13
|
+
/**
|
|
14
|
+
* 图标组件
|
|
15
|
+
*/
|
|
16
|
+
icon?: string;
|
|
17
|
+
/**
|
|
18
|
+
* 是否禁用
|
|
19
|
+
*/
|
|
20
|
+
disabled: boolean;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* 文本按钮组件事件
|
|
24
|
+
*/
|
|
25
|
+
export interface TextButtonEmits {
|
|
26
|
+
/**
|
|
27
|
+
* 点击事件
|
|
28
|
+
*/
|
|
29
|
+
(e: 'click', event: MouseEvent): void;
|
|
30
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { MessageParams, ElMessageBoxOptions, NotificationParams } from 'element-plus';
|
|
2
|
+
import { Ref } from 'vue';
|
|
3
|
+
type MessageBoxType = "toast" | "dialog" | "notif";
|
|
4
|
+
type MessageType = "success" | "warning" | "error" | "info";
|
|
5
|
+
type ConfirmCallback = () => any | void;
|
|
6
|
+
type CancelCallback = (action: "confirm" | "cancel" | "close") => any | void;
|
|
7
|
+
/**
|
|
8
|
+
* 消息提示框
|
|
9
|
+
* @param message 消息内容
|
|
10
|
+
* @param type 消息类型
|
|
11
|
+
* @param status 状态
|
|
12
|
+
* @param title 标题
|
|
13
|
+
*/
|
|
14
|
+
export declare function message_box(message: string, type: MessageBoxType, status?: boolean, title?: string): void;
|
|
15
|
+
/**
|
|
16
|
+
* 确认提示框
|
|
17
|
+
* @param str 提示信息
|
|
18
|
+
* @param callback 确认回调函数
|
|
19
|
+
* @param options MessageBox配置项,参考element-plus文档
|
|
20
|
+
*/
|
|
21
|
+
export declare function confirm_box(str: string, callback: ConfirmCallback, options?: Partial<ElMessageBoxOptions>): void;
|
|
22
|
+
/**
|
|
23
|
+
* 同步的确认提示框
|
|
24
|
+
* @param str 提示信息
|
|
25
|
+
* @param callback 确认回调函数
|
|
26
|
+
* @param options MessageBox配置项,参考element-plus文档
|
|
27
|
+
* @param cancelCallback 取消回调函数
|
|
28
|
+
* @returns Promise
|
|
29
|
+
*/
|
|
30
|
+
export declare function confirm_box_async(str: string, callback: ConfirmCallback, options?: Partial<ElMessageBoxOptions>, cancelCallback?: CancelCallback): Promise<any>;
|
|
31
|
+
/**
|
|
32
|
+
* 消息提示
|
|
33
|
+
* @param type 类型
|
|
34
|
+
* @param message 消息
|
|
35
|
+
* @param options 配置项
|
|
36
|
+
*/
|
|
37
|
+
export declare function message_alert(type: MessageType, message?: string, options?: MessageParams): void;
|
|
38
|
+
/**
|
|
39
|
+
* 侧窗提示
|
|
40
|
+
* @param type 类型
|
|
41
|
+
* @param title 标题
|
|
42
|
+
* @param message 消息
|
|
43
|
+
* @param options 配置项
|
|
44
|
+
*/
|
|
45
|
+
export declare function notification(type: MessageType, title?: string, message?: string, options?: NotificationParams): void;
|
|
46
|
+
/**
|
|
47
|
+
* 关闭所有消息
|
|
48
|
+
*/
|
|
49
|
+
export declare function close_all_messages(): void;
|
|
50
|
+
/**
|
|
51
|
+
* 关闭所有通知
|
|
52
|
+
*/
|
|
53
|
+
export declare function close_all_notifications(): void;
|
|
54
|
+
/**
|
|
55
|
+
* 关闭所有MessageBox
|
|
56
|
+
*/
|
|
57
|
+
export declare function close_all_message_boxes(): void;
|
|
58
|
+
/**
|
|
59
|
+
* 校验表单
|
|
60
|
+
* @param formRef 表单对象
|
|
61
|
+
* @returns
|
|
62
|
+
*/
|
|
63
|
+
export declare function validateForm(formRef: Ref<any>): Promise<boolean>;
|
|
64
|
+
export declare function validateFormItem(formItemRef: Ref<any>): Promise<boolean>;
|
|
65
|
+
/**
|
|
66
|
+
* 重置表单
|
|
67
|
+
* @param formRef
|
|
68
|
+
*/
|
|
69
|
+
export declare function resetForm(formRef: Ref<any>): void;
|
|
70
|
+
/**
|
|
71
|
+
* 校验对象
|
|
72
|
+
* @param rules 规则,同表单规则一致
|
|
73
|
+
* @param data 校验对象
|
|
74
|
+
* @returns
|
|
75
|
+
*/
|
|
76
|
+
export declare function validateObject(rules: any, data: any): Promise<unknown>;
|
|
77
|
+
export {};
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { ElMessageBox, ElMessage, ElNotification } from "element-plus";
|
|
2
|
+
import { getCurrentInstance } from "vue";
|
|
3
|
+
function get_app_context() {
|
|
4
|
+
const instance = getCurrentInstance();
|
|
5
|
+
return instance?.appContext;
|
|
6
|
+
}
|
|
7
|
+
function message_box(message, type, status = true, title = "") {
|
|
8
|
+
switch (type) {
|
|
9
|
+
case "toast":
|
|
10
|
+
message_alert(
|
|
11
|
+
status ? "success" : "error",
|
|
12
|
+
message || (status ? "执行成功" : "执行失败")
|
|
13
|
+
);
|
|
14
|
+
break;
|
|
15
|
+
case "dialog":
|
|
16
|
+
confirm_box_async(message || (status ? "执行成功" : "执行失败"), () => {
|
|
17
|
+
}, {
|
|
18
|
+
title: title || "提示",
|
|
19
|
+
type: status ? "success" : "error",
|
|
20
|
+
showCancelButton: false
|
|
21
|
+
});
|
|
22
|
+
break;
|
|
23
|
+
case "notif":
|
|
24
|
+
notification(status ? "success" : "error", title || "消息提示", message);
|
|
25
|
+
break;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
function confirm_box(str, callback, options) {
|
|
29
|
+
const option = {
|
|
30
|
+
beforeClose: (action, instance, done) => {
|
|
31
|
+
if (action === "confirm") {
|
|
32
|
+
setTimeout(() => {
|
|
33
|
+
done();
|
|
34
|
+
}, 0);
|
|
35
|
+
} else {
|
|
36
|
+
done();
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
...options
|
|
40
|
+
};
|
|
41
|
+
const appContext = get_app_context();
|
|
42
|
+
ElMessageBox.confirm(str, "提示", option, appContext).then(async () => {
|
|
43
|
+
callback && callback();
|
|
44
|
+
}).catch(() => {
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
function confirm_box_async(str, callback, options, cancelCallback) {
|
|
48
|
+
return new Promise((resolve) => {
|
|
49
|
+
const option = {
|
|
50
|
+
beforeClose: (action, instance, done) => {
|
|
51
|
+
if (action === "confirm") {
|
|
52
|
+
setTimeout(() => {
|
|
53
|
+
done();
|
|
54
|
+
}, 0);
|
|
55
|
+
} else {
|
|
56
|
+
done();
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
...options
|
|
60
|
+
};
|
|
61
|
+
const appContext = get_app_context();
|
|
62
|
+
ElMessageBox.confirm(str, "提示", option, appContext).then(() => {
|
|
63
|
+
resolve(callback && callback());
|
|
64
|
+
}).catch((action) => {
|
|
65
|
+
cancelCallback ? resolve(cancelCallback(action)) : resolve(false);
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
function message_alert(type, message = "", options = {}) {
|
|
70
|
+
const defaultOptions = {
|
|
71
|
+
showClose: true,
|
|
72
|
+
message,
|
|
73
|
+
type,
|
|
74
|
+
duration: 3e3,
|
|
75
|
+
dangerouslyUseHTMLString: false,
|
|
76
|
+
grouping: true,
|
|
77
|
+
placement: "top"
|
|
78
|
+
};
|
|
79
|
+
const appContext = get_app_context();
|
|
80
|
+
const mergedOptions = Object.assign({}, defaultOptions, options);
|
|
81
|
+
ElMessage(mergedOptions, appContext);
|
|
82
|
+
}
|
|
83
|
+
function notification(type, title = "", message = "", options = {}) {
|
|
84
|
+
const defaultOptions = {
|
|
85
|
+
title,
|
|
86
|
+
message,
|
|
87
|
+
type,
|
|
88
|
+
dangerouslyUseHTMLString: true,
|
|
89
|
+
duration: 3e3,
|
|
90
|
+
showClose: true,
|
|
91
|
+
position: "bottom-right"
|
|
92
|
+
};
|
|
93
|
+
const appContext = get_app_context();
|
|
94
|
+
const mergedOptions = Object.assign({}, defaultOptions, options);
|
|
95
|
+
ElNotification(mergedOptions, appContext);
|
|
96
|
+
}
|
|
97
|
+
function close_all_messages() {
|
|
98
|
+
ElMessage.closeAll();
|
|
99
|
+
}
|
|
100
|
+
function close_all_notifications() {
|
|
101
|
+
ElNotification.closeAll();
|
|
102
|
+
}
|
|
103
|
+
function close_all_message_boxes() {
|
|
104
|
+
ElMessageBox.close();
|
|
105
|
+
}
|
|
106
|
+
function validateForm(formRef) {
|
|
107
|
+
return new Promise((resolve, reject) => {
|
|
108
|
+
if (!formRef.value) return resolve(false);
|
|
109
|
+
formRef.value.validate((valid) => {
|
|
110
|
+
return resolve(!!valid);
|
|
111
|
+
});
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
export {
|
|
115
|
+
close_all_message_boxes,
|
|
116
|
+
close_all_messages,
|
|
117
|
+
close_all_notifications,
|
|
118
|
+
confirm_box,
|
|
119
|
+
confirm_box_async,
|
|
120
|
+
message_alert,
|
|
121
|
+
message_box,
|
|
122
|
+
notification,
|
|
123
|
+
validateForm
|
|
124
|
+
};
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@qy_better_lib/pc",
|
|
3
|
+
"private": false,
|
|
4
|
+
"version": "0.3.6",
|
|
5
|
+
"description": "qy better lib pc compontens",
|
|
6
|
+
"author": "luhuiming",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"scripts": {
|
|
9
|
+
"build:lib": "vite build --config vite.lib.config.ts",
|
|
10
|
+
"build:dist-min": "vite build --config vite.dist.min.config.ts",
|
|
11
|
+
"build": "yarn build:lib && yarn build:dist-min"
|
|
12
|
+
},
|
|
13
|
+
"main": "lib/index.js",
|
|
14
|
+
"module": "lib/index.js",
|
|
15
|
+
"types": "lib/index.d.ts",
|
|
16
|
+
"typesVersions": {
|
|
17
|
+
"*": {
|
|
18
|
+
"lib/index.js": [
|
|
19
|
+
"lib/index.d.ts"
|
|
20
|
+
],
|
|
21
|
+
"@qy-better-lib/core": [
|
|
22
|
+
"lib/index.d.ts"
|
|
23
|
+
],
|
|
24
|
+
"*": [
|
|
25
|
+
"*",
|
|
26
|
+
"dist/*",
|
|
27
|
+
"lib/*",
|
|
28
|
+
"lib/*.scss",
|
|
29
|
+
"lib/*.d.ts",
|
|
30
|
+
"lib/*/index.d.ts"
|
|
31
|
+
]
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
"exports": {
|
|
35
|
+
".": {
|
|
36
|
+
"import": "./lib/index.js",
|
|
37
|
+
"types": "./lib/index.d.ts"
|
|
38
|
+
},
|
|
39
|
+
"./*": {
|
|
40
|
+
"import": "./lib/*/index.js",
|
|
41
|
+
"types": "./lib/*/index.d.ts"
|
|
42
|
+
},
|
|
43
|
+
"./utils": {
|
|
44
|
+
"import": "./lib/utils/index.js",
|
|
45
|
+
"types": "./lib/utils/index.d.ts"
|
|
46
|
+
},
|
|
47
|
+
"./styles": "./lib/styles/index.scss",
|
|
48
|
+
"./styles/*": "./lib/styles/*"
|
|
49
|
+
},
|
|
50
|
+
"peerDependencies": {
|
|
51
|
+
"@qy_better_lib/core": "^0.2.2",
|
|
52
|
+
"@qy_better_lib/hooks": "^0.2.4",
|
|
53
|
+
"element-plus": "^2.13.2",
|
|
54
|
+
"vue": "^3.5.27",
|
|
55
|
+
"vue-i18n": "^9.13.1"
|
|
56
|
+
},
|
|
57
|
+
"devDependencies": {
|
|
58
|
+
"@qy_better_lib/core": "^0.2.8",
|
|
59
|
+
"@qy_better_lib/hooks": "^0.2.6",
|
|
60
|
+
"@types/node": "^24.5.0",
|
|
61
|
+
"@vitejs/plugin-vue": "^6.0.1",
|
|
62
|
+
"@vitejs/plugin-vue-jsx": "^5.1.4",
|
|
63
|
+
"async-validator": "^4.2.5",
|
|
64
|
+
"element-plus": "^2.13.2",
|
|
65
|
+
"magic-string": "^0.30.19",
|
|
66
|
+
"mkdirp": "^3.0.1",
|
|
67
|
+
"vite": "^7.1.5",
|
|
68
|
+
"vite-plugin-dts": "^4.5.4",
|
|
69
|
+
"vue": "^3.5.27",
|
|
70
|
+
"vue-i18n": "^9.13.1"
|
|
71
|
+
},
|
|
72
|
+
"dependencies": {}
|
|
73
|
+
}
|