40 lines
2.5 KiB
HTML
40 lines
2.5 KiB
HTML
|
|
<!doctype html>
|
||
|
|
<html lang="zh-CN"><meta charset="UTF-8"><title>表头主题检查</title>
|
||
|
|
<div id="app"></div>
|
||
|
|
<script type="module">
|
||
|
|
import {createApp,h,ref,nextTick,resolveComponent} from 'vue'
|
||
|
|
import ElementPlus from 'element-plus'
|
||
|
|
import 'element-plus/dist/index.css'
|
||
|
|
import '/src/styles/index.scss'
|
||
|
|
import '/src/cmvr/styles.scss'
|
||
|
|
const app=createApp({setup(){
|
||
|
|
const dark=ref(true),report=ref('')
|
||
|
|
const rows=[{name:'测试用例示例',state:'已配置'},{name:'机器人示例',state:'在线'}]
|
||
|
|
async function update(value){
|
||
|
|
dark.value=value;document.documentElement.classList.toggle('dark',value);await nextTick()
|
||
|
|
const cells=[...document.querySelectorAll('th')].filter(el=>el.getBoundingClientRect().width)
|
||
|
|
report.value=JSON.stringify({theme:value?'深色':'浅色',headers:cells.map(el=>({text:el.textContent.trim(),background:getComputedStyle(el).backgroundColor,color:getComputedStyle(el).color}))},null,2)
|
||
|
|
}
|
||
|
|
nextTick(()=>update(true))
|
||
|
|
const column=(props,children)=>h(resolveComponent('el-table-column'),props,children)
|
||
|
|
return()=>h('main',[
|
||
|
|
h('h2','表头跟随主题'),h('p','使用正式公共样式和表格组件,数据仅在本页内存中,不调用业务或设备接口。'),
|
||
|
|
h(resolveComponent('el-button'),{onClick:()=>update(false)},()=> '浅色主题'),
|
||
|
|
h(resolveComponent('el-button'),{onClick:()=>update(true)},()=> '深色主题'),
|
||
|
|
h('div',{class:'cmvr-module',style:{height:'auto',minHeight:0,marginTop:'20px'}},[
|
||
|
|
h('h3','测试用例 / 机器人列表(含固定列)'),
|
||
|
|
h(resolveComponent('el-table'),{data:rows,border:true},{default:()=>[
|
||
|
|
column({type:'selection',width:50,fixed:'left'}),column({prop:'name',label:'名称',minWidth:500}),
|
||
|
|
column({label:'设备信息'},{default:()=>[column({prop:'state',label:'状态',minWidth:500})]}),
|
||
|
|
column({label:'操作',width:100,fixed:'right'},{default:()=>h(resolveComponent('el-button'),{link:true,type:'primary'},()=> '查看')})
|
||
|
|
]})
|
||
|
|
]),
|
||
|
|
h('h3','普通业务表格'),h(resolveComponent('el-table'),{data:rows},{default:()=>[column({prop:'name',label:'名称'}),column({prop:'state',label:'状态'})]}),
|
||
|
|
h('pre',{id:'result'},report.value)
|
||
|
|
])
|
||
|
|
}})
|
||
|
|
app.use(ElementPlus);app.mount('#app')
|
||
|
|
</script>
|
||
|
|
<style>body{margin:0;background:var(--el-bg-color);color:var(--el-text-color-primary);font:14px system-ui}main{padding:24px;max-width:1200px;margin:auto}pre{font-size:12px;max-height:170px;overflow:auto;color:var(--el-text-color-secondary)}</style>
|
||
|
|
</html>
|