适配新的ront

This commit is contained in:
Xu Chang 2022-05-26 09:15:44 +08:00
parent db5d86dc71
commit f1445d6864
6 changed files with 30 additions and 64 deletions

View File

@ -1,7 +1,9 @@
import { loginByPassword, loginMp, loginWechatMp, syncUserInfoWechatMp } from './token';
import { getUploadInfo } from './extraFile';
export declare const aspectDict: {
loginByPassword: typeof loginByPassword;
loginMp: typeof loginMp;
loginWechatMp: typeof loginWechatMp;
syncUserInfoWechatMp: typeof syncUserInfoWechatMp;
getUploadInfo: typeof getUploadInfo;
};

View File

@ -2,10 +2,12 @@
Object.defineProperty(exports, "__esModule", { value: true });
exports.aspectDict = void 0;
const token_1 = require("./token");
const extraFile_1 = require("./extraFile");
exports.aspectDict = {
loginByPassword: token_1.loginByPassword,
loginMp: token_1.loginMp,
loginWechatMp: token_1.loginWechatMp,
syncUserInfoWechatMp: token_1.syncUserInfoWechatMp,
getUploadInfo: extraFile_1.getUploadInfo,
};
// export type AspectDict<ED extends EntityDict & BaseEntityDict> = TokenAD<ED> & CrudAD<ED>;

View File

@ -1,6 +1,8 @@
import { EntityDict } from 'oak-app-domain';
import { Aspect, Context } from 'oak-domain/lib/types';
import { Token } from './token';
import { ExtraFile } from './extraFile';
export declare function initialize<ED extends EntityDict, Cxt extends Context<ED>, AD extends Record<string, Aspect<ED, Cxt>>>(): {
token: Token<ED, Cxt, AD>;
extraFile: ExtraFile<ED, Cxt, AD>;
};

View File

@ -2,10 +2,13 @@
Object.defineProperty(exports, "__esModule", { value: true });
exports.initialize = void 0;
const token_1 = require("./token");
const extraFile_1 = require("./extraFile");
function initialize() {
const token = new token_1.Token();
const extraFile = new extraFile_1.ExtraFile();
return {
token,
extraFile,
};
}
exports.initialize = initialize;

View File

@ -1,7 +1,22 @@
import { isMockId } from "oak-frontend-base/src/utils/mockId";
import { composeFileUrl } from '../../../../src/utils/extraFile';
Component({
OakComponent({
entity: 'extraFile',
async formData (files, features) {
const number2 = this.data.maxNumber;
if (typeof number2 === 'number' && files?.length >= number2) {
return {
files,
disableInsert: true,
};
}
return {
files,
disableInsert: false,
};
}
}, {
data: {
selected: -1,
// 根据 size 不同,计算的图片显示大小不同
@ -117,43 +132,9 @@ Component({
}
}
},
checkAllowInsert(value?: Array<any>, num?: number) {
const number2 = num || this.data.maxNumber;
const value2 = value || this.data.oakValue;
if (typeof number2 === 'number' && value2?.length >= number2) {
this.setData({
disableInsert: true,
});
}
},
async setFullpath(oakParent: string) {
const {
globalData: { features },
} = getApp();
if (oakParent) {
const oakFullpath = `${oakParent}.${this.data.oakPath}`;
await features.runningNode.createNode({
path: this.data.oakPath,
parent: oakParent,
});
this.setData({
oakFullpath,
});
}
},
add(options: any[]) {
const {
globalData: { features },
} = getApp();
options.forEach((ele) =>
features.runningNode.addNode(
Object.assign(
{
parent: this.data.oakFullpath,
},
ele
)
)
this.pushNode(undefined, ele)
);
},
async onItemTapped(event: WechatMiniprogram.Touch) {
@ -179,16 +160,10 @@ Component({
}
},
async onDelete(event: WechatMiniprogram.Touch) {
const {
globalData: { features },
} = getApp();
const { value, index } = event.currentTarget.dataset;
const { id } = value;
if (isMockId(id)) {
features.runningNode.removeNode({
parent: this.data.oakFullpath,
path: `${index}`,
});
this.removeNode(this.data.oakFullpath, `${index}`);
} else {
const result = await wx.showModal({
title: '确认删除吗',
@ -196,24 +171,15 @@ Component({
});
const { confirm } = result;
if (confirm) {
features.runningNode.removeNode({
parent: this.data.oakFullpath,
path: `${index}`,
});
this.removeNode(this.data.oakFullpath, `${index}`);
}
}
},
},
observers: {
oakValue: function (oakValue) {
this.checkAllowInsert(oakValue);
},
maxNumber: function (maxNumber) {
this.checkAllowInsert(undefined, maxNumber);
},
oakParent: async function (oakParent) {
await this.setFullpath(oakParent);
this.reRender();
},
/**
* size
@ -238,13 +204,4 @@ Component({
this.setData({ itemSizePercentage: itemSizePercentage });
},
},
lifetimes: {
ready() {
this.checkAllowInsert();
if (this.data.oakParent) {
this.setFullpath(this.data.oakParent);
}
},
},
});

View File

@ -1,5 +1,5 @@
<view class="file-list__container l-class">
<block wx:for="{{oakValue}}" wx:key="index">
<block wx:for="{{files}}" wx:key="index">
<view
class="file-list__item file-list__item--{{size}} l-item-class"
style="{{itemSizePercentage?'width:'+itemSizePercentage+'padding-bottom:'+itemSizePercentage:'xxx'}}"