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 { PreviewImageMetadata } from "../../../../types/Attachment";
import { MomentApi } from "../../../../api/MomentApi";
import { JournalApi } from "../../../../api/JournalApi";
import { Network } from "../../../../utils/Network";
import Permission from "../../../../utils/Permission";
type Item = {
id: number;
@ -44,6 +45,7 @@ interface MomentData {
isVisibleArchivePopup: boolean;
archiveStep: ArchiveStep;
selectedJournalId: number | null;
canUpload: boolean;
}
Page({
@ -64,10 +66,11 @@ Page({
isAuthLocation: false,
isVisibleArchivePopup: false,
archiveStep: "select-type",
selectedJournalId: null
selectedJournalId: null,
canUpload: false
},
async onLoad() {
this.fetch();
await this.fetch();
// 授权定位
const setting = await wx.getSetting();
@ -116,6 +119,15 @@ Page({
});
});
},
async onShow() {
const cached = Permission.getCachedUploadPermission();
if (cached !== null) {
this.setData({ canUpload: cached });
} else {
const canUpload = await Permission.checkAndCacheUploadPermission();
this.setData({ canUpload });
}
},
async chooseLocation() {
const location = await wx.chooseLocation({});
this.setData({