This commit is contained in:
Xu Chang 2024-08-19 10:01:57 +08:00
commit db3637259f
7 changed files with 188 additions and 0 deletions

11
lib/components/errorPage/index.d.ts vendored Normal file
View File

@ -0,0 +1,11 @@
import { ED } from '../../types/AbstractComponent';
import { ReactComponentProps } from '../../types/Page';
import { ECode } from '../../types/ErrorPage';
declare const _default: <ED2 extends ED, T2 extends keyof ED2>(props: ReactComponentProps<ED2, T2, false, {
code: ECode;
title?: string;
desc?: string;
children?: React.ReactNode;
icon?: React.ReactNode;
}>) => React.ReactElement;
export default _default;

View File

@ -0,0 +1,71 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const ErrorPage_1 = require("../../types/ErrorPage");
const DefaultErrorInfo = {
[ErrorPage_1.ECode.forbidden]: {
title: '403 Forbidden',
desc: '抱歉,您无权限访问此页面。',
imagePath: './assets/svg/assets-result-403.svg',
},
[ErrorPage_1.ECode.notFound]: {
title: '404 Not Found',
desc: '抱歉,您访问的页面不存在。',
imagePath: './assets/svg/assets-result-404.svg',
},
[ErrorPage_1.ECode.error]: {
title: '500 Internal Server Error',
desc: '抱歉,服务器出错啦!',
imagePath: './assets/svg/assets-result-500.svg',
},
[ErrorPage_1.ECode.networkError]: {
title: '网络异常',
desc: '网络异常,请稍后再试。',
imagePath: './assets/svg/assets-result-network-error.svg',
},
[ErrorPage_1.ECode.maintenance]: {
title: '系统维护中',
desc: '系统维护中,请稍后再试。',
imagePath: './assets/svg/assets-result-maintenance.svg',
},
[ErrorPage_1.ECode.browserIncompatible]: {
title: '浏览器版本低',
desc: '抱歉,您正在使用的浏览器版本过低,无法打开当前网页。',
imagePath: './assets/svg/assets-result-browser-incompatible.svg',
},
};
exports.default = OakComponent({
isList: false,
properties: {
code: '',
title: '',
desc: '',
icon: '', //web独有
imagePath: '', //小程序独有
},
lifetimes: {
ready() {
if (process.env.OAK_PLATFORM === 'wechatMp') {
const { title, desc, code, imagePath } = this.props;
let title2 = title;
if (code) {
this.setState({
desc: desc || DefaultErrorInfo[code].desc,
imagePath: imagePath ||
DefaultErrorInfo[code].imagePath,
});
if (!title2) {
title2 = DefaultErrorInfo[code].title;
}
wx.setNavigationBarTitle({
title: title2,
});
}
}
},
},
methods: {
goBack(delta) {
this.navigateBack(delta);
},
},
});

View File

@ -0,0 +1,4 @@
/// <reference types="wechat-miniprogram" />
/// <reference types="react" />
declare const _default: (props: import("../../..").ReactComponentProps<import("oak-domain/lib/types").EntityDict & import("oak-domain/lib/base-app-domain").EntityDict, string | number, true, WechatMiniprogram.Component.DataOption>) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;
export default _default;

View File

@ -0,0 +1,67 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = OakComponent({
isList: true,
data: {
visible: false,
dialogVisible: false,
},
methods: {
async printDebugStore(e) {
const fullData = await this.features.cache.getFullData();
console.log(fullData);
},
printCachedStore() {
console.log(this.features.cache.getCachedData());
},
printRunningTree() {
console.log(this.features.runningTree.getRoot());
},
async resetInitialData() {
await this.features.localStorage.clear();
},
setVisible(visible) {
this.setState({
visible,
});
},
handlePopup() {
this.setVisible(true);
},
handlePopupClose() {
// this.setVisible(false);
},
//小程序重置
handleReset() {
this.resetInitialData();
const pages = getCurrentPages(); //获取加载的页面
const currentPage = pages[pages.length - 1]; //获取当前页面的对象
const url = currentPage.route; //当前页面url
const options = currentPage.options; //如果要获取url中所带的参数可以查看options
this.redirectTo({
url: url
.replace('/pages', '')
.replace('pages', '')
.replace('/index', ''),
}, options);
this.closeDialog();
},
showDialog() {
this.setState({
dialogVisible: true,
});
},
closeDialog() {
this.setState({
dialogVisible: false,
});
},
async downloadEnv() {
const data = await this.features.localStorage.loadAll();
return data;
},
async resetEnv(data) {
await this.features.localStorage.resetAll(data);
},
},
});

4
lib/components/message/index.d.ts vendored Normal file
View File

@ -0,0 +1,4 @@
/// <reference types="wechat-miniprogram" />
/// <reference types="react" />
declare const _default: (props: import("../..").ReactComponentProps<import("oak-domain/lib/types").EntityDict & import("oak-domain/lib/base-app-domain").EntityDict, string | number, false, WechatMiniprogram.Component.DataOption>) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;
export default _default;

View File

@ -0,0 +1,27 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = OakComponent({
isList: false,
formData({ props }) {
const data = this.consumeMessage();
if (data) {
if (process.env.OAK_PLATFORM === 'wechatMp') {
// lin-ui的message: https://doc.mini.talelin.com/component/response/message.html
const type = !data.type || data.type === 'info' ? 'primary' : data.type;
wx.lin.showMessage({
type: type,
content: data.content,
icon: data.icon,
duration: data.duration,
top: data.offset,
});
return {};
}
return {
data,
};
}
return {};
},
features: ['message'],
});

View File

@ -23,7 +23,11 @@
"keepalive-for-react": "^2.0.7",
"node-schedule": "^2.1.1",
"nprogress": "^0.2.0",
<<<<<<< HEAD
"oak-common-aspect": "~3.0.1",
=======
"oak-common-aspect": "~3.0.0",
>>>>>>> dev
"oak-domain": "~5.0.19",
"oak-memory-tree-store": "~3.3.1",
"ol": "^7.3.0",