feat(miniapp): scaffold WeChat mini program MVP
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
const { listMindSpacePages } = require('../../utils/api');
|
||||
|
||||
Page({
|
||||
data: {
|
||||
pages: [],
|
||||
loading: false,
|
||||
error: ''
|
||||
},
|
||||
|
||||
onShow() {
|
||||
this.loadPages();
|
||||
},
|
||||
|
||||
async loadPages() {
|
||||
this.setData({ loading: true, error: '' });
|
||||
try {
|
||||
const result = await listMindSpacePages({ limit: 30 });
|
||||
const pages = result?.data || result?.pages || [];
|
||||
this.setData({ pages });
|
||||
} catch (error) {
|
||||
this.setData({ error: error?.message || '页面加载失败' });
|
||||
} finally {
|
||||
this.setData({ loading: false });
|
||||
}
|
||||
},
|
||||
|
||||
openPage(event) {
|
||||
const url = event.currentTarget.dataset.url;
|
||||
if (!url) {
|
||||
wx.showToast({ title: '该页面暂无可打开链接', icon: 'none' });
|
||||
return;
|
||||
}
|
||||
wx.navigateTo({
|
||||
url: `/pages/webview/index?url=${encodeURIComponent(url)}`
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"navigationBarTitleText": "MindSpace 页面"
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<view class="page">
|
||||
<view class="toolbar">
|
||||
<text class="title">MindSpace</text>
|
||||
<button class="reload" loading="{{loading}}" bindtap="loadPages">刷新</button>
|
||||
</view>
|
||||
|
||||
<view wx:if="{{error}}" class="error">{{error}}</view>
|
||||
|
||||
<view wx:if="{{pages.length === 0 && !loading}}" class="empty panel">
|
||||
<text>暂无页面</text>
|
||||
</view>
|
||||
|
||||
<view wx:for="{{pages}}" wx:key="id" class="page-card panel" bindtap="openPage" data-url="{{item.publicUrl || item.previewUrl}}">
|
||||
<text class="page-title">{{item.title || '未命名页面'}}</text>
|
||||
<text class="page-meta">{{item.status || item.visibility || ''}}</text>
|
||||
</view>
|
||||
</view>
|
||||
@@ -0,0 +1,50 @@
|
||||
.toolbar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 24rpx;
|
||||
}
|
||||
|
||||
.title {
|
||||
font-size: 42rpx;
|
||||
font-weight: 800;
|
||||
}
|
||||
|
||||
.reload {
|
||||
width: 132rpx;
|
||||
height: 64rpx;
|
||||
line-height: 64rpx;
|
||||
border-radius: 12rpx;
|
||||
background: #e7f3f1;
|
||||
color: #0f766e;
|
||||
font-size: 26rpx;
|
||||
}
|
||||
|
||||
.page-card {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 10rpx;
|
||||
padding: 24rpx;
|
||||
margin-bottom: 18rpx;
|
||||
}
|
||||
|
||||
.page-title {
|
||||
font-size: 30rpx;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.page-meta {
|
||||
color: #64748b;
|
||||
font-size: 24rpx;
|
||||
}
|
||||
|
||||
.empty {
|
||||
padding: 40rpx;
|
||||
text-align: center;
|
||||
color: #64748b;
|
||||
}
|
||||
|
||||
.error {
|
||||
margin-bottom: 20rpx;
|
||||
color: #b42318;
|
||||
}
|
||||
Reference in New Issue
Block a user