248 lines
6.9 KiB
JavaScript
248 lines
6.9 KiB
JavaScript
const entry = {
|
|
template: /*language=HTML*/ `
|
|
<div class="entry-wrapper">
|
|
<!-- 标签页导航 -->
|
|
<div class="tabs">
|
|
<div class="tab-item" :class="{ active: activeCategory === 'serv' }"
|
|
@click="setActiveCategory('serv')">
|
|
<i class="fa fa-star"></i> 推荐服务
|
|
</div>
|
|
<div class="tab-item" :class="{ active: activeCategory === 'app' }"
|
|
@click="setActiveCategory('app')">
|
|
<i class="fa fa-fire"></i> 推荐应用
|
|
</div>
|
|
<div class="tab-item" :class="{ active: activeCategory === 'fav' }"
|
|
@click="setActiveCategory('fav')">
|
|
<i class="fa fa-heart"></i> 我的收藏
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 应用块区域 -->
|
|
<div class="apps-container">
|
|
<div class="app-grid">
|
|
<div class="app-item" v-for="(item, index) in currentServices" :key="index"
|
|
@click="openService(item)">
|
|
<div class="app-icon">
|
|
<img :src="item.picIcon" alt="" />
|
|
</div>
|
|
<div class="app-name">{{ item.name }}</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
`,
|
|
data() {
|
|
return {
|
|
activeCategory: 'serv',
|
|
hasMore: true,
|
|
entries: {
|
|
serv: [],
|
|
app: [],
|
|
fav: []
|
|
},
|
|
}
|
|
},
|
|
computed: {
|
|
currentServices() {
|
|
return this.entries[this.activeCategory] || [];
|
|
}
|
|
},
|
|
created() {
|
|
this.getRecommendService()
|
|
this.getRecommendApp()
|
|
this.getFavorite()
|
|
},
|
|
methods: {
|
|
setActiveCategory(category) {
|
|
this.activeCategory = category;
|
|
},
|
|
|
|
// 查询推荐服务
|
|
async getRecommendService() {
|
|
this.$axios.post('/platform/home/listRecommendService', {platform: "PC"}).then(res => {
|
|
if (res.code === 0) {
|
|
this.entries.serv = res.data
|
|
}
|
|
})
|
|
},
|
|
|
|
// 获取推荐应用
|
|
async getRecommendApp() {
|
|
this.$axios.post('/platform/home/listRecommendApp', {platform: "PC"}).then(res => {
|
|
if (res.code === 0) {
|
|
this.entries.app = res.data
|
|
}
|
|
})
|
|
},
|
|
|
|
// 获取我的收藏
|
|
async getFavorite() {
|
|
this.$axios.post('/platform/home/listFavorite', {platform: "PC"}).then(res => {
|
|
if (res.code === 0) {
|
|
this.entries.fav = res.data
|
|
}
|
|
})
|
|
},
|
|
|
|
// 点击服务
|
|
openService(service) {
|
|
if(this.activeCategory === 'serv'){
|
|
if(!service.href) this.$message.error('无效的链接地址')
|
|
window.open(service.href)
|
|
return
|
|
}
|
|
|
|
if(this.activeCategory === 'app'){
|
|
// 储存到缓存
|
|
window.sessionStorage.setItem("zhgh_sub_app", JSON.stringify(service))
|
|
// 新标签页打开
|
|
window.open("/platform/v4/subApp?appId=" + service.id, "_blank")
|
|
return
|
|
}
|
|
|
|
if(this.activeCategory === 'fav'){
|
|
if(!service.href) this.$message.error('无效的链接地址')
|
|
window.open(service.href)
|
|
return
|
|
|
|
if(!service.parentId){
|
|
// 储存到缓存
|
|
window.sessionStorage.setItem("zhgh_sub_app", JSON.stringify(app))
|
|
// 新标签页打开
|
|
window.open("/platform/v4/subApp?appId=" + app.id, "_blank")
|
|
}
|
|
}
|
|
|
|
}
|
|
},
|
|
style: /*language=CSS*/ `
|
|
.entry-wrapper {
|
|
width: 100%;
|
|
box-sizing: border-box;
|
|
}
|
|
|
|
.tabs {
|
|
margin-top: 5px;
|
|
display: flex;
|
|
gap: 20px;
|
|
border-bottom: 2px solid #e8e8e8;
|
|
padding-bottom: 10px;
|
|
}
|
|
|
|
.tab-item {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 6px;
|
|
font-size: 14px;
|
|
color: #666;
|
|
cursor: pointer;
|
|
padding-bottom: 8px;
|
|
transition: color 0.2s ease;
|
|
}
|
|
|
|
.tab-item:hover {
|
|
color: #1890ff;
|
|
}
|
|
|
|
.tab-item.active {
|
|
color: #1890ff;
|
|
font-weight: bold;
|
|
border-bottom: 2px solid #1890ff;
|
|
}
|
|
|
|
.tab-item i {
|
|
font-size: 14px;
|
|
}
|
|
|
|
.apps-container {
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 20px;
|
|
}
|
|
|
|
.app-grid {
|
|
display: grid;
|
|
/* 改为自适应列数:每格最小 80px,自动换行 */
|
|
grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
|
|
|
|
justify-items: center; /* 子项内容居中(图标和文字) */
|
|
justify-content: start; /* 整体网格靠左对齐,避免居中 */
|
|
|
|
gap: 4px;
|
|
padding: 12px 4px;
|
|
background: #fff;
|
|
overflow-x: hidden;
|
|
|
|
max-height: calc(350px - 74px);
|
|
overflow-y: auto;
|
|
}
|
|
|
|
.app-item {
|
|
position: relative;
|
|
display: flex;
|
|
flex-direction: column;
|
|
align-items: center;
|
|
border-radius: 8px;
|
|
background: #fff;
|
|
width: 100%;
|
|
max-width: 100%;
|
|
padding: 6px;
|
|
transition: transform 0.2s ease, box-shadow 0.2s ease;
|
|
}
|
|
|
|
.app-item:hover {
|
|
transform: translateY(-2px);
|
|
box-shadow: 0 4px 12px rgba(0,0,0,0.1);
|
|
}
|
|
|
|
.app-icon {
|
|
width: 46px;
|
|
height: 46px;
|
|
margin-bottom: 8px;
|
|
}
|
|
|
|
.app-icon img {
|
|
width: 100%;
|
|
height: 100%;
|
|
object-fit: contain;
|
|
}
|
|
|
|
.app-name {
|
|
font-size: 12px;
|
|
color: #333;
|
|
line-height: 1.4;
|
|
word-break: break-word;
|
|
text-align: center;
|
|
}
|
|
|
|
/* 响应式设计 */
|
|
@media (max-width: 768px) {
|
|
.tabs {
|
|
flex-wrap: wrap;
|
|
gap: 10px;
|
|
}
|
|
|
|
.tab-item {
|
|
padding: 8px 0;
|
|
font-size: 12px;
|
|
}
|
|
|
|
.app-grid {
|
|
grid-template-columns: repeat(2, 1fr);
|
|
gap: 15px;
|
|
}
|
|
|
|
.app-item {
|
|
padding: 12px;
|
|
}
|
|
}
|
|
|
|
@media (max-width: 480px) {
|
|
.app-grid {
|
|
grid-template-columns: 1fr;
|
|
gap: 12px;
|
|
}
|
|
}
|
|
`
|
|
};
|