appstore/dist/views/home.js

180 lines
3.9 KiB
JavaScript
Raw Permalink Normal View History

2023-12-20 19:06:35 +08:00
/**
* {}
* @author yutent<yutent.io@gmail.com>
* @date 2023/12/19 16:53:27
*/
2023-12-21 13:59:15 +08:00
import { html, css, Component, range } from 'wkit'
2023-12-20 19:06:35 +08:00
import { watch } from 'wkitd'
import '../components/titlebar.js'
2023-12-21 13:59:15 +08:00
import '../components/app-menu.js'
2023-12-20 19:06:35 +08:00
import '../components/slider.js'
2023-12-21 13:59:15 +08:00
import '../components/list.js'
2023-12-20 19:06:35 +08:00
class Home extends Component {
static animation = { type: 'scale', immediate: true }
static styles = [
css`
:host {
display: flex;
position: fixed;
left: calc(50vw - 512px);
top: calc(50vh - 380px);
z-index: 2;
width: 1024px;
height: 760px;
font-size: 14px;
color: var(--color-dark-1);
-webkit-user-select: none;
user-select: none;
}
.container {
display: flex;
flex-direction: column;
width: 100%;
height: 100%;
border-radius: 8px;
background: rgba(233, 233, 233, 0.9);
box-shadow: 0 0 12px rgba(0, 0, 0, 0.1);
--titlebar-background: linear-gradient(
90deg,
transparent 180px,
#fff 180px
);
}
2023-12-21 13:59:15 +08:00
ul,
menu,
2023-12-20 19:06:35 +08:00
li {
list-style: none;
}
`,
css`
.body {
flex: 1;
display: flex;
2023-12-21 13:59:15 +08:00
height: calc(100% - 48px);
2023-12-20 19:06:35 +08:00
line-height: 1.5;
}
.sidebar {
flex-shrink: 0;
width: 180px;
height: 100%;
border-radius: 0 0 0 8px;
backdrop-filter: blur(5px);
}
.content {
flex: 1;
height: 100%;
2023-12-21 13:59:15 +08:00
padding: 0 8px 8px 0;
2023-12-20 19:06:35 +08:00
border-radius: 0 0 8px 0;
background: #fff;
}
2023-12-21 13:59:15 +08:00
.wrapper {
overflow: hidden auto;
height: 100%;
padding: 0 32px 32px;
2023-12-20 19:06:35 +08:00
2023-12-21 13:59:15 +08:00
&::-webkit-scrollbar {
width: 3px;
height: 3px;
background-color: transparent;
2023-12-20 19:06:35 +08:00
}
2023-12-21 13:59:15 +08:00
&::-webkit-scrollbar-thumb {
background-color: #c6c7ca;
border-radius: 10px;
}
&::-webkit-scrollbar-thumb:hover {
background-color: #a1a1a1;
}
&::-webkit-scrollbar-track {
background-color: transparent;
2023-12-20 19:06:35 +08:00
}
}
2023-12-21 13:59:15 +08:00
`,
2023-12-28 15:48:00 +08:00
css`
.category {
display: flex;
flex-wrap: wrap;
width: 100%;
gap: 8px;
padding-bottom: 16px;
border-bottom: 1px solid var(--color-plain-1);
2023-12-29 15:49:55 +08:00
--wc-icon-size: 14px;
2023-12-28 15:48:00 +08:00
wc-tag {
cursor: pointer;
}
}
`
2023-12-20 19:06:35 +08:00
]
2023-12-28 15:48:00 +08:00
#path = '/'
2023-12-20 19:06:35 +08:00
#hide() {
this.$store.storeAppShow = false
}
mounted() {
// this.$store.storeAppShow = true
watch('$store.storeAppShow', v => {
this.$animate(!v)
})
2023-12-28 15:48:00 +08:00
watch('$router.path', r => {
this.#path = r.path
this.$requestUpdate()
})
2023-12-20 19:06:35 +08:00
}
render() {
2023-12-28 15:48:00 +08:00
let path = this.#path
2023-12-20 19:06:35 +08:00
return html`
<main class="container">
<wc-titlebar
minimize
@close=${this.#hide}
@minimize=${this.#hide}
></wc-titlebar>
<div class="body">
2023-12-21 13:59:15 +08:00
<wc-aside class="sidebar"></wc-aside>
2023-12-28 15:48:00 +08:00
2023-12-20 19:06:35 +08:00
<div class="content">
2023-12-21 13:59:15 +08:00
<div class="wrapper">
2023-12-28 15:48:00 +08:00
${path === '/'
? html`<wc-slider></wc-slider>`
: html`
<menu class="category">
${this.$store.categories.map(
it =>
html`<wc-tag
size="small"
type=${it.path === path ? 'info' : ''}
@click=${ev => this.$router.push({ path: it.path })}
2023-12-29 15:49:55 +08:00
>
<wc-icon name=${it.icon}></wc-icon>
${it.name}
</wc-tag> `
2023-12-28 15:48:00 +08:00
)}
</menu>
`}
2023-12-21 13:59:15 +08:00
<wc-list :list=${range(10)}></wc-list>
</div>
2023-12-20 19:06:35 +08:00
</div>
</div>
</main>
`
}
}
Home.reg('home')