add upload permission

This commit is contained in:
Timi
2026-01-29 11:58:18 +08:00
parent 81cb0b361d
commit 6e01e927b1
14 changed files with 213 additions and 36 deletions

View File

@ -3,6 +3,7 @@
import Time from "../../../../utils/Time";
import { TravelApi } from "../../../../api/TravelApi";
import { Travel, TravelPage, TravelStatus, TravelStatusLabel, TravelStatusIcon, TransportationTypeLabel, TransportationTypeIcon } from "../../../../types/Travel";
import Permission from "../../../../utils/Permission";
interface TravelData {
/** 分页参数 */
@ -28,6 +29,8 @@ interface TravelData {
transportLabels: typeof TransportationTypeLabel;
/** 交通类型图标映射 */
transportIcons: typeof TransportationTypeIcon;
/** 是否允许上传 */
canUpload: boolean;
}
Page({
@ -46,12 +49,20 @@ Page({
statusLabels: TravelStatusLabel,
statusIcons: TravelStatusIcon,
transportLabels: TransportationTypeLabel,
transportIcons: TransportationTypeIcon
transportIcons: TransportationTypeIcon,
canUpload: false
},
onLoad() {
this.resetAndFetch();
},
onShow() {
async onShow() {
const cached = Permission.getCachedUploadPermission();
if (cached !== null) {
this.setData({ canUpload: cached });
} else {
const canUpload = await Permission.checkAndCacheUploadPermission();
this.setData({ canUpload });
}
// 页面显示时刷新数据(从编辑页返回时)
if (0 < this.data.list.length) {
this.resetAndFetch();

View File

@ -96,6 +96,6 @@
<view wx:if="{{isFinished && 0 < list.length}}" class="finished">没有更多了</view>
</view>
<!-- 新建按钮 -->
<view class="fab" bind:tap="toCreate">
<view wx:if="{{canUpload}}" class="fab" bind:tap="toCreate">
<t-icon name="add" size="24px" color="#fff" />
</view>