bootstrap-vue-top 1.0.13 → 1.0.14
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/package.json +2 -7
- package/.browserslistrc +0 -12
- package/postcss.config.js +0 -5
- package/src/components/accordion/accordion-item.vue +0 -27
- package/src/components/accordion/accordion-keys.js +0 -1
- package/src/components/accordion/accordion.vue +0 -84
- package/src/components/alert/alert.js +0 -10
- package/src/components/alert-box/alert-box.vue +0 -73
- package/src/components/alert-box/index.js +0 -25
- package/src/components/alert-confirm/alert-confirm.vue +0 -80
- package/src/components/alert-confirm/index.js +0 -26
- package/src/components/alert-message/alert-message.vue +0 -63
- package/src/components/alert-message/index.js +0 -27
- package/src/components/backtop/backtop.vue +0 -61
- package/src/components/carousel/carousel.vue +0 -107
- package/src/components/collapse/collapse.js +0 -8
- package/src/components/dropdown/dropdown.js +0 -11
- package/src/components/image-preview/image-preview.vue +0 -261
- package/src/components/image-preview/index.js +0 -26
- package/src/components/loading/index.js +0 -45
- package/src/components/loading/loading-fullscreen.vue +0 -47
- package/src/components/loading/loading.vue +0 -47
- package/src/components/modal/modal.vue +0 -83
- package/src/components/modal-2/counter.js +0 -25
- package/src/components/modal-2/modal-2.vue +0 -256
- package/src/components/offcanvas/offcanvas.vue +0 -71
- package/src/components/pagination/pagination.vue +0 -216
- package/src/components/popover/popover.js +0 -10
- package/src/components/scrollspy/scrollspy.js +0 -16
- package/src/components/table/table-col.vue +0 -61
- package/src/components/table/table-keys.js +0 -2
- package/src/components/table/table.vue +0 -320
- package/src/components/tabs/tab-pane.vue +0 -32
- package/src/components/tabs/tabs-keys.js +0 -1
- package/src/components/tabs/tabs.vue +0 -240
- package/src/components/toast/index.js +0 -29
- package/src/components/toast/toast.vue +0 -92
- package/src/components/tooltip/tooltip.js +0 -10
- package/src/components/tree/tree-keys.js +0 -7
- package/src/components/tree/tree-node.vue +0 -144
- package/src/components/tree/tree.vue +0 -92
- package/src/components/treetable/treetable-col.vue +0 -37
- package/src/components/treetable/treetable-keys.js +0 -3
- package/src/components/treetable/treetable-node.vue +0 -104
- package/src/components/treetable/treetable.vue +0 -114
- package/src/components/uploader/file-uploader.vue +0 -68
- package/src/components/uploader/image-many-uploader.vue +0 -173
- package/src/components/uploader/image-one-uploader.vue +0 -78
- package/src/index.js +0 -64
- package/src/styles/alert.scss +0 -33
- package/src/styles/backtop.scss +0 -7
- package/src/styles/image-preview.scss +0 -11
- package/src/styles/index.scss +0 -97
- package/src/styles/loading.scss +0 -12
- package/src/styles/modal-2.scss +0 -8
- package/src/styles/uploader.scss +0 -29
- package/vite.config.js +0 -58
package/package.json
CHANGED
|
@@ -1,20 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bootstrap-vue-top",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.14",
|
|
4
4
|
"homepage": "https://bootstrap-vue.top",
|
|
5
5
|
"private": false,
|
|
6
6
|
"type": "module",
|
|
7
7
|
"description": "bootstrap-vue-top is a frontend framework based on Bootstrap & Vue.",
|
|
8
8
|
"files": [
|
|
9
9
|
"dist",
|
|
10
|
-
"src",
|
|
11
|
-
".browserslistrc",
|
|
12
|
-
"package.json",
|
|
13
|
-
"postcss.config.js",
|
|
14
10
|
"README.md",
|
|
15
11
|
"README.zh-CN.md",
|
|
16
|
-
"LICENSE"
|
|
17
|
-
"vite.config.js"
|
|
12
|
+
"LICENSE"
|
|
18
13
|
],
|
|
19
14
|
"main": "./dist/bootstrap-vue.umd.cjs",
|
|
20
15
|
"module": "./dist/bootstrap-vue.js",
|
package/.browserslistrc
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
# https://github.com/browserslist/browserslist#readme
|
|
2
|
-
|
|
3
|
-
>= 0.5%
|
|
4
|
-
last 2 major versions
|
|
5
|
-
not dead
|
|
6
|
-
Chrome >= 84
|
|
7
|
-
Firefox >= 63
|
|
8
|
-
Firefox ESR
|
|
9
|
-
iOS >= 14.5
|
|
10
|
-
Safari >= 14.1
|
|
11
|
-
not Explorer <= 11
|
|
12
|
-
not kaios <= 2.5 # fix floating label issues in Firefox (see https://github.com/postcss/autoprefixer/issues/1533)
|
package/postcss.config.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
<template></template>
|
|
2
|
-
<script setup>
|
|
3
|
-
import { inject, onMounted, onBeforeUnmount, useId } from 'vue';
|
|
4
|
-
import { items_injection_key } from './accordion-keys.js';
|
|
5
|
-
|
|
6
|
-
const props = defineProps({
|
|
7
|
-
header: {
|
|
8
|
-
type: String,
|
|
9
|
-
default: 'Header'
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
const items = inject(items_injection_key);
|
|
14
|
-
const keyId = useId();
|
|
15
|
-
onMounted(() => {
|
|
16
|
-
const item = {
|
|
17
|
-
keyId: keyId,
|
|
18
|
-
header: props.header
|
|
19
|
-
};
|
|
20
|
-
items.push(item);
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
onBeforeUnmount(() => {
|
|
24
|
-
const index = items.findIndex((item) => item.keyId === keyId);
|
|
25
|
-
items.splice(index, 1);
|
|
26
|
-
});
|
|
27
|
-
</script>
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export const items_injection_key = Symbol();
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div :id="id" class="accordion" :class="accordionClass">
|
|
3
|
-
<slot></slot>
|
|
4
|
-
<template v-if="ready">
|
|
5
|
-
<div v-for="(item, index) in items" class="accordion-item" :key="item.keyId">
|
|
6
|
-
<h2 class="accordion-header">
|
|
7
|
-
<button
|
|
8
|
-
type="button"
|
|
9
|
-
class="accordion-button"
|
|
10
|
-
:class="{ collapsed: initActiveIndex !== index }"
|
|
11
|
-
data-bs-toggle="collapse"
|
|
12
|
-
:data-bs-target="`#${item.keyId}`"
|
|
13
|
-
:aria-expanded="initActiveIndex === index"
|
|
14
|
-
:aria-controls="`#${item.keyId}`"
|
|
15
|
-
>
|
|
16
|
-
{{ item.header }}
|
|
17
|
-
</button>
|
|
18
|
-
</h2>
|
|
19
|
-
<div
|
|
20
|
-
:id="item.keyId"
|
|
21
|
-
class="accordion-collapse collapse"
|
|
22
|
-
:class="{ show: initActiveIndex === index }"
|
|
23
|
-
:data-bs-parent="always ? null : `#${id}`"
|
|
24
|
-
>
|
|
25
|
-
<div class="accordion-body">
|
|
26
|
-
<component :is="item.body" />
|
|
27
|
-
</div>
|
|
28
|
-
</div>
|
|
29
|
-
</div>
|
|
30
|
-
</template>
|
|
31
|
-
</div>
|
|
32
|
-
</template>
|
|
33
|
-
|
|
34
|
-
<script setup>
|
|
35
|
-
import { useSlots, ref, provide, onMounted, useId } from 'vue';
|
|
36
|
-
import { items_injection_key } from './accordion-keys.js';
|
|
37
|
-
import Collapse from 'bootstrap/js/dist/collapse';
|
|
38
|
-
|
|
39
|
-
const ready = ref(false);
|
|
40
|
-
const id = useId();
|
|
41
|
-
const props = defineProps({
|
|
42
|
-
accordionClass: {
|
|
43
|
-
type: String,
|
|
44
|
-
default: null
|
|
45
|
-
},
|
|
46
|
-
always: {
|
|
47
|
-
type: Boolean,
|
|
48
|
-
default: false
|
|
49
|
-
},
|
|
50
|
-
initActiveIndex: {
|
|
51
|
-
type: Number,
|
|
52
|
-
default: null
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
const items = [];
|
|
57
|
-
provide(items_injection_key, items);
|
|
58
|
-
|
|
59
|
-
onMounted(() => {
|
|
60
|
-
_initItems();
|
|
61
|
-
|
|
62
|
-
ready.value = true;
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
function _initItems() {
|
|
66
|
-
const slots = useSlots();
|
|
67
|
-
const vNodes = slots.default();
|
|
68
|
-
|
|
69
|
-
const itemVNodes = [];
|
|
70
|
-
for (const vNode of vNodes) {
|
|
71
|
-
if (vNode.type.__name === 'accordion-item') {
|
|
72
|
-
itemVNodes.push(vNode);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
for (let i = 0; i < items.length; i++) {
|
|
77
|
-
if (itemVNodes[i].children !== null && itemVNodes[i].children.default !== 'undefined') {
|
|
78
|
-
items[i].body = itemVNodes[i].children.default;
|
|
79
|
-
} else {
|
|
80
|
-
items[i].body = null;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
</script>
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<Transition name="fadeIn" @after-leave="$emit('destroy')">
|
|
3
|
-
<div
|
|
4
|
-
v-show="visible"
|
|
5
|
-
ref="elementRef"
|
|
6
|
-
tabindex="-1"
|
|
7
|
-
class="alert-box d-flex justify-content-center align-items-start"
|
|
8
|
-
role="alert"
|
|
9
|
-
>
|
|
10
|
-
<div class="shadow rounded bg-body p-3 col-10 col-sm-9 col-md-6 col-lg-4 col-xl-3" style="margin-top: 25vh">
|
|
11
|
-
<div class="d-flex justify-content-center align-items-center">
|
|
12
|
-
<div class="me-2">
|
|
13
|
-
<BiExclamationCircle class="text-danger fs-5" />
|
|
14
|
-
</div>
|
|
15
|
-
<div class="fs-5 fw-bolder">{{ message }}</div>
|
|
16
|
-
</div>
|
|
17
|
-
<hr />
|
|
18
|
-
<div class="text-center">
|
|
19
|
-
<button type="button" class="btn btn-primary" @click="confirm">确定</button>
|
|
20
|
-
</div>
|
|
21
|
-
</div>
|
|
22
|
-
</div>
|
|
23
|
-
</Transition>
|
|
24
|
-
</template>
|
|
25
|
-
|
|
26
|
-
<script setup>
|
|
27
|
-
import { onMounted, onBeforeUnmount, ref, shallowRef, nextTick } from 'vue';
|
|
28
|
-
import { createFocusTrap } from 'focus-trap';
|
|
29
|
-
|
|
30
|
-
const elementRef = shallowRef(null);
|
|
31
|
-
let focusTrapInstance = null;
|
|
32
|
-
|
|
33
|
-
const props = defineProps({
|
|
34
|
-
message: {
|
|
35
|
-
type: String,
|
|
36
|
-
default: 'Alert Box'
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
const visible = ref(false);
|
|
41
|
-
|
|
42
|
-
onMounted(() => {
|
|
43
|
-
if (document.body.scrollHeight > window.innerHeight) {
|
|
44
|
-
document.body.style.cssText = `overflow: hidden; padding-right: ${window.innerWidth - document.body.clientWidth}px;`;
|
|
45
|
-
}
|
|
46
|
-
visible.value = true;
|
|
47
|
-
|
|
48
|
-
nextTick(() => {
|
|
49
|
-
//焦点陷阱
|
|
50
|
-
if (elementRef.value !== null) {
|
|
51
|
-
focusTrapInstance = createFocusTrap(elementRef.value, {
|
|
52
|
-
initialFocus: false
|
|
53
|
-
});
|
|
54
|
-
focusTrapInstance.activate();
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
onBeforeUnmount(() => {
|
|
60
|
-
if (document.body.scrollHeight > window.innerHeight) {
|
|
61
|
-
document.body.style = null;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
//停止焦点陷阱
|
|
65
|
-
if (focusTrapInstance !== null) {
|
|
66
|
-
focusTrapInstance.deactivate();
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
function confirm() {
|
|
71
|
-
visible.value = false;
|
|
72
|
-
}
|
|
73
|
-
</script>
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { createVNode, render } from 'vue';
|
|
2
|
-
import AlertBox from './alert-box.vue';
|
|
3
|
-
|
|
4
|
-
let container = null;
|
|
5
|
-
const alertBox = function (data) {
|
|
6
|
-
if (container) {
|
|
7
|
-
render(null, container);
|
|
8
|
-
container = null;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
container = document.createElement('div');
|
|
12
|
-
|
|
13
|
-
const vnode = createVNode(AlertBox, {
|
|
14
|
-
message: data.message,
|
|
15
|
-
onDestroy: () => {
|
|
16
|
-
render(null, container);
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
render(vnode, container);
|
|
21
|
-
|
|
22
|
-
document.body.appendChild(container.firstElementChild);
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
export default alertBox;
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<Transition name="fadeIn" @after-leave="$emit('destroy')">
|
|
3
|
-
<div
|
|
4
|
-
ref="elementRef"
|
|
5
|
-
v-show="visible"
|
|
6
|
-
class="alert-confirm d-flex justify-content-center align-items-start"
|
|
7
|
-
tabindex="-1"
|
|
8
|
-
role="alert"
|
|
9
|
-
>
|
|
10
|
-
<div class="shadow rounded bg-body p-3 col-10 col-sm-9 col-md-6 col-lg-4 col-xl-3" style="margin-top: 25vh">
|
|
11
|
-
<div class="d-flex justify-content-center align-items-center">
|
|
12
|
-
<div class="me-2"><BiExclamationCircle class="text-warning fs-5" /></div>
|
|
13
|
-
<div class="fs-5 fw-bolder">{{ message }}</div>
|
|
14
|
-
</div>
|
|
15
|
-
<hr />
|
|
16
|
-
<div class="text-center">
|
|
17
|
-
<button type="button" class="btn btn-secondary me-3" @click="cancel">取消</button>
|
|
18
|
-
<button type="button" class="btn btn-primary" @click="confirm">确定</button>
|
|
19
|
-
</div>
|
|
20
|
-
</div>
|
|
21
|
-
</div>
|
|
22
|
-
</Transition>
|
|
23
|
-
</template>
|
|
24
|
-
|
|
25
|
-
<script setup>
|
|
26
|
-
import { onMounted, onBeforeUnmount, ref, shallowRef, nextTick } from 'vue';
|
|
27
|
-
import { createFocusTrap } from 'focus-trap';
|
|
28
|
-
|
|
29
|
-
const elementRef = shallowRef(null);
|
|
30
|
-
let focusTrapInstance = null;
|
|
31
|
-
|
|
32
|
-
const props = defineProps({
|
|
33
|
-
message: {
|
|
34
|
-
type: String,
|
|
35
|
-
required: true
|
|
36
|
-
},
|
|
37
|
-
callback: {
|
|
38
|
-
type: Function,
|
|
39
|
-
required: true
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
const visible = ref(false);
|
|
44
|
-
onMounted(() => {
|
|
45
|
-
if (document.body.scrollHeight > window.innerHeight) {
|
|
46
|
-
document.body.style.cssText = `overflow: hidden; padding-right: ${window.innerWidth - document.body.clientWidth}px;`;
|
|
47
|
-
}
|
|
48
|
-
visible.value = true;
|
|
49
|
-
|
|
50
|
-
nextTick(() => {
|
|
51
|
-
//焦点陷阱
|
|
52
|
-
if (elementRef.value !== null) {
|
|
53
|
-
focusTrapInstance = createFocusTrap(elementRef.value, {
|
|
54
|
-
initialFocus: false
|
|
55
|
-
});
|
|
56
|
-
focusTrapInstance.activate();
|
|
57
|
-
}
|
|
58
|
-
});
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
onBeforeUnmount(() => {
|
|
62
|
-
if (document.body.scrollHeight > window.innerHeight) {
|
|
63
|
-
document.body.style = null;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
//停止焦点陷阱
|
|
67
|
-
if (focusTrapInstance !== null) {
|
|
68
|
-
focusTrapInstance.deactivate();
|
|
69
|
-
}
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
function confirm() {
|
|
73
|
-
visible.value = false;
|
|
74
|
-
props.callback();
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
function cancel() {
|
|
78
|
-
visible.value = false;
|
|
79
|
-
}
|
|
80
|
-
</script>
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { createVNode, render } from 'vue';
|
|
2
|
-
import AlertConfirm from './alert-confirm.vue';
|
|
3
|
-
|
|
4
|
-
let container = null;
|
|
5
|
-
const alertConfirm = function (data) {
|
|
6
|
-
if (container) {
|
|
7
|
-
render(null, container);
|
|
8
|
-
container = null;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
container = document.createElement('div');
|
|
12
|
-
|
|
13
|
-
const vnode = createVNode(AlertConfirm, {
|
|
14
|
-
message: data.message,
|
|
15
|
-
callback: data.confirm,
|
|
16
|
-
onDestroy: () => {
|
|
17
|
-
render(null, container);
|
|
18
|
-
}
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
render(vnode, container);
|
|
22
|
-
|
|
23
|
-
document.body.appendChild(container.firstElementChild);
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
export default alertConfirm;
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<Transition name="fadeInDown" @after-leave="$emit('destroy')">
|
|
3
|
-
<div v-show="visible" class="alert-message" @mouseenter="clearTimer" @mouseleave="startTimer" role="alert">
|
|
4
|
-
<div class="d-flex align-items-center rounded px-3 py-2" :class="className">
|
|
5
|
-
<div class="me-2">
|
|
6
|
-
<BiCheckCircle v-if="type === 'success'" />
|
|
7
|
-
<BiXCircle v-else-if="type === 'danger'" />
|
|
8
|
-
<BiExclamationCircle v-else-if="type === 'warning'" />
|
|
9
|
-
<BiInfoCircle v-else />
|
|
10
|
-
</div>
|
|
11
|
-
<div>{{ message }}</div>
|
|
12
|
-
</div>
|
|
13
|
-
</div>
|
|
14
|
-
</Transition>
|
|
15
|
-
</template>
|
|
16
|
-
|
|
17
|
-
<script setup>
|
|
18
|
-
import { computed, onMounted, ref } from 'vue';
|
|
19
|
-
|
|
20
|
-
const props = defineProps({
|
|
21
|
-
type: {
|
|
22
|
-
type: String,
|
|
23
|
-
default: 'info',
|
|
24
|
-
validator(value) {
|
|
25
|
-
return ['primary', 'secondary', 'success', 'danger', 'warning', 'info', 'light', 'dark'].includes(value);
|
|
26
|
-
}
|
|
27
|
-
},
|
|
28
|
-
message: {
|
|
29
|
-
type: String,
|
|
30
|
-
default: 'Alert Message'
|
|
31
|
-
},
|
|
32
|
-
duration: {
|
|
33
|
-
type: Number,
|
|
34
|
-
default: 3000
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
const visible = ref(false);
|
|
39
|
-
|
|
40
|
-
const className = computed(() => {
|
|
41
|
-
return `text-bg-${props.type}`;
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
onMounted(() => {
|
|
45
|
-
startTimer();
|
|
46
|
-
visible.value = true;
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
function close() {
|
|
50
|
-
visible.value = false;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
let timer = null;
|
|
54
|
-
function clearTimer() {
|
|
55
|
-
clearTimeout(timer);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
function startTimer() {
|
|
59
|
-
timer = setTimeout(() => {
|
|
60
|
-
close();
|
|
61
|
-
}, props.duration);
|
|
62
|
-
}
|
|
63
|
-
</script>
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { createVNode, render } from 'vue';
|
|
2
|
-
import AlertMessage from './alert-message.vue';
|
|
3
|
-
|
|
4
|
-
let container = null;
|
|
5
|
-
const alertMessage = function (data) {
|
|
6
|
-
if (container !== null) {
|
|
7
|
-
render(null, container);
|
|
8
|
-
container = null;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
container = document.createElement('div');
|
|
12
|
-
|
|
13
|
-
const vnode = createVNode(AlertMessage, {
|
|
14
|
-
type: data.type,
|
|
15
|
-
message: data.message,
|
|
16
|
-
duration: data.duration,
|
|
17
|
-
onDestroy: () => {
|
|
18
|
-
render(null, container);
|
|
19
|
-
}
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
render(vnode, container);
|
|
23
|
-
|
|
24
|
-
document.body.appendChild(container.firstElementChild);
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
export default alertMessage;
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<Teleport to="body">
|
|
3
|
-
<transition name="fadeIn">
|
|
4
|
-
<a v-if="visible" href="#" role="button" class="backtop" :class="backtopClass" @click.prevent="handleClick">
|
|
5
|
-
<BiArrowUpCircleFill />
|
|
6
|
-
</a>
|
|
7
|
-
</transition>
|
|
8
|
-
</Teleport>
|
|
9
|
-
</template>
|
|
10
|
-
|
|
11
|
-
<script setup>
|
|
12
|
-
import { ref, onMounted, onBeforeUnmount, computed } from 'vue';
|
|
13
|
-
|
|
14
|
-
const visible = ref(false);
|
|
15
|
-
|
|
16
|
-
const props = defineProps({
|
|
17
|
-
color: {
|
|
18
|
-
type: String,
|
|
19
|
-
default: 'primary',
|
|
20
|
-
validator(value) {
|
|
21
|
-
return ['primary', 'secondary', 'success', 'danger', 'warning', 'info', 'light', 'dark'].includes(value);
|
|
22
|
-
}
|
|
23
|
-
},
|
|
24
|
-
size: {
|
|
25
|
-
type: String,
|
|
26
|
-
default: 'md',
|
|
27
|
-
validator(value) {
|
|
28
|
-
return ['sm', 'md', 'lg'].includes(value);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
const backtopClass = computed(() => {
|
|
34
|
-
const classList = [`link-${props.color}`];
|
|
35
|
-
if (props.size === 'md') {
|
|
36
|
-
classList.push('display-4');
|
|
37
|
-
} else if (props.size === 'sm') {
|
|
38
|
-
classList.push('display-6');
|
|
39
|
-
} else if (props.size === 'lg') {
|
|
40
|
-
classList.push('display-2');
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
return classList;
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
onMounted(() => {
|
|
47
|
-
document.addEventListener('scroll', handleScroll);
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
onBeforeUnmount(() => {
|
|
51
|
-
document.removeEventListener('scroll', handleScroll);
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
function handleScroll() {
|
|
55
|
-
visible.value = document.documentElement.scrollTop >= 200;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
function handleClick() {
|
|
59
|
-
document.documentElement.scrollTo({ top: 0 });
|
|
60
|
-
}
|
|
61
|
-
</script>
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div :id="id" class="carousel slide" :class="carouselClass">
|
|
3
|
-
<div v-if="indicator" class="carousel-indicators">
|
|
4
|
-
<template v-for="(item, index) in items" :key="index">
|
|
5
|
-
<button
|
|
6
|
-
type="button"
|
|
7
|
-
:data-bs-target="`#${id}`"
|
|
8
|
-
:data-bs-slide-to="index"
|
|
9
|
-
:class="{ active: index === 0 }"
|
|
10
|
-
:aria-current="index === 0"
|
|
11
|
-
:aria-label="item.title"
|
|
12
|
-
></button>
|
|
13
|
-
</template>
|
|
14
|
-
</div>
|
|
15
|
-
<div class="carousel-inner">
|
|
16
|
-
<template v-for="(item, index) in items" :key="index">
|
|
17
|
-
<div class="carousel-item" :class="{ active: index === 0 }">
|
|
18
|
-
<img :src="item.image" class="d-block w-100" />
|
|
19
|
-
<div class="carousel-caption">
|
|
20
|
-
<h5>{{ item.title }}</h5>
|
|
21
|
-
<p>{{ item.description }}</p>
|
|
22
|
-
</div>
|
|
23
|
-
</div>
|
|
24
|
-
</template>
|
|
25
|
-
</div>
|
|
26
|
-
<template v-if="control">
|
|
27
|
-
<button class="carousel-control-prev" type="button" :data-bs-target="`#${id}`" data-bs-slide="prev">
|
|
28
|
-
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
|
|
29
|
-
<span class="visually-hidden">Previous</span>
|
|
30
|
-
</button>
|
|
31
|
-
<button class="carousel-control-next" type="button" :data-bs-target="`#${id}`" data-bs-slide="next">
|
|
32
|
-
<span class="carousel-control-next-icon" aria-hidden="true"></span>
|
|
33
|
-
<span class="visually-hidden">Next</span>
|
|
34
|
-
</button>
|
|
35
|
-
</template>
|
|
36
|
-
</div>
|
|
37
|
-
</template>
|
|
38
|
-
|
|
39
|
-
<script setup>
|
|
40
|
-
import { useId, onMounted, onBeforeUnmount } from 'vue';
|
|
41
|
-
import Carousel from 'bootstrap/js/dist/carousel';
|
|
42
|
-
|
|
43
|
-
const id = useId();
|
|
44
|
-
const props = defineProps({
|
|
45
|
-
items: {
|
|
46
|
-
type: Array,
|
|
47
|
-
required: true
|
|
48
|
-
},
|
|
49
|
-
carouselClass: {
|
|
50
|
-
type: String,
|
|
51
|
-
default: null
|
|
52
|
-
},
|
|
53
|
-
interval: {
|
|
54
|
-
type: Number,
|
|
55
|
-
default: 5000
|
|
56
|
-
},
|
|
57
|
-
keyboard: {
|
|
58
|
-
type: Boolean,
|
|
59
|
-
default: true
|
|
60
|
-
},
|
|
61
|
-
pause: {
|
|
62
|
-
type: [String, Boolean],
|
|
63
|
-
default: 'hover'
|
|
64
|
-
},
|
|
65
|
-
ride: {
|
|
66
|
-
type: [String, Boolean],
|
|
67
|
-
default: false
|
|
68
|
-
},
|
|
69
|
-
touch: {
|
|
70
|
-
type: Boolean,
|
|
71
|
-
default: true
|
|
72
|
-
},
|
|
73
|
-
wrap: {
|
|
74
|
-
type: Boolean,
|
|
75
|
-
default: true
|
|
76
|
-
},
|
|
77
|
-
control: {
|
|
78
|
-
type: Boolean,
|
|
79
|
-
default: true
|
|
80
|
-
},
|
|
81
|
-
indicator: {
|
|
82
|
-
type: Boolean,
|
|
83
|
-
default: true
|
|
84
|
-
}
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
let carousel = null;
|
|
88
|
-
onMounted(() => {
|
|
89
|
-
if (carousel === null) {
|
|
90
|
-
carousel = new Carousel(`#${id}`, {
|
|
91
|
-
interval: props.interval,
|
|
92
|
-
keyboard: props.keyboard,
|
|
93
|
-
pause: props.pause,
|
|
94
|
-
ride: props.ride,
|
|
95
|
-
touch: props.touch,
|
|
96
|
-
wrap: props.wrap
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
onBeforeUnmount(() => {
|
|
102
|
-
if (carousel !== null) {
|
|
103
|
-
carousel.dispose();
|
|
104
|
-
carousel = null;
|
|
105
|
-
}
|
|
106
|
-
});
|
|
107
|
-
</script>
|