fuck wechat reviewer
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
// 备忘录页面逻辑
|
||||
import { ToolApi } from "../../../../api/ToolApi";
|
||||
import Permission from "../../../../utils/Permission";
|
||||
|
||||
type EditorInputEvent = WechatMiniprogram.CustomEvent<{
|
||||
html?: string;
|
||||
@@ -16,6 +17,8 @@ interface MemoData {
|
||||
isEditorReady: boolean;
|
||||
contentHtml: string;
|
||||
contentText: string;
|
||||
canUpload: boolean;
|
||||
permissionChecked: boolean;
|
||||
}
|
||||
|
||||
Page({
|
||||
@@ -28,13 +31,19 @@ Page({
|
||||
isSaving: false,
|
||||
isEditorReady: false,
|
||||
contentHtml: "",
|
||||
contentText: ""
|
||||
contentText: "",
|
||||
canUpload: false,
|
||||
permissionChecked: false
|
||||
},
|
||||
editorCtx: null as WechatMiniprogram.EditorContext | null,
|
||||
pendingHtml: "",
|
||||
hasSavedOnLeave: false,
|
||||
hasLoadFailed: false,
|
||||
async onLoad() {
|
||||
const canUpload = await this.ensureUploadPermission();
|
||||
if (!canUpload) {
|
||||
return;
|
||||
}
|
||||
const platform = wx.getSystemInfoSync().platform;
|
||||
const isIOS = platform === "ios";
|
||||
this.setData({ isIOS });
|
||||
@@ -46,11 +55,46 @@ Page({
|
||||
this.hasSavedOnLeave = false;
|
||||
},
|
||||
async onUnload() {
|
||||
if (!this.data.canUpload) {
|
||||
return;
|
||||
}
|
||||
await this.saveMemoOnLeave();
|
||||
},
|
||||
async onHide() {
|
||||
if (!this.data.canUpload) {
|
||||
return;
|
||||
}
|
||||
await this.saveMemoOnLeave();
|
||||
},
|
||||
async ensureUploadPermission(): Promise<boolean> {
|
||||
const cached = Permission.getCachedUploadPermission();
|
||||
if (cached !== null) {
|
||||
this.setData({
|
||||
canUpload: cached,
|
||||
permissionChecked: true
|
||||
});
|
||||
if (!cached) {
|
||||
this.redirectNoPermission();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
const canUpload = await Permission.checkAndCacheUploadPermission();
|
||||
this.setData({
|
||||
canUpload,
|
||||
permissionChecked: true
|
||||
});
|
||||
if (!canUpload) {
|
||||
this.redirectNoPermission();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
},
|
||||
redirectNoPermission() {
|
||||
wx.switchTab({
|
||||
url: "/pages/main/tabs/journal/index"
|
||||
});
|
||||
},
|
||||
bindKeyboardHeightChange() {
|
||||
let keyboardHeight = 0;
|
||||
wx.onKeyboardHeightChange((res) => {
|
||||
@@ -159,4 +203,4 @@ Page({
|
||||
this.setData({ isSaving: false });
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user