feat: establish teaching feedback mini program

Connect student profiles, defaults, and feedback records to the Rust API. Configure the WeChat AppID, custom tab bar, and local development workflow for version 0.1.0.
This commit is contained in:
2026-07-15 15:36:51 +08:00
commit 0a07538dce
37 changed files with 2550 additions and 0 deletions

3
pages/profile/index.json Normal file
View File

@@ -0,0 +1,3 @@
{
"navigationBarTitleText": "教学反馈助手"
}

54
pages/profile/index.ts Normal file
View File

@@ -0,0 +1,54 @@
import {
DEVELOPMENT_USER_ID,
getApiBaseUrl,
getApiErrorMessage,
getHealth,
setApiBaseUrl
} from '../../utils/api'
type InputEvent = { detail: { value: string } }
Page({
data: {
apiBaseUrl: getApiBaseUrl(),
developmentUserId: DEVELOPMENT_USER_ID,
connectionText: '尚未检测',
connectionTone: 'idle',
testing: false
},
onShow() {
this.getTabBar()?.setData({ selected: 3 })
this.setData({ apiBaseUrl: getApiBaseUrl() })
void this.checkConnection()
},
onUrlInput(event: InputEvent) {
this.setData({ apiBaseUrl: event.detail.value })
},
async saveAndCheck() {
try {
const apiBaseUrl = setApiBaseUrl(this.data.apiBaseUrl)
this.setData({ apiBaseUrl })
await this.checkConnection()
} catch (error) {
this.setData({ connectionText: getApiErrorMessage(error), connectionTone: 'error' })
}
},
async checkConnection() {
this.setData({ testing: true, connectionText: '正在检测服务...', connectionTone: 'idle' })
try {
const health = await getHealth()
this.setData({
connectionText: health.databaseConfigured ? '服务和数据库连接正常' : '服务正常,数据库尚未配置',
connectionTone: health.databaseConfigured ? 'success' : 'warning'
})
} catch (error) {
this.setData({ connectionText: getApiErrorMessage(error), connectionTone: 'error' })
} finally {
this.setData({ testing: false })
}
}
})

25
pages/profile/index.wxml Normal file
View File

@@ -0,0 +1,25 @@
<view class="page-shell profile-page">
<text class="eyebrow">个人中心</text>
<view class="page-heading">
<text class="heading-icon">◉</text>
<text class="page-title">我的</text>
</view>
<text class="page-subtitle">管理小程序连接的教学反馈服务。</text>
<view class="server-card surface">
<text class="section-title">Rust API 服务</text>
<text class="form-label url-label">服务地址</text>
<input class="url-input" value="{{apiBaseUrl}}" placeholder="https://api.example.com" bindinput="onUrlInput" />
<view class="connection-row">
<text class="connection-dot connection-{{connectionTone}}"></text>
<text class="connection-text">{{connectionText}}</text>
</view>
<button class="primary-button check-button" loading="{{testing}}" disabled="{{testing}}" bindtap="saveAndCheck">保存并检测</button>
</view>
<view class="identity-card surface">
<text class="section-title">开发身份</text>
<text class="identity-value">{{developmentUserId}}</text>
<text class="identity-note">微信登录接入前,业务数据按此开发用户隔离。</text>
</view>
</view>

91
pages/profile/index.wxss Normal file
View File

@@ -0,0 +1,91 @@
.profile-page {
padding-top: 44rpx;
}
.server-card,
.identity-card {
margin-top: 30rpx;
padding: 26rpx;
}
.identity-card {
margin-top: 18rpx;
}
.section-title,
.identity-value,
.identity-note {
display: block;
}
.section-title {
color: #17233a;
font-size: 32rpx;
font-weight: 800;
}
.url-label {
display: block;
margin-top: 24rpx;
}
.url-input {
height: 78rpx;
margin-top: 12rpx;
padding: 0 20rpx;
border: 2rpx solid #cbdced;
border-radius: 12rpx;
background: #fbfdff;
color: #17233a;
font-size: 27rpx;
}
.connection-row {
display: flex;
align-items: center;
gap: 12rpx;
margin-top: 20rpx;
}
.connection-dot {
width: 16rpx;
height: 16rpx;
border-radius: 50%;
background: #8a97a6;
}
.connection-success {
background: #23855b;
}
.connection-warning {
background: #c17a18;
}
.connection-error {
background: #c34343;
}
.connection-text {
color: #566577;
font-size: 25rpx;
}
.check-button {
margin-top: 24rpx;
}
.identity-value {
margin-top: 18rpx;
color: #2b67e8;
font-size: 24rpx;
font-weight: 700;
word-break: break-all;
}
.identity-note {
margin-top: 12rpx;
color: #718096;
font-size: 24rpx;
line-height: 1.5;
}