fuck wechat reviewer

This commit is contained in:
Timi
2026-01-29 14:37:46 +08:00
parent 8269a29100
commit b2cf9572a4
16 changed files with 917 additions and 677 deletions

View File

@ -7,6 +7,7 @@
"t-button": "tdesign-miniprogram/button/button", "t-button": "tdesign-miniprogram/button/button",
"t-navbar": "tdesign-miniprogram/navbar/navbar", "t-navbar": "tdesign-miniprogram/navbar/navbar",
"t-dialog": "tdesign-miniprogram/dialog/dialog", "t-dialog": "tdesign-miniprogram/dialog/dialog",
"t-empty": "tdesign-miniprogram/empty/empty",
"t-radio-group": "tdesign-miniprogram/radio-group/radio-group" "t-radio-group": "tdesign-miniprogram/radio-group/radio-group"
} }
} }

View File

@ -170,3 +170,14 @@
margin-bottom: 24rpx; margin-bottom: 24rpx;
} }
} }
page {
.no-permission {
width: 100%;
display: flex;
background: var(--td-bg-color-page);
min-height: 100vh;
align-items: center;
justify-content: center;
}
}

View File

@ -8,6 +8,7 @@ import { JournalType } from "../../../../types/Journal";
import { MediaAttachType, PreviewImageMetadata } from "../../../../types/Attachment"; import { MediaAttachType, PreviewImageMetadata } from "../../../../types/Attachment";
import IOSize, { Unit } from "../../../../utils/IOSize"; import IOSize, { Unit } from "../../../../utils/IOSize";
import { JournalApi } from "../../../../api/JournalApi"; import { JournalApi } from "../../../../api/JournalApi";
import Permission from "../../../../utils/Permission";
interface JournalEditorData { interface JournalEditorData {
/** 模式create 或 edit */ /** 模式create 或 edit */
@ -48,6 +49,10 @@ interface JournalEditorData {
deleteDialogVisible: boolean; deleteDialogVisible: boolean;
/** 删除确认文本 */ /** 删除确认文本 */
deleteConfirmText: string; deleteConfirmText: string;
/** 是否拥有上传权限 */
canUpload: boolean;
/** 是否已检查权限 */
permissionChecked: boolean;
} }
Page({ Page({
@ -72,10 +77,16 @@ Page({
}, },
isAuthLocation: false, isAuthLocation: false,
deleteDialogVisible: false, deleteDialogVisible: false,
deleteConfirmText: "" deleteConfirmText: "",
canUpload: false,
permissionChecked: false
}, },
async onLoad(options: any) { async onLoad(options: any) {
const canUpload = await this.ensureUploadPermission();
if (!canUpload) {
return;
}
// 授权定位 // 授权定位
const setting = await wx.getSetting(); const setting = await wx.getSetting();
wx.setStorageSync("isAuthLocation", setting.authSetting["scope.userLocation"] || false); wx.setStorageSync("isAuthLocation", setting.authSetting["scope.userLocation"] || false);
@ -116,6 +127,35 @@ Page({
this.getDefaultLocation(); this.getDefaultLocation();
} }
}, },
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"
});
},
/** 获取默认定位(创建模式) */ /** 获取默认定位(创建模式) */
getDefaultLocation() { getDefaultLocation() {
wx.getLocation({ wx.getLocation({

View File

@ -1,14 +1,15 @@
<!--pages/main/journal/editor/index.wxml--> <!--pages/main/journal/editor/index.wxml-->
<t-navbar title="{{mode === 'create' ? '新纪录' : '编辑记录'}}" placeholder> <block wx:if="{{canUpload}}">
<t-navbar title="{{mode === 'create' ? '新纪录' : '编辑记录'}}" placeholder>
<text slot="left" bindtap="cancel">取消</text> <text slot="left" bindtap="cancel">取消</text>
</t-navbar> </t-navbar>
<scroll-view <scroll-view
class="container" class="container"
type="custom" type="custom"
scroll-y scroll-y
show-scrollbar="{{false}}" show-scrollbar="{{false}}"
scroll-into-view="{{intoView}}" scroll-into-view="{{intoView}}"
> >
<view class="content"> <view class="content">
<view wx:if="{{isLoading}}" class="loading"> <view wx:if="{{isLoading}}" class="loading">
<text>加载中...</text> <text>加载中...</text>
@ -221,9 +222,9 @@
</view> </view>
</block> </block>
</view> </view>
</scroll-view> </scroll-view>
<!-- 删除对话框(仅编辑模式) --> <!-- 删除对话框(仅编辑模式) -->
<t-dialog <t-dialog
wx:if="{{mode === 'edit'}}" wx:if="{{mode === 'edit'}}"
visible="{{deleteDialogVisible}}" visible="{{deleteDialogVisible}}"
title="删除记录" title="删除记录"
@ -231,7 +232,7 @@
cancel-btn="取消" cancel-btn="取消"
bind:confirm="confirmDelete" bind:confirm="confirmDelete"
bind:cancel="cancelDelete" bind:cancel="cancelDelete"
> >
<view slot="content" class="delete-dialog"> <view slot="content" class="delete-dialog">
<view class="tips"> <view class="tips">
<text>此记录的照片和视频也会同步删除,删除后无法恢复,请输入 "</text> <text>此记录的照片和视频也会同步删除,删除后无法恢复,请输入 "</text>
@ -240,4 +241,10 @@
</view> </view>
<t-input model:value="{{deleteConfirmText}}" placeholder="请输入:确认删除" /> <t-input model:value="{{deleteConfirmText}}" placeholder="请输入:确认删除" />
</view> </view>
</t-dialog> </t-dialog>
</block>
<block wx:elif="{{permissionChecked}}">
<view class="no-permission">
<t-empty icon="error-circle" description="无权限操作" />
</view>
</block>

View File

@ -1,6 +1,7 @@
{ {
"usingComponents": { "usingComponents": {
"t-icon": "tdesign-miniprogram/icon/icon", "t-icon": "tdesign-miniprogram/icon/icon",
"t-empty": "tdesign-miniprogram/empty/empty",
"t-navbar": "tdesign-miniprogram/navbar/navbar" "t-navbar": "tdesign-miniprogram/navbar/navbar"
}, },
"disableScroll": true "disableScroll": true

View File

@ -64,3 +64,14 @@
} }
} }
} }
page {
.no-permission {
width: 100%;
display: flex;
background: var(--td-bg-color-page);
min-height: 100vh;
align-items: center;
justify-content: center;
}
}

View File

@ -1,5 +1,6 @@
// 备忘录页面逻辑 // 备忘录页面逻辑
import { ToolApi } from "../../../../api/ToolApi"; import { ToolApi } from "../../../../api/ToolApi";
import Permission from "../../../../utils/Permission";
type EditorInputEvent = WechatMiniprogram.CustomEvent<{ type EditorInputEvent = WechatMiniprogram.CustomEvent<{
html?: string; html?: string;
@ -16,6 +17,8 @@ interface MemoData {
isEditorReady: boolean; isEditorReady: boolean;
contentHtml: string; contentHtml: string;
contentText: string; contentText: string;
canUpload: boolean;
permissionChecked: boolean;
} }
Page({ Page({
@ -28,13 +31,19 @@ Page({
isSaving: false, isSaving: false,
isEditorReady: false, isEditorReady: false,
contentHtml: "", contentHtml: "",
contentText: "" contentText: "",
canUpload: false,
permissionChecked: false
}, },
editorCtx: null as WechatMiniprogram.EditorContext | null, editorCtx: null as WechatMiniprogram.EditorContext | null,
pendingHtml: "", pendingHtml: "",
hasSavedOnLeave: false, hasSavedOnLeave: false,
hasLoadFailed: false, hasLoadFailed: false,
async onLoad() { async onLoad() {
const canUpload = await this.ensureUploadPermission();
if (!canUpload) {
return;
}
const platform = wx.getSystemInfoSync().platform; const platform = wx.getSystemInfoSync().platform;
const isIOS = platform === "ios"; const isIOS = platform === "ios";
this.setData({ isIOS }); this.setData({ isIOS });
@ -46,11 +55,46 @@ Page({
this.hasSavedOnLeave = false; this.hasSavedOnLeave = false;
}, },
async onUnload() { async onUnload() {
if (!this.data.canUpload) {
return;
}
await this.saveMemoOnLeave(); await this.saveMemoOnLeave();
}, },
async onHide() { async onHide() {
if (!this.data.canUpload) {
return;
}
await this.saveMemoOnLeave(); 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() { bindKeyboardHeightChange() {
let keyboardHeight = 0; let keyboardHeight = 0;
wx.onKeyboardHeightChange((res) => { wx.onKeyboardHeightChange((res) => {

View File

@ -1,8 +1,9 @@
<!-- 备忘录页面 --> <!-- 备忘录页面 -->
<view class="custom-navbar"> <block wx:if="{{canUpload}}">
<view class="custom-navbar">
<t-navbar class="custom-navbar" title="备忘录" left-arrow placeholder /> <t-navbar class="custom-navbar" title="备忘录" left-arrow placeholder />
</view> </view>
<view class="memo setting-bg"> <view class="memo setting-bg">
<view class="content"> <view class="content">
<view class="container" style="height:{{editorHeight}}px;"> <view class="container" style="height:{{editorHeight}}px;">
<editor <editor
@ -62,4 +63,10 @@
/> />
</view> </view>
</view> </view>
</view> </view>
</block>
<block wx:elif="{{permissionChecked}}">
<view class="no-permission">
<t-empty icon="error-circle" description="无权限操作" />
</view>
</block>

View File

@ -11,6 +11,7 @@
"t-loading": "tdesign-miniprogram/loading/loading", "t-loading": "tdesign-miniprogram/loading/loading",
"t-stepper": "tdesign-miniprogram/stepper/stepper", "t-stepper": "tdesign-miniprogram/stepper/stepper",
"t-textarea": "tdesign-miniprogram/textarea/textarea", "t-textarea": "tdesign-miniprogram/textarea/textarea",
"t-empty": "tdesign-miniprogram/empty/empty",
"t-cell-group": "tdesign-miniprogram/cell-group/cell-group" "t-cell-group": "tdesign-miniprogram/cell-group/cell-group"
}, },
"styleIsolation": "shared" "styleIsolation": "shared"

View File

@ -110,3 +110,14 @@
margin-bottom: 24rpx; margin-bottom: 24rpx;
} }
} }
page {
.no-permission {
width: 100%;
display: flex;
background: var(--td-bg-color-page);
min-height: 100vh;
align-items: center;
justify-content: center;
}
}

View File

@ -3,6 +3,7 @@
import Time from "../../../../utils/Time"; import Time from "../../../../utils/Time";
import { TravelApi } from "../../../../api/TravelApi"; import { TravelApi } from "../../../../api/TravelApi";
import { TravelStatus, TransportationType } from "../../../../types/Travel"; import { TravelStatus, TransportationType } from "../../../../types/Travel";
import Permission from "../../../../utils/Permission";
interface TravelEditorData { interface TravelEditorData {
/** 模式create 或 edit */ /** 模式create 或 edit */
@ -43,6 +44,10 @@ interface TravelEditorData {
deleteDialogVisible: boolean; deleteDialogVisible: boolean;
/** 删除确认文本 */ /** 删除确认文本 */
deleteConfirmText: string; deleteConfirmText: string;
/** 是否拥有上传权限 */
canUpload: boolean;
/** 是否已检查权限 */
permissionChecked: boolean;
} }
Page({ Page({
@ -76,9 +81,15 @@ Page({
{ label: "已完成", value: TravelStatus.COMPLETED } { label: "已完成", value: TravelStatus.COMPLETED }
], ],
deleteDialogVisible: false, deleteDialogVisible: false,
deleteConfirmText: "" deleteConfirmText: "",
canUpload: false,
permissionChecked: false
}, },
onLoad(options: any) { async onLoad(options: any) {
const canUpload = await this.ensureUploadPermission();
if (!canUpload) {
return;
}
// 判断模式:有 ID 是编辑,无 ID 是创建 // 判断模式:有 ID 是编辑,无 ID 是创建
const id = options.id ? parseInt(options.id) : undefined; const id = options.id ? parseInt(options.id) : undefined;
@ -89,7 +100,7 @@ Page({
id, id,
isLoading: true isLoading: true
}); });
this.loadTravelDetail(id); await this.loadTravelDetail(id);
} else { } else {
// 创建模式 // 创建模式
this.setData({ this.setData({
@ -105,6 +116,35 @@ Page({
}); });
} }
}, },
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"
});
},
/** 加载出行详情(编辑模式) */ /** 加载出行详情(编辑模式) */
async loadTravelDetail(id: number) { async loadTravelDetail(id: number) {
wx.showLoading({ title: "加载中...", mask: true }); wx.showLoading({ title: "加载中...", mask: true });

View File

@ -1,9 +1,10 @@
<!--pages/main/travel/editor/index.wxml--> <!--pages/main/travel/editor/index.wxml-->
<t-navbar title="{{mode === 'create' ? '新建出行' : '编辑出行'}}" placeholder> <block wx:if="{{canUpload}}">
<t-navbar title="{{mode === 'create' ? '新建出行' : '编辑出行'}}" placeholder>
<text slot="left" bindtap="cancel">取消</text> <text slot="left" bindtap="cancel">取消</text>
</t-navbar> </t-navbar>
<scroll-view class="travel-editor setting-bg" type="custom" scroll-y show-scrollbar="{{false}}"> <scroll-view class="travel-editor setting-bg" type="custom" scroll-y show-scrollbar="{{false}}">
<view class="content"> <view class="content">
<view wx:if="{{isLoading}}" class="loading"> <view wx:if="{{isLoading}}" class="loading">
<t-loading theme="dots" size="40rpx" /> <t-loading theme="dots" size="40rpx" />
@ -132,17 +133,17 @@
</view> </view>
</block> </block>
</view> </view>
</scroll-view> </scroll-view>
<!-- 删除确认对话框 --> <!-- 删除确认对话框 -->
<t-dialog <t-dialog
visible="{{deleteDialogVisible}}" visible="{{deleteDialogVisible}}"
title="删除出行计划" title="删除出行计划"
confirm-btn="{{ {content: '删除', variant: 'text', theme: 'danger'} }}" confirm-btn="{{ {content: '删除', variant: 'text', theme: 'danger'} }}"
cancel-btn="取消" cancel-btn="取消"
bind:confirm="confirmDelete" bind:confirm="confirmDelete"
bind:cancel="cancelDelete" bind:cancel="cancelDelete"
> >
<view slot="content" class="delete-dialog"> <view slot="content" class="delete-dialog">
<view class="tips"> <view class="tips">
<text>此计划的地点、图片和视频也会同步删除,删除后无法恢复,请输入 "</text> <text>此计划的地点、图片和视频也会同步删除,删除后无法恢复,请输入 "</text>
@ -151,4 +152,10 @@
</view> </view>
<t-input placeholder="请输入:确认删除" model:value="{{deleteConfirmText}}" /> <t-input placeholder="请输入:确认删除" model:value="{{deleteConfirmText}}" />
</view> </view>
</t-dialog> </t-dialog>
</block>
<block wx:elif="{{permissionChecked}}">
<view class="no-permission">
<t-empty icon="error-circle" description="无权限操作" />
</view>
</block>

View File

@ -11,6 +11,7 @@
"t-loading": "tdesign-miniprogram/loading/loading", "t-loading": "tdesign-miniprogram/loading/loading",
"t-stepper": "tdesign-miniprogram/stepper/stepper", "t-stepper": "tdesign-miniprogram/stepper/stepper",
"t-textarea": "tdesign-miniprogram/textarea/textarea", "t-textarea": "tdesign-miniprogram/textarea/textarea",
"t-empty": "tdesign-miniprogram/empty/empty",
"t-cell-group": "tdesign-miniprogram/cell-group/cell-group" "t-cell-group": "tdesign-miniprogram/cell-group/cell-group"
}, },
"styleIsolation": "shared" "styleIsolation": "shared"

View File

@ -199,3 +199,14 @@
margin-bottom: 24rpx; margin-bottom: 24rpx;
} }
} }
page {
.no-permission {
width: 100%;
display: flex;
background: var(--td-bg-color-page);
min-height: 100vh;
align-items: center;
justify-content: center;
}
}

View File

@ -6,6 +6,7 @@ import { TravelLocationType, TravelLocationTypeLabel } from "../../../../types/T
import { MediaAttachType, PreviewImageMetadata } from "../../../../types/Attachment"; import { MediaAttachType, PreviewImageMetadata } from "../../../../types/Attachment";
import config from "../../../../config/index"; import config from "../../../../config/index";
import { MediaItem, MediaItemType } from "../../../../types/UI"; import { MediaItem, MediaItemType } from "../../../../types/UI";
import Permission from "../../../../utils/Permission";
interface TravelLocationEditorData { interface TravelLocationEditorData {
/** 模式create 或 edit */ /** 模式create 或 edit */
@ -64,6 +65,10 @@ interface TravelLocationEditorData {
deleteConfirmText: string; deleteConfirmText: string;
/** 媒体类型枚举 */ /** 媒体类型枚举 */
mediaItemTypeEnum: any; mediaItemTypeEnum: any;
/** 是否拥有上传权限 */
canUpload: boolean;
/** 是否已检查权限 */
permissionChecked: boolean;
} }
Page({ Page({
@ -105,10 +110,16 @@ Page({
], ],
locationTypeIndex: 0, locationTypeIndex: 0,
deleteDialogVisible: false, deleteDialogVisible: false,
deleteConfirmText: "" deleteConfirmText: "",
canUpload: false,
permissionChecked: false
}, },
onLoad(options: any) { async onLoad(options: any) {
const canUpload = await this.ensureUploadPermission();
if (!canUpload) {
return;
}
// 获取 travelId必填 // 获取 travelId必填
const travelId = options.travelId ? parseInt(options.travelId) : 0; const travelId = options.travelId ? parseInt(options.travelId) : 0;
if (!travelId) { if (!travelId) {
@ -133,7 +144,7 @@ Page({
travelId, travelId,
isLoading: true isLoading: true
}); });
this.loadLocationDetail(id); await this.loadLocationDetail(id);
} else { } else {
// 创建模式 // 创建模式
this.setData({ this.setData({
@ -143,6 +154,35 @@ Page({
}); });
} }
}, },
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"
});
},
/** 加载地点详情(编辑模式) */ /** 加载地点详情(编辑模式) */
async loadLocationDetail(id: number) { async loadLocationDetail(id: number) {

View File

@ -1,9 +1,10 @@
<!--pages/main/travel/location-editor/index.wxml--> <!--pages/main/travel/location-editor/index.wxml-->
<t-navbar title="{{mode === 'create' ? '添加地点' : '编辑地点'}}" placeholder> <block wx:if="{{canUpload}}">
<t-navbar title="{{mode === 'create' ? '添加地点' : '编辑地点'}}" placeholder>
<text slot="left" bindtap="cancel">取消</text> <text slot="left" bindtap="cancel">取消</text>
</t-navbar> </t-navbar>
<scroll-view class="travel-location-editor setting-bg" type="custom" scroll-y show-scrollbar="{{false}}"> <scroll-view class="travel-location-editor setting-bg" type="custom" scroll-y show-scrollbar="{{false}}">
<view class="content"> <view class="content">
<view wx:if="{{isLoading}}" class="loading"> <view wx:if="{{isLoading}}" class="loading">
<t-loading theme="dots" size="40rpx" /> <t-loading theme="dots" size="40rpx" />
@ -266,17 +267,17 @@
</view> </view>
</block> </block>
</view> </view>
</scroll-view> </scroll-view>
<!-- 删除确认对话框 --> <!-- 删除确认对话框 -->
<t-dialog <t-dialog
visible="{{deleteDialogVisible}}" visible="{{deleteDialogVisible}}"
title="删除地点" title="删除地点"
confirm-btn="{{ {content: '删除', variant: 'text', theme: 'danger'} }}" confirm-btn="{{ {content: '删除', variant: 'text', theme: 'danger'} }}"
cancel-btn="取消" cancel-btn="取消"
bind:confirm="confirmDelete" bind:confirm="confirmDelete"
bind:cancel="cancelDelete" bind:cancel="cancelDelete"
> >
<view slot="content" class="delete-dialog"> <view slot="content" class="delete-dialog">
<view class="tips"> <view class="tips">
<text>此地点的图片和视频也会同步删除,删除后无法恢复,请输入 "</text> <text>此地点的图片和视频也会同步删除,删除后无法恢复,请输入 "</text>
@ -285,4 +286,10 @@
</view> </view>
<t-input placeholder="请输入:确认删除" model:value="{{deleteConfirmText}}" /> <t-input placeholder="请输入:确认删除" model:value="{{deleteConfirmText}}" />
</view> </view>
</t-dialog> </t-dialog>
</block>
<block wx:elif="{{permissionChecked}}">
<view class="no-permission">
<t-empty icon="error-circle" description="无权限操作" />
</view>
</block>