mirror of
https://github.com/element-plus/element-plus.git
synced 2025-04-06 16:30:35 +08:00
test(ssr): add ssr testing cases
- Add more cases for running ssr tests
This commit is contained in:
parent
3f72ec5818
commit
c2ecb3a773
BIN
ssr-testing/assets/test-image.jpeg
Normal file
BIN
ssr-testing/assets/test-image.jpeg
Normal file
Binary file not shown.
After Width: | Height: | Size: 66 KiB |
16
ssr-testing/cases/basic.vue
Normal file
16
ssr-testing/cases/basic.vue
Normal file
@ -0,0 +1,16 @@
|
||||
<template>
|
||||
<el-switch v-model="value1" />
|
||||
<el-switch
|
||||
v-model="value2"
|
||||
class="ml-2"
|
||||
active-color="#13ce66"
|
||||
inactive-color="#ff4949"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref } from 'vue'
|
||||
|
||||
const value1 = ref(true)
|
||||
const value2 = ref(true)
|
||||
</script>
|
53
ssr-testing/cases/drawer.vue
Normal file
53
ssr-testing/cases/drawer.vue
Normal file
@ -0,0 +1,53 @@
|
||||
<template>
|
||||
<el-radio-group v-model="direction">
|
||||
<el-radio label="ltr">left to right</el-radio>
|
||||
<el-radio label="rtl">right to left</el-radio>
|
||||
<el-radio label="ttb">top to bottom</el-radio>
|
||||
<el-radio label="btt">bottom to top</el-radio>
|
||||
</el-radio-group>
|
||||
|
||||
<el-button type="primary" style="margin-left: 16px" @click="drawer = true">
|
||||
open
|
||||
</el-button>
|
||||
<el-button type="primary" style="margin-left: 16px" @click="drawer2 = true">
|
||||
with footer
|
||||
</el-button>
|
||||
|
||||
<el-drawer v-model="drawer" title="I am the title" :direction="direction">
|
||||
<span>Hi, there!</span>
|
||||
</el-drawer>
|
||||
<el-drawer v-model="drawer2" :direction="direction">
|
||||
<template #title>
|
||||
<h4>set title by slot</h4>
|
||||
</template>
|
||||
<template #default>
|
||||
<div>
|
||||
<el-radio v-model="radio1" label="Option 1" size="large"
|
||||
>Option 1</el-radio
|
||||
>
|
||||
<el-radio v-model="radio1" label="Option 2" size="large"
|
||||
>Option 2</el-radio
|
||||
>
|
||||
</div>
|
||||
</template>
|
||||
<template #footer>
|
||||
<div style="flex: auto">
|
||||
<el-button @click="cancelClick">cancel</el-button>
|
||||
<el-button type="primary">confirm</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-drawer>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref } from 'vue'
|
||||
|
||||
const drawer = ref(false)
|
||||
const drawer2 = ref(false)
|
||||
const direction = ref<'rtl'>('rtl')
|
||||
const radio1 = ref('Option 1')
|
||||
|
||||
function cancelClick() {
|
||||
drawer2.value = false
|
||||
}
|
||||
</script>
|
31
ssr-testing/cases/dropdown.vue
Normal file
31
ssr-testing/cases/dropdown.vue
Normal file
@ -0,0 +1,31 @@
|
||||
<template>
|
||||
<el-dropdown>
|
||||
<span
|
||||
class="el-dropdown-link"
|
||||
style="
|
||||
cursor: pointer;
|
||||
color: var(--el-color-primary);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
"
|
||||
>
|
||||
Dropdown List
|
||||
<el-icon class="el-icon--right">
|
||||
<arrow-down />
|
||||
</el-icon>
|
||||
</span>
|
||||
<template #dropdown>
|
||||
<el-dropdown-menu>
|
||||
<el-dropdown-item>Action 1</el-dropdown-item>
|
||||
<el-dropdown-item>Action 2</el-dropdown-item>
|
||||
<el-dropdown-item>Action 3</el-dropdown-item>
|
||||
<el-dropdown-item disabled>Action 4</el-dropdown-item>
|
||||
<el-dropdown-item divided>Action 5</el-dropdown-item>
|
||||
</el-dropdown-menu>
|
||||
</template>
|
||||
</el-dropdown>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ArrowDown } from '@element-plus/icons-vue'
|
||||
</script>
|
3
ssr-testing/cases/empty.vue
Normal file
3
ssr-testing/cases/empty.vue
Normal file
@ -0,0 +1,3 @@
|
||||
<template>
|
||||
<el-empty description="description" />
|
||||
</template>
|
103
ssr-testing/cases/form.vue
Normal file
103
ssr-testing/cases/form.vue
Normal file
@ -0,0 +1,103 @@
|
||||
<template>
|
||||
<el-form
|
||||
ref="formRef"
|
||||
:model="dynamicValidateForm"
|
||||
label-width="120px"
|
||||
class="demo-dynamic"
|
||||
>
|
||||
<el-form-item
|
||||
prop="email"
|
||||
label="Email"
|
||||
:rules="[
|
||||
{
|
||||
required: true,
|
||||
message: 'Please input email address',
|
||||
trigger: 'blur',
|
||||
},
|
||||
{
|
||||
type: 'email',
|
||||
message: 'Please input correct email address',
|
||||
trigger: ['blur', 'change'],
|
||||
},
|
||||
]"
|
||||
>
|
||||
<el-input v-model="dynamicValidateForm.email" />
|
||||
</el-form-item>
|
||||
<el-form-item
|
||||
v-for="(domain, index) in dynamicValidateForm.domains"
|
||||
:key="domain.key"
|
||||
:label="'Domain' + index"
|
||||
:prop="'domains.' + index + '.value'"
|
||||
:rules="{
|
||||
required: true,
|
||||
message: 'domain can not be null',
|
||||
trigger: 'blur',
|
||||
}"
|
||||
>
|
||||
<el-input v-model="domain.value" />
|
||||
<el-button style="margin-top: 8px" @click.prevent="removeDomain(domain)"
|
||||
>Delete</el-button
|
||||
>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" @click="submitForm(formRef)">Submit</el-button>
|
||||
<el-button @click="addDomain">New domain</el-button>
|
||||
<el-button @click="resetForm(formRef)">Reset</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { reactive, ref } from 'vue'
|
||||
import type { FormInstance } from 'element-plus'
|
||||
|
||||
const formRef = ref<FormInstance>()
|
||||
const dynamicValidateForm = reactive<{
|
||||
domains: DomainItem[]
|
||||
email: string
|
||||
}>({
|
||||
domains: [
|
||||
{
|
||||
key: 1,
|
||||
value: '',
|
||||
},
|
||||
],
|
||||
email: '',
|
||||
})
|
||||
|
||||
interface DomainItem {
|
||||
key: number
|
||||
value: string
|
||||
}
|
||||
|
||||
const removeDomain = (item: DomainItem) => {
|
||||
const index = dynamicValidateForm.domains.indexOf(item)
|
||||
if (index !== -1) {
|
||||
dynamicValidateForm.domains.splice(index, 1)
|
||||
}
|
||||
}
|
||||
|
||||
const addDomain = () => {
|
||||
dynamicValidateForm.domains.push({
|
||||
key: Date.now(),
|
||||
value: '',
|
||||
})
|
||||
}
|
||||
|
||||
const submitForm = (formEl: FormInstance | undefined) => {
|
||||
if (!formEl) return
|
||||
formEl.validate((valid) => {
|
||||
if (valid) {
|
||||
console.log('submit!')
|
||||
} else {
|
||||
console.log('error submit!')
|
||||
return false
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const resetForm = (formEl: FormInstance | undefined) => {
|
||||
if (!formEl) return
|
||||
formEl.resetFields()
|
||||
}
|
||||
</script>
|
36
ssr-testing/cases/image.vue
Normal file
36
ssr-testing/cases/image.vue
Normal file
@ -0,0 +1,36 @@
|
||||
<template>
|
||||
<div class="demo-image">
|
||||
<div
|
||||
v-for="fit in fits"
|
||||
:key="fit"
|
||||
class="block"
|
||||
style="
|
||||
padding: 30px 0;
|
||||
text-align: center;
|
||||
border-right: solid 1px var(--el-border-color);
|
||||
display: inline-block;
|
||||
width: 20%;
|
||||
box-sizing: border-box;
|
||||
vertical-align: top;
|
||||
"
|
||||
>
|
||||
<span
|
||||
class="demonstration"
|
||||
style="
|
||||
display: block;
|
||||
color: var(--el-text-color-secondary);
|
||||
font-size: 14px;
|
||||
margin-bottom: 20px;
|
||||
"
|
||||
>{{ fit }}</span
|
||||
>
|
||||
<el-image style="width: 100px; height: 100px" :url="url" :fit="fit" />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
const fits = ['fill', 'contain', 'cover', 'none', 'scale-down'] as const
|
||||
const url =
|
||||
'https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg'
|
||||
</script>
|
39
ssr-testing/cases/infinite-scroll.vue
Normal file
39
ssr-testing/cases/infinite-scroll.vue
Normal file
@ -0,0 +1,39 @@
|
||||
<template>
|
||||
<ul
|
||||
v-infinite-scroll="load"
|
||||
class="infinite-list"
|
||||
style="
|
||||
overflow: auto;
|
||||
height: 300px;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
list-style: none;
|
||||
"
|
||||
>
|
||||
<li
|
||||
v-for="i in count"
|
||||
:key="i"
|
||||
class="infinite-list-item"
|
||||
style="
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
height: 50px;
|
||||
background: var(--el-color-primary-light-9);
|
||||
margin: 10px;
|
||||
color: var(--el-color-primary);
|
||||
margin-top: 10px;
|
||||
"
|
||||
>
|
||||
{{ i }}
|
||||
</li>
|
||||
</ul>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref } from 'vue'
|
||||
const count = ref(0)
|
||||
const load = () => {
|
||||
count.value += 2
|
||||
}
|
||||
</script>
|
9
ssr-testing/cases/input-number.vue
Normal file
9
ssr-testing/cases/input-number.vue
Normal file
@ -0,0 +1,9 @@
|
||||
<template>
|
||||
<el-input-number v-model="num" :min="1" :max="10" />
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref } from 'vue'
|
||||
|
||||
const num = ref(1)
|
||||
</script>
|
8
ssr-testing/cases/input.vue
Normal file
8
ssr-testing/cases/input.vue
Normal file
@ -0,0 +1,8 @@
|
||||
<template>
|
||||
<el-input v-model="input" placeholder="Please input" />
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref } from 'vue'
|
||||
const input = ref('')
|
||||
</script>
|
92
ssr-testing/cases/layout.vue
Normal file
92
ssr-testing/cases/layout.vue
Normal file
@ -0,0 +1,92 @@
|
||||
<template>
|
||||
<el-row style="margin-bottom: 20px">
|
||||
<el-col :span="24" style="border-radius: 4px"
|
||||
><div
|
||||
class="grid-content bg-purple-dark"
|
||||
style="border-radius: 4px; min-height: 36px; background: #99a9bf"
|
||||
/></el-col>
|
||||
</el-row>
|
||||
<el-row style="margin-bottom: 20px">
|
||||
<el-col :span="12" style="border-radius: 4px"
|
||||
><div
|
||||
class="grid-content bg-purple"
|
||||
style="border-radius: 4px; min-height: 36px; background: #d3dce6"
|
||||
/></el-col>
|
||||
<el-col :span="12" style="border-radius: 4px"
|
||||
><div
|
||||
class="grid-content bg-purple"
|
||||
style="border-radius: 4px; min-height: 36px; background: #e5e9f2"
|
||||
/></el-col>
|
||||
</el-row>
|
||||
<el-row style="margin-bottom: 20px">
|
||||
<el-col :span="8" style="border-radius: 4px"
|
||||
><div
|
||||
class="grid-content bg-purple"
|
||||
style="border-radius: 4px; min-height: 36px; background: #d3dce6"
|
||||
/></el-col>
|
||||
<el-col :span="8" style="border-radius: 4px"
|
||||
><div
|
||||
class="grid-content bg-purple"
|
||||
style="border-radius: 4px; min-height: 36px; background: #e5e9f2"
|
||||
/></el-col>
|
||||
<el-col :span="8" style="border-radius: 4px"
|
||||
><div
|
||||
class="grid-content bg-purple"
|
||||
style="border-radius: 4px; min-height: 36px; background: #d3dce6"
|
||||
/></el-col>
|
||||
</el-row>
|
||||
<el-row style="margin-bottom: 20px">
|
||||
<el-col :span="6" style="border-radius: 4px"
|
||||
><div
|
||||
class="grid-content bg-purple"
|
||||
style="border-radius: 4px; min-height: 36px; background: #d3dce6"
|
||||
/></el-col>
|
||||
<el-col :span="6" style="border-radius: 4px"
|
||||
><div
|
||||
class="grid-content bg-purple"
|
||||
style="border-radius: 4px; min-height: 36px; background: #e5e9f2"
|
||||
/></el-col>
|
||||
<el-col :span="6" style="border-radius: 4px"
|
||||
><div
|
||||
class="grid-content bg-purple"
|
||||
style="border-radius: 4px; min-height: 36px; background: #d3dce6"
|
||||
/></el-col>
|
||||
<el-col :span="6" style="border-radius: 4px"
|
||||
><div
|
||||
class="grid-content bg-purple"
|
||||
style="border-radius: 4px; min-height: 36px; background: #e5e9f2"
|
||||
/></el-col>
|
||||
</el-row>
|
||||
<el-row style="margin-bottom: 20px">
|
||||
<el-col :span="4" style="border-radius: 4px"
|
||||
><div
|
||||
class="grid-content bg-purple"
|
||||
style="border-radius: 4px; min-height: 36px; background: #d3dce6"
|
||||
/></el-col>
|
||||
<el-col :span="4" style="border-radius: 4px"
|
||||
><div
|
||||
class="grid-content bg-purple"
|
||||
style="border-radius: 4px; min-height: 36px; background: #e5e9f2"
|
||||
/></el-col>
|
||||
<el-col :span="4" style="border-radius: 4px"
|
||||
><div
|
||||
class="grid-content bg-purple"
|
||||
style="border-radius: 4px; min-height: 36px; background: #d3dce6"
|
||||
/></el-col>
|
||||
<el-col :span="4" style="border-radius: 4px"
|
||||
><div
|
||||
class="grid-content bg-purple"
|
||||
style="border-radius: 4px; min-height: 36px; background: #e5e9f2"
|
||||
/></el-col>
|
||||
<el-col :span="4" style="border-radius: 4px"
|
||||
><div
|
||||
class="grid-content bg-purple"
|
||||
style="border-radius: 4px; min-height: 36px; background: #d3dce6"
|
||||
/></el-col>
|
||||
<el-col :span="4" style="border-radius: 4px"
|
||||
><div
|
||||
class="grid-content bg-purple"
|
||||
style="border-radius: 4px; min-height: 36px; background: #e5e9f2"
|
||||
/></el-col>
|
||||
</el-row>
|
||||
</template>
|
18
ssr-testing/cases/link.vue
Normal file
18
ssr-testing/cases/link.vue
Normal file
@ -0,0 +1,18 @@
|
||||
<template>
|
||||
<div>
|
||||
<el-link href="https://element.eleme.io" target="_blank">default</el-link>
|
||||
<el-link type="primary">primary</el-link>
|
||||
<el-link type="success">success</el-link>
|
||||
<el-link type="warning">warning</el-link>
|
||||
<el-link type="danger">danger</el-link>
|
||||
<el-link type="info">info</el-link>
|
||||
</div>
|
||||
</template>
|
||||
<style scoped>
|
||||
.el-link {
|
||||
margin-right: 8px;
|
||||
}
|
||||
.el-link .el-icon--right.el-icon {
|
||||
vertical-align: text-bottom;
|
||||
}
|
||||
</style>
|
37
ssr-testing/cases/loading.vue
Normal file
37
ssr-testing/cases/loading.vue
Normal file
@ -0,0 +1,37 @@
|
||||
<template>
|
||||
<el-table v-loading="loading" :data="tableData" style="width: 100%">
|
||||
<el-table-column prop="date" label="Date" width="180" />
|
||||
<el-table-column prop="name" label="Name" width="180" />
|
||||
<el-table-column prop="address" label="Address" />
|
||||
</el-table>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref } from 'vue'
|
||||
|
||||
const loading = ref(true)
|
||||
|
||||
const tableData = [
|
||||
{
|
||||
date: '2016-05-02',
|
||||
name: 'John Smith',
|
||||
address: 'No.1518, Jinshajiang Road, Putuo District',
|
||||
},
|
||||
{
|
||||
date: '2016-05-04',
|
||||
name: 'John Smith',
|
||||
address: 'No.1518, Jinshajiang Road, Putuo District',
|
||||
},
|
||||
{
|
||||
date: '2016-05-01',
|
||||
name: 'John Smith',
|
||||
address: 'No.1518, Jinshajiang Road, Putuo District',
|
||||
},
|
||||
]
|
||||
</script>
|
||||
|
||||
<style>
|
||||
body {
|
||||
margin: 0;
|
||||
}
|
||||
</style>
|
17
ssr-testing/cases/menu.vue
Normal file
17
ssr-testing/cases/menu.vue
Normal file
@ -0,0 +1,17 @@
|
||||
<template>
|
||||
<el-menu :default-active="activeIndex" class="el-menu-demo" mode="horizontal">
|
||||
<el-menu-item index="1">Processing Center</el-menu-item>
|
||||
<el-sub-menu index="2">
|
||||
<template #title>Workspace</template>
|
||||
<el-menu-item index="2-1">item one</el-menu-item>
|
||||
</el-sub-menu>
|
||||
<el-menu-item index="3" disabled>Info</el-menu-item>
|
||||
<el-menu-item index="4">Orders</el-menu-item>
|
||||
</el-menu>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref } from 'vue'
|
||||
|
||||
const activeIndex = ref('1')
|
||||
</script>
|
17
ssr-testing/cases/notification.vue
Normal file
17
ssr-testing/cases/notification.vue
Normal file
@ -0,0 +1,17 @@
|
||||
<template>
|
||||
<div>notify</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { getCurrentInstance } from 'vue'
|
||||
|
||||
const vm = getCurrentInstance()!
|
||||
|
||||
const notify = vm.appContext.config.globalProperties.$notify
|
||||
|
||||
notify({
|
||||
title: 'Prompt',
|
||||
message: 'This is a message that does not automatically close',
|
||||
duration: 0,
|
||||
})
|
||||
</script>
|
3
ssr-testing/cases/page-header.vue
Normal file
3
ssr-testing/cases/page-header.vue
Normal file
@ -0,0 +1,3 @@
|
||||
<template>
|
||||
<el-page-header content="detail" />
|
||||
</template>
|
19
ssr-testing/cases/pagination.vue
Normal file
19
ssr-testing/cases/pagination.vue
Normal file
@ -0,0 +1,19 @@
|
||||
<template>
|
||||
<div class="example-pagination-block">
|
||||
<div class="example-demonstration">When you have few pages</div>
|
||||
<el-pagination layout="prev, pager, next" :total="50" />
|
||||
</div>
|
||||
<div class="example-pagination-block">
|
||||
<div class="example-demonstration">When you have more than 7 pages</div>
|
||||
<el-pagination layout="prev, pager, next" :total="1000" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.example-pagination-block + .example-pagination-block {
|
||||
margin-top: 10px;
|
||||
}
|
||||
.example-pagination-block .example-demonstration {
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
</style>
|
7
ssr-testing/cases/popconfirm.vue
Normal file
7
ssr-testing/cases/popconfirm.vue
Normal file
@ -0,0 +1,7 @@
|
||||
<template>
|
||||
<el-popconfirm title="Are you sure to delete this?">
|
||||
<template #reference>
|
||||
<el-button>Delete</el-button>
|
||||
</template>
|
||||
</el-popconfirm>
|
||||
</template>
|
14
ssr-testing/cases/popover.vue
Normal file
14
ssr-testing/cases/popover.vue
Normal file
@ -0,0 +1,14 @@
|
||||
<template>
|
||||
<el-popover
|
||||
ref="popover"
|
||||
placement="right"
|
||||
title="Title"
|
||||
:width="200"
|
||||
trigger="focus"
|
||||
content="this is content, this is content, this is content"
|
||||
>
|
||||
<template #reference>
|
||||
<el-button>Focus to activate</el-button>
|
||||
</template>
|
||||
</el-popover>
|
||||
</template>
|
29
ssr-testing/cases/progress.vue
Normal file
29
ssr-testing/cases/progress.vue
Normal file
@ -0,0 +1,29 @@
|
||||
<template>
|
||||
<div class="demo-progress">
|
||||
<el-progress :percentage="50" :indeterminate="true" />
|
||||
<el-progress :percentage="100" :format="format" :indeterminate="true" />
|
||||
<el-progress
|
||||
:percentage="100"
|
||||
status="success"
|
||||
:indeterminate="true"
|
||||
:duration="5"
|
||||
/>
|
||||
<el-progress
|
||||
:percentage="100"
|
||||
status="warning"
|
||||
:indeterminate="true"
|
||||
:duration="1"
|
||||
/>
|
||||
<el-progress :percentage="50" status="exception" :indeterminate="true" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
const format = (percentage) => (percentage === 100 ? 'Full' : `${percentage}%`)
|
||||
</script>
|
||||
<style scoped>
|
||||
.demo-progress .el-progress--line {
|
||||
margin-bottom: 15px;
|
||||
width: 350px;
|
||||
}
|
||||
</style>
|
30
ssr-testing/cases/radio.vue
Normal file
30
ssr-testing/cases/radio.vue
Normal file
@ -0,0 +1,30 @@
|
||||
<template>
|
||||
<div>
|
||||
<el-radio v-model="radio1" label="1" size="large">Option 1</el-radio>
|
||||
<el-radio v-model="radio1" label="2" size="large">Option 2</el-radio>
|
||||
</div>
|
||||
<div>
|
||||
<el-radio v-model="radio2" label="1">Option 1</el-radio>
|
||||
<el-radio v-model="radio2" label="2">Option 2</el-radio>
|
||||
</div>
|
||||
<div>
|
||||
<el-radio v-model="radio3" label="1" size="small">Option 1</el-radio>
|
||||
<el-radio v-model="radio3" label="2" size="small">Option 2</el-radio>
|
||||
</div>
|
||||
<div>
|
||||
<el-radio v-model="radio3" label="1" size="small" disabled
|
||||
>Option 1</el-radio
|
||||
>
|
||||
<el-radio v-model="radio3" label="2" size="small" disabled
|
||||
>Option 2</el-radio
|
||||
>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref } from 'vue'
|
||||
|
||||
const radio1 = ref('1')
|
||||
const radio2 = ref('1')
|
||||
const radio3 = ref('1')
|
||||
</script>
|
38
ssr-testing/cases/rate.vue
Normal file
38
ssr-testing/cases/rate.vue
Normal file
@ -0,0 +1,38 @@
|
||||
<template>
|
||||
<div class="demo-rate-block">
|
||||
<span class="demonstration">Default</span>
|
||||
<el-rate v-model="value1" />
|
||||
</div>
|
||||
<div class="demo-rate-block">
|
||||
<span class="demonstration">Color for different levels</span>
|
||||
<el-rate v-model="value2" :colors="colors" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref } from 'vue'
|
||||
|
||||
const value1 = ref(null)
|
||||
const value2 = ref(null)
|
||||
const colors = ref(['#99A9BF', '#F7BA2A', '#FF9900']) // same as { 2: '#99A9BF', 4: { value: '#F7BA2A', excluded: true }, 5: '#FF9900' }
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.demo-rate-block {
|
||||
padding: 30px 0;
|
||||
text-align: center;
|
||||
border-right: solid 1px var(--el-border-color);
|
||||
display: inline-block;
|
||||
width: 49%;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
.demo-rate-block:last-child {
|
||||
border-right: none;
|
||||
}
|
||||
.demo-rate-block .demonstration {
|
||||
display: block;
|
||||
color: var(--el-text-color-secondary);
|
||||
font-size: 14px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
</style>
|
47
ssr-testing/cases/result.vue
Normal file
47
ssr-testing/cases/result.vue
Normal file
@ -0,0 +1,47 @@
|
||||
<template>
|
||||
<el-row>
|
||||
<el-col :sm="12" :lg="6">
|
||||
<el-result
|
||||
icon="success"
|
||||
title="Success Tip"
|
||||
sub-title="Please follow the instructions"
|
||||
>
|
||||
<template #extra>
|
||||
<el-button type="primary">Back</el-button>
|
||||
</template>
|
||||
</el-result>
|
||||
</el-col>
|
||||
<el-col :sm="12" :lg="6">
|
||||
<el-result
|
||||
icon="warning"
|
||||
title="Warning Tip"
|
||||
sub-title="Please follow the instructions"
|
||||
>
|
||||
<template #extra>
|
||||
<el-button type="primary">Back</el-button>
|
||||
</template>
|
||||
</el-result>
|
||||
</el-col>
|
||||
<el-col :sm="12" :lg="6">
|
||||
<el-result
|
||||
icon="error"
|
||||
title="Error Tip"
|
||||
sub-title="Please follow the instructions"
|
||||
>
|
||||
<template #extra>
|
||||
<el-button type="primary">Back</el-button>
|
||||
</template>
|
||||
</el-result>
|
||||
</el-col>
|
||||
<el-col :sm="12" :lg="6">
|
||||
<el-result icon="info" title="Info Tip">
|
||||
<template #sub-title>
|
||||
<p>Using slot as subtitle</p>
|
||||
</template>
|
||||
<template #extra>
|
||||
<el-button type="primary">Back</el-button>
|
||||
</template>
|
||||
</el-result>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</template>
|
19
ssr-testing/cases/scrollbar.vue
Normal file
19
ssr-testing/cases/scrollbar.vue
Normal file
@ -0,0 +1,19 @@
|
||||
<template>
|
||||
<el-scrollbar height="400px">
|
||||
<p v-for="item in 20" :key="item" class="scrollbar-demo-item">{{ item }}</p>
|
||||
</el-scrollbar>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.scrollbar-demo-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
height: 50px;
|
||||
margin: 10px;
|
||||
text-align: center;
|
||||
border-radius: 4px;
|
||||
background: var(--el-color-primary-light-9);
|
||||
color: var(--el-color-primary);
|
||||
}
|
||||
</style>
|
54
ssr-testing/cases/select-v2.vue
Normal file
54
ssr-testing/cases/select-v2.vue
Normal file
@ -0,0 +1,54 @@
|
||||
<template>
|
||||
<div style="flex: auto">
|
||||
<div>
|
||||
<el-select-v2
|
||||
v-model="value1"
|
||||
:options="options"
|
||||
placeholder="Please select"
|
||||
style="width: 240px; margin-right: 16px; vertical-align: middle"
|
||||
allow-create
|
||||
filterable
|
||||
multiple
|
||||
clearable
|
||||
/>
|
||||
<el-select-v2
|
||||
v-model="value2"
|
||||
:options="options"
|
||||
placeholder="Please select"
|
||||
style="width: 240px; vertical-align: middle"
|
||||
allow-create
|
||||
filterable
|
||||
clearable
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<p style="margin-top: 20px; margin-bottom: 8px">
|
||||
set reserve-keyword false
|
||||
</p>
|
||||
<el-select-v2
|
||||
v-model="value3"
|
||||
:options="options"
|
||||
placeholder="Please select"
|
||||
style="width: 240px; margin-right: 16px; vertical-align: middle"
|
||||
allow-create
|
||||
filterable
|
||||
multiple
|
||||
clearable
|
||||
:reserve-keyword="false"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref } from 'vue'
|
||||
const initials = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']
|
||||
|
||||
const value1 = ref([])
|
||||
const value2 = ref('')
|
||||
const value3 = ref([])
|
||||
const options = Array.from({ length: 1000 }).map((_, idx) => ({
|
||||
value: `Option ${idx + 1}`,
|
||||
label: `${initials[idx % 10]}${idx}`,
|
||||
}))
|
||||
</script>
|
55
ssr-testing/cases/select.vue
Normal file
55
ssr-testing/cases/select.vue
Normal file
@ -0,0 +1,55 @@
|
||||
<template>
|
||||
<el-select v-model="value" class="m-2" placeholder="Select" size="large">
|
||||
<el-option
|
||||
v-for="item in options"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value"
|
||||
/>
|
||||
</el-select>
|
||||
<el-select v-model="value" class="m-2" placeholder="Select">
|
||||
<el-option
|
||||
v-for="item in options"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value"
|
||||
/>
|
||||
</el-select>
|
||||
<el-select v-model="value" class="m-2" placeholder="Select" size="small">
|
||||
<el-option
|
||||
v-for="item in options"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value"
|
||||
/>
|
||||
</el-select>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref } from 'vue'
|
||||
|
||||
const value = ref('')
|
||||
|
||||
const options = [
|
||||
{
|
||||
value: 'Option1',
|
||||
label: 'Option1',
|
||||
},
|
||||
{
|
||||
value: 'Option2',
|
||||
label: 'Option2',
|
||||
},
|
||||
{
|
||||
value: 'Option3',
|
||||
label: 'Option3',
|
||||
},
|
||||
{
|
||||
value: 'Option4',
|
||||
label: 'Option4',
|
||||
},
|
||||
{
|
||||
value: 'Option5',
|
||||
label: 'Option5',
|
||||
},
|
||||
]
|
||||
</script>
|
9
ssr-testing/cases/skeleton.vue
Normal file
9
ssr-testing/cases/skeleton.vue
Normal file
@ -0,0 +1,9 @@
|
||||
<template>
|
||||
<el-skeleton />
|
||||
<br />
|
||||
<el-skeleton style="--el-skeleton-circle-size: 100px">
|
||||
<template #template>
|
||||
<el-skeleton-item variant="circle" />
|
||||
</template>
|
||||
</el-skeleton>
|
||||
</template>
|
59
ssr-testing/cases/slider.vue
Normal file
59
ssr-testing/cases/slider.vue
Normal file
@ -0,0 +1,59 @@
|
||||
<template>
|
||||
<div class="slider-demo-block">
|
||||
<span class="demonstration">Default value</span>
|
||||
<el-slider v-model="value1" />
|
||||
</div>
|
||||
<div class="slider-demo-block">
|
||||
<span class="demonstration">Customized initial value</span>
|
||||
<el-slider v-model="value2" />
|
||||
</div>
|
||||
<div class="slider-demo-block">
|
||||
<span class="demonstration">Hide Tooltip</span>
|
||||
<el-slider v-model="value3" :show-tooltip="false" />
|
||||
</div>
|
||||
<div class="slider-demo-block">
|
||||
<span class="demonstration">Format Tooltip</span>
|
||||
<el-slider v-model="value4" :format-tooltip="formatTooltip" />
|
||||
</div>
|
||||
<div class="slider-demo-block">
|
||||
<span class="demonstration">Disabled</span>
|
||||
<el-slider v-model="value5" disabled />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref } from 'vue'
|
||||
|
||||
const value1 = ref(0)
|
||||
const value2 = ref(0)
|
||||
const value3 = ref(0)
|
||||
const value4 = ref(0)
|
||||
const value5 = ref(0)
|
||||
|
||||
const formatTooltip = (val: number) => {
|
||||
return val / 100
|
||||
}
|
||||
</script>
|
||||
<style scoped>
|
||||
.slider-demo-block {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
.slider-demo-block .el-slider {
|
||||
margin-top: 0;
|
||||
margin-left: 12px;
|
||||
}
|
||||
.slider-demo-block .demonstration {
|
||||
font-size: 14px;
|
||||
color: var(--el-text-color-secondary);
|
||||
line-height: 44px;
|
||||
flex: 1;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
.slider-demo-block .demonstration + .el-slider {
|
||||
flex: 0 0 70%;
|
||||
}
|
||||
</style>
|
15
ssr-testing/cases/space.vue
Normal file
15
ssr-testing/cases/space.vue
Normal file
@ -0,0 +1,15 @@
|
||||
<template>
|
||||
<el-space wrap>
|
||||
<el-card v-for="i in 3" :key="i" class="box-card" style="width: 250px">
|
||||
<template #header>
|
||||
<div class="card-header">
|
||||
<span>Card name</span>
|
||||
<el-button class="button" type="text">Operation button</el-button>
|
||||
</div>
|
||||
</template>
|
||||
<div v-for="o in 4" :key="o" class="text item">
|
||||
{{ 'List item ' + o }}
|
||||
</div>
|
||||
</el-card>
|
||||
</el-space>
|
||||
</template>
|
19
ssr-testing/cases/steps.vue
Normal file
19
ssr-testing/cases/steps.vue
Normal file
@ -0,0 +1,19 @@
|
||||
<template>
|
||||
<el-steps :active="active" finish-status="success">
|
||||
<el-step title="Step 1" />
|
||||
<el-step title="Step 2" />
|
||||
<el-step title="Step 3" />
|
||||
</el-steps>
|
||||
|
||||
<el-button style="margin-top: 12px" @click="next">Next step</el-button>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref } from 'vue'
|
||||
|
||||
const active = ref(0)
|
||||
|
||||
const next = () => {
|
||||
if (active.value++ > 2) active.value = 0
|
||||
}
|
||||
</script>
|
32
ssr-testing/cases/table.vue
Normal file
32
ssr-testing/cases/table.vue
Normal file
@ -0,0 +1,32 @@
|
||||
<template>
|
||||
<el-table :data="tableData" style="width: 100%">
|
||||
<el-table-column prop="date" label="Date" width="180" />
|
||||
<el-table-column prop="name" label="Name" width="180" />
|
||||
<el-table-column prop="address" label="Address" />
|
||||
</el-table>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
const tableData = [
|
||||
{
|
||||
date: '2016-05-03',
|
||||
name: 'Tom',
|
||||
address: 'No. 189, Grove St, Los Angeles',
|
||||
},
|
||||
{
|
||||
date: '2016-05-02',
|
||||
name: 'Tom',
|
||||
address: 'No. 189, Grove St, Los Angeles',
|
||||
},
|
||||
{
|
||||
date: '2016-05-04',
|
||||
name: 'Tom',
|
||||
address: 'No. 189, Grove St, Los Angeles',
|
||||
},
|
||||
{
|
||||
date: '2016-05-01',
|
||||
name: 'Tom',
|
||||
address: 'No. 189, Grove St, Los Angeles',
|
||||
},
|
||||
]
|
||||
</script>
|
25
ssr-testing/cases/tabs.vue
Normal file
25
ssr-testing/cases/tabs.vue
Normal file
@ -0,0 +1,25 @@
|
||||
<template>
|
||||
<el-tabs v-model="activeName" class="demo-tabs" @tab-click="handleClick">
|
||||
<el-tab-pane label="User" name="first">User</el-tab-pane>
|
||||
<el-tab-pane label="Config" name="second">Config</el-tab-pane>
|
||||
<el-tab-pane label="Role" name="third">Role</el-tab-pane>
|
||||
<el-tab-pane label="Task" name="fourth">Task</el-tab-pane>
|
||||
</el-tabs>
|
||||
</template>
|
||||
<script lang="ts" setup>
|
||||
import { ref } from 'vue'
|
||||
|
||||
const activeName = ref('first')
|
||||
|
||||
const handleClick = (tab: string, event: Event) => {
|
||||
console.log(tab, event)
|
||||
}
|
||||
</script>
|
||||
<style>
|
||||
.demo-tabs > .el-tabs__content {
|
||||
padding: 32px;
|
||||
color: #6b778c;
|
||||
font-size: 32px;
|
||||
font-weight: 600;
|
||||
}
|
||||
</style>
|
7
ssr-testing/cases/tag.vue
Normal file
7
ssr-testing/cases/tag.vue
Normal file
@ -0,0 +1,7 @@
|
||||
<template>
|
||||
<el-tag>Tag 1</el-tag>
|
||||
<el-tag class="ml-2" type="success">Tag 2</el-tag>
|
||||
<el-tag class="ml-2" type="info">Tag 3</el-tag>
|
||||
<el-tag class="ml-2" type="warning">Tag 4</el-tag>
|
||||
<el-tag class="ml-2" type="danger">Tag 5</el-tag>
|
||||
</template>
|
22
ssr-testing/cases/time-picker.vue
Normal file
22
ssr-testing/cases/time-picker.vue
Normal file
@ -0,0 +1,22 @@
|
||||
<template>
|
||||
<div class="example-basic">
|
||||
<el-time-picker v-model="value1" placeholder="Arbitrary time" />
|
||||
<el-time-picker
|
||||
v-model="value2"
|
||||
arrow-control
|
||||
placeholder="Arbitrary time"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref } from 'vue'
|
||||
const value1 = ref()
|
||||
const value2 = ref()
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.example-basic .el-date-editor {
|
||||
margin: 8px;
|
||||
}
|
||||
</style>
|
15
ssr-testing/cases/time-select.vue
Normal file
15
ssr-testing/cases/time-select.vue
Normal file
@ -0,0 +1,15 @@
|
||||
<template>
|
||||
<el-time-select
|
||||
v-model="value"
|
||||
start="08:30"
|
||||
step="00:15"
|
||||
end="18:30"
|
||||
placeholder="Select time"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref } from 'vue'
|
||||
|
||||
const value = ref('')
|
||||
</script>
|
28
ssr-testing/cases/timeline.vue
Normal file
28
ssr-testing/cases/timeline.vue
Normal file
@ -0,0 +1,28 @@
|
||||
<template>
|
||||
<el-timeline>
|
||||
<el-timeline-item
|
||||
v-for="(activity, index) in activities"
|
||||
:key="index"
|
||||
:timestamp="activity.timestamp"
|
||||
>
|
||||
{{ activity.content }}
|
||||
</el-timeline-item>
|
||||
</el-timeline>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
const activities = [
|
||||
{
|
||||
content: 'Event start',
|
||||
timestamp: '2018-04-15',
|
||||
},
|
||||
{
|
||||
content: 'Approved',
|
||||
timestamp: '2018-04-13',
|
||||
},
|
||||
{
|
||||
content: 'Success',
|
||||
timestamp: '2018-04-11',
|
||||
},
|
||||
]
|
||||
</script>
|
32
ssr-testing/cases/tooltip.vue
Normal file
32
ssr-testing/cases/tooltip.vue
Normal file
@ -0,0 +1,32 @@
|
||||
<template>
|
||||
<el-tooltip
|
||||
:disabled="disabled"
|
||||
content="click to close tooltip function"
|
||||
placement="bottom"
|
||||
effect="light"
|
||||
>
|
||||
<el-button @click="disabled = !disabled"
|
||||
>click to {{ disabled ? 'active' : 'close' }} tooltip function</el-button
|
||||
>
|
||||
</el-tooltip>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref } from 'vue'
|
||||
|
||||
const disabled = ref(false)
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.slide-fade-enter-active {
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
.slide-fade-leave-active {
|
||||
transition: all 0.3s cubic-bezier(1, 0.5, 0.8, 1);
|
||||
}
|
||||
.slide-fade-enter,
|
||||
.expand-fade-leave-active {
|
||||
margin-left: 20px;
|
||||
opacity: 0;
|
||||
}
|
||||
</style>
|
108
ssr-testing/cases/transfer.vue
Normal file
108
ssr-testing/cases/transfer.vue
Normal file
@ -0,0 +1,108 @@
|
||||
<template>
|
||||
<p style="text-align: center; margin: 0 0 20px">
|
||||
Customize data items using render-content
|
||||
</p>
|
||||
<div style="text-align: center">
|
||||
<el-transfer
|
||||
v-model="leftValue"
|
||||
style="text-align: left; display: inline-block"
|
||||
filterable
|
||||
:left-default-checked="[2, 3]"
|
||||
:right-default-checked="[1]"
|
||||
:render-content="renderFunc"
|
||||
:titles="['Source', 'Target']"
|
||||
:button-texts="['To left', 'To right']"
|
||||
:format="{
|
||||
noChecked: '${total}',
|
||||
hasChecked: '${checked}/${total}',
|
||||
}"
|
||||
:data="data"
|
||||
@change="handleChange"
|
||||
>
|
||||
<template #left-footer>
|
||||
<el-button class="transfer-footer" size="small">Operation</el-button>
|
||||
</template>
|
||||
<template #right-footer>
|
||||
<el-button class="transfer-footer" size="small">Operation</el-button>
|
||||
</template>
|
||||
</el-transfer>
|
||||
<p style="text-align: center; margin: 50px 0 20px">
|
||||
Customize data items using scoped slot
|
||||
</p>
|
||||
<div style="text-align: center">
|
||||
<el-transfer
|
||||
v-model="rightValue"
|
||||
style="text-align: left; display: inline-block"
|
||||
filterable
|
||||
:left-default-checked="[2, 3]"
|
||||
:right-default-checked="[1]"
|
||||
:titles="['Source', 'Target']"
|
||||
:button-texts="['To left', 'To right']"
|
||||
:format="{
|
||||
noChecked: '${total}',
|
||||
hasChecked: '${checked}/${total}',
|
||||
}"
|
||||
:data="data"
|
||||
@change="handleChange"
|
||||
>
|
||||
<template #default="{ option }">
|
||||
<span>{{ option.key }} - {{ option.label }}</span>
|
||||
</template>
|
||||
<template #left-footer>
|
||||
<el-button class="transfer-footer" size="small">Operation</el-button>
|
||||
</template>
|
||||
<template #right-footer>
|
||||
<el-button class="transfer-footer" size="small">Operation</el-button>
|
||||
</template>
|
||||
</el-transfer>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref } from 'vue'
|
||||
import type { VNode, VNodeProps } from 'vue'
|
||||
|
||||
interface Option {
|
||||
key: number
|
||||
label: string
|
||||
disabled: boolean
|
||||
}
|
||||
|
||||
const generateData = (): Option[] => {
|
||||
const data: Option[] = []
|
||||
for (let i = 1; i <= 15; i++) {
|
||||
data.push({
|
||||
key: i,
|
||||
label: `Option ${i}`,
|
||||
disabled: i % 4 === 0,
|
||||
})
|
||||
}
|
||||
return data
|
||||
}
|
||||
|
||||
const data = ref(generateData())
|
||||
const rightValue = ref([1])
|
||||
const leftValue = ref([1])
|
||||
|
||||
const renderFunc = (
|
||||
h: (type: string, props: VNodeProps | null, children?: string) => VNode,
|
||||
option: Option
|
||||
) => {
|
||||
return h('span', null, option.label)
|
||||
}
|
||||
const handleChange = (
|
||||
value: number | string,
|
||||
direction: 'left' | 'right',
|
||||
movedKeys: string[] | number[]
|
||||
) => {
|
||||
console.log(value, direction, movedKeys)
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.transfer-footer {
|
||||
margin-left: 15px;
|
||||
padding: 6px 5px;
|
||||
}
|
||||
</style>
|
35
ssr-testing/cases/transition.vue
Normal file
35
ssr-testing/cases/transition.vue
Normal file
@ -0,0 +1,35 @@
|
||||
<template>
|
||||
<div>
|
||||
<el-button @click="show = !show">Click Me</el-button>
|
||||
|
||||
<div style="margin-top: 20px; height: 200px">
|
||||
<el-collapse-transition>
|
||||
<div v-show="show">
|
||||
<div class="transition-box">el-collapse-transition</div>
|
||||
<div class="transition-box">el-collapse-transition</div>
|
||||
</div>
|
||||
</el-collapse-transition>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref } from 'vue'
|
||||
|
||||
const show = ref(true)
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.transition-box {
|
||||
margin-bottom: 10px;
|
||||
width: 200px;
|
||||
height: 100px;
|
||||
border-radius: 4px;
|
||||
background-color: #409eff;
|
||||
text-align: center;
|
||||
color: #fff;
|
||||
padding: 40px 20px;
|
||||
box-sizing: border-box;
|
||||
margin-right: 20px;
|
||||
}
|
||||
</style>
|
45
ssr-testing/cases/tree-v2.vue
Normal file
45
ssr-testing/cases/tree-v2.vue
Normal file
@ -0,0 +1,45 @@
|
||||
<template>
|
||||
<el-tree-v2 :data="data" :props="props" :height="208" />
|
||||
</template>
|
||||
<script lang="ts" setup>
|
||||
interface Tree {
|
||||
id: string
|
||||
label: string
|
||||
children?: Tree[]
|
||||
}
|
||||
|
||||
const getKey = (prefix: string, id: number) => {
|
||||
return `${prefix}-${id}`
|
||||
}
|
||||
|
||||
const createData = (
|
||||
maxDeep: number,
|
||||
maxChildren: number,
|
||||
minNodesNumber: number,
|
||||
deep = 1,
|
||||
key = 'node'
|
||||
): Tree[] => {
|
||||
let id = 0
|
||||
return Array.from({ length: minNodesNumber })
|
||||
.fill(deep)
|
||||
.map(() => {
|
||||
const childrenNumber =
|
||||
deep === maxDeep ? 0 : Math.round(Math.random() * maxChildren)
|
||||
const nodeKey = getKey(key, ++id)
|
||||
return {
|
||||
id: nodeKey,
|
||||
label: nodeKey,
|
||||
children: childrenNumber
|
||||
? createData(maxDeep, maxChildren, childrenNumber, deep + 1, nodeKey)
|
||||
: undefined,
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const props = {
|
||||
value: 'id',
|
||||
label: 'label',
|
||||
children: 'children',
|
||||
}
|
||||
const data = createData(4, 30, 40)
|
||||
</script>
|
36
ssr-testing/cases/tree.vue
Normal file
36
ssr-testing/cases/tree.vue
Normal file
@ -0,0 +1,36 @@
|
||||
<template>
|
||||
<el-tree :data="data" :props="defaultProps" @node-click="handleNodeClick" />
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
interface Tree {
|
||||
label: string
|
||||
children?: Tree[]
|
||||
}
|
||||
|
||||
const handleNodeClick = (data: Tree) => {
|
||||
console.log(data)
|
||||
}
|
||||
|
||||
const data: Tree[] = [
|
||||
{
|
||||
label: 'Level one 1',
|
||||
children: [
|
||||
{
|
||||
label: 'Level two 1-1',
|
||||
children: [
|
||||
{
|
||||
label: 'Level three 1-1-1',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
]
|
||||
|
||||
const defaultProps = {
|
||||
children: 'children',
|
||||
label: 'label',
|
||||
}
|
||||
</script>
|
||||
```
|
41
ssr-testing/cases/upload.vue
Normal file
41
ssr-testing/cases/upload.vue
Normal file
@ -0,0 +1,41 @@
|
||||
<template>
|
||||
<el-upload
|
||||
class="upload-demo"
|
||||
action="https://jsonplaceholder.typicode.com/posts/"
|
||||
:on-preview="handlePreview"
|
||||
:on-remove="handleRemove"
|
||||
multiple
|
||||
:limit="3"
|
||||
:file-list="fileList"
|
||||
>
|
||||
<el-button type="primary">Click to upload</el-button>
|
||||
<template #tip>
|
||||
<div class="el-upload__tip">
|
||||
jpg/png files with a size less than 500kb
|
||||
</div>
|
||||
</template>
|
||||
</el-upload>
|
||||
</template>
|
||||
<script lang="ts" setup>
|
||||
import { ref } from 'vue'
|
||||
|
||||
import type { UploadUserFile, UploadFile } from 'element-plus'
|
||||
|
||||
const fileList = ref<UploadUserFile[]>([
|
||||
{
|
||||
name: 'food.jpeg',
|
||||
url: 'https://fuss10.elemecdn.com/3/63/4e7f3a15429bfda99bce42a18cdd1jpeg.jpeg?imageMogr2/thumbnail/360x360/format/webp/quality/100',
|
||||
},
|
||||
{
|
||||
name: 'food2.jpeg',
|
||||
url: 'https://fuss10.elemecdn.com/3/63/4e7f3a15429bfda99bce42a18cdd1jpeg.jpeg?imageMogr2/thumbnail/360x360/format/webp/quality/100',
|
||||
},
|
||||
])
|
||||
|
||||
const handleRemove = (file: UploadFile, fileList: UploadFile[]) => {
|
||||
console.log(file, fileList)
|
||||
}
|
||||
const handlePreview = (file: UploadFile) => {
|
||||
console.log(file)
|
||||
}
|
||||
</script>
|
@ -34,6 +34,7 @@ describe('Cypress Button', () => {
|
||||
'index.css'
|
||||
),
|
||||
})
|
||||
|
||||
const { default: Demo } = await import(path.join(demoRoot, demoPath))
|
||||
const app = createApp(<Demo />)
|
||||
.use(ElementPlus)
|
||||
@ -41,20 +42,22 @@ describe('Cypress Button', () => {
|
||||
prefix: 100,
|
||||
current: 0,
|
||||
})
|
||||
|
||||
const html = await renderToString(app)
|
||||
|
||||
await page.evaluate((innerHTML) => {
|
||||
document.querySelector('#root')!.innerHTML = innerHTML
|
||||
}, html)
|
||||
|
||||
const screenshotPath = demoPath
|
||||
.split('/')
|
||||
.join('-')
|
||||
.replace(/\.vue$/, '.png')
|
||||
await page.screenshot({
|
||||
path: path.join(testRoot, 'screenshots', screenshotPath),
|
||||
fullPage: true,
|
||||
})
|
||||
// SSR testing don't need screenshots.
|
||||
// const screenshotPath = demoPath
|
||||
// .split('/')
|
||||
// .join('-')
|
||||
// .replace(/\.vue$/, '.png')
|
||||
// await page.screenshot({
|
||||
// path: path.join(testRoot, 'screenshots', screenshotPath),
|
||||
// fullPage: true,
|
||||
// })
|
||||
await page.close()
|
||||
expect(true).toBe(true)
|
||||
})
|
||||
|
Loading…
x
Reference in New Issue
Block a user