23 lines
732 B
TypeScript
23 lines
732 B
TypeScript
import type { ContentPostDetail } from '@lehuo/contracts';
|
|
import { fetchPublicContentDetail } from '../../services/content-notifications';
|
|
Page({
|
|
data: { loading: true, message: '', post: null as ContentPostDetail | null },
|
|
onLoad(o) {
|
|
const id = o['publicId'];
|
|
if (!id) {
|
|
this.setData({ loading: false, message: '缺少内容标识,请返回资讯列表重新选择。' });
|
|
return;
|
|
}
|
|
void this.load(id);
|
|
},
|
|
async load(id: string) {
|
|
try {
|
|
this.setData({ post: (await fetchPublicContentDetail(id)).post });
|
|
} catch (e) {
|
|
this.setData({ message: e instanceof Error ? e.message : '内容加载失败' });
|
|
} finally {
|
|
this.setData({ loading: false });
|
|
}
|
|
},
|
|
});
|