完成80%
This commit is contained in:
@@ -259,6 +259,7 @@
|
||||
<view class="add-dialog__heading">
|
||||
<text class="dialog-title">添加家谱</text>
|
||||
<text class="dialog-copy">建议先搜索已有家谱,避免重复创建</text>
|
||||
<text v-if="quota" class="dialog-copy">{{ quota.createRemaining === -1 ? '当前可继续创建家谱' : `还可创建 ${quota.createRemaining} 部家谱` }}</text>
|
||||
<view
|
||||
class="add-dialog__close"
|
||||
role="button"
|
||||
@@ -285,6 +286,7 @@
|
||||
block
|
||||
type="secondary"
|
||||
label="继续创建家谱"
|
||||
:disabled="quota?.canCreate === false"
|
||||
@click="createGenealogy"
|
||||
/>
|
||||
</view>
|
||||
@@ -380,8 +382,14 @@ const switcherVisible = ref(false);
|
||||
const selectedGenealogyId = ref(null);
|
||||
const listScrollCommand = ref(0);
|
||||
const currentListScrollTop = ref(0);
|
||||
const unreadCount = ref(0);
|
||||
const quota = ref(null);
|
||||
const listRequestController = createRequestController();
|
||||
const unreadRequestController = createRequestController();
|
||||
const quotaRequestController = createRequestController();
|
||||
let loadGeneration = 0;
|
||||
let unreadLoadGeneration = 0;
|
||||
let quotaLoadGeneration = 0;
|
||||
let pageActive = true;
|
||||
let presentationState = "default";
|
||||
let skipNextShowRefresh = true;
|
||||
@@ -454,11 +462,39 @@ const loadGenealogies = async () => {
|
||||
}
|
||||
};
|
||||
|
||||
const loadUnreadCount = async () => {
|
||||
const generation = ++unreadLoadGeneration;
|
||||
unreadRequestController.abort();
|
||||
try {
|
||||
const count = await appApi.getUnreadNotificationCount({
|
||||
requestController: unreadRequestController,
|
||||
});
|
||||
if (pageActive && generation === unreadLoadGeneration) unreadCount.value = count;
|
||||
} catch (error) {
|
||||
if (!isRequestCancelled(error)) unreadCount.value = 0;
|
||||
}
|
||||
};
|
||||
|
||||
const loadQuota = async () => {
|
||||
const generation = ++quotaLoadGeneration;
|
||||
quotaRequestController.abort();
|
||||
try {
|
||||
const result = await appApi.getGenealogyQuota({
|
||||
requestController: quotaRequestController,
|
||||
});
|
||||
if (pageActive && generation === quotaLoadGeneration) quota.value = result;
|
||||
} catch (error) {
|
||||
if (!isRequestCancelled(error) && pageActive && generation === quotaLoadGeneration) quota.value = null;
|
||||
}
|
||||
};
|
||||
|
||||
onLoad((query) => {
|
||||
syncEmptyStateFromRoute(query);
|
||||
requestedGenealogyId.value = String(query?.genealogyId || "");
|
||||
if (presentationState === "default") {
|
||||
loadGenealogies();
|
||||
loadUnreadCount();
|
||||
loadQuota();
|
||||
} else {
|
||||
reconcilePageGenealogyContext();
|
||||
}
|
||||
@@ -480,15 +516,20 @@ onShow(() => {
|
||||
return;
|
||||
}
|
||||
if (presentationState === "default") loadGenealogies();
|
||||
if (presentationState === "default") loadUnreadCount();
|
||||
if (presentationState === "default") loadQuota();
|
||||
});
|
||||
|
||||
onUnload(() => {
|
||||
pageActive = false;
|
||||
loadGeneration += 1;
|
||||
unreadLoadGeneration += 1;
|
||||
quotaLoadGeneration += 1;
|
||||
listRequestController.abort();
|
||||
unreadRequestController.abort();
|
||||
quotaRequestController.abort();
|
||||
});
|
||||
|
||||
const unreadCount = computed(() => 0);
|
||||
const hasGenealogies = computed(
|
||||
() => !forceEmptyState.value && list.value.length > 0,
|
||||
);
|
||||
@@ -725,11 +766,16 @@ const openShortcut = (key) => {
|
||||
align-items: center;
|
||||
}
|
||||
.current-name {
|
||||
min-width: 0;
|
||||
flex: 1;
|
||||
color: $ink;
|
||||
font-family: "STKaiti", "KaiTi", serif;
|
||||
font-size: 50rpx;
|
||||
font-size: 38rpx;
|
||||
font-weight: 700;
|
||||
overflow-wrap: anywhere;
|
||||
line-height: 1.25;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
.current-switch-copy {
|
||||
flex: 0 0 auto;
|
||||
|
||||
Reference in New Issue
Block a user