feat: 调整样式

This commit is contained in:
Blizzard
2026-02-14 11:31:44 +08:00
parent cbbe82ef63
commit d6f781a666
42 changed files with 827 additions and 293 deletions
+38 -10
View File
@@ -13,16 +13,26 @@ Page({
showImageSheet: false,
imageSheetItems: [
{ label: '拍照', value: 'camera' },
{ label: '从相册选', value: 'album' }
]
{ label: '从相册选', value: 'album' }
],
topicColors: ['#558B2F', '#1976D2', '#7B1FA2', '#F57C00', '#C2185B', '#00796B'],
topicBgColors: ['#E8F5E9', '#E3F2FD', '#F3E5F5', '#FFF3E0', '#FCE4EC', '#E0F2F1']
},
onLoad() {
// No draft loading
this.fetchTopics();
},
onUnload() {
// No draft saving
fetchTopics() {
request.get('/topic/list').then(res => {
const list = res.list || [];
const topics = list.map(t => t.title);
if (topics.length > 0) {
this.setData({ suggestedTopics: topics });
}
}).catch(err => {
console.error('Fetch topics failed', err);
});
},
onContentInput(e) {
@@ -105,7 +115,6 @@ Page({
itemList: ['设为封面', '删除'],
success: (res) => {
if (res.tapIndex === 0) {
// Move to first position
const images = [...this.data.images];
const [img] = images.splice(index, 1);
images.unshift(img);
@@ -121,14 +130,33 @@ Page({
chooseLocation() {
wx.chooseLocation({
success: (res) => {
this.setData({ location: res.name || res.address });
const formatted = this.formatLocation(res.address, res.name);
this.setData({ location: formatted });
},
fail: () => {
// User cancelled or no permission
}
fail: () => { }
});
},
formatLocation(address, name) {
if (!address) return name || '';
// Municipalities
const munis = ['北京', '上海', '天津', '重庆'];
for (let m of munis) {
if (address.startsWith(m)) {
return m;
}
}
// Standard: Prov + City (Simplify names)
const match = address.match(/^(.+?)(?:省|自治区)(.+?)(?:市|自治州|地区|盟)/);
if (match) {
return `${match[1]}.${match[2]}`;
}
return name || address;
},
toggleTopic(e) {
const topic = e.currentTarget.dataset.topic;
const hashtag = `#${topic} `;
+1
View File
@@ -78,6 +78,7 @@
</view>
<view class="topic-list">
<view class="topic-tag {{selectedTopics.includes(item) ? 'selected' : ''}}"
style="{{selectedTopics.includes(item) ? 'color:' + topicColors[index % topicColors.length] + '; background-color:' + topicBgColors[index % topicBgColors.length] : ''}}"
wx:for="{{suggestedTopics}}"
wx:key="*this"
bindtap="toggleTopic"
+1
View File
@@ -87,6 +87,7 @@ Page({
avatar: avatarObj.url,
content: item.content,
images: (item.imgList || []).map(img => img.url),
location: item.location || '',
time: item.createdAtStr || '刚刚',
likes: item.hasLiked === 1 ? ['我'] : [],
comments: (item.commentList || []).map(c => ({
+5
View File
@@ -45,6 +45,11 @@
</view>
</view>
<!-- Location -->
<view wx:if="{{item.location}}" class="post-location">
<text>{{item.location}}</text>
</view>
<!-- Meta: Time + Action -->
<view class="post-meta">
<text class="post-time">{{item.time}}</text>
+7
View File
@@ -165,6 +165,13 @@ page {
aspect-ratio: 1;
}
/* Location */
.post-location {
font-size: 24rpx;
color: #576b95;
margin-bottom: 12rpx;
}
/* Post Meta */
.post-meta {
display: flex;