Skip to content
This repository was archived by the owner on Nov 13, 2024. It is now read-only.

Commit e36c63f

Browse files
committed
Test: buttom
1 parent 3534f1e commit e36c63f

File tree

5 files changed

+196
-2
lines changed

5 files changed

+196
-2
lines changed

src/app/index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ app.use(elementPlus);
3939

4040
// global component
4141
import ItemGroup from "../components/ItemGroup";
42+
import FunctionGroup from "../components/FunctionGroup.vue";
43+
import FunctionGroupComponent from "../components/FunctionGroupComponent.vue";
4244

4345
app.component("ItemGroup", ItemGroup);
46+
app.component("FunctionGroup", FunctionGroup);
47+
app.component("FunctionComponent", FunctionGroupComponent);
4448
app.mount("#app");

src/app/views/Instances.vue

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,21 @@
3737
</ItemGroup>
3838
</el-col>
3939
<el-col :md="12" :offset="0">
40-
<ItemGroup style="text-align: right">
40+
<FunctionGroup :items="functionGroups">
41+
<FunctionComponent
42+
component="button"
43+
type="success"
44+
size="small"
45+
:plain="true"
46+
@click="toNewInstance"
47+
>
48+
New My Instance
49+
</FunctionComponent>
50+
<FunctionComponent component="button" size="small" :plain="true" @click="toNewInstance">
51+
Delete My Instance
52+
</FunctionComponent>
53+
</FunctionGroup>
54+
<!-- <ItemGroup style="text-align: right">
4155
<el-button
4256
type="primary"
4357
size="small"
@@ -54,6 +68,7 @@
5468
v-show="!showTableList"
5569
>{{ $t("instances.showTableList") }}</el-button
5670
>
71+
5772
<el-button size="small" type="success" @click="toNewInstance">
5873
<i class="el-icon-plus"></i> {{ $t("instances.newInstance") }}
5974
</el-button>
@@ -72,7 +87,7 @@
7287
<el-button size="small" type="danger" @click="batDelete(2)" v-if="showTableList">
7388
<i class="el-icon-delete"></i> {{ $t("instances.delete") }}
7489
</el-button>
75-
</ItemGroup>
90+
</ItemGroup> -->
7691
</el-col>
7792
</el-row>
7893

@@ -390,6 +405,18 @@ export default {
390405
components: { Panel, CircleCheckFilled, CircleCloseFilled },
391406
data() {
392407
return {
408+
functionGroups: [
409+
{
410+
type: "button",
411+
binds: {
412+
type: "success"
413+
},
414+
events: {
415+
click: this.toNewInstance
416+
},
417+
label: "New Instance"
418+
}
419+
],
393420
remoteList: [],
394421
currentRemoteUuid: null,
395422
instances: [],

src/components/Dialog.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ export default {
6464
overflow-y: auto;
6565
}
6666
.component-dialog-wrapper {
67+
text-align: left;
6768
position: fixed;
6869
top: 0;
6970
bottom: 0;

src/components/FunctionGroup.vue

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
<!--
2+
Copyright (C) 2022 MCSManager <[email protected]>
3+
-->
4+
5+
<template>
6+
<div>
7+
<div v-if="!isPhone">
8+
<div class="function_group">
9+
<slot></slot>
10+
</div>
11+
</div>
12+
<div v-else>
13+
<el-button type="primary" size="small" @click="operationClickHandler">Operation</el-button>
14+
</div>
15+
</div>
16+
<Dialog v-model="dialogVisible" :cancel="() => (dialogVisible = false)">
17+
<template #title>Operation</template>
18+
<template #default>
19+
<slot></slot>
20+
</template>
21+
</Dialog>
22+
</template>
23+
24+
<script>
25+
import Dialog from "./Dialog.vue";
26+
27+
export default {
28+
components: { Dialog },
29+
props: {
30+
style: {
31+
type: String,
32+
default: () => {}
33+
}
34+
},
35+
data() {
36+
return {
37+
dialogVisible: false,
38+
isPhone: false
39+
};
40+
},
41+
mounted() {
42+
this.resizeHandler();
43+
window.addEventListener("resize", this.resizeHandler);
44+
},
45+
unmounted() {
46+
window.removeEventListener("resize", this.resizeHandler);
47+
},
48+
methods: {
49+
resizeHandler() {
50+
if (window.innerWidth <= 900) {
51+
this.isPhone = true;
52+
} else {
53+
this.isPhone = false;
54+
}
55+
},
56+
operationClickHandler() {
57+
this.dialogVisible = true;
58+
}
59+
}
60+
};
61+
</script>
62+
63+
<style scoped>
64+
.func {
65+
display: inline-block;
66+
}
67+
.function_group {
68+
margin: -6px;
69+
}
70+
</style>
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
<!--
2+
Copyright (C) 2022 MCSManager <[email protected]>
3+
-->
4+
5+
<template>
6+
<div class="function-group-component" v-if="!isPhone" style="display: inline-block">
7+
<el-button v-if="component === 'button'" type="primary" size="small" v-bind="this.$props">
8+
<slot></slot>
9+
</el-button>
10+
</div>
11+
<div class="item" v-else style="display: block">
12+
<el-button
13+
v-if="component === 'button'"
14+
size="small"
15+
plain
16+
v-bind="this.$props"
17+
style="width: 100%; margin: 4px 0px"
18+
>
19+
<slot></slot>
20+
</el-button>
21+
</div>
22+
</template>
23+
24+
<script>
25+
export default {
26+
props: [
27+
"component",
28+
"type",
29+
"plain",
30+
"round",
31+
"size",
32+
"loading",
33+
"circle",
34+
"disabled",
35+
"icon",
36+
"autofocus",
37+
"native-type"
38+
],
39+
data: function () {
40+
return {
41+
isPhone: false
42+
};
43+
},
44+
mounted() {
45+
this.resizeHandler();
46+
window.addEventListener("resize", this.resizeHandler);
47+
},
48+
unmounted() {
49+
window.removeEventListener("resize", this.resizeHandler);
50+
},
51+
methods: {
52+
resizeHandler() {
53+
console.log(this);
54+
if (window.innerWidth <= 900) {
55+
this.isPhone = true;
56+
} else {
57+
this.isPhone = false;
58+
}
59+
}
60+
}
61+
};
62+
</script>
63+
64+
<style>
65+
.function-group-component {
66+
display: inline-block;
67+
margin: 6px;
68+
}
69+
/* @media (min-width: 900px) {
70+
.function-group-component {
71+
display: block;
72+
width: 100%;
73+
}
74+
} */
75+
</style>
76+
77+
<style scoped>
78+
.list-item {
79+
display: block;
80+
font-size: 14px;
81+
margin: 4px 0px;
82+
border: 1px solid #dcdfe4;
83+
border-top: 1px solid #dcdfe4;
84+
border-bottom: 1px solid #dcdfe4;
85+
padding: 16px 4px;
86+
cursor: pointer;
87+
}
88+
89+
.list-item :hover {
90+
background-color: #dcdfe4;
91+
}
92+
</style>

0 commit comments

Comments
 (0)