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

@@ -9,6 +9,7 @@ import { OrderType } from "../../../../types/Model";
import { PreviewImageMetadata } from "../../../../types/Attachment";
import { MediaItem, MediaItemType } from "../../../../types/UI";
import { JournalApi } from "../../../../api/JournalApi";
import Permission from "../../../../utils/Permission";
interface JournalData {
page: JournalPage;
@@ -23,6 +24,7 @@ interface JournalData {
isShowMoreMenu: boolean;
menuTop: number;
menuLeft: number;
canUpload: boolean;
}
Page({
@@ -52,7 +54,17 @@ Page({
stickyOffset: 0,
isShowMoreMenu: false,
menuTop: 0,
menuLeft: 0
menuLeft: 0,
canUpload: false
},
async onShow() {
const cached = Permission.getCachedUploadPermission();
if (cached !== null) {
this.setData({ canUpload: cached });
return;
}
const canUpload = await Permission.checkAndCacheUploadPermission();
this.setData({ canUpload });
},
onLoad() {
Events.reset("JOURNAL_REFRESH", () => {

View File

@@ -12,8 +12,8 @@
style="top: {{menuTop}}px; left: {{menuLeft}}px;"
catchtap="stopPropagation"
>
<t-cell title="新纪录" leftIcon="add" bind:tap="toCreater" />
<t-cell title="按列表查找" leftIcon="view-list" bind:tap="toSearch" />
<t-cell wx:if="{{canUpload}}" title="新纪录" leftIcon="add" bind:tap="toCreater" />
<t-cell wx:if="{{canUpload}}" title="按列表查找" leftIcon="view-list" bind:tap="toSearch" />
<t-cell title="按日期查找" leftIcon="calendar-1" bind:tap="toDate" />
<t-cell title="按地图查找" leftIcon="location" bind:tap="toMap" />
</t-cell-group>
@@ -53,4 +53,4 @@
</view>
</view>
<view wx:if="{{isFinished}}" class="start">已回到最初的起点</view>
</t-indexes>
</t-indexes>