build-lib

This commit is contained in:
Xu Chang 2022-10-19 16:31:46 +08:00
parent 55fff46e2a
commit 0ec97a142e
620 changed files with 20834 additions and 0 deletions

48
lib/aspects/AspectDict.d.ts vendored Normal file
View File

@ -0,0 +1,48 @@
import { WebEnv, WechatMpEnv } from "../general-app-domain/Token/Schema";
import { AppType } from '../general-app-domain/Application/Schema';
import { EntityDict } from "../general-app-domain";
import { QiniuUploadInfo } from "oak-frontend-base/lib/types/Upload";
import { RuntimeContext } from '../context/RuntimeContext';
import { Config, Origin } from "../types/Config";
declare type GeneralAspectDict<ED extends EntityDict, Cxt extends RuntimeContext<ED>> = {
loginByMobile: (params: {
captcha?: string;
password?: string;
mobile: string;
env: WebEnv | WechatMpEnv;
}, context: Cxt) => Promise<string>;
loginWechat: ({ code, env, }: {
code: string;
env: WebEnv;
}, context: Cxt) => Promise<string>;
loginWechatMp: ({ code, env, }: {
code: string;
env: WechatMpEnv;
}, context: Cxt) => Promise<string>;
syncUserInfoWechatMp: ({ nickname, avatarUrl, encryptedData, iv, signature, }: {
nickname: string;
avatarUrl: string;
encryptedData: string;
iv: string;
signature: string;
}, context: Cxt) => Promise<void>;
getUploadInfo: (params: {
origin: Origin;
bucket?: string;
key?: string;
}, context: Cxt) => Promise<QiniuUploadInfo>;
sendCaptcha: (params: {
mobile: string;
env: WechatMpEnv | WebEnv;
}) => Promise<string>;
getApplication: (params: {
type: AppType;
}, context: Cxt) => Promise<string>;
updateConfig: (params: {
entity: 'platform' | 'system';
entityId: string;
config: Config;
}, context: Cxt) => Promise<void>;
};
export declare type AspectDict<ED extends EntityDict, Cxt extends RuntimeContext<ED>> = GeneralAspectDict<ED, Cxt>;
export {};

View File

@ -0,0 +1,2 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });

4
lib/aspects/application.d.ts vendored Normal file
View File

@ -0,0 +1,4 @@
import { getApplication as getApplicationDev } from './application.dev';
import { getApplication as getApplicationProd } from './application.prod';
declare const getApplication: typeof getApplicationDev | typeof getApplicationProd;
export { getApplication, };

6
lib/aspects/application.dev.d.ts vendored Normal file
View File

@ -0,0 +1,6 @@
import { EntityDict } from "../general-app-domain";
import { AppType } from "../general-app-domain/Application/Schema";
import { RuntimeContext } from '../context/RuntimeContext';
export declare function getApplication<ED extends EntityDict, Cxt extends RuntimeContext<ED>>(params: {
type: AppType;
}, context: Cxt): Promise<string>;

View File

@ -0,0 +1,43 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getApplication = void 0;
var tslib_1 = require("tslib");
var DEV_CONFIG_1 = require("../data/DEV-CONFIG");
function getApplication(params, context) {
return tslib_1.__awaiter(this, void 0, void 0, function () {
var type, APP_ID, appId, _a, application;
return tslib_1.__generator(this, function (_b) {
switch (_b.label) {
case 0:
type = params.type;
APP_ID = {
web: DEV_CONFIG_1.DEV_WEB_APPLICATION_ID,
wechatMp: DEV_CONFIG_1.DEV_WECHATMP_APPLICATION_ID,
wechatPublic: DEV_CONFIG_1.DEV_WECHATPUPLIC_APPLICATION_ID,
};
appId = APP_ID[type];
return [4 /*yield*/, context.rowStore.select('application', {
data: {
id: 1,
name: 1,
config: 1,
type: 1,
systemId: 1,
system: {
id: 1,
name: 1,
config: 1,
}
},
filter: {
id: appId
}
}, context, {})];
case 1:
_a = tslib_1.__read.apply(void 0, [(_b.sent()).result, 1]), application = _a[0];
return [2 /*return*/, application.id];
}
});
});
}
exports.getApplication = getApplication;

View File

@ -0,0 +1,7 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getApplication = void 0;
var application_dev_1 = require("./application.dev");
var application_prod_1 = require("./application.prod");
var getApplication = process.env.NODE_ENV === 'development' ? application_dev_1.getApplication : application_prod_1.getApplication;
exports.getApplication = getApplication;

6
lib/aspects/application.prod.d.ts vendored Normal file
View File

@ -0,0 +1,6 @@
import { EntityDict } from "../general-app-domain";
import { AppType } from "../general-app-domain/Application/Schema";
import { RuntimeContext } from '../context/RuntimeContext';
export declare function getApplication<ED extends EntityDict, Cxt extends RuntimeContext<ED>>(params: {
type: AppType;
}, context: Cxt): Promise<string>;

View File

@ -0,0 +1,45 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getApplication = void 0;
var tslib_1 = require("tslib");
var DEV_CONFIG_1 = require("../data/DEV-CONFIG");
function getApplication(params, context) {
return tslib_1.__awaiter(this, void 0, void 0, function () {
var type, APP_ID, appId, url, _a, application;
return tslib_1.__generator(this, function (_b) {
switch (_b.label) {
case 0:
type = params.type;
APP_ID = {
web: DEV_CONFIG_1.DEV_WEB_APPLICATION_ID,
wechatMp: DEV_CONFIG_1.DEV_WECHATMP_APPLICATION_ID,
wechatPublic: DEV_CONFIG_1.DEV_WECHATPUPLIC_APPLICATION_ID,
};
appId = APP_ID[type];
url = context.getHeader('url');
console.log('url is', url);
return [4 /*yield*/, context.rowStore.select('application', {
data: {
id: 1,
name: 1,
config: 1,
type: 1,
systemId: 1,
system: {
id: 1,
name: 1,
config: 1,
}
},
filter: {
id: appId
}
}, context, {})];
case 1:
_a = tslib_1.__read.apply(void 0, [(_b.sent()).result, 1]), application = _a[0];
return [2 /*return*/, application.id];
}
});
});
}
exports.getApplication = getApplication;

8
lib/aspects/config.d.ts vendored Normal file
View File

@ -0,0 +1,8 @@
import { RuntimeContext } from '../context/RuntimeContext';
import { EntityDict } from '../general-app-domain';
import { Config } from '../types/Config';
export declare function updateConfig<ED extends EntityDict, Cxt extends RuntimeContext<ED>>(params: {
entity: 'platform' | 'system';
entityId: string;
config: Config;
}, context: Cxt): Promise<void>;

34
lib/aspects/config.js Normal file
View File

@ -0,0 +1,34 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.updateConfig = void 0;
var tslib_1 = require("tslib");
function updateConfig(params, context) {
return tslib_1.__awaiter(this, void 0, void 0, function () {
var rowStore, entity, entityId, config, _a, _b, _c;
var _d;
return tslib_1.__generator(this, function (_e) {
switch (_e.label) {
case 0:
rowStore = context.rowStore;
entity = params.entity, entityId = params.entityId, config = params.config;
_b = (_a = rowStore).operate;
_c = [entity];
_d = {};
return [4 /*yield*/, generateNewId()];
case 1: return [4 /*yield*/, _b.apply(_a, _c.concat([(_d.id = _e.sent(),
_d.action = 'update',
_d.data = {
config: config,
},
_d.filter = {
id: entityId,
},
_d), context, {}]))];
case 2:
_e.sent();
return [2 /*return*/];
}
});
});
}
exports.updateConfig = updateConfig;

9
lib/aspects/extraFile.d.ts vendored Normal file
View File

@ -0,0 +1,9 @@
import { RuntimeContext } from '../context/RuntimeContext';
import { EntityDict } from '../general-app-domain';
import { Origin } from '../types/Config';
import { QiniuUploadInfo } from 'oak-frontend-base/lib/types/Upload';
export declare function getUploadInfo<ED extends EntityDict, Cxt extends RuntimeContext<ED>>(params: {
origin: Origin;
bucket?: string;
key?: string;
}, context: Cxt): Promise<QiniuUploadInfo>;

24
lib/aspects/extraFile.js Normal file
View File

@ -0,0 +1,24 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getUploadInfo = void 0;
var tslib_1 = require("tslib");
var getContextConfig_1 = require("../utils/getContextConfig");
var assert_1 = require("oak-domain/lib/utils/assert");
function getUploadInfo(params, context) {
return tslib_1.__awaiter(this, void 0, void 0, function () {
var origin, key, bucket, _a, instance, config, _b, uploadHost, domain, bucket2;
return tslib_1.__generator(this, function (_c) {
switch (_c.label) {
case 0:
origin = params.origin, key = params.key, bucket = params.bucket;
return [4 /*yield*/, (0, getContextConfig_1.getConfig)(context, 'Cos', origin)];
case 1:
_a = _c.sent(), instance = _a.instance, config = _a.config;
(0, assert_1.assert)(origin === 'qiniu');
_b = config, uploadHost = _b.uploadHost, domain = _b.domain, bucket2 = _b.bucket;
return [2 /*return*/, instance.getUploadInfo(uploadHost, domain, bucket || bucket2, key)];
}
});
});
}
exports.getUploadInfo = getUploadInfo;

13
lib/aspects/index.d.ts vendored Normal file
View File

@ -0,0 +1,13 @@
import { loginByMobile, loginWechat, loginWechatMp, syncUserInfoWechatMp, sendCaptcha } from './token';
import { getUploadInfo } from './extraFile';
import { updateConfig } from './config';
export declare const aspectDict: {
loginByMobile: typeof loginByMobile;
loginWechat: typeof loginWechat;
loginWechatMp: typeof loginWechatMp;
syncUserInfoWechatMp: typeof syncUserInfoWechatMp;
getUploadInfo: typeof getUploadInfo;
sendCaptcha: typeof sendCaptcha;
getApplication: typeof import("./application.dev").getApplication | typeof import("./application.prod").getApplication;
updateConfig: typeof updateConfig;
};

19
lib/aspects/index.js Normal file
View File

@ -0,0 +1,19 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.aspectDict = void 0;
var token_1 = require("./token");
var extraFile_1 = require("./extraFile");
var application_1 = require("./application");
var config_1 = require("./config");
// import commonAspectDict from 'oak-common-aspect';
exports.aspectDict = {
loginByMobile: token_1.loginByMobile,
loginWechat: token_1.loginWechat,
loginWechatMp: token_1.loginWechatMp,
syncUserInfoWechatMp: token_1.syncUserInfoWechatMp,
getUploadInfo: extraFile_1.getUploadInfo,
sendCaptcha: token_1.sendCaptcha,
getApplication: application_1.getApplication,
updateConfig: config_1.updateConfig,
};
// export type AspectDict<ED extends EntityDict & BaseEntityDict> = TokenAD<ED> & CrudAD<ED>;

45
lib/aspects/token.d.ts vendored Normal file
View File

@ -0,0 +1,45 @@
import { RuntimeContext } from '../context/RuntimeContext';
import { EntityDict } from '../general-app-domain';
import { WechatMpConfig } from '../general-app-domain/Application/Schema';
import { WebEnv, WechatMpEnv } from '../general-app-domain/Token/Schema';
export declare function loginByMobile<ED extends EntityDict, Cxt extends RuntimeContext<ED>>(params: {
captcha?: string;
password?: string;
mobile: string;
env: WebEnv | WechatMpEnv;
}, context: Cxt): Promise<string>;
/**
*
* @param param0
* @param context
*/
export declare function loginWechat<ED extends EntityDict, Cxt extends RuntimeContext<ED>>({ code, env }: {
code: string;
env: WebEnv;
}, context: Cxt): Promise<string>;
/**
*
* @param param0
* @param context
* @returns
*/
export declare function loginWechatMp<ED extends EntityDict, Cxt extends RuntimeContext<ED>>({ code, env }: {
code: string;
env: WechatMpEnv;
}, context: Cxt): Promise<string>;
/**
* wx.getUserProfile拿到的用户信息
* @param param0
* @param context
*/
export declare function syncUserInfoWechatMp<ED extends EntityDict, Cxt extends RuntimeContext<ED>>({ nickname, avatarUrl, encryptedData, iv, signature }: {
nickname: string;
avatarUrl: string;
encryptedData: string;
iv: string;
signature: string;
}, context: Cxt): Promise<void>;
export declare function sendCaptcha<ED extends EntityDict, Cxt extends RuntimeContext<ED>>({ mobile, env }: {
mobile: string;
env: WechatMpConfig | WebEnv;
}, context: Cxt): Promise<string>;

1347
lib/aspects/token.js Normal file

File diff suppressed because it is too large Load Diff

35
lib/aspects/wechatQrCode.d.ts vendored Normal file
View File

@ -0,0 +1,35 @@
import { EntityDict } from "../general-app-domain";
import { WechatQrCodeProps } from '../general-app-domain/WechatQrCode/Schema';
import { RuntimeContext } from '../context/RuntimeContext';
export declare function createWechatQrCode<ED extends EntityDict, T extends keyof ED, Cxt extends RuntimeContext<ED>>(options: {
entity: T;
entityId: string;
applicationId: string;
tag?: string;
lifetimeLength?: number;
permanent?: boolean;
props: WechatQrCodeProps;
}, context: Cxt): Promise<(Omit<Omit<import("../general-app-domain/WechatQrCode/Schema").OpSchema, "applicationId" | "entity" | "entityId">, import("oak-domain/lib/types").InstinctiveAttributes> & {
id: string;
} & {
applicationId: string;
application?: import("../general-app-domain/Application/Schema").UpdateOperation | undefined;
} & {
[K: string]: any;
entity?: string | undefined;
entityId?: string | undefined;
} & {
operEntity$entity?: import("oak-domain/lib/types").Operation<"create", Omit<import("../general-app-domain/OperEntity/Schema").CreateOperationData, "entity" | "entityId">[], undefined, undefined> | import("oak-domain/lib/types").Operation<"create", Omit<import("../general-app-domain/OperEntity/Schema").CreateOperationData, "entity" | "entityId">, undefined, undefined>[] | undefined;
modiEntity$entity?: import("oak-domain/lib/types").Operation<"create", Omit<import("../general-app-domain/ModiEntity/Schema").CreateOperationData, "entity" | "entityId">[], undefined, undefined> | import("oak-domain/lib/types").Operation<"create", Omit<import("../general-app-domain/ModiEntity/Schema").CreateOperationData, "entity" | "entityId">, undefined, undefined>[] | undefined;
}) | (Omit<Omit<import("../general-app-domain/WechatQrCode/Schema").OpSchema, "applicationId" | "entity" | "entityId">, import("oak-domain/lib/types").InstinctiveAttributes> & {
id: string;
} & {
applicationId: string;
} & {
[K: string]: any;
entity?: string | undefined;
entityId?: string | undefined;
} & {
operEntity$entity?: import("oak-domain/lib/types").Operation<"create", Omit<import("../general-app-domain/OperEntity/Schema").CreateOperationData, "entity" | "entityId">[], undefined, undefined> | import("oak-domain/lib/types").Operation<"create", Omit<import("../general-app-domain/OperEntity/Schema").CreateOperationData, "entity" | "entityId">, undefined, undefined>[] | undefined;
modiEntity$entity?: import("oak-domain/lib/types").Operation<"create", Omit<import("../general-app-domain/ModiEntity/Schema").CreateOperationData, "entity" | "entityId">[], undefined, undefined> | import("oak-domain/lib/types").Operation<"create", Omit<import("../general-app-domain/ModiEntity/Schema").CreateOperationData, "entity" | "entityId">, undefined, undefined>[] | undefined;
})>;

145
lib/aspects/wechatQrCode.js Normal file
View File

@ -0,0 +1,145 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.createWechatQrCode = void 0;
var tslib_1 = require("tslib");
var assert_1 = require("oak-domain/lib/utils/assert");
function createWechatQrCode(options, context) {
return tslib_1.__awaiter(this, void 0, void 0, function () {
var entity, entityId, applicationId, tag, lifetimeLength, permanent, props, _a, appType, config, qrCodePrefix, id, data, _b, _c, _d, data, _e, _f, _g, id, data, _h, _j, _k, id, data, _l, _m, _o;
var _p, _q, _r, _s;
return tslib_1.__generator(this, function (_t) {
switch (_t.label) {
case 0:
entity = options.entity, entityId = options.entityId, applicationId = options.applicationId, tag = options.tag, lifetimeLength = options.lifetimeLength, permanent = options.permanent, props = options.props;
return [4 /*yield*/, context.getApplication()];
case 1:
_a = (_t.sent()), appType = _a.type, config = _a.config;
if (!(appType === 'wechatMp')) return [3 /*break*/, 9];
qrCodePrefix = config.qrCodePrefix;
return [4 /*yield*/, generateNewId()];
case 2:
id = _t.sent();
if (!qrCodePrefix) return [3 /*break*/, 5];
data = {
id: id,
type: 'wechatMpDomainUrl',
tag: tag,
entity: entity,
entityId: entityId,
applicationId: applicationId,
allowShare: true,
permanent: true,
url: "".concat(qrCodePrefix, "/id"),
expired: false,
props: props,
};
_c = (_b = context.rowStore).operate;
_d = ['wechatQrCode'];
_p = {};
return [4 /*yield*/, generateNewId()];
case 3: return [4 /*yield*/, _c.apply(_b, _d.concat([(_p.id = _t.sent(),
_p.action = 'create',
_p.data = data,
_p), context,
{
dontCollect: true,
}]))];
case 4:
_t.sent();
return [2 /*return*/, data];
case 5:
data = {
id: id,
type: 'wechatMpWxaCode',
tag: tag,
entity: entity,
entityId: entityId,
applicationId: applicationId,
allowShare: true,
permanent: false,
expired: false,
props: props,
};
_f = (_e = context.rowStore).operate;
_g = ['wechatQrCode'];
_q = {};
return [4 /*yield*/, generateNewId()];
case 6: return [4 /*yield*/, _f.apply(_e, _g.concat([(_q.id = _t.sent(),
_q.action = 'create',
_q.data = data,
_q), context,
{
dontCollect: true,
}]))];
case 7:
_t.sent();
return [2 /*return*/, data];
case 8: return [3 /*break*/, 17];
case 9:
if (!(appType === 'wechatPublic')) return [3 /*break*/, 13];
return [4 /*yield*/, generateNewId()];
case 10:
id = _t.sent();
data = {
id: id,
type: 'wechatPublic',
tag: tag,
entity: entity,
entityId: entityId,
applicationId: applicationId,
allowShare: true,
permanent: false,
expired: false,
props: props,
};
_j = (_h = context.rowStore).operate;
_k = ['wechatQrCode'];
_r = {};
return [4 /*yield*/, generateNewId()];
case 11: return [4 /*yield*/, _j.apply(_h, _k.concat([(_r.id = _t.sent(),
_r.action = 'create',
_r.data = data,
_r), context,
{
dontCollect: true,
}]))];
case 12:
_t.sent();
return [2 /*return*/, data];
case 13:
(0, assert_1.assert)(appType === 'web');
return [4 /*yield*/, generateNewId()];
case 14:
id = _t.sent();
data = {
id: id,
type: 'webForWechatPublic',
tag: tag,
entity: entity,
entityId: entityId,
applicationId: applicationId,
allowShare: true,
permanent: false,
expired: false,
props: props,
};
_m = (_l = context.rowStore).operate;
_o = ['wechatQrCode'];
_s = {};
return [4 /*yield*/, generateNewId()];
case 15: return [4 /*yield*/, _m.apply(_l, _o.concat([(_s.id = _t.sent(),
_s.action = 'create',
_s.data = data,
_s), context,
{
dontCollect: true,
}]))];
case 16:
_t.sent();
return [2 /*return*/, data];
case 17: return [2 /*return*/];
}
});
});
}
exports.createWechatQrCode = createWechatQrCode;

5
lib/checkers/address.d.ts vendored Normal file
View File

@ -0,0 +1,5 @@
import { Checker } from "oak-domain/lib/types";
import { EntityDict } from '../general-app-domain';
import { RuntimeContext } from '../context/RuntimeContext';
declare const checkers: Checker<EntityDict, 'address', RuntimeContext<EntityDict>>[];
export default checkers;

39
lib/checkers/address.js Normal file
View File

@ -0,0 +1,39 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var validator_1 = require("oak-domain/lib/utils/validator");
var types_1 = require("oak-domain/lib/types");
var validator_2 = require("oak-domain/lib/utils/validator");
var checkers = [
{
type: 'data',
action: 'create',
entity: 'address',
checker: function (_a) {
var operation = _a.operation;
return tslib_1.__awaiter(void 0, void 0, void 0, function () {
var action, data;
return tslib_1.__generator(this, function (_b) {
action = operation.action, data = operation.data;
if (data instanceof Array) {
data.forEach(function (ele) {
var a = 'name';
(0, validator_2.checkAttributesNotNull)(ele, ['name', 'detail', 'phone', 'areaId']);
if (!(0, validator_1.isMobile)(ele.phone)) {
throw new types_1.OakInputIllegalException(['phone'], '手机号非法');
}
});
}
else {
(0, validator_2.checkAttributesNotNull)(data, ['name', 'detail', 'phone', 'areaId']);
if (!(0, validator_1.isMobile)(data.phone)) {
throw new types_1.OakInputIllegalException(['phone'], '手机号非法');
}
}
return [2 /*return*/, 0];
});
});
},
}
];
exports.default = checkers;

2
lib/checkers/index.d.ts vendored Normal file
View File

@ -0,0 +1,2 @@
declare const checkers: (import("oak-domain/lib/types").Checker<import("../general-app-domain").EntityDict, "address", import("../context/RuntimeContext").RuntimeContext<import("../general-app-domain").EntityDict>> | import("oak-domain/lib/types").Checker<import("../general-app-domain").EntityDict, "token", import("../context/RuntimeContext").RuntimeContext<import("../general-app-domain").EntityDict>> | import("oak-domain/lib/types").Checker<import("../general-app-domain").EntityDict, "user", import("../context/RuntimeContext").RuntimeContext<import("../general-app-domain").EntityDict>> | import("oak-domain/lib/types").Checker<import("../general-app-domain").EntityDict, "userEntityGrant", import("../context/RuntimeContext").RuntimeContext<import("../general-app-domain").EntityDict>> | import("oak-domain/lib/types").Checker<import("../general-app-domain").EntityDict, "wechatQrCode", import("../context/RuntimeContext").RuntimeContext<import("../general-app-domain").EntityDict>>)[];
export default checkers;

12
lib/checkers/index.js Normal file
View File

@ -0,0 +1,12 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var address_1 = tslib_1.__importDefault(require("./address"));
var token_1 = tslib_1.__importDefault(require("./token"));
var user_1 = tslib_1.__importDefault(require("./user"));
var userEntityGrant_1 = tslib_1.__importDefault(require("./userEntityGrant"));
var wechatQrCode_1 = tslib_1.__importDefault(require("./wechatQrCode"));
var check_1 = require("../utils/check");
var checkers = tslib_1.__spreadArray(tslib_1.__spreadArray(tslib_1.__spreadArray(tslib_1.__spreadArray(tslib_1.__spreadArray([], tslib_1.__read(address_1.default), false), tslib_1.__read(token_1.default), false), tslib_1.__read(user_1.default), false), tslib_1.__read(userEntityGrant_1.default), false), tslib_1.__read(wechatQrCode_1.default), false);
(0, check_1.processCheckers)(checkers);
exports.default = checkers;

5
lib/checkers/token.d.ts vendored Normal file
View File

@ -0,0 +1,5 @@
import { Checker } from "oak-domain/lib/types";
import { EntityDict } from '../general-app-domain';
import { RuntimeContext } from '../context/RuntimeContext';
declare const checkers: Checker<EntityDict, 'token', RuntimeContext<EntityDict>>[];
export default checkers;

4
lib/checkers/token.js Normal file
View File

@ -0,0 +1,4 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var checkers = [];
exports.default = checkers;

5
lib/checkers/user.d.ts vendored Normal file
View File

@ -0,0 +1,5 @@
import { Checker } from "oak-domain/lib/types";
import { EntityDict } from '../general-app-domain';
import { RuntimeContext } from '../context/RuntimeContext';
declare const checkers: Checker<EntityDict, 'user', RuntimeContext<EntityDict>>[];
export default checkers;

83
lib/checkers/user.js Normal file
View File

@ -0,0 +1,83 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var actionDef_1 = require("oak-domain/lib/store/actionDef");
var types_1 = require("oak-domain/lib/types");
var checkers = [
{
type: 'data',
action: 'remove',
entity: 'user',
checker: function (_a, context) {
var operation = _a.operation;
return tslib_1.__awaiter(void 0, void 0, void 0, function () {
var filter;
return tslib_1.__generator(this, function (_b) {
switch (_b.label) {
case 0:
filter = operation.filter;
return [4 /*yield*/, (0, actionDef_1.checkFilterContains)('user', context.rowStore.getSchema(), {
idState: 'shadow',
}, context, filter)];
case 1:
_b.sent();
return [2 /*return*/, 0];
}
});
});
},
},
{
type: 'user',
action: 'play',
entity: 'user',
checker: function () { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
return tslib_1.__generator(this, function (_a) {
// 只有root才能play
throw new types_1.OakUserUnpermittedException();
});
}); },
},
{
type: 'data',
action: 'play',
entity: 'user',
checker: function (_a, context) {
var operation = _a.operation;
return tslib_1.__awaiter(void 0, void 0, void 0, function () {
var token, userId;
return tslib_1.__generator(this, function (_b) {
switch (_b.label) {
case 0: return [4 /*yield*/, context.getToken()];
case 1:
token = _b.sent();
userId = token.userId;
if (userId === operation.filter.id) {
throw new types_1.OakRowInconsistencyException();
}
return [2 /*return*/, 0];
}
});
});
},
},
{
type: 'data',
action: 'grant',
entity: 'user',
checker: function (_a) {
var operation = _a.operation;
return tslib_1.__awaiter(void 0, void 0, void 0, function () {
var data;
return tslib_1.__generator(this, function (_b) {
data = operation.data;
if (Object.keys(data).filter(function (ele) { return !ele.includes('$'); }).length > 0) {
throw new types_1.OakInputIllegalException(Object.keys(data), '授权不允许传入其它属性');
}
return [2 /*return*/, 0];
});
});
}
}
];
exports.default = checkers;

5
lib/checkers/userEntityGrant.d.ts vendored Normal file
View File

@ -0,0 +1,5 @@
import { Checker } from 'oak-domain/lib/types';
import { EntityDict } from '../general-app-domain';
import { RuntimeContext } from '../context/RuntimeContext';
declare const checkers: Checker<EntityDict, 'userEntityGrant', RuntimeContext<EntityDict>>[];
export default checkers;

View File

@ -0,0 +1,57 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var types_1 = require("oak-domain/lib/types");
var validator_1 = require("oak-domain/lib/utils/validator");
var checkers = [
{
type: 'data',
action: 'create',
entity: 'userEntityGrant',
checker: function (_a, context) {
var operation = _a.operation;
return tslib_1.__awaiter(void 0, void 0, void 0, function () {
var data;
return tslib_1.__generator(this, function (_b) {
data = operation.data;
if (data instanceof Array) {
data.forEach(function (ele) {
(0, validator_1.checkAttributesNotNull)(ele, ['type', 'entity', 'entityId', 'relation']);
if (!ele.hasOwnProperty('number') || ele.type === 'transfer') {
Object.assign(ele, {
number: 1,
});
}
else {
if (ele.number <= 0) {
throw new types_1.OakInputIllegalException(['number', '分享的权限数量必须大于0']);
}
}
Object.assign(ele, {
confirmed: 0,
});
});
}
else {
(0, validator_1.checkAttributesNotNull)(data, ['type', 'entity', 'entityId', 'relation']);
if (!data.hasOwnProperty('number') || data.type === 'transfer') {
Object.assign(data, {
number: 1,
});
}
else {
if (data.number <= 0) {
throw new types_1.OakInputIllegalException(['number', '分享的权限数量必须大于0']);
}
}
Object.assign(data, {
confirmed: 0,
});
}
return [2 /*return*/, 0];
});
});
},
},
];
exports.default = checkers;

5
lib/checkers/wechatQrCode.d.ts vendored Normal file
View File

@ -0,0 +1,5 @@
import { Checker } from 'oak-domain/lib/types';
import { EntityDict } from '../general-app-domain';
import { RuntimeContext } from '../context/RuntimeContext';
declare const checkers: Checker<EntityDict, 'wechatQrCode', RuntimeContext<EntityDict>>[];
export default checkers;

View File

@ -0,0 +1,19 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var checkers = [
{
type: 'data',
action: 'create',
entity: 'wechatQrCode',
checker: function (_a, context) {
var operation = _a.operation;
return tslib_1.__awaiter(void 0, void 0, void 0, function () {
return tslib_1.__generator(this, function (_b) {
return [2 /*return*/, 0];
});
});
},
},
];
exports.default = checkers;

3
lib/components/amap/index.d.ts vendored Normal file
View File

@ -0,0 +1,3 @@
import Map from './map';
import Location from './location';
export { Map, Location };

View File

@ -0,0 +1,8 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Location = exports.Map = void 0;
var tslib_1 = require("tslib");
var map_1 = tslib_1.__importDefault(require("./map"));
exports.Map = map_1.default;
var location_1 = tslib_1.__importDefault(require("./location"));
exports.Location = location_1.default;

View File

@ -0,0 +1,10 @@
/// <reference types="@uiw/react-amap-types" />
import React from 'react';
export declare type PositionProps = {
loadUI: boolean;
__map__: AMap.Map | undefined;
onSuccess?: (result: AMapUI.PositionPickerResult) => void;
onFail?: (error: any) => void;
};
declare const _default: React.MemoExoticComponent<(props: PositionProps) => null>;
export default _default;

View File

@ -0,0 +1,35 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var react_1 = require("react");
exports.default = (0, react_1.memo)(function (props) {
var map = props.__map__;
var loadUI = props.loadUI;
var onSuccess = props.onSuccess, onFail = props.onFail;
(0, react_1.useEffect)(function () {
if (map && window.AMapUI) {
dragSiteSelection();
}
}, [map, window.AMapUI]);
var dragSiteSelection = function () {
window.AMapUI.loadUI(['misc/PositionPicker'], function (PositionPicker) {
var positionPicker = new PositionPicker({
mode: 'dragMap',
map: map,
iconStyle: {
//自定义外观
url: '//webapi.amap.com/ui/1.0/assets/position-picker2.png',
ancher: [24, 40],
size: [48, 48],
},
});
positionPicker.on('success', function (result) {
onSuccess && onSuccess(result);
});
positionPicker.on('fail', function (error) {
onFail && onFail(error);
});
positionPicker.start();
});
};
return null;
});

39
lib/components/amap/location/index.d.ts vendored Normal file
View File

@ -0,0 +1,39 @@
/// <reference types="@uiw/react-amap-types" />
import React from 'react';
import { DialogProps } from 'tdesign-react';
import { GeolocationProps } from '@uiw/react-amap';
import './index.less';
export declare type LocationProps = {
akey: string;
version?: string;
visible?: boolean;
className?: string;
children?: React.ReactNode;
onClose?: () => void;
onConfirm?: (poi: Poi, result?: AMap.SearchResult | AMapUI.PositionPickerResult) => void;
geolocationProps?: GeolocationProps;
useGeolocation?: boolean;
dialogProps?: DialogProps;
};
export declare type Poi = {
id: string;
name: string;
type: string;
tel: string;
direction?: string;
distance: number;
address: string;
location: AMap.LngLat;
website?: string;
pcode: string;
citycode: string;
adcode: string;
postcode?: string;
pname: string;
cityname: string;
adname: string;
email?: string;
businessArea?: string;
};
declare const Location: (props: LocationProps) => JSX.Element;
export default Location;

View File

@ -0,0 +1,200 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var jsx_runtime_1 = require("react/jsx-runtime");
var react_1 = tslib_1.__importStar(require("react"));
var tdesign_react_1 = require("tdesign-react");
var tdesign_icons_react_1 = require("tdesign-icons-react");
var react_amap_1 = require("@uiw/react-amap");
var map_1 = tslib_1.__importDefault(require("./../map"));
var PositionPicker_1 = tslib_1.__importDefault(require("./PositionPicker"));
require("./index.less");
var ListItem = tdesign_react_1.List.ListItem, ListItemMeta = tdesign_react_1.List.ListItemMeta;
var Location = function (props) {
var visible = props.visible, akey = props.akey, _a = props.version, version = _a === void 0 ? '2.0' : _a, onClose = props.onClose, onConfirm = props.onConfirm, _b = props.geolocationProps, geolocationProps = _b === void 0 ? {} : _b, _c = props.useGeolocation, useGeolocation = _c === void 0 ? true : _c, _d = props.dialogProps, dialogProps = _d === void 0 ? {} : _d;
var prefixCls = 'oak';
var searchRef = (0, react_1.useRef)();
var _e = tslib_1.__read((0, react_1.useState)(''), 2), searchValue = _e[0], setSearchValue = _e[1];
var _f = tslib_1.__read((0, react_1.useState)(true), 2), refresh = _f[0], setRefresh = _f[1]; // 点击poi不触发setPositionPickerResult
var _g = tslib_1.__read((0, react_1.useState)('dragMap'), 2), mode = _g[0], setMode = _g[1];
var _h = tslib_1.__read((0, react_1.useState)(), 2), map = _h[0], setMap = _h[1];
var _j = tslib_1.__read((0, react_1.useState)(), 2), positionPickerResult = _j[0], setPositionPickerResult = _j[1];
var _k = tslib_1.__read((0, react_1.useState)(), 2), searchResult = _k[0], setSearchResult = _k[1];
var _l = tslib_1.__read((0, react_1.useState)(), 2), pois = _l[0], setPois = _l[1];
var _m = tslib_1.__read((0, react_1.useState)(), 2), currentPoi = _m[0], setCurrentPoi = _m[1];
var _o = tslib_1.__read((0, react_1.useState)(), 2), oldPois = _o[0], setOldPois = _o[1];
var _p = tslib_1.__read((0, react_1.useState)(), 2), oldPoi = _p[0], setOldPoi = _p[1];
var _q = tslib_1.__read((0, react_1.useState)(false), 2), loadUI = _q[0], setLoadUI = _q[1];
var _r = tslib_1.__read((0, react_1.useState)(false), 2), focus = _r[0], setFocus = _r[1];
var _s = tslib_1.__read((0, react_1.useState)(false), 2), searchLoading = _s[0], setSearchLoading = _s[1];
var _t = tslib_1.__read((0, react_1.useState)(false), 2), show = _t[0], setShow = _t[1];
var setCenter = function (center) {
if (map) {
map.setCenter(center);
}
};
var placeSearch = function (value) {
// window.AMap存在再搜素
return new Promise(function (resolve, reject) {
var _a;
(_a = window.AMap) === null || _a === void 0 ? void 0 : _a.plugin(['AMap.PlaceSearch'], function () {
var placeSearch = new window.AMap.PlaceSearch({
pageSize: 20,
pageIndex: 1,
extensions: 'all',
city: '全国', //城市
});
placeSearch.search(value, function (status, result) {
if (status === 'complete') {
resolve(result);
}
else {
reject(result);
}
});
});
});
};
(0, react_1.useEffect)(function () {
if (window.AMap && !window.AMapUI) {
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = "".concat(window.location.protocol, "//webapi.amap.com/ui/1.1/main.js");
document.getElementsByTagName('head')[0].appendChild(script);
script.onload = function () {
setLoadUI(true);
};
script.onerror = function (error) {
setLoadUI(false);
};
}
else if (window.AMap && window.AMapUI) {
setLoadUI(true);
}
}, [window.AMap]);
(0, react_1.useEffect)(function () {
if (currentPoi && !refresh) {
var lngLat = new window.AMap.LngLat(currentPoi.location.lng, currentPoi.location.lat);
setCenter(lngLat);
}
}, [refresh, currentPoi]);
(0, react_1.useEffect)(function () {
// 拖动地图才触发
if (mode === 'dragMap' && positionPickerResult && refresh) {
var regeocode = positionPickerResult.regeocode;
var pois_1 = regeocode.pois, addressComponent_1 = regeocode.addressComponent;
var pois2 = pois_1 === null || pois_1 === void 0 ? void 0 : pois_1.map(function (poi, index) {
return tslib_1.__assign(tslib_1.__assign({}, poi), { pcode: '', citycode: addressComponent_1 === null || addressComponent_1 === void 0 ? void 0 : addressComponent_1.citycode, adcode: addressComponent_1.adcode, postcode: '', pname: addressComponent_1.province, cityname: addressComponent_1.city, adname: addressComponent_1 === null || addressComponent_1 === void 0 ? void 0 : addressComponent_1.district });
});
setPois(pois2);
setCurrentPoi(pois2[0]);
}
}, [refresh, positionPickerResult]);
(0, react_1.useEffect)(function () {
if (searchValue) {
setSearchLoading(true);
placeSearch(searchValue).then(function (result) {
var pois = (result === null || result === void 0 ? void 0 : result.poiList).pois;
setSearchResult(result);
setShow(true);
setSearchLoading(false);
setPois(pois);
setCurrentPoi(pois[0]);
}, function (error) {
setSearchResult(undefined);
setShow(true);
setSearchLoading(false);
});
}
}, [searchValue]);
(0, react_1.useEffect)(function () {
if (mode === 'searchPoi') {
setOldPoi(currentPoi);
setOldPois(pois);
setPois([]);
setCurrentPoi(undefined);
}
else {
setPois(oldPois);
setCurrentPoi(oldPoi);
}
}, [mode]);
(0, react_1.useEffect)(function () {
if (visible && map && loadUI) {
setCenter(map.getCenter());
}
}, [visible, map, loadUI]);
var clearData = function () {
setMode('dragMap');
setFocus(false);
setShow(false);
setSearchValue('');
setRefresh(true);
};
return ((0, jsx_runtime_1.jsx)(tdesign_react_1.Dialog, tslib_1.__assign({ width: "80%" }, dialogProps, { visible: visible, onClose: function () {
onClose && onClose();
clearData();
}, onConfirm: function () {
if (!currentPoi) {
return;
}
onConfirm &&
onConfirm(currentPoi, mode === 'dragMap' ? positionPickerResult : searchResult);
clearData();
} }, { children: (0, jsx_runtime_1.jsx)("div", tslib_1.__assign({ className: "".concat(prefixCls, "-location") }, { children: (0, jsx_runtime_1.jsxs)(tdesign_react_1.Row, { children: [(0, jsx_runtime_1.jsx)(tdesign_react_1.Col, tslib_1.__assign({ xs: 12, sm: 7 }, { children: (0, jsx_runtime_1.jsxs)(map_1.default, tslib_1.__assign({ className: "".concat(prefixCls, "-location-map"), akey: akey, version: version, useAMapUI: true, mapRef: function (instance) {
if (instance && instance.map && !map) {
setMap(instance.map);
}
}, mapProps: {
onDragStart: function () {
setRefresh(true);
setMode('dragMap');
setSearchValue('');
setShow(false);
},
} }, { children: [(0, jsx_runtime_1.jsx)(PositionPicker_1.default, { loadUI: loadUI, __map__: map, onSuccess: function (result) {
setPositionPickerResult(result);
} }), useGeolocation && ((0, jsx_runtime_1.jsx)(react_amap_1.Geolocation, tslib_1.__assign({ maximumAge: 100000, borderRadius: "5px", position: "RB", offset: [10, 10], zoomToAccuracy: true, showCircle: true }, geolocationProps, { onComplete: function (data) { }, onError: function (err) {
console.error(err);
} })))] })) })), (0, jsx_runtime_1.jsx)(tdesign_react_1.Col, tslib_1.__assign({ xs: 12, sm: 5 }, { children: (0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsxs)(tdesign_react_1.List, tslib_1.__assign({ className: "".concat(prefixCls, "-location-list"), header: (0, jsx_runtime_1.jsxs)("div", tslib_1.__assign({ className: "".concat(prefixCls, "-location-list-header") }, { children: [(0, jsx_runtime_1.jsx)(tdesign_react_1.Input, { ref: searchRef, placeholder: "\u641C\u7D22\u5730\u70B9", value: searchValue, clearable: true, onChange: function (value) {
setSearchValue(value);
}, onClear: function () {
setSearchValue('');
}, prefixIcon: (0, jsx_runtime_1.jsx)(tdesign_icons_react_1.SearchIcon, {}), onFocus: function () {
setMode('searchPoi');
setFocus(true);
}, onBlur: function () {
setFocus(false);
} }), mode === 'searchPoi' && ((0, jsx_runtime_1.jsx)(tdesign_react_1.Button, tslib_1.__assign({ style: { marginLeft: 5 }, variant: "text", theme: "primary", onClick: function () {
var _a;
setMode('dragMap');
setSearchValue('');
setShow(false);
//@ts-ignore
(_a = searchRef === null || searchRef === void 0 ? void 0 : searchRef.current) === null || _a === void 0 ? void 0 : _a.blur();
} }, { children: "\u53D6\u6D88" })))] })) }, { children: [mode === 'dragMap' &&
(pois === null || pois === void 0 ? void 0 : pois.map(function (poi, index) {
return ((0, jsx_runtime_1.jsx)("div", tslib_1.__assign({ onClick: function () {
setRefresh(false);
setCurrentPoi(poi);
} }, { children: (0, jsx_runtime_1.jsx)(ListItem, tslib_1.__assign({ action: (currentPoi === null || currentPoi === void 0 ? void 0 : currentPoi.id) ===
poi.id ? ((0, jsx_runtime_1.jsx)(tdesign_icons_react_1.CheckCircleFilledIcon, { className: "".concat(prefixCls, "-location-list-checked"), size: 24 })) : ((0, jsx_runtime_1.jsx)("div", { style: {
width: 24,
} })) }, { children: (0, jsx_runtime_1.jsx)(ListItemMeta, { title: poi.name, description: "".concat(poi.distance
? "".concat(poi.distance, "m\u5185 | ")
: '').concat(poi.address) }) })) }), poi.id));
})), mode === 'searchPoi' && ((0, jsx_runtime_1.jsxs)(react_1.default.Fragment, { children: [searchLoading && ((0, jsx_runtime_1.jsx)("div", tslib_1.__assign({ className: "".concat(prefixCls, "-location-list-loadingBox") }, { children: (0, jsx_runtime_1.jsx)(tdesign_react_1.Loading, { delay: 0, fullscreen: false, indicator: true, inheritColor: false, loading: true, preventScrollThrough: true, showOverlay: true, size: "medium" }) }))), (pois === null || pois === void 0 ? void 0 : pois.length)
? pois.map(function (poi, index) {
return ((0, jsx_runtime_1.jsx)("div", tslib_1.__assign({ onClick: function () {
setRefresh(false);
setCurrentPoi(poi);
} }, { children: (0, jsx_runtime_1.jsx)(ListItem, tslib_1.__assign({ action: (currentPoi === null || currentPoi === void 0 ? void 0 : currentPoi.id) ===
poi.id ? ((0, jsx_runtime_1.jsx)(tdesign_icons_react_1.CheckCircleFilledIcon, { className: "".concat(prefixCls, "-location-list-checked"), size: 24 })) : ((0, jsx_runtime_1.jsx)("div", { style: {
width: 24,
} })) }, { children: (0, jsx_runtime_1.jsx)(ListItemMeta, { title: poi.name, description: "".concat(poi.distance
? "".concat(poi.distance, "m\u5185 | ")
: '').concat(poi.address) }) })) }), poi.id));
})
: show && ((0, jsx_runtime_1.jsx)("div", tslib_1.__assign({ className: "".concat(prefixCls, "-location-list-noData") }, { children: "\u65E0\u641C\u7D20\u7ED3\u679C" })))] }))] })) }) }))] }) })) })));
};
exports.default = Location;

31
lib/components/amap/map/index.d.ts vendored Normal file
View File

@ -0,0 +1,31 @@
/// <reference types="@uiw/react-amap-types" />
import React from 'react';
import { MapProps, APILoaderConfig } from '@uiw/react-amap';
import './index.less';
export declare type APILoaderProps = {
akey: APILoaderConfig['akay'];
version?: APILoaderConfig['version'];
};
declare type RenderProps = {
children?: (data: {
AMap: typeof AMap;
map: AMap.Map;
container?: HTMLDivElement | null;
}) => undefined;
} | {
children?: React.ReactNode;
};
export interface AMapProps extends APILoaderProps {
style?: React.CSSProperties;
className?: string;
children?: RenderProps['children'];
mapProps?: MapProps;
mapRef?: React.Ref<MapProps & {
map?: AMap.Map | undefined;
}>;
useAMapUI?: boolean;
uiVersion?: string;
uiCallback?: (status: 'success' | 'fail', result?: any) => void;
}
declare const memo: (props: AMapProps) => JSX.Element;
export default memo;

View File

@ -0,0 +1,32 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var jsx_runtime_1 = require("react/jsx-runtime");
var react_1 = require("react");
var react_amap_1 = require("@uiw/react-amap");
var classnames_1 = tslib_1.__importDefault(require("classnames"));
require("./index.less");
;
var memo = function (props) {
var akey = props.akey, version = props.version, className = props.className, style = props.style, children = props.children, _a = props.mapProps, mapProps = _a === void 0 ? {} : _a, mapRef = props.mapRef, useAMapUI = props.useAMapUI, _b = props.uiVersion, uiVersion = _b === void 0 ? '1.1' : _b, uiCallback = props.uiCallback;
var prefixCls = 'oak';
(0, react_1.useEffect)(function () {
if (!useAMapUI) {
return;
}
if (window.AMap && !window.AMapUI) {
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = "".concat(window.location.protocol, "//webapi.amap.com/ui/").concat(uiVersion, "/main.js");
document.getElementsByTagName('head')[0].appendChild(script);
script.onload = function () {
uiCallback && uiCallback('success');
};
script.onerror = function (error) {
uiCallback && uiCallback('fail', error);
};
}
}, [window.AMap, useAMapUI]);
return ((0, jsx_runtime_1.jsx)("div", tslib_1.__assign({ style: style, className: (0, classnames_1.default)("".concat(prefixCls, "-map"), className) }, { children: (0, jsx_runtime_1.jsx)(react_amap_1.APILoader, tslib_1.__assign({ akay: akey, version: version }, { children: (0, jsx_runtime_1.jsx)(react_amap_1.Map, tslib_1.__assign({ ref: mapRef }, mapProps, { children: children })) })) })));
};
exports.default = memo;

0
lib/components/area/upsert/index.d.ts vendored Normal file
View File

View File

@ -0,0 +1,52 @@
"use strict";
// index.ts
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
OakComponent({
entity: 'area',
isList: false,
formData: function (_a) {
var area = _a.data;
return __awaiter(void 0, void 0, void 0, function () {
return __generator(this, function (_b) {
return [2 /*return*/, ({
name: area === null || area === void 0 ? void 0 : area.name,
})];
});
});
},
});

View File

@ -0,0 +1 @@
{}

View File

@ -0,0 +1,4 @@
/// <reference types="react" />
import './index.less';
declare const Empty: () => JSX.Element;
export default Empty;

View File

@ -0,0 +1,12 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var jsx_runtime_1 = require("react/jsx-runtime");
require("./index.less");
var Empty = function () {
var prefixCls = 'oak';
var themeMode = document.documentElement.getAttribute('theme-mode');
var themePrefixCls = "".concat(prefixCls, "-empty-img-default") + (themeMode === 'dark' ? '-dark' : '');
return ((0, jsx_runtime_1.jsx)("svg", tslib_1.__assign({ className: themePrefixCls, width: "184", height: "152", viewBox: "0 0 184 152", xmlns: "http://www.w3.org/2000/svg" }, { children: (0, jsx_runtime_1.jsxs)("g", tslib_1.__assign({ fill: "none", fillRule: "evenodd" }, { children: [(0, jsx_runtime_1.jsxs)("g", tslib_1.__assign({ transform: "translate(24 31.67)" }, { children: [(0, jsx_runtime_1.jsx)("ellipse", { className: "".concat(themePrefixCls, "-ellipse"), cx: "67.797", cy: "106.89", rx: "67.797", ry: "12.668" }), (0, jsx_runtime_1.jsx)("path", { className: "".concat(themePrefixCls, "-path-1"), d: "M122.034 69.674L98.109 40.229c-1.148-1.386-2.826-2.225-4.593-2.225h-51.44c-1.766 0-3.444.839-4.592 2.225L13.56 69.674v15.383h108.475V69.674z" }), (0, jsx_runtime_1.jsx)("path", { className: "".concat(themePrefixCls, "-path-2"), d: "M101.537 86.214L80.63 61.102c-1.001-1.207-2.507-1.867-4.048-1.867H31.724c-1.54 0-3.047.66-4.048 1.867L6.769 86.214v13.792h94.768V86.214z", transform: "translate(13.56)" }), (0, jsx_runtime_1.jsx)("path", { className: "".concat(themePrefixCls, "-path-3"), d: "M33.83 0h67.933a4 4 0 0 1 4 4v93.344a4 4 0 0 1-4 4H33.83a4 4 0 0 1-4-4V4a4 4 0 0 1 4-4z" }), (0, jsx_runtime_1.jsx)("path", { className: "".concat(themePrefixCls, "-path-4"), d: "M42.678 9.953h50.237a2 2 0 0 1 2 2V36.91a2 2 0 0 1-2 2H42.678a2 2 0 0 1-2-2V11.953a2 2 0 0 1 2-2zM42.94 49.767h49.713a2.262 2.262 0 1 1 0 4.524H42.94a2.262 2.262 0 0 1 0-4.524zM42.94 61.53h49.713a2.262 2.262 0 1 1 0 4.525H42.94a2.262 2.262 0 0 1 0-4.525zM121.813 105.032c-.775 3.071-3.497 5.36-6.735 5.36H20.515c-3.238 0-5.96-2.29-6.734-5.36a7.309 7.309 0 0 1-.222-1.79V69.675h26.318c2.907 0 5.25 2.448 5.25 5.42v.04c0 2.971 2.37 5.37 5.277 5.37h34.785c2.907 0 5.277-2.421 5.277-5.393V75.1c0-2.972 2.343-5.426 5.25-5.426h26.318v33.569c0 .617-.077 1.216-.221 1.789z" })] })), (0, jsx_runtime_1.jsx)("path", { className: "".concat(prefixCls, "-path-5"), d: "M149.121 33.292l-6.83 2.65a1 1 0 0 1-1.317-1.23l1.937-6.207c-2.589-2.944-4.109-6.534-4.109-10.408C138.802 8.102 148.92 0 161.402 0 173.881 0 184 8.102 184 18.097c0 9.995-10.118 18.097-22.599 18.097-4.528 0-8.744-1.066-12.28-2.902z" }), (0, jsx_runtime_1.jsxs)("g", tslib_1.__assign({ className: "".concat(themePrefixCls, "-g"), transform: "translate(149.65 15.383)" }, { children: [(0, jsx_runtime_1.jsx)("ellipse", { cx: "20.654", cy: "3.167", rx: "2.849", ry: "2.815" }), (0, jsx_runtime_1.jsx)("path", { d: "M5.698 5.63H0L2.898.704zM9.259.704h4.985V5.63H9.259z" })] }))] })) })));
};
exports.default = Empty;

16
lib/components/common/empty/index.d.ts vendored Normal file
View File

@ -0,0 +1,16 @@
import * as React from 'react';
import './index.less';
declare type EmptyProps = {
className?: string;
style?: React.CSSProperties;
imageStyle?: React.CSSProperties;
image?: React.ReactNode;
description?: React.ReactNode;
children?: React.ReactNode;
};
interface EmptyType extends React.FC<EmptyProps> {
PRESENTED_IMAGE_DEFAULT: React.ReactNode;
PRESENTED_IMAGE_SIMPLE: React.ReactNode;
}
declare const Empty: EmptyType;
export default Empty;

View File

@ -0,0 +1,30 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var jsx_runtime_1 = require("react/jsx-runtime");
var classnames_1 = tslib_1.__importDefault(require("classnames"));
require("./index.less");
var empty_1 = tslib_1.__importDefault(require("./empty"));
var simple_1 = tslib_1.__importDefault(require("./simple"));
var defaultEmptyImg = (0, jsx_runtime_1.jsx)(empty_1.default, {});
var simpleEmptyImg = (0, jsx_runtime_1.jsx)(simple_1.default, {});
var Empty = function (props) {
var _a;
var className = props.className, _b = props.image, image = _b === void 0 ? defaultEmptyImg : _b, description = props.description, children = props.children, imageStyle = props.imageStyle, restProps = tslib_1.__rest(props, ["className", "image", "description", "children", "imageStyle"]);
var des = typeof description !== 'undefined' ? description : '暂无数据';
var alt = typeof des === 'string' ? des : 'empty';
var imageNode = null;
if (typeof image === 'string') {
imageNode = (0, jsx_runtime_1.jsx)("img", { alt: alt, src: image });
}
else {
imageNode = image;
}
var prefixCls = 'oak';
return ((0, jsx_runtime_1.jsxs)("div", tslib_1.__assign({ className: (0, classnames_1.default)("".concat(prefixCls, "-empty"), (_a = {},
_a["".concat(prefixCls, "-empty-normal")] = image === simpleEmptyImg,
_a), className) }, restProps, { children: [(0, jsx_runtime_1.jsx)("div", tslib_1.__assign({ className: "".concat(prefixCls, "-empty-image"), style: imageStyle }, { children: imageNode })), des && (0, jsx_runtime_1.jsx)("div", tslib_1.__assign({ className: "".concat(prefixCls, "-empty-description") }, { children: des })), children && ((0, jsx_runtime_1.jsx)("div", tslib_1.__assign({ className: "".concat(prefixCls, "-empty-footer") }, { children: children })))] })));
};
Empty.PRESENTED_IMAGE_DEFAULT = defaultEmptyImg;
Empty.PRESENTED_IMAGE_SIMPLE = simpleEmptyImg;
exports.default = Empty;

View File

@ -0,0 +1,4 @@
/// <reference types="react" />
import './index.less';
declare const Empty: () => JSX.Element;
export default Empty;

View File

@ -0,0 +1,12 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var jsx_runtime_1 = require("react/jsx-runtime");
require("./index.less");
var Empty = function () {
var prefixCls = 'oak';
var themeMode = document.documentElement.getAttribute('theme-mode');
var themePrefixCls = "".concat(prefixCls, "-empty-img-simple") + (themeMode === 'dark' ? '-dark' : '');
return ((0, jsx_runtime_1.jsx)("svg", tslib_1.__assign({ className: themePrefixCls, width: "64", height: "41", viewBox: "0 0 64 41", xmlns: "http://www.w3.org/2000/svg" }, { children: (0, jsx_runtime_1.jsxs)("g", tslib_1.__assign({ transform: "translate(0 1)", fill: "none", fillRule: "evenodd" }, { children: [(0, jsx_runtime_1.jsx)("ellipse", { className: "".concat(themePrefixCls, "-ellipse"), cx: "32", cy: "33", rx: "32", ry: "7" }), (0, jsx_runtime_1.jsxs)("g", tslib_1.__assign({ className: "".concat(themePrefixCls, "-g"), fillRule: "nonzero" }, { children: [(0, jsx_runtime_1.jsx)("path", { d: "M55 12.76L44.854 1.258C44.367.474 43.656 0 42.907 0H21.093c-.749 0-1.46.474-1.947 1.257L9 12.761V22h46v-9.24z" }), (0, jsx_runtime_1.jsx)("path", { d: "M41.613 15.931c0-1.605.994-2.93 2.227-2.931H55v18.137C55 33.26 53.68 35 52.05 35h-40.1C10.32 35 9 33.259 9 31.137V13h11.16c1.233 0 2.227 1.323 2.227 2.928v.022c0 1.605 1.005 2.901 2.237 2.901h14.752c1.232 0 2.237-1.308 2.237-2.913v-.007z", className: "".concat(themePrefixCls, "-path") })] }))] })) })));
};
exports.default = Empty;

19
lib/components/common/grid/index.d.ts vendored Normal file
View File

@ -0,0 +1,19 @@
import React from 'react';
import './index.less';
declare type Item = {
text: React.ReactNode;
image: React.ReactNode;
};
declare type GridProps = {
column?: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8;
gutter?: number;
style?: React.CSSProperties;
className?: string;
imageClassName?: string;
textClassName?: string;
children?: React.ReactNode;
list: Array<Item>;
onChange?: (index: number, event?: React.MouseEvent<HTMLDivElement, MouseEvent>) => void;
};
declare const _default: React.MemoExoticComponent<(props: GridProps) => JSX.Element>;
export default _default;

View File

@ -0,0 +1,22 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var jsx_runtime_1 = require("react/jsx-runtime");
var react_1 = require("react");
var classnames_1 = tslib_1.__importDefault(require("classnames"));
require("./index.less");
var prefixCls = 'oak';
exports.default = (0, react_1.memo)(function (props) {
var style = props.style, className = props.className, _a = props.column, column = _a === void 0 ? 4 : _a, _b = props.gutter, gutter = _b === void 0 ? 0 : _b, list = props.list, onChange = props.onChange, imageClassName = props.imageClassName, textClassName = props.textClassName;
return ((0, jsx_runtime_1.jsx)("div", tslib_1.__assign({ className: "".concat(prefixCls, "-grid"), style: {
gap: gutter,
} }, { children: list === null || list === void 0 ? void 0 : list.map(function (ele, index) {
var _a;
return ((0, jsx_runtime_1.jsxs)("div", tslib_1.__assign({ className: (0, classnames_1.default)(className, "".concat(prefixCls, "-grid-item"), (_a = {},
_a["".concat(prefixCls, "-grid-item-column-").concat(column)] = column,
_a)), style: style, onClick: onChange ? function (event) { return onChange(index, event); } : undefined }, { children: [typeof ele.image === 'string' ? ((0, jsx_runtime_1.jsx)("img", { className: (0, classnames_1.default)("".concat(prefixCls, "-grid-item-image"), imageClassName), src: ele.image })) : (ele.image), (0, jsx_runtime_1.jsx)("div", tslib_1.__assign({ className: "".concat(prefixCls, "-grid-item-text") }, { children: (0, jsx_runtime_1.jsx)("div", tslib_1.__assign({ className: (0, classnames_1.default)("".concat(prefixCls, "-grid-item-title"), textClassName), style: {
paddingTop: 8,
marginBottom: 4,
} }, { children: ele.text })) }))] }), index));
}) })));
});

View File

@ -0,0 +1,20 @@
import React from 'react';
import './index.less';
declare type PageHeaderProps = {
style?: React.CSSProperties;
className?: string;
title?: React.ReactNode;
showBack?: boolean;
onBack?: () => void;
backIcon?: React.ReactNode;
delta?: number;
extra?: React.ReactNode;
subTitle?: React.ReactNode;
contentMargin?: boolean;
contentStyle?: React.CSSProperties;
contentClassName?: string;
tags?: React.ReactNode;
children?: React.ReactNode;
};
declare const _default: React.MemoExoticComponent<(props: PageHeaderProps) => JSX.Element>;
export default _default;

View File

@ -0,0 +1,25 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var jsx_runtime_1 = require("react/jsx-runtime");
var react_1 = require("react");
var react_router_dom_1 = require("react-router-dom");
var tdesign_react_1 = require("tdesign-react");
var tdesign_icons_react_1 = require("tdesign-icons-react");
var classnames_1 = tslib_1.__importDefault(require("classnames"));
require("./index.less");
exports.default = (0, react_1.memo)(function (props) {
var _a;
var style = props.style, className = props.className, children = props.children, title = props.title, subTitle = props.subTitle, extra = props.extra, showBack = props.showBack, onBack = props.onBack, backIcon = props.backIcon, delta = props.delta, _b = props.contentMargin, contentMargin = _b === void 0 ? true : _b, contentStyle = props.contentStyle, contentClassName = props.contentClassName, tags = props.tags;
var prefixCls = 'oak';
var navigate = (0, react_router_dom_1.useNavigate)();
return ((0, jsx_runtime_1.jsxs)("div", tslib_1.__assign({ style: style, className: (0, classnames_1.default)("".concat(prefixCls, "-pageHeader"), className) }, { children: [(title || showBack || subTitle || tags || extra) && ((0, jsx_runtime_1.jsx)("div", tslib_1.__assign({ className: "".concat(prefixCls, "-pageHeader-header") }, { children: (0, jsx_runtime_1.jsxs)(tdesign_react_1.Row, { children: [(0, jsx_runtime_1.jsxs)(tdesign_react_1.Col, tslib_1.__assign({ flex: "auto" }, { children: [showBack && ((0, jsx_runtime_1.jsx)(tdesign_react_1.Button, tslib_1.__assign({ shape: "square", variant: "text", className: "".concat(prefixCls, "-pageHeader-header-back"), onClick: function () {
if (typeof onBack === 'function') {
onBack();
return;
}
navigate(delta || -1);
} }, { children: backIcon || ((0, jsx_runtime_1.jsx)(tdesign_icons_react_1.ArrowLeftIcon, { className: "".concat(prefixCls, "-pageHeader-header-backIcon") })) }))), title && ((0, jsx_runtime_1.jsx)("span", tslib_1.__assign({ className: "".concat(prefixCls, "-pageHeader-header-title") }, { children: title }))), subTitle && ((0, jsx_runtime_1.jsx)("span", tslib_1.__assign({ className: "".concat(prefixCls, "-pageHeader-header-subTitle") }, { children: subTitle }))), tags] })), (0, jsx_runtime_1.jsx)(tdesign_react_1.Col, tslib_1.__assign({ flex: "auto" }, { children: extra }))] }) }))), (0, jsx_runtime_1.jsx)("div", tslib_1.__assign({ style: contentStyle, className: (0, classnames_1.default)("".concat(prefixCls, "-pageHeader-content"), contentClassName, (_a = {},
_a["".concat(prefixCls, "-pageHeader-content-margin")] = contentMargin,
_a)) }, { children: children }))] })));
});

92
lib/components/common/search/index.d.ts vendored Normal file
View File

@ -0,0 +1,92 @@
import React from 'react';
import './index.less';
declare type SearchProps = {
/**
*
* @default ''
*/
action?: React.ReactNode;
/**
*
* @default false
*/
center?: boolean;
/**
*
* @default false
*/
disabled?: boolean;
/**
*
* @default false
*/
focus?: boolean;
/**
*
* @default ''
*/
label?: string;
/**
*
*/
leftIcon?: React.ReactNode;
/**
*
* @default ''
*/
placeholder?: string;
/**
*
*/
rightIcon?: React.ReactNode;
/**
*
* @default 'square'
*/
shape?: 'square' | 'round';
/**
*
* @default ''
*/
value?: string;
/**
*
* @default ''
*/
defaultValue?: string;
/**
*
* @default ''
*/
onActionClick?: (e?: React.MouseEvent<HTMLButtonElement> | React.MouseEvent<HTMLElement, MouseEvent>) => void;
/**
*
* @default ''
*/
onBlur?: (value: string, e?: React.FocusEvent<HTMLDivElement>) => void;
/**
*
* @default ''
*/
onChange?: (value: string, e?: React.FormEvent<HTMLDivElement> | React.MouseEvent<HTMLDivElement>) => void;
/**
*
* @default ''
*/
onClear?: (e: React.MouseEvent<SVGSVGElement>) => void;
/**
*
* @default ''
*/
onFocus?: (value: string, e?: React.FocusEvent<HTMLDivElement>) => void;
/**
*
* @default ''
*/
onSubmit?: (value: string, e?: React.KeyboardEvent<HTMLDivElement> | React.FocusEvent<HTMLInputElement, Element>) => void;
style?: React.CSSProperties;
className?: string;
onClick?: (e?: React.MouseEvent<HTMLDivElement>) => void;
};
declare const Search: (props: SearchProps) => JSX.Element;
export default Search;

View File

@ -0,0 +1,55 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var jsx_runtime_1 = require("react/jsx-runtime");
var react_1 = require("react");
var tdesign_icons_react_1 = require("tdesign-icons-react");
var tdesign_react_1 = require("tdesign-react");
require("./index.less");
var Search = function (props) {
var _a = props.className, className = _a === void 0 ? '' : _a, _b = props.style, style = _b === void 0 ? {} : _b, _c = props.action, action = _c === void 0 ? '' : _c, center = props.center, disabled = props.disabled, focus = props.focus, label = props.label, leftIcon = props.leftIcon, placeholder = props.placeholder, rightIcon = props.rightIcon, _d = props.shape, shape = _d === void 0 ? 'square' : _d, _e = props.value, value = _e === void 0 ? '' : _e, onActionClick = props.onActionClick, onBlur = props.onBlur, onChange = props.onChange, onClear = props.onClear, onFocus = props.onFocus, onSubmit = props.onSubmit, onClick = props.onClick;
var prefixCls = 'oak';
var inputRef = (0, react_1.useRef)(null);
var _f = tslib_1.__read((0, react_1.useState)(focus), 2), focusState = _f[0], setFocus = _f[1];
function handleBlur(e) {
var _a;
setFocus(false);
(_a = inputRef === null || inputRef === void 0 ? void 0 : inputRef.current) === null || _a === void 0 ? void 0 : _a.blur();
var value = e.currentTarget.value;
onBlur && onBlur(value, e);
}
function handleClear(e) {
onClear && onClear(e);
onChange && onChange('');
}
function handleAction(e) {
onActionClick && onActionClick(e);
}
function handleChange(e) {
var value = e.currentTarget.value;
onChange && onChange(value, e);
}
function handleFocus(e) {
var value = e.currentTarget.value;
onFocus && onFocus(value, e);
}
function handleSubmit(e) {
var value = e.currentTarget.value;
onSubmit && onSubmit(value, e);
}
function handleClick() {
var _a;
(_a = inputRef === null || inputRef === void 0 ? void 0 : inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
setFocus(true);
}
var shapeStyle = { borderRadius: shape === 'square' ? 'none' : '50px' };
return ((0, jsx_runtime_1.jsxs)("div", tslib_1.__assign({ className: "".concat(prefixCls, "-search ").concat(focusState ? "".concat(prefixCls, "-search-is-focused") : '', " ").concat(className), style: tslib_1.__assign({}, style), onClick: onClick }, { children: [label && ((0, jsx_runtime_1.jsx)("div", tslib_1.__assign({ className: "".concat(prefixCls, "-search__label-text"), style: {
marginLeft: '0px',
paddingRight: '8px',
color: 'rgba(0,0,0,0.9)',
whiteSpace: 'nowrap',
} }, { children: label }))), (0, jsx_runtime_1.jsxs)("div", tslib_1.__assign({ className: "".concat(prefixCls, "-search__form"), style: tslib_1.__assign({}, shapeStyle) }, { children: [(0, jsx_runtime_1.jsxs)("div", tslib_1.__assign({ className: "".concat(prefixCls, "-search__box") }, { children: [(0, jsx_runtime_1.jsx)("div", tslib_1.__assign({ className: "".concat(prefixCls, "-search__icon-search") }, { children: leftIcon })), (0, jsx_runtime_1.jsx)("input", { style: { textAlign: center ? 'center' : 'unset' }, ref: inputRef, type: "text", autoFocus: focusState, disabled: disabled, value: value, placeholder: placeholder, className: "".concat(prefixCls, "-search__input"), onBlur: handleBlur, onChange: handleChange,
// onFocus={handleFocus}
onSubmit: handleSubmit }), (0, jsx_runtime_1.jsxs)("div", tslib_1.__assign({ className: "".concat(prefixCls, "-search__icon-close") }, { children: [value.length > 0 && ((0, jsx_runtime_1.jsx)(tdesign_icons_react_1.CloseCircleFilledIcon, { onClick: handleClear })), rightIcon] }))] })), (0, jsx_runtime_1.jsxs)("label", tslib_1.__assign({ className: "".concat(prefixCls, "-search__label"), style: tslib_1.__assign({}, shapeStyle), onClick: handleClick }, { children: [(0, jsx_runtime_1.jsx)("div", tslib_1.__assign({ className: "".concat(prefixCls, "-search__label-icon-search") }, { children: leftIcon })), (0, jsx_runtime_1.jsx)("span", tslib_1.__assign({ className: "".concat(prefixCls, "-search__label-text") }, { children: placeholder }))] }))] })), focusState && action && ((0, jsx_runtime_1.jsx)(tdesign_react_1.Button, tslib_1.__assign({ className: "".concat(prefixCls, "-search__cancel-button"), variant: "text", theme: "primary", onClick: handleAction }, { children: action })))] })));
};
exports.default = Search;

22
lib/components/common/tabBar/index.d.ts vendored Normal file
View File

@ -0,0 +1,22 @@
import React from 'react';
import './index.less';
declare type Item = {
value: string;
icon: React.ReactNode;
text: React.ReactNode;
count?: number;
};
declare type TabBarProps = {
style?: React.CSSProperties;
className?: string;
iconClassName?: string;
textClassName?: string;
children?: React.ReactNode;
list: Array<Item>;
onChange?: (value: string, event?: React.MouseEvent<HTMLDivElement, MouseEvent>) => void;
fixed?: boolean;
bordered?: boolean;
value?: string;
};
declare const _default: React.MemoExoticComponent<(props: TabBarProps) => JSX.Element>;
export default _default;

View File

@ -0,0 +1,25 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var jsx_runtime_1 = require("react/jsx-runtime");
var react_1 = require("react");
var classnames_1 = tslib_1.__importDefault(require("classnames"));
require("./index.less");
var prefixCls = 'oak';
exports.default = (0, react_1.memo)(function (props) {
var _a;
var style = props.style, className = props.className, list = props.list, onChange = props.onChange, iconClassName = props.iconClassName, textClassName = props.textClassName, _b = props.fixed, fixed = _b === void 0 ? true : _b, _c = props.bordered, bordered = _c === void 0 ? false : _c, _d = props.value, value = _d === void 0 ? '' : _d;
var length = list === null || list === void 0 ? void 0 : list.length;
return ((0, jsx_runtime_1.jsx)("div", tslib_1.__assign({ className: (0, classnames_1.default)("".concat(prefixCls, "-tabBar"), (_a = {},
_a["".concat(prefixCls, "-tabBar--fixed")] = fixed,
_a["".concat(prefixCls, "-tabBar--bordered")] = bordered,
_a)) }, { children: list === null || list === void 0 ? void 0 : list.map(function (ele, index) {
var _a;
return ((0, jsx_runtime_1.jsxs)("div", tslib_1.__assign({ className: (0, classnames_1.default)(className, "".concat(prefixCls, "-tabBar-item"), (_a = {},
_a["".concat(prefixCls, "-tabBar-item-column-").concat(length)] = length,
_a["".concat(prefixCls, "-tabBar-item-checked")] = value === ele.value,
_a)), style: style, onClick: onChange
? function (event) { return onChange(ele.value, event); }
: undefined }, { children: [(0, jsx_runtime_1.jsx)("div", tslib_1.__assign({ className: (0, classnames_1.default)("".concat(prefixCls, "-tabBar-item-icon"), iconClassName) }, { children: typeof ele.icon === 'string' ? ((0, jsx_runtime_1.jsx)("img", { className: (0, classnames_1.default)("".concat(prefixCls, "-tabBar-item-image"), iconClassName), src: ele.icon })) : (ele.icon) })), (0, jsx_runtime_1.jsx)("div", tslib_1.__assign({ className: (0, classnames_1.default)("".concat(prefixCls, "-tabBar-item-text"), textClassName) }, { children: ele.text }))] }), index));
}) })));
});

View File

@ -0,0 +1,23 @@
import React from 'react';
import './index.less';
declare type HTMLHeadingElement = 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
declare type TypographyProps = {
theme?: 'default' | 'secondary' | 'primary' | 'danger' | 'warning' | 'success' | 'placeholder' | 'disabled' | 'brand' | 'anti' | 'link';
size?: 'small' | 'medium' | 'large';
variant?: 'link' | 'mark' | 'body' | 'title' | 'headline' | 'display' | HTMLHeadingElement;
children?: React.ReactNode;
italic?: boolean;
strong?: boolean;
disabled?: boolean;
underline?: boolean;
delete?: boolean;
code?: boolean;
keyboard?: boolean;
mark?: boolean;
link?: boolean;
onClick?: (event: React.MouseEvent<HTMLSpanElement, MouseEvent>) => void;
style?: React.CSSProperties;
className?: string;
};
declare const _default: React.MemoExoticComponent<(props: TypographyProps) => JSX.Element>;
export default _default;

View File

@ -0,0 +1,30 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var jsx_runtime_1 = require("react/jsx-runtime");
var react_1 = require("react");
var classnames_1 = tslib_1.__importDefault(require("classnames"));
require("./index.less");
var headingElement = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'];
exports.default = (0, react_1.memo)(function (props) {
var _a;
var children = props.children, _b = props.size, size = _b === void 0 ? 'medium' : _b, _c = props.theme, theme = _c === void 0 ? 'default' : _c, _d = props.variant, variant = _d === void 0 ? 'title' : _d, _e = props.italic, italic = _e === void 0 ? false : _e, _f = props.strong, strong = _f === void 0 ? false : _f, _g = props.disabled, disabled = _g === void 0 ? false : _g, _h = props.underline, underline = _h === void 0 ? false : _h, _j = props.delete, delete2 = _j === void 0 ? false : _j, _k = props.code, code = _k === void 0 ? false : _k, _l = props.keyboard, keyboard = _l === void 0 ? false : _l, _m = props.mark, mark = _m === void 0 ? false : _m, _o = props.link, link = _o === void 0 ? false : _o, onClick = props.onClick, style = props.style, className = props.className;
var prefixCls = 'oak';
var isHeadingElement = headingElement.includes(variant);
var Component = isHeadingElement
? variant
: 'span';
return ((0, jsx_runtime_1.jsx)(Component, tslib_1.__assign({ style: style, onClick: !disabled ? onClick : undefined, className: (0, classnames_1.default)("".concat(prefixCls, "-typography"), className, (_a = {},
_a["".concat(prefixCls, "-typography-").concat(variant, "-").concat(size)] = !isHeadingElement,
_a["".concat(prefixCls, "-typography-color-").concat(theme)] = !disabled,
_a["".concat(prefixCls, "-typography-italic")] = italic,
_a["".concat(prefixCls, "-typography-underline")] = underline,
_a["".concat(prefixCls, "-typography-delete")] = delete2,
_a["".concat(prefixCls, "-typography-strong")] = strong,
_a["".concat(prefixCls, "-typography-keyboard")] = keyboard,
_a["".concat(prefixCls, "-typography-code")] = code,
_a["".concat(prefixCls, "-typography-mark")] = mark,
_a["".concat(prefixCls, "-typography-link")] = link,
_a["".concat(prefixCls, "-typography-disabled")] = disabled,
_a)) }, { children: children })));
});

View File

@ -0,0 +1,7 @@
/// <reference types="react" />
import { Config } from '../../../../types/Config';
export default function Account(props: {
account: Required<Config>['Account'];
setValue: (path: string, value: any) => void;
removeItem: (path: string, index: number) => void;
}): JSX.Element;

View File

@ -0,0 +1,33 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var jsx_runtime_1 = require("react/jsx-runtime");
var tdesign_react_1 = require("tdesign-react");
var web_module_less_1 = tslib_1.__importDefault(require("./web.module.less"));
var FormItem = tdesign_react_1.Form.FormItem;
var TabPanel = tdesign_react_1.Tabs.TabPanel;
function TencentAccount(props) {
var accounts = props.accounts, setValue = props.setValue, removeItem = props.removeItem;
return ((0, jsx_runtime_1.jsxs)(tdesign_react_1.Col, tslib_1.__assign({ align: "stretch" }, { children: [(0, jsx_runtime_1.jsx)(tdesign_react_1.Divider, tslib_1.__assign({ align: "left", className: web_module_less_1.default.title }, { children: "\u817E\u8BAF\u4E91\u914D\u7F6E" })), (0, jsx_runtime_1.jsx)(tdesign_react_1.Tabs, tslib_1.__assign({ placement: 'top', size: 'medium', disabled: false, theme: "normal", addable: accounts.length > 0 }, { children: accounts.length > 0 ? accounts.map(function (ele, idx) {
console.log(ele);
return ((0, jsx_runtime_1.jsx)(TabPanel, tslib_1.__assign({ value: idx, label: "\u5E10\u53F7".concat(idx + 1), removable: true, onRemove: function () { return removeItem('', idx); } }, { children: (0, jsx_runtime_1.jsxs)(tdesign_react_1.Form, tslib_1.__assign({ colon: false, labelAlign: "left", labelWidth: "100px", layout: "vertical", preventSubmitDefault: true, resetType: "empty", showErrorMessage: true, submitWithWarningMessage: false, style: { marginTop: 10 } }, { children: [(0, jsx_runtime_1.jsx)(FormItem, tslib_1.__assign({ label: "secretId", name: "secretId", successBorder: false }, { children: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsx)(tdesign_react_1.Input, { align: "left", autoWidth: false, autofocus: false, clearable: false, placeholder: "\u8BF7\u8F93\u5165secretId", readonly: false, showClearIconOnEmpty: false, size: "medium", status: "default", type: "text", value: ele.secretId, onChange: function (value) { return setValue("".concat(idx, ".secretId"), value); } }) }) })), (0, jsx_runtime_1.jsx)(FormItem, tslib_1.__assign({ label: "secretKey", name: "secretKey", successBorder: false }, { children: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsx)(tdesign_react_1.Input, { align: "left", autoWidth: false, autofocus: false, clearable: false, placeholder: "\u8BF7\u8F93\u5165secretKey", readonly: false, showClearIconOnEmpty: false, size: "medium", status: "default", type: "text", value: ele.secretKey, onChange: function (value) { return setValue("".concat(idx, ".secretKey"), value); } }) }) })), (0, jsx_runtime_1.jsx)(FormItem, tslib_1.__assign({ label: "region", name: "region", successBorder: false }, { children: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsx)(tdesign_react_1.Input, { align: "left", autoWidth: false, autofocus: false, clearable: false, placeholder: "\u8BF7\u8F93\u5165region", readonly: false, showClearIconOnEmpty: false, size: "medium", status: "default", type: "text", value: ele.region, onChange: function (value) { return setValue("".concat(idx, ".region"), value); } }) }) }))] })) }), idx));
}) : ((0, jsx_runtime_1.jsx)(TabPanel, tslib_1.__assign({ value: 0, label: "\u65B0\u5EFA\u5E10\u53F7" }, { children: (0, jsx_runtime_1.jsxs)(tdesign_react_1.Form, tslib_1.__assign({ colon: true, labelAlign: "left", labelWidth: "100px", layout: "vertical", style: { marginTop: 10 } }, { children: [(0, jsx_runtime_1.jsx)(FormItem, tslib_1.__assign({ label: "secretId", name: "secretId", successBorder: false }, { children: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsx)(tdesign_react_1.Input, { align: "left", autoWidth: false, autofocus: false, clearable: false, placeholder: "\u8BF7\u8F93\u5165secretId", readonly: false, showClearIconOnEmpty: false, size: "medium", status: "default", type: "text", value: "", onChange: function (value) { return setValue("0.secretId", value); } }) }) })), (0, jsx_runtime_1.jsx)(FormItem, tslib_1.__assign({ label: "secretKey", name: "secretKey", successBorder: false }, { children: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsx)(tdesign_react_1.Input, { align: "left", autoWidth: false, autofocus: false, clearable: false, placeholder: "\u8BF7\u8F93\u5165secretKey", readonly: false, showClearIconOnEmpty: false, size: "medium", status: "default", type: "text", value: "", onChange: function (value) { return setValue("0.secretKey", value); } }) }) })), (0, jsx_runtime_1.jsx)(FormItem, tslib_1.__assign({ label: "region", name: "region", successBorder: false }, { children: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsx)(tdesign_react_1.Input, { align: "left", autoWidth: false, autofocus: false, clearable: false, placeholder: "\u8BF7\u8F93\u5165region", readonly: false, showClearIconOnEmpty: false, size: "medium", status: "default", type: "text", value: "", onChange: function (value) { return setValue("0.region", value); } }) }) }))] })) }), 0)) }))] })));
}
function QiniuAccount(props) {
var accounts = props.accounts, setValue = props.setValue, removeItem = props.removeItem;
return ((0, jsx_runtime_1.jsxs)(tdesign_react_1.Col, tslib_1.__assign({ align: "stretch" }, { children: [(0, jsx_runtime_1.jsx)(tdesign_react_1.Divider, tslib_1.__assign({ align: "left", className: web_module_less_1.default.title }, { children: "\u4E03\u725B\u4E91\u914D\u7F6E" })), (0, jsx_runtime_1.jsx)(tdesign_react_1.Tabs, tslib_1.__assign({ placement: 'top', size: 'medium', disabled: false, theme: "normal", addable: accounts.length > 0 }, { children: accounts.length > 0 ? accounts.map(function (ele, idx) { return ((0, jsx_runtime_1.jsx)(TabPanel, tslib_1.__assign({ value: idx, label: "\u5E10\u53F7".concat(idx + 1), removable: true, onRemove: function () { return removeItem('', idx); } }, { children: (0, jsx_runtime_1.jsxs)(tdesign_react_1.Form, tslib_1.__assign({ colon: false, labelAlign: "left", labelWidth: "100px", layout: "vertical", preventSubmitDefault: true, resetType: "empty", showErrorMessage: true, submitWithWarningMessage: false, style: { marginTop: 10 } }, { children: [(0, jsx_runtime_1.jsx)(FormItem, tslib_1.__assign({ label: "accessKey", name: "accessKey", successBorder: false }, { children: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsx)(tdesign_react_1.Input, { align: "left", autoWidth: false, autofocus: false, clearable: false, placeholder: "\u8BF7\u8F93\u5165accessKey", readonly: false, showClearIconOnEmpty: false, size: "medium", status: "default", type: "text", value: ele.accessKey, onChange: function (value) { return setValue("".concat(idx, ".accessKey"), value); } }) }) })), (0, jsx_runtime_1.jsx)(FormItem, tslib_1.__assign({ label: "secretKey", name: "secretKey", successBorder: false }, { children: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsx)(tdesign_react_1.Input, { align: "left", autoWidth: false, autofocus: false, clearable: false, placeholder: "\u8BF7\u8F93\u5165secretKey", readonly: false, showClearIconOnEmpty: false, size: "medium", status: "default", type: "text", value: ele.secretKey, onChange: function (value) { return setValue("".concat(idx, ".secretKey"), value); } }) }) }))] })) }), idx)); }) : ((0, jsx_runtime_1.jsx)(TabPanel, tslib_1.__assign({ value: 0, label: "\u65B0\u5EFA\u5E10\u53F7" }, { children: (0, jsx_runtime_1.jsxs)(tdesign_react_1.Form, tslib_1.__assign({ colon: true, labelAlign: "left", labelWidth: "100px", layout: "vertical", style: { marginTop: 10 } }, { children: [(0, jsx_runtime_1.jsx)(FormItem, tslib_1.__assign({ label: "accessKey", name: "accessKey", successBorder: false }, { children: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsx)(tdesign_react_1.Input, { align: "left", autoWidth: false, autofocus: false, clearable: false, placeholder: "\u8BF7\u8F93\u5165accessKey", readonly: false, showClearIconOnEmpty: false, size: "medium", status: "default", type: "text", value: "", onChange: function (value) { return setValue("0.accessKey", value); } }) }) })), (0, jsx_runtime_1.jsx)(FormItem, tslib_1.__assign({ label: "secretKey", name: "secretKey", successBorder: false }, { children: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsx)(tdesign_react_1.Input, { align: "left", autoWidth: false, autofocus: false, clearable: false, placeholder: "\u8BF7\u8F93\u5165secretKey", readonly: false, showClearIconOnEmpty: false, size: "medium", status: "default", type: "text", value: "", onChange: function (value) { return setValue("0.secretKey", value); } }) }) }))] })) }), 0)) }))] })));
}
function AliAccount(props) {
var accounts = props.accounts, setValue = props.setValue, removeItem = props.removeItem;
return ((0, jsx_runtime_1.jsxs)(tdesign_react_1.Col, tslib_1.__assign({ align: "stretch" }, { children: [(0, jsx_runtime_1.jsx)(tdesign_react_1.Divider, tslib_1.__assign({ align: "left", className: web_module_less_1.default.title }, { children: "\u963F\u91CC\u4E91\u914D\u7F6E" })), (0, jsx_runtime_1.jsx)(tdesign_react_1.Tabs, tslib_1.__assign({ placement: 'top', size: 'medium', disabled: false, theme: "normal", addable: accounts.length > 0 }, { children: accounts.length > 0 ? accounts.map(function (ele, idx) { return ((0, jsx_runtime_1.jsx)(TabPanel, tslib_1.__assign({ value: idx, label: "\u5E10\u53F7".concat(idx + 1), removable: true, onRemove: function () { return removeItem('', idx); } }, { children: (0, jsx_runtime_1.jsxs)(tdesign_react_1.Form, tslib_1.__assign({ colon: false, labelAlign: "left", labelWidth: "100px", layout: "vertical", preventSubmitDefault: true, resetType: "empty", showErrorMessage: true, submitWithWarningMessage: false, style: { marginTop: 10 } }, { children: [(0, jsx_runtime_1.jsx)(FormItem, tslib_1.__assign({ label: "accessKeyId", name: "accessKeyId", successBorder: false }, { children: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsx)(tdesign_react_1.Input, { align: "left", autoWidth: false, autofocus: false, clearable: false, placeholder: "\u8BF7\u8F93\u5165accessKeyId", readonly: false, showClearIconOnEmpty: false, size: "medium", status: "default", type: "text", value: ele.accessKeyId, onChange: function (value) { return setValue("".concat(idx, ".accessKeyId"), value); } }) }) })), (0, jsx_runtime_1.jsx)(FormItem, tslib_1.__assign({ label: "accessKeySecret", name: "accessKeySecret", successBorder: false }, { children: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsx)(tdesign_react_1.Input, { align: "left", autoWidth: false, autofocus: false, clearable: false, placeholder: "\u8BF7\u8F93\u5165accessKeySecret", readonly: false, showClearIconOnEmpty: false, size: "medium", status: "default", type: "text", value: ele.accessKeySecret, onChange: function (value) { return setValue("".concat(idx, ".accessKeySecret"), value); } }) }) })), (0, jsx_runtime_1.jsx)(FormItem, tslib_1.__assign({ label: "regionId", name: "regionId", successBorder: false }, { children: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsx)(tdesign_react_1.Input, { align: "left", autoWidth: false, autofocus: false, clearable: false, placeholder: "\u8BF7\u8F93\u5165regionId", readonly: false, showClearIconOnEmpty: false, size: "medium", status: "default", type: "text", value: ele.regionId, onChange: function (value) { return setValue("".concat(idx, ".regionId"), value); } }) }) }))] })) }), idx)); }) : ((0, jsx_runtime_1.jsx)(TabPanel, tslib_1.__assign({ value: 0, label: "\u65B0\u5EFA\u5E10\u53F7" }, { children: (0, jsx_runtime_1.jsxs)(tdesign_react_1.Form, tslib_1.__assign({ colon: true, labelAlign: "left", labelWidth: "100px", layout: "vertical", style: { marginTop: 10 } }, { children: [(0, jsx_runtime_1.jsx)(FormItem, tslib_1.__assign({ label: "accessKeyId", name: "accessKeyId", successBorder: false }, { children: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsx)(tdesign_react_1.Input, { align: "left", autoWidth: false, autofocus: false, clearable: false, placeholder: "\u8BF7\u8F93\u5165accessKeyId", readonly: false, showClearIconOnEmpty: false, size: "medium", status: "default", type: "text", value: "", onChange: function (value) { return setValue("0.accessKeyId", value); } }) }) })), (0, jsx_runtime_1.jsx)(FormItem, tslib_1.__assign({ label: "accessKeySecret", name: "accessKeySecret", successBorder: false }, { children: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsx)(tdesign_react_1.Input, { align: "left", autoWidth: false, autofocus: false, clearable: false, placeholder: "\u8BF7\u8F93\u5165accessKeySecret", readonly: false, showClearIconOnEmpty: false, size: "medium", status: "default", type: "text", value: "", onChange: function (value) { return setValue("0.accessKeySecret", value); } }) }) })), (0, jsx_runtime_1.jsx)(FormItem, tslib_1.__assign({ label: "regionId", name: "regionId", successBorder: false }, { children: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsx)(tdesign_react_1.Input, { align: "left", autoWidth: false, autofocus: false, clearable: false, placeholder: "\u8BF7\u8F93\u5165regionId", readonly: false, showClearIconOnEmpty: false, size: "medium", status: "default", type: "text", value: "", onChange: function (value) { return setValue("0.regionId", value); } }) }) }))] })) }), 0)) }))] })));
}
function AmapAccount(props) {
var accounts = props.accounts, setValue = props.setValue, removeItem = props.removeItem;
return ((0, jsx_runtime_1.jsxs)(tdesign_react_1.Col, tslib_1.__assign({ align: "stretch" }, { children: [(0, jsx_runtime_1.jsx)(tdesign_react_1.Divider, tslib_1.__assign({ align: "left", className: web_module_less_1.default.title }, { children: "\u9AD8\u5FB7\u4E91\u914D\u7F6E" })), (0, jsx_runtime_1.jsx)(tdesign_react_1.Tabs, tslib_1.__assign({ placement: 'top', size: 'medium', disabled: false, theme: "normal", addable: accounts.length > 0 }, { children: accounts.length > 0 ? accounts.map(function (ele, idx) { return ((0, jsx_runtime_1.jsx)(TabPanel, tslib_1.__assign({ value: idx, label: "\u5E10\u53F7".concat(idx + 1), removable: true, onRemove: function () { return removeItem('', idx); } }, { children: (0, jsx_runtime_1.jsx)(tdesign_react_1.Form, tslib_1.__assign({ colon: false, labelAlign: "left", labelWidth: "100px", layout: "vertical", preventSubmitDefault: true, resetType: "empty", showErrorMessage: true, submitWithWarningMessage: false, style: { marginTop: 10 } }, { children: (0, jsx_runtime_1.jsx)(FormItem, tslib_1.__assign({ label: "webApiKey", name: "webApiKey", successBorder: false }, { children: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsx)(tdesign_react_1.Input, { align: "left", autoWidth: false, autofocus: false, clearable: false, placeholder: "\u8BF7\u8F93\u5165webApiKey", readonly: false, showClearIconOnEmpty: false, size: "medium", status: "default", type: "text", value: ele.webApiKey, onChange: function (value) { return setValue("".concat(idx, ".webApiKey"), value); } }) }) })) })) }), idx)); }) : ((0, jsx_runtime_1.jsx)(TabPanel, tslib_1.__assign({ value: 0, label: "\u65B0\u5EFA\u5E10\u53F7" }, { children: (0, jsx_runtime_1.jsx)(tdesign_react_1.Form, tslib_1.__assign({ colon: true, labelAlign: "left", labelWidth: "100px", layout: "vertical", style: { marginTop: 10 } }, { children: (0, jsx_runtime_1.jsx)(FormItem, tslib_1.__assign({ label: "webApiKey", name: "webApiKey", successBorder: false }, { children: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsx)(tdesign_react_1.Input, { align: "left", autoWidth: false, autofocus: false, clearable: false, placeholder: "\u8BF7\u8F93\u5165webApiKey", readonly: false, showClearIconOnEmpty: false, size: "medium", status: "default", type: "text", value: "", onChange: function (value) { return setValue("0.webApiKey", value); } }) }) })) })) }), 0)) }))] })));
}
function Account(props) {
var account = props.account, setValue = props.setValue, removeItem = props.removeItem;
var tencent = account.tencent, qiniu = account.qiniu, ali = account.ali, amap = account.amap;
return ((0, jsx_runtime_1.jsxs)(tdesign_react_1.Col, { children: [(0, jsx_runtime_1.jsx)(tdesign_react_1.Row, { children: (0, jsx_runtime_1.jsx)(tdesign_react_1.Card, tslib_1.__assign({ className: web_module_less_1.default.tips }, { children: "\u6BCF\u79CD\u4E91\u5382\u5546\u5747\u53EF\u914D\u7F6E\u591A\u4E2A\u5E10\u53F7\uFF0C\u76F8\u5E94\u7684\u670D\u52A1\u6240\u4F7F\u7528\u7684\u5E10\u53F7\u8BF7\u51C6\u786E\u5BF9\u5E94" })) }), (0, jsx_runtime_1.jsx)(TencentAccount, { accounts: tencent || [], setValue: function (path, value) { return setValue("tencent.".concat(path), value); }, removeItem: function (path, index) { return removeItem("tencent", index); } }), (0, jsx_runtime_1.jsx)(QiniuAccount, { accounts: qiniu || [], setValue: function (path, value) { return setValue("qiniu.".concat(path), value); }, removeItem: function (path, index) { return removeItem("qiniu", index); } }), (0, jsx_runtime_1.jsx)(AliAccount, { accounts: ali || [], setValue: function (path, value) { return setValue("ali.".concat(path), value); }, removeItem: function (path, index) { return removeItem("ali", index); } }), (0, jsx_runtime_1.jsx)(AmapAccount, { accounts: amap || [], setValue: function (path, value) { return setValue("amap.".concat(path), value); }, removeItem: function (path, index) { return removeItem("amap", index); } })] }));
}
exports.default = Account;

View File

@ -0,0 +1,3 @@
/// <reference types="react" />
declare const _default: import("react").ComponentType<any>;
export default _default;

View File

@ -0,0 +1,75 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var lodash_1 = require("oak-domain/lib/utils/lodash");
exports.default = OakComponent({
isList: false,
properties: {
config: Object,
entity: String,
name: String,
entityId: String,
},
data: {
initialConfig: {},
dirty: false,
currentConfig: {},
},
observers: {
config: function (config) {
this.setState({
initialConfig: config,
dirty: false,
currentConfig: (0, lodash_1.cloneDeep)(config),
});
}
},
methods: {
setValue: function (path, value) {
var currentConfig = this.state.currentConfig;
var newConfig = (0, lodash_1.cloneDeep)(currentConfig);
(0, lodash_1.set)(newConfig, path, value);
this.setState({
currentConfig: newConfig,
dirty: true,
});
},
removeItem: function (path, index) {
var currentConfig = this.state.currentConfig;
var array = (0, lodash_1.get)(currentConfig, path);
array.splice(index, 1);
var newConfig = (0, lodash_1.cloneDeep)(currentConfig);
this.setState({
currentConfig: newConfig,
dirty: true,
});
},
resetConfig: function () {
var initialConfig = this.state.initialConfig;
this.setState({
dirty: false,
currentConfig: (0, lodash_1.cloneDeep)(initialConfig),
});
},
updateConfig: function () {
return tslib_1.__awaiter(this, void 0, void 0, function () {
var currentConfig, _a, entity, entityId;
return tslib_1.__generator(this, function (_b) {
switch (_b.label) {
case 0:
currentConfig = this.state.currentConfig;
_a = this.props, entity = _a.entity, entityId = _a.entityId;
return [4 /*yield*/, this.features.config.updateConfig(entity, entityId, currentConfig)];
case 1:
_b.sent();
this.setMessage({
content: '操作成功',
type: 'success',
});
return [2 /*return*/];
}
});
});
}
},
});

View File

@ -0,0 +1,2 @@
/// <reference types="react" />
export default function render(this: any): JSX.Element;

View File

@ -0,0 +1,20 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var jsx_runtime_1 = require("react/jsx-runtime");
var tdesign_react_1 = require("tdesign-react");
var TabPanel = tdesign_react_1.Tabs.TabPanel;
var web_module_less_1 = tslib_1.__importDefault(require("./web.module.less"));
var index_1 = tslib_1.__importDefault(require("./account/index"));
function render() {
var _this = this;
var _a = this.props, entity = _a.entity, name = _a.name;
var _b = this.state, currentConfig = _b.currentConfig, dirty = _b.dirty;
var account = currentConfig.Account;
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { className: web_module_less_1.default.padding }), (0, jsx_runtime_1.jsxs)("div", tslib_1.__assign({ className: web_module_less_1.default.ctrl }, { children: [(0, jsx_runtime_1.jsxs)("text", { children: ["\u60A8\u6B63\u5728\u66F4\u65B0", (0, jsx_runtime_1.jsx)("text", tslib_1.__assign({ className: web_module_less_1.default.weight }, { children: entity })), "\u5BF9\u8C61", (0, jsx_runtime_1.jsx)("text", tslib_1.__assign({ className: web_module_less_1.default.weight }, { children: name })), "\u7684\u914D\u7F6E\uFF0C\u8BF7\u8C28\u614E\u64CD\u4F5C"] }), (0, jsx_runtime_1.jsxs)("span", { children: [(0, jsx_runtime_1.jsx)(tdesign_react_1.Button, tslib_1.__assign({ disabled: !dirty, theme: "primary", onClick: function () { return _this.resetConfig(); }, style: {
marginRight: 10,
} }, { children: "\u91CD\u7F6E" })), (0, jsx_runtime_1.jsx)(tdesign_react_1.Button, tslib_1.__assign({ disabled: !dirty, theme: "danger", onClick: function () { return _this.updateConfig(); } }, { children: "\u786E\u5B9A" }))] })] })), (0, jsx_runtime_1.jsx)("div", tslib_1.__assign({ className: web_module_less_1.default.container }, { children: (0, jsx_runtime_1.jsx)(tdesign_react_1.Tabs, tslib_1.__assign({ placement: 'left' }, { children: (0, jsx_runtime_1.jsx)(TabPanel, tslib_1.__assign({ label: "\u4E91\u5E73\u53F0\u5E10\u53F7", style: {
marginLeft: 20,
} }, { children: (0, jsx_runtime_1.jsx)(index_1.default, { account: account || {}, setValue: function (path, value) { return _this.setValue("Account.".concat(path), value); }, removeItem: function (path, index) { return _this.removeItem("Account.".concat(path), index); } }) })) })) }))] }));
}
exports.default = render;

View File

@ -0,0 +1 @@
export {};

View File

@ -0,0 +1,35 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var mockId_1 = require("oak-frontend-base/lib/utils/mockId");
var extraFile_1 = require("../../../utils/extraFile");
OakComponent({
entity: 'extraFile',
isList: false,
formData: function (_a) {
var extraFile = _a.data, features = _a.features;
return tslib_1.__awaiter(void 0, void 0, void 0, function () {
var application, isTmp;
var _b;
return tslib_1.__generator(this, function (_c) {
switch (_c.label) {
case 0: return [4 /*yield*/, features.application.getApplication()];
case 1:
application = _c.sent();
isTmp = (extraFile === null || extraFile === void 0 ? void 0 : extraFile.id) && (0, mockId_1.isMockId)(extraFile.id);
return [2 /*return*/, {
src: extraFile && (0, extraFile_1.composeFileUrl)(extraFile, (_b = application === null || application === void 0 ? void 0 : application.system) === null || _b === void 0 ? void 0 : _b.config),
isTmp: isTmp,
}];
}
});
});
},
properties: {
// 图片显示模式
mode: {
type: String,
value: 'aspectFit',
},
},
});

View File

@ -0,0 +1 @@
{}

View File

@ -0,0 +1,2 @@
/// <reference types="react" />
export default function render(): JSX.Element;

View File

@ -0,0 +1,7 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var jsx_runtime_1 = require("react/jsx-runtime");
function render() {
return ((0, jsx_runtime_1.jsx)("div", { children: "react" }));
}
exports.default = render;

View File

@ -0,0 +1,3 @@
/// <reference types="react" />
declare const _default: import("react").ComponentType<any>;
export default _default;

View File

@ -0,0 +1,538 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var assert_1 = tslib_1.__importDefault(require("assert"));
var index_1 = tslib_1.__importDefault(require("../../../utils/dialog/index"));
var extraFile_1 = require("../../../utils/extraFile");
exports.default = OakComponent({
entity: 'extraFile',
isList: true,
projection: {
id: 1,
tag1: 1,
origin: 1,
bucket: 1,
objectId: 1,
filename: 1,
extra1: 1,
extension: 1,
type: 1,
entity: 1,
},
formData: function (_a) {
var _b, _c;
var originalFiles = _a.data, features = _a.features;
return tslib_1.__awaiter(this, void 0, void 0, function () {
var application, number2, files;
var _this = this;
return tslib_1.__generator(this, function (_d) {
switch (_d.label) {
case 0: return [4 /*yield*/, features.application.getApplication()];
case 1:
application = _d.sent();
number2 = this.props.maxNumber;
files = originalFiles;
if (this.props.tag1) {
files = files === null || files === void 0 ? void 0 : files.filter(function (ele) { return (ele === null || ele === void 0 ? void 0 : ele.tag1) === _this.props.tag1; });
}
if (this.props.tag2) {
files = files === null || files === void 0 ? void 0 : files.filter(function (ele) { return (ele === null || ele === void 0 ? void 0 : ele.tag2) === _this.props.tag2; });
}
if (typeof number2 === 'number' &&
(number2 === 0 || (files === null || files === void 0 ? void 0 : files.length) >= number2)) {
return [2 /*return*/, {
files: files,
disableInsert: true,
systemConfig: (_b = application === null || application === void 0 ? void 0 : application.system) === null || _b === void 0 ? void 0 : _b.config,
originalFiles: originalFiles,
}];
}
return [2 /*return*/, {
files: files,
disableInsert: false,
systemConfig: (_c = application === null || application === void 0 ? void 0 : application.system) === null || _c === void 0 ? void 0 : _c.config,
originalFiles: originalFiles,
}];
}
});
});
},
data: {
selected: -1,
// 根据 size 不同,计算的图片显示大小不同
itemSizePercentage: '',
newUploadFiles: [],
},
wechatMp: {
externalClasses: ['l-class', 'l-item-class'],
},
properties: {
oakFullpath: String,
oakParent: String,
oakPath: String,
autoUpload: {
type: Boolean,
value: false,
},
maxNumber: {
type: Number,
value: 20,
},
selectCount: {
//小程序独有 文件一次选择几个
type: Number,
value: 1,
},
sourceType: {
type: Array,
value: ['album', 'camera'],
},
mediaType: {
//小程序独有 文件上传类型
type: Array,
value: ['image'],
},
accept: {
// web独有 文件上传类型
type: String,
value: 'image/*',
},
// 图片显示模式
mode: {
type: String,
value: 'aspectFit',
},
// 图片是否可预览
preview: {
type: Boolean,
value: true,
},
// 每行可显示的个数
size: {
type: Number,
value: 3,
},
// 图片是否可删除
disableDelete: {
type: Boolean,
value: false,
},
type: String,
origin: String,
tag1: String,
tag2: String,
entity: String,
entityId: String,
},
methods: {
/**
* 获取组件内部节点位置信息单个
* @param component 组件实例
* @param selector {String} css选择器
* @returns boundingClientRect() 回调函数的值
*/
getNodeRectFromComponent: function (component, selector) {
return tslib_1.__awaiter(this, void 0, void 0, function () {
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, new Promise(function (resolve) {
component
.createSelectorQuery()
.select(selector)
.boundingClientRect(function (res) {
resolve(res);
})
.exec();
})];
case 1: return [2 /*return*/, _a.sent()];
}
});
});
},
/**
// * px 转 rpx
// * @param px 像素值
// */
px2rpx: function (px) {
var windowWidth = wx.getSystemInfoSync().windowWidth;
return (750 / windowWidth) * px;
},
onPick: function () {
return tslib_1.__awaiter(this, void 0, void 0, function () {
var _a, selectCount, mediaType, sourceType, _b, errMsg, tempFiles, err_1;
var _this = this;
return tslib_1.__generator(this, function (_c) {
switch (_c.label) {
case 0:
_a = this.props, selectCount = _a.selectCount, mediaType = _a.mediaType, sourceType = _a.sourceType;
_c.label = 1;
case 1:
_c.trys.push([1, 6, , 7]);
return [4 /*yield*/, wx.chooseMedia({
count: selectCount,
mediaType: mediaType,
sourceType: sourceType,
})];
case 2:
_b = _c.sent(), errMsg = _b.errMsg, tempFiles = _b.tempFiles;
if (!(errMsg !== 'chooseMedia:ok')) return [3 /*break*/, 3];
this.triggerEvent('error', {
level: 'warning',
msg: errMsg,
});
return [3 /*break*/, 5];
case 3: return [4 /*yield*/, Promise.all(tempFiles.map(function (tempExtraFile) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
var tempFilePath, thumbTempFilePath, fileType, size, filePath, fileFullName;
return tslib_1.__generator(this, function (_a) {
tempFilePath = tempExtraFile.tempFilePath, thumbTempFilePath = tempExtraFile.thumbTempFilePath, fileType = tempExtraFile.fileType, size = tempExtraFile.size;
filePath = tempFilePath || thumbTempFilePath;
fileFullName = filePath.match(/[^/]+(?!.*\/)/g)[0];
this.pushExtraFile({
name: fileFullName,
fileType: fileType,
size: size,
extra1: filePath,
});
return [2 /*return*/];
});
}); }))];
case 4:
_c.sent();
_c.label = 5;
case 5: return [3 /*break*/, 7];
case 6:
err_1 = _c.sent();
console.error(err_1);
if (err_1.errMsg !== 'chooseMedia:fail cancel') {
this.triggerEvent('error', {
level: 'error',
msg: err_1.errMsg,
});
}
return [3 /*break*/, 7];
case 7: return [2 /*return*/];
}
});
});
},
onWebPick: function (uploadFiles, callback) {
return tslib_1.__awaiter(this, void 0, void 0, function () {
var _this = this;
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, Promise.all(uploadFiles.map(function (uploadFile) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
var name, fileType, size, raw;
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {
case 0:
name = uploadFile.name, fileType = uploadFile.type, size = uploadFile.size, raw = uploadFile.raw;
return [4 /*yield*/, this.pushExtraFile({
name: name,
fileType: fileType,
size: size,
extra1: raw,
}, callback)];
case 1:
_a.sent();
return [2 /*return*/];
}
});
}); }))];
case 1:
_a.sent();
return [2 /*return*/];
}
});
});
},
pushExtraFile: function (options, callback) {
return tslib_1.__awaiter(this, void 0, void 0, function () {
var _a, type, origin, tag1, tag2, entity, entityId, autoUpload, name, extra1, fileType, size, extension, filename, updateData, bucket, error_1;
var _b;
var _this = this;
return tslib_1.__generator(this, function (_c) {
switch (_c.label) {
case 0:
_a = this.props, type = _a.type, origin = _a.origin, tag1 = _a.tag1, tag2 = _a.tag2, entity = _a.entity, entityId = _a.entityId, autoUpload = _a.autoUpload;
name = options.name, extra1 = options.extra1, fileType = options.fileType, size = options.size;
extension = name.substring(name.lastIndexOf('.') + 1);
filename = name.substring(0, name.lastIndexOf('.'));
(0, assert_1.default)(entity, '必须传入entity');
(0, assert_1.default)(origin === 'qiniu', '目前只支持七牛上传'); // 目前只支持七牛上传
_b = {
extra1: extra1,
origin: origin,
type: type || 'file',
tag1: tag1,
tag2: tag2
};
return [4 /*yield*/, generateNewId()];
case 1:
_b.objectId = _c.sent(),
_b.entity = entity,
_b.filename = filename,
_b.size = size,
_b.extension = extension,
_b.fileType = fileType;
return [4 /*yield*/, generateNewId()];
case 2:
updateData = (_b.id = _c.sent(),
_b.entityId = entityId,
_b);
if (!autoUpload) return [3 /*break*/, 9];
if (callback) {
callback(updateData, 'uploading');
}
_c.label = 3;
case 3:
_c.trys.push([3, 5, , 6]);
return [4 /*yield*/, this.features.extraFile.upload(updateData)];
case 4:
bucket = (_c.sent()).bucket;
Object.assign(updateData, {
bucket: bucket,
extra1: null,
});
if (callback) {
callback(updateData, 'success');
}
return [3 /*break*/, 6];
case 5:
error_1 = _c.sent();
if (callback) {
callback(updateData, 'failed');
}
//todo 保存extraFile失败 需要remove七牛图片
throw error_1;
case 6: return [4 /*yield*/, this.addOperation({
action: 'create',
data: updateData
})];
case 7:
_c.sent();
return [4 /*yield*/, this.execute()];
case 8:
_c.sent();
return [3 /*break*/, 11];
case 9: return [4 /*yield*/, this.addOperation({
action: 'create',
data: updateData,
}, function () { return tslib_1.__awaiter(_this, void 0, void 0, function () {
var bucket;
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.features.extraFile.upload(updateData)];
case 1:
bucket = (_a.sent()).bucket;
Object.assign(updateData, {
bucket: bucket,
extra1: null,
});
return [2 /*return*/];
}
});
}); })];
case 10:
_c.sent();
_c.label = 11;
case 11: return [2 /*return*/];
}
});
});
},
onItemTapped: function (event) {
return tslib_1.__awaiter(this, void 0, void 0, function () {
var _a, files, systemConfig, index, imageUrl, urls, detail, result;
return tslib_1.__generator(this, function (_b) {
switch (_b.label) {
case 0:
_a = this.state, files = _a.files, systemConfig = _a.systemConfig;
index = event.currentTarget.dataset.index;
imageUrl = (0, extraFile_1.composeFileUrl)(files[index], systemConfig);
urls = files === null || files === void 0 ? void 0 : files.filter(function (ele) { return !!ele; }).map(function (ele) { return (0, extraFile_1.composeFileUrl)(ele, systemConfig); });
detail = {
all: files,
index: index,
urls: urls,
current: imageUrl,
};
this.triggerEvent('tap', detail);
if (!this.props.preview) return [3 /*break*/, 2];
return [4 /*yield*/, wx.previewImage({
urls: urls,
current: imageUrl,
})];
case 1:
result = _b.sent();
this.triggerEvent('preview', detail);
_b.label = 2;
case 2: return [2 /*return*/];
}
});
});
},
onDelete: function (event) {
return tslib_1.__awaiter(this, void 0, void 0, function () {
var value, id, bucket, result, confirm_1;
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {
case 0:
value = event.currentTarget.dataset.value;
id = value.id, bucket = value.bucket;
if (!!bucket) return [3 /*break*/, 2];
return [4 /*yield*/, this.addOperation({
action: 'remove',
data: {},
filter: {
id: id,
}
})];
case 1:
_a.sent();
return [3 /*break*/, 6];
case 2: return [4 /*yield*/, wx.showModal({
title: '确认删除吗',
content: '删除现有文件',
})];
case 3:
result = _a.sent();
confirm_1 = result.confirm;
if (!confirm_1) return [3 /*break*/, 6];
return [4 /*yield*/, this.addOperation({
action: 'remove',
data: {},
filter: {
id: id,
}
})];
case 4:
_a.sent();
return [4 /*yield*/, this.execute()];
case 5:
_a.sent();
_a.label = 6;
case 6: return [2 /*return*/];
}
});
});
},
onWebDelete: function (value) {
return tslib_1.__awaiter(this, void 0, void 0, function () {
var originalFiles, id, bucket, findIndex, confirm_2;
var _this = this;
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {
case 0:
originalFiles = this.state.originalFiles;
id = value.id, bucket = value.bucket;
findIndex = originalFiles === null || originalFiles === void 0 ? void 0 : originalFiles.findIndex(function (ele) { return (ele === null || ele === void 0 ? void 0 : ele.id) === id; });
if (!!bucket) return [3 /*break*/, 2];
return [4 /*yield*/, this.addOperation({
action: 'remove',
data: {},
filter: {
id: id,
}
})];
case 1:
_a.sent();
return [3 /*break*/, 3];
case 2:
confirm_2 = index_1.default.confirm({
header: '确认删除当前文件?',
body: '删除后,文件不可恢复',
title: '确认删除当前文件?',
content: '删除后,文件不可恢复',
cancelBtn: '取消',
confirmBtn: '确定',
onConfirm: function () { return tslib_1.__awaiter(_this, void 0, void 0, function () {
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.addOperation({
action: 'remove',
data: {},
filter: {
id: id,
}
})];
case 1:
_a.sent();
return [4 /*yield*/, this.execute()];
case 2:
_a.sent();
confirm_2.hide();
return [2 /*return*/];
}
});
}); },
onCancel: function () {
confirm_2.hide();
},
onClose: function () {
confirm_2.hide();
},
});
_a.label = 3;
case 3: return [2 /*return*/];
}
});
});
},
setNewUploadFiles: function (file, status) {
var filename = file.filename, size = file.size, id = file.id;
var newUploadFiles = this.state.newUploadFiles;
var file2 = newUploadFiles.find(function (ele) { return (ele.filename = filename && ele.size === size); });
Object.assign(file2, {
status: status,
id: id,
});
this.setState({
newUploadFiles: newUploadFiles,
});
},
customDelete: function (index) {
return tslib_1.__awaiter(this, void 0, void 0, function () {
var newUploadFiles, arr;
return tslib_1.__generator(this, function (_a) {
newUploadFiles = this.state.newUploadFiles;
arr = tslib_1.__spreadArray([], tslib_1.__read(newUploadFiles), false);
arr.splice(index, 1);
this.setState({
newUploadFiles: arr,
});
return [2 /*return*/];
});
});
},
},
observers: {
maxNumber: function () {
this.reRender();
},
/**
* size 属性变化时重新调整图片大小
* @param size 新值
*/
size: function (size) {
return tslib_1.__awaiter(this, void 0, void 0, function () {
var res, widthRpx, itemSizePercentage;
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {
case 0:
if (!size) {
this.setState({ itemSizePercentage: '' });
return [2 /*return*/];
}
return [4 /*yield*/, this.getNodeRectFromComponent(this, '.file-list__container')];
case 1:
res = _a.sent();
widthRpx = this.px2rpx(res.right - res.left);
itemSizePercentage = (10 / size) * 10 - (20 / widthRpx) * 100 + '%;';
this.setState({ itemSizePercentage: itemSizePercentage });
return [2 /*return*/];
}
});
});
},
},
});

View File

@ -0,0 +1,9 @@
{
"component": true,
"usingComponents": {
"t-icon": "../../../miniprogram_npm/tdesign/icon/icon"
},
"componentGenerics": {
"item": true
}
}

View File

@ -0,0 +1,4 @@
{
"waiting": "等待中",
"success": "上传成功"
}

View File

@ -0,0 +1,2 @@
/// <reference types="react" />
export default function render(this: any): JSX.Element;

View File

@ -0,0 +1,101 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var jsx_runtime_1 = require("react/jsx-runtime");
var tdesign_react_1 = require("tdesign-react");
var extraFile_1 = require("../../../utils/extraFile");
function extraFileToUploadFile(extraFile, systemConfig) {
return Object.assign({}, extraFile, {
url: (0, extraFile_1.composeFileUrl)(extraFile, systemConfig),
name: extraFile.filename,
});
}
function render() {
var _this = this;
var _a = this.props, _b = _a.accept, accept = _b === void 0 ? 'image/*' : _b, _c = _a.maxNumber, maxNumber = _c === void 0 ? 20 : _c, _d = _a.multiple, multiple = _d === void 0 ? true : _d, _e = _a.useMockProgress, useMockProgress = _e === void 0 ? false : _e, _f = _a.draggable, draggable = _f === void 0 ? false : _f, _g = _a.showUploadProgress, showUploadProgress = _g === void 0 ? false : _g, _h = _a.theme, theme = _h === void 0 ? 'image' : _h, tips = _a.tips, placeholder = _a.placeholder, beforeUpload = _a.beforeUpload, disabled = _a.disabled, style = _a.style, className = _a.className, sizeLimit = _a.sizeLimit;
var _j = this.state, files = _j.files, systemConfig = _j.systemConfig, newUploadFiles = _j.newUploadFiles;
return ((0, jsx_runtime_1.jsxs)(tdesign_react_1.Space, tslib_1.__assign({ direction: "vertical" }, { children: [(0, jsx_runtime_1.jsx)(tdesign_react_1.Upload, tslib_1.__assign({ sizeLimit: sizeLimit, className: className, style: style, disabled: disabled, beforeUpload: beforeUpload, placeholder: placeholder, tips: tips, multiple: multiple, autoUpload: false, draggable: draggable, useMockProgress: useMockProgress, max: maxNumber, accept: accept, showUploadProgress: showUploadProgress, theme: theme, files: theme === 'custom'
? []
: (files || []).map(function (ele) {
return extraFileToUploadFile(ele, systemConfig);
}), onChange: function (uploadFiles) {
var arr = (uploadFiles === null || uploadFiles === void 0 ? void 0 : uploadFiles.filter(function (ele) { return !ele.id; })) || [];
_this.setState({
newUploadFiles: arr,
});
if (theme !== 'custom') {
_this.onWebPick(arr);
}
}, onRemove: function (_a) {
var file = _a.file, index = _a.index, e = _a.e;
_this.onWebDelete(file, index);
}, onPreview: function (_a) {
var file = _a.file, e = _a.e;
} }, { children: theme === 'custom' && ((0, jsx_runtime_1.jsx)(tdesign_react_1.Button, tslib_1.__assign({ variant: "outline", theme: "default" }, { children: "\u9009\u62E9\u6587\u4EF6" }))) })), theme === 'custom' && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(tdesign_react_1.Table, { data: newUploadFiles || [], rowKey: "id", columns: [
{
align: 'center',
colKey: 'tableIndex',
title: '序号',
cell: function (_a) {
var row = _a.row, rowIndex = _a.rowIndex;
return rowIndex + 1;
},
width: 100,
},
{
colKey: 'name',
title: '文件名',
},
{
colKey: 'size',
title: '文件大小',
cell: function (_a) {
var row = _a.row;
var b = (row === null || row === void 0 ? void 0 : row.size) / 1024;
return (0, extraFile_1.bytesToSize)(b);
},
},
{
colKey: 'status',
title: '状态',
cell: function (_a) {
var row = _a.row;
var cpn;
switch (row.status) {
case 'success':
cpn = ((0, jsx_runtime_1.jsx)(tdesign_react_1.Tag, tslib_1.__assign({ theme: "success", variant: "light" }, { children: "success" })));
break;
case 'uploading':
cpn = ((0, jsx_runtime_1.jsx)(tdesign_react_1.Loading, { loading: true, text: "uploading..." }));
break;
default:
cpn = ((0, jsx_runtime_1.jsx)(tdesign_react_1.Tag, tslib_1.__assign({ theme: "warning", variant: "light" }, { children: "waiting" })));
break;
}
return cpn;
},
},
{
colKey: 'op',
width: 300,
title: '操作',
align: 'center',
cell: function (_a) {
var row = _a.row, rowIndex = _a.rowIndex;
return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: !row.id && ((0, jsx_runtime_1.jsx)(tdesign_react_1.Button, tslib_1.__assign({ theme: "primary", variant: "text", onClick: function () {
_this.customDelete(rowIndex);
} }, { children: "\u5220\u9664" }))) }));
},
fixed: 'right',
},
] }), (0, jsx_runtime_1.jsx)("div", tslib_1.__assign({ style: { display: 'flex', justifyContent: 'flex-end' } }, { children: (0, jsx_runtime_1.jsxs)(tdesign_react_1.Space, { children: [(0, jsx_runtime_1.jsx)(tdesign_react_1.Button, tslib_1.__assign({ theme: "default", onClick: function () {
_this.setState({
newUploadFiles: [],
});
} }, { children: "\u5168\u90E8\u6E05\u7A7A" })), (0, jsx_runtime_1.jsx)(tdesign_react_1.Button, tslib_1.__assign({ onClick: function () {
_this.onWebPick(newUploadFiles, function (file, status) {
_this.setNewUploadFiles(file, status);
});
} }, { children: "\u4E0A\u4F20" }))] }) }))] }))] })));
}
exports.default = render;

View File

View File

@ -0,0 +1,36 @@
"use strict";
Component({
properties: {
actions: Array,
actionDescriptions: Object,
show: {
type: Boolean,
value: false,
}
},
methods: {
onClick: function (touch) {
var index = touch.currentTarget.dataset.index;
var actions = this.data.actions;
var action = actions[index];
this.triggerEvent('click', { action: action });
},
closeDrawer: function () {
this.triggerEvent('close');
}
},
observers: {
actions: function (actions) {
var actionDescriptions = this.data.actionDescriptions;
var actionss = actions.map(function (action) { return actionDescriptions[action]; });
this.setData({ actionss: actionss });
},
},
lifetimes: {
ready: function () {
var _a = this.data, actions = _a.actions, actionDescriptions = _a.actionDescriptions;
var actionss = actions.map(function (action) { return actionDescriptions[action]; });
this.setData({ actionss: actionss });
}
}
});

View File

@ -0,0 +1,10 @@
{
"component": true,
"usingComponents": {
"t-button": "../../../miniprogram_npm/tdesign/button/button",
"t-icon": "../../../miniprogram_npm/tdesign/icon/icon",
"t-popup": "../../../miniprogram_npm/tdesign/popup/popup",
"t-grid": "../../../miniprogram_npm/tdesign/grid/grid",
"t-grid-item": "../../../miniprogram_npm/tdesign/grid/grid-item"
}
}

View File

@ -0,0 +1,3 @@
/// <reference types="react" />
declare const _default: import("react").ComponentType<any>;
export default _default;

View File

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

View File

@ -0,0 +1,8 @@
{
"component": true,
"usingComponents": {
"t-button": "../../../miniprogram_npm/tdesign/button/button",
"t-popup": "../../../miniprogram_npm/tdesign/popup/popup",
"t-dialog": "../../../miniprogram_npm/tdesign/dialog/dialog"
}
}

View File

@ -0,0 +1,2 @@
/// <reference types="react" />
export default function render(this: any): JSX.Element;

View File

@ -0,0 +1,68 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var jsx_runtime_1 = require("react/jsx-runtime");
var react_1 = tslib_1.__importDefault(require("react"));
var tdesign_react_1 = require("tdesign-react");
var tdesign_icons_react_1 = require("tdesign-icons-react");
// import { saveAs } from 'file-saver';
function render() {
var _this = this;
var _a = this.props, _b = _a.placement, placement = _b === void 0 ? 'bottom' : _b, _c = _a.style, style = _c === void 0 ? {} : _c;
var visible = this.state.visible;
return ((0, jsx_runtime_1.jsxs)(react_1.default.Fragment, { children: [(0, jsx_runtime_1.jsx)(tdesign_react_1.Button, { variant: "text", shape: "circle", theme: "primary", icon: (0, jsx_runtime_1.jsx)(tdesign_icons_react_1.ChevronUpIcon, {}), style: tslib_1.__assign({ position: 'fixed', bottom: 0, right: '45vw' }, style), onClick: function () {
_this.setVisible(true);
} }), (0, jsx_runtime_1.jsxs)(tdesign_react_1.Drawer, tslib_1.__assign({ placement: placement, visible: visible, onClose: function () {
_this.setVisible(false);
}, header: "Debug\u63A7\u5236\u53F0", footer: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, {}) }, { children: [(0, jsx_runtime_1.jsx)("input", { type: "file", accept: 'application/json', hidden: true, id: "upload", onChange: function () {
var that = _this;
var file = document.getElementById('upload').files[0];
if (typeof FileReader === undefined) {
alert('浏览器版本太老了');
}
else {
var reader = new FileReader();
reader.readAsText(file);
reader.onload = function () {
try {
var data = JSON.parse(this.result);
that.features.localStorage.resetAll(data);
window.location.reload();
}
catch (err) {
console.error(err);
}
};
}
} }), (0, jsx_runtime_1.jsxs)(tdesign_react_1.Space, tslib_1.__assign({ breakLine: true, direction: "horizontal", size: "medium" }, { children: [(0, jsx_runtime_1.jsx)(tdesign_react_1.Button, tslib_1.__assign({ theme: "primary", shape: "circle", onClick: function () { return _this.printRunningTree(); } }, { children: "R" })), (0, jsx_runtime_1.jsx)(tdesign_react_1.Button, tslib_1.__assign({ theme: "primary", shape: "circle", onClick: function () { return _this.printDebugStore(); } }, { children: "S" })), (0, jsx_runtime_1.jsx)(tdesign_react_1.Button, tslib_1.__assign({ theme: "primary", shape: "circle", onClick: function () { return _this.printCachedStore(); } }, { children: "C" })), (0, jsx_runtime_1.jsx)(tdesign_react_1.Button, tslib_1.__assign({ theme: "primary", shape: "circle", onClick: function () {
var data = _this.features.localStorage.loadAll();
var element = document.createElement('a');
element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(JSON.stringify(data)));
element.setAttribute('download', 'data.json');
element.style.display = 'none';
document.body.appendChild(element);
element.click();
document.body.removeChild(element);
} }, { children: "D" })), (0, jsx_runtime_1.jsx)(tdesign_react_1.Button, tslib_1.__assign({ theme: "primary", shape: "circle", onClick: function () {
var element = document.getElementById('upload');
element.click();
} }, { children: "U" })), (0, jsx_runtime_1.jsx)(tdesign_react_1.Button, tslib_1.__assign({ theme: "warning", shape: "circle", onClick: function () {
var confirmDia = tdesign_react_1.DialogPlugin.confirm({
header: '重置数据',
body: '重置后,原来的数据不可恢复',
confirmBtn: '确定',
cancelBtn: '取消',
onConfirm: function (_a) {
var e = _a.e;
_this.resetInitialData();
confirmDia.hide();
window.location.reload();
},
onClose: function (_a) {
var e = _a.e, trigger = _a.trigger;
confirmDia.hide();
},
});
} }, { children: "Reset" }))] }))] }))] }));
}
exports.default = render;

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

@ -0,0 +1,3 @@
/// <reference types="react" />
declare const _default: import("react").ComponentType<any>;
export default _default;

View File

@ -0,0 +1,30 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var message_1 = tslib_1.__importDefault(require("../../utils/message"));
exports.default = OakComponent({
isList: false,
formData: function (_a) {
var props = _a.props;
return tslib_1.__awaiter(this, void 0, void 0, function () {
var width, data, self_1;
return tslib_1.__generator(this, function (_b) {
width = props.width;
data = this.consumeMessage();
if (data) {
self_1 = this;
message_1.default[data.type](Object.assign({}, width === 'xs' && {
//处理mobile
icon: true,
}, process.env.OAK_PLATFORM === 'wechatMp' && {
// 处理小程序
offset: [20, 32],
icon: true,
context: self_1,
}, data));
}
return [2 /*return*/, {}];
});
});
},
});

View File

@ -0,0 +1,6 @@
{
"component": true,
"usingComponents": {
"t-message": "../../miniprogram_npm/tdesign/message/message"
}
}

1
lib/components/message/web.d.ts vendored Normal file
View File

@ -0,0 +1 @@
export default function render(): null;

View File

@ -0,0 +1,6 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function render() {
return null;
}
exports.default = render;

9
lib/constants.d.ts vendored Normal file
View File

@ -0,0 +1,9 @@
export declare const ROOT_ROLE_ID = "oak-root-role";
export declare const ROOT_USER_ID = "oak-root-user";
export declare const ROOT_MOBILE_ID = "oak-root-mobile";
export declare const ROOT_TOKEN_ID = "oak-root-token";
export declare const DefaultConfig: {
userEntityGrant: {
lifetimeLength: number;
};
};

12
lib/constants.js Normal file
View File

@ -0,0 +1,12 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.DefaultConfig = exports.ROOT_TOKEN_ID = exports.ROOT_MOBILE_ID = exports.ROOT_USER_ID = exports.ROOT_ROLE_ID = void 0;
exports.ROOT_ROLE_ID = 'oak-root-role';
exports.ROOT_USER_ID = 'oak-root-user';
exports.ROOT_MOBILE_ID = 'oak-root-mobile';
exports.ROOT_TOKEN_ID = 'oak-root-token';
exports.DefaultConfig = {
userEntityGrant: {
lifetimeLength: 3600 * 1000,
},
};

41
lib/context/BackendRuntimeContext.d.ts vendored Normal file
View File

@ -0,0 +1,41 @@
import { SelectRowShape } from 'oak-domain/lib/types';
import { GetApplicationShape, GetTokeShape, RuntimeContext } from './RuntimeContext';
import { EntityDict } from '../general-app-domain';
import { SerializedData } from './FrontendRuntimeContext';
import { UniversalContext } from 'oak-domain/lib/store/UniversalContext';
export declare type GetTokeShape2 = {
id: 1;
userId: 1;
playerId: 1;
ableState: 1;
player: {
id: 1;
userState: 1;
userRole$user: {
$entity: 'userRole';
data: {
id: 1;
userId: 1;
roleId: 1;
};
};
};
};
/**
* general数据结构要求的后台上下文
*/
export declare class BackendRuntimeContext<ED extends EntityDict> extends UniversalContext<ED> implements RuntimeContext<ED> {
private application?;
private token?;
private amIRoot?;
private rootMode?;
protected initialize(data?: SerializedData): Promise<void>;
getApplicationId(): Promise<("id" extends infer T ? T extends "id" ? T extends keyof ED["application"]["Schema"] ? GetApplicationShape[T] extends 1 | undefined ? ED["application"]["Schema"][T] : GetApplicationShape[T] extends import("oak-domain/lib/types").OtmSubProjection ? never[] | SelectRowShape<Required<ED["application"]["Schema"]>[T][0], GetApplicationShape[T]["data"]>[] : T extends import("oak-domain/lib/types").OptionalKeys<ED["application"]["Schema"]> ? SelectRowShape<NonNullable<Required<ED["application"]["Schema"]>[T]>, GetApplicationShape[T]> | null : SelectRowShape<NonNullable<Required<ED["application"]["Schema"]>[T]>, GetApplicationShape[T]> : never : never : never) | undefined>;
getSystemId(): Promise<("systemId" extends infer T ? T extends "systemId" ? T extends keyof ED["application"]["Schema"] ? GetApplicationShape[T] extends 1 | undefined ? ED["application"]["Schema"][T] : GetApplicationShape[T] extends import("oak-domain/lib/types").OtmSubProjection ? never[] | SelectRowShape<Required<ED["application"]["Schema"]>[T][0], GetApplicationShape[T]["data"]>[] : T extends import("oak-domain/lib/types").OptionalKeys<ED["application"]["Schema"]> ? SelectRowShape<NonNullable<Required<ED["application"]["Schema"]>[T]>, GetApplicationShape[T]> | null : SelectRowShape<NonNullable<Required<ED["application"]["Schema"]>[T]>, GetApplicationShape[T]> : never : never : never) | undefined>;
getApplication(): Promise<SelectRowShape<ED["application"]["Schema"], GetApplicationShape> | undefined>;
getTokenValue(): Promise<"oak-root-token" | ("id" extends infer T ? T extends "id" ? T extends keyof ED["token"]["Schema"] ? GetTokeShape[T] extends 1 | undefined ? ED["token"]["Schema"][T] : GetTokeShape[T] extends import("oak-domain/lib/types").OtmSubProjection ? never[] | SelectRowShape<Required<ED["token"]["Schema"]>[T][0], GetTokeShape[T]["data"]>[] : T extends import("oak-domain/lib/types").OptionalKeys<ED["token"]["Schema"]> ? SelectRowShape<NonNullable<Required<ED["token"]["Schema"]>[T]>, GetTokeShape[T]> | null : SelectRowShape<NonNullable<Required<ED["token"]["Schema"]>[T]>, GetTokeShape[T]> : never : never : never) | undefined>;
getToken(): Promise<SelectRowShape<ED["token"]["Schema"], GetTokeShape> | undefined>;
getCurrentUserId(): Promise<string>;
toString(): Promise<string>;
isRoot(): Promise<boolean>;
}

View File

@ -0,0 +1,180 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.BackendRuntimeContext = void 0;
var tslib_1 = require("tslib");
var assert_1 = tslib_1.__importDefault(require("assert"));
var Exceptions_1 = require("../types/Exceptions");
var constants_1 = require("../constants");
var UniversalContext_1 = require("oak-domain/lib/store/UniversalContext");
/**
* general数据结构要求的后台上下文
*/
var BackendRuntimeContext = /** @class */ (function (_super) {
tslib_1.__extends(BackendRuntimeContext, _super);
function BackendRuntimeContext() {
return _super !== null && _super.apply(this, arguments) || this;
}
BackendRuntimeContext.prototype.initialize = function (data) {
return tslib_1.__awaiter(this, void 0, void 0, function () {
var appId, tokenValue, result, result, token, player, _a, userState, userRole$user;
return tslib_1.__generator(this, function (_b) {
switch (_b.label) {
case 0:
if (!data) return [3 /*break*/, 5];
appId = data.a, tokenValue = data.t;
if (!appId) return [3 /*break*/, 2];
return [4 /*yield*/, this.rowStore.select('application', {
data: {
id: 1,
name: 1,
config: 1,
type: 1,
systemId: 1,
system: {
id: 1,
name: 1,
config: 1,
},
},
filter: {
id: appId,
},
}, this, {})];
case 1:
result = (_b.sent()).result;
(0, assert_1.default)(result.length > 0, "\u6784\u5EFABackendRuntimeContext\u5BF9\u5E94appId\u300C".concat(appId, "\u300D\u627E\u4E0D\u5230application"));
this.application = result[0];
_b.label = 2;
case 2:
if (!tokenValue) return [3 /*break*/, 4];
return [4 /*yield*/, this.rowStore.select('token', {
data: {
id: 1,
userId: 1,
playerId: 1,
ableState: 1,
player: {
id: 1,
userState: 1,
userRole$user: {
$entity: 'userRole',
data: {
id: 1,
userId: 1,
roleId: 1,
role: {
id: 1,
name: 1,
}
},
},
},
},
filter: {
id: tokenValue,
},
}, this, {})];
case 3:
result = (_b.sent()).result;
if (result.length === 0) {
console.log("\u6784\u5EFABackendRuntimeContext\u5BF9\u5E94tokenValue\u300C".concat(tokenValue, "\u627E\u4E0D\u5230\u76F8\u5173\u7684user"));
throw new Exceptions_1.OakTokenExpiredException();
}
token = result[0];
if (token.ableState === 'disabled') {
throw new Exceptions_1.OakTokenExpiredException();
}
player = token.player;
_a = player, userState = _a.userState, userRole$user = _a.userRole$user;
if (['disabled', 'merged'].includes(userState)) {
throw new Exceptions_1.OakUserDisabledException();
}
this.amIRoot = userRole$user.length > 0 && userRole$user.find(function (ele) { return ele.role.name === 'root'; });
this.token = token;
_b.label = 4;
case 4: return [3 /*break*/, 6];
case 5:
// 否则是后台模式默认用root
this.rootMode = true;
_b.label = 6;
case 6: return [2 /*return*/];
}
});
});
};
BackendRuntimeContext.prototype.getApplicationId = function () {
var _a;
return tslib_1.__awaiter(this, void 0, void 0, function () {
return tslib_1.__generator(this, function (_b) {
return [2 /*return*/, (_a = this.application) === null || _a === void 0 ? void 0 : _a.id];
});
});
};
BackendRuntimeContext.prototype.getSystemId = function () {
var _a;
return tslib_1.__awaiter(this, void 0, void 0, function () {
return tslib_1.__generator(this, function (_b) {
return [2 /*return*/, (_a = this.application) === null || _a === void 0 ? void 0 : _a.systemId];
});
});
};
BackendRuntimeContext.prototype.getApplication = function () {
return tslib_1.__awaiter(this, void 0, void 0, function () {
return tslib_1.__generator(this, function (_a) {
return [2 /*return*/, this.application];
});
});
};
BackendRuntimeContext.prototype.getTokenValue = function () {
var _a;
return tslib_1.__awaiter(this, void 0, void 0, function () {
return tslib_1.__generator(this, function (_b) {
if (this.rootMode) {
return [2 /*return*/, constants_1.ROOT_TOKEN_ID];
}
return [2 /*return*/, (_a = this.token) === null || _a === void 0 ? void 0 : _a.id];
});
});
};
BackendRuntimeContext.prototype.getToken = function () {
return tslib_1.__awaiter(this, void 0, void 0, function () {
return tslib_1.__generator(this, function (_a) {
return [2 /*return*/, this.token];
});
});
};
BackendRuntimeContext.prototype.getCurrentUserId = function () {
var _a;
return tslib_1.__awaiter(this, void 0, void 0, function () {
return tslib_1.__generator(this, function (_b) {
if (this.rootMode) {
return [2 /*return*/, constants_1.ROOT_USER_ID];
}
return [2 /*return*/, (_a = this.token) === null || _a === void 0 ? void 0 : _a.userId];
});
});
};
BackendRuntimeContext.prototype.toString = function () {
var _a, _b;
return tslib_1.__awaiter(this, void 0, void 0, function () {
return tslib_1.__generator(this, function (_c) {
if (this.rootMode) {
return [2 /*return*/, JSON.stringify({ rootMode: true })];
}
return [2 /*return*/, JSON.stringify({ a: (_a = this.application) === null || _a === void 0 ? void 0 : _a.id, t: (_b = this.token) === null || _b === void 0 ? void 0 : _b.id })];
});
});
};
BackendRuntimeContext.prototype.isRoot = function () {
return tslib_1.__awaiter(this, void 0, void 0, function () {
return tslib_1.__generator(this, function (_a) {
if (this.rootMode) {
return [2 /*return*/, true];
}
return [2 /*return*/, !!this.amIRoot];
});
});
};
return BackendRuntimeContext;
}(UniversalContext_1.UniversalContext));
exports.BackendRuntimeContext = BackendRuntimeContext;

147
lib/context/FrontendRuntimeContext.d.ts vendored Normal file
View File

@ -0,0 +1,147 @@
import { RowStore } from 'oak-domain/lib/types';
import { EntityDict } from '../general-app-domain';
import { RuntimeContext } from './RuntimeContext';
import { Application } from '../features/application';
import { Token } from '../features/token';
import { AspectDict as GeneralAspectDict } from '../aspects/AspectDict';
import { CommonAspectDict } from 'oak-common-aspect';
import { UniversalContext } from 'oak-domain/lib/store/UniversalContext';
declare type AspectDict<ED extends EntityDict, Cxt extends RuntimeContext<ED>> = GeneralAspectDict<ED, Cxt> & CommonAspectDict<ED, Cxt>;
export declare type SerializedData = {
a?: string;
t?: string;
};
export declare class FrontendRuntimeContext<ED extends EntityDict, Cxt extends RuntimeContext<ED>, AD extends AspectDict<ED, Cxt>> extends UniversalContext<ED> implements RuntimeContext<ED> {
private application?;
private token?;
constructor(store: RowStore<ED, Cxt>, application?: Application<ED, Cxt, AD>, token?: Token<ED, Cxt, AD>);
getApplicationId(): Promise<string | undefined>;
getSystemId(): Promise<("systemId" extends infer T ? T extends "systemId" ? T extends keyof ED["application"]["Schema"] ? {
id: 1;
name: 1;
config: 1;
type: 1;
systemId: 1;
system: {
id: 1;
name: 1;
config: 1;
};
}[T] extends 1 | undefined ? ED["application"]["Schema"][T] : {
id: 1;
name: 1;
config: 1;
type: 1;
systemId: 1;
system: {
id: 1;
name: 1;
config: 1;
};
}[T] extends import("oak-domain/lib/types").OtmSubProjection ? never[] | import("oak-domain/lib/types").SelectRowShape<Required<ED["application"]["Schema"]>[T][0], {
id: 1;
name: 1;
config: 1;
type: 1;
systemId: 1;
system: {
id: 1;
name: 1;
config: 1;
};
}[T]["data"]>[] : T extends import("oak-domain/lib/types").OptionalKeys<ED["application"]["Schema"]> ? import("oak-domain/lib/types").SelectRowShape<NonNullable<Required<ED["application"]["Schema"]>[T]>, {
id: 1;
name: 1;
config: 1;
type: 1;
systemId: 1;
system: {
id: 1;
name: 1;
config: 1;
};
}[T]> | null : import("oak-domain/lib/types").SelectRowShape<NonNullable<Required<ED["application"]["Schema"]>[T]>, {
id: 1;
name: 1;
config: 1;
type: 1;
systemId: 1;
system: {
id: 1;
name: 1;
config: 1;
};
}[T]> : never : never : never) | undefined>;
getApplication(): Promise<import("oak-domain/lib/types").SelectRowShape<ED["application"]["Schema"], {
id: 1;
name: 1;
config: 1;
type: 1;
systemId: 1;
system: {
id: 1;
name: 1;
config: 1;
};
}> | undefined>;
getTokenValue(): Promise<string | undefined>;
getToken(): Promise<import("oak-domain/lib/types").SelectRowShape<ED["token"]["Schema"], {
id: 1;
userId: 1;
user: {
id: 1;
nickname: 1;
name: 1;
userState: 1;
extraFile$entity: {
$entity: "extraFile";
data: {
id: 1;
tag1: 1;
origin: 1;
bucket: 1;
objectId: 1;
filename: 1;
extra1: 1;
type: 1;
entity: 1;
extension: 1;
};
filter: {
tag1: "avatar";
};
indexFrom: 0;
count: 1;
};
mobile$user: {
$entity: "mobile";
data: {
id: 1;
mobile: 1;
userId: 1;
};
};
};
ableState: 1;
player: {
id: 1;
userRole$user: {
$entity: "userRole";
data: {
id: 1;
userId: 1;
roleId: 1;
role: {
id: 1;
name: 1;
};
};
};
};
playerId: 1;
}> | undefined>;
getCurrentUserId(): Promise<string | undefined>;
toString(): Promise<string>;
isRoot(): Promise<boolean>;
}
export {};

View File

@ -0,0 +1,108 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.FrontendRuntimeContext = void 0;
var tslib_1 = require("tslib");
var UniversalContext_1 = require("oak-domain/lib/store/UniversalContext");
var FrontendRuntimeContext = /** @class */ (function (_super) {
tslib_1.__extends(FrontendRuntimeContext, _super);
function FrontendRuntimeContext(store, application, token) {
var _this = _super.call(this, store) || this;
_this.application = application;
_this.token = token;
return _this;
}
FrontendRuntimeContext.prototype.getApplicationId = function () {
var _a;
return tslib_1.__awaiter(this, void 0, void 0, function () {
return tslib_1.__generator(this, function (_b) {
return [2 /*return*/, (_a = this.application) === null || _a === void 0 ? void 0 : _a.getApplicationId()];
});
});
};
FrontendRuntimeContext.prototype.getSystemId = function () {
var _a;
return tslib_1.__awaiter(this, void 0, void 0, function () {
var app;
return tslib_1.__generator(this, function (_b) {
switch (_b.label) {
case 0: return [4 /*yield*/, ((_a = this.application) === null || _a === void 0 ? void 0 : _a.getApplication())];
case 1:
app = _b.sent();
return [2 /*return*/, app === null || app === void 0 ? void 0 : app.systemId];
}
});
});
};
FrontendRuntimeContext.prototype.getApplication = function () {
var _a;
return tslib_1.__awaiter(this, void 0, void 0, function () {
return tslib_1.__generator(this, function (_b) {
return [2 /*return*/, (_a = this.application) === null || _a === void 0 ? void 0 : _a.getApplication()];
});
});
};
FrontendRuntimeContext.prototype.getTokenValue = function () {
var _a;
return tslib_1.__awaiter(this, void 0, void 0, function () {
return tslib_1.__generator(this, function (_b) {
return [2 /*return*/, (_a = this.token) === null || _a === void 0 ? void 0 : _a.getTokenValue()];
});
});
};
FrontendRuntimeContext.prototype.getToken = function () {
var _a;
return tslib_1.__awaiter(this, void 0, void 0, function () {
return tslib_1.__generator(this, function (_b) {
return [2 /*return*/, (_a = this.token) === null || _a === void 0 ? void 0 : _a.getToken()];
});
});
};
FrontendRuntimeContext.prototype.getCurrentUserId = function () {
var _a;
return tslib_1.__awaiter(this, void 0, void 0, function () {
return tslib_1.__generator(this, function (_b) {
return [2 /*return*/, (_a = this.token) === null || _a === void 0 ? void 0 : _a.getUserId()];
});
});
};
FrontendRuntimeContext.prototype.toString = function () {
var _a, _b;
return tslib_1.__awaiter(this, void 0, void 0, function () {
var data, a, t;
return tslib_1.__generator(this, function (_c) {
switch (_c.label) {
case 0:
data = {};
return [4 /*yield*/, ((_a = this.application) === null || _a === void 0 ? void 0 : _a.getApplicationId(true))];
case 1:
a = _c.sent();
return [4 /*yield*/, ((_b = this.token) === null || _b === void 0 ? void 0 : _b.getTokenValue(true))];
case 2:
t = _c.sent();
if (t) {
Object.assign(data, {
t: t,
});
}
if (a) {
Object.assign(data, {
a: a,
});
}
return [2 /*return*/, JSON.stringify(data)];
}
});
});
};
FrontendRuntimeContext.prototype.isRoot = function () {
var _a;
return tslib_1.__awaiter(this, void 0, void 0, function () {
return tslib_1.__generator(this, function (_b) {
return [2 /*return*/, ((_a = this.token) === null || _a === void 0 ? void 0 : _a.isRoot()) || false];
});
});
};
return FrontendRuntimeContext;
}(UniversalContext_1.UniversalContext));
exports.FrontendRuntimeContext = FrontendRuntimeContext;
;

28
lib/context/RuntimeContext.d.ts vendored Normal file
View File

@ -0,0 +1,28 @@
import { SelectRowShape } from 'oak-domain/lib/types';
import { UniversalContext } from 'oak-domain/lib/store/UniversalContext';
import { EntityDict } from '../general-app-domain';
export declare type GetApplicationShape = {
id: 1;
name: 1;
config: 1;
type: 1;
systemId: 1;
system: {
id: 1;
name: 1;
config: 1;
};
};
export declare type GetTokeShape = {
id: 1;
userId: 1;
playerId: 1;
};
export interface RuntimeContext<ED extends EntityDict> extends UniversalContext<ED> {
getApplicationId(): Promise<string | undefined>;
getSystemId(): Promise<string | undefined>;
getApplication(): Promise<SelectRowShape<EntityDict['application']['Schema'], GetApplicationShape> | undefined>;
getToken(): Promise<SelectRowShape<EntityDict['token']['Schema'], GetTokeShape> | undefined>;
getTokenValue(): Promise<string | undefined>;
isRoot(): Promise<boolean>;
}

View File

@ -0,0 +1,3 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
;

6
lib/data/DEV-CONFIG.d.ts vendored Normal file
View File

@ -0,0 +1,6 @@
export declare const DEV_WECHATMP_APPLICATION_ID = "MY_DEV_WECHATMP_APPLICATION_ID";
export declare const DEV_WEB_APPLICATION_ID = "MY_DEV_WEB_APPLICATION_ID";
export declare const DEV_WECHATPUPLIC_APPLICATION_ID = "MY_DEV_WECHATPUPLIC_APPLICATION_ID";
export declare const DEV_DOMAIN_ID = "MY_DEV_DOMAIN_ID";
export declare const DEV_SYSTEM_ID = "MY_DEV_SYSTEM_ID";
export declare const DEV_PLATFORM_ID = "MY_DEV_PLATFORM_ID";

9
lib/data/DEV-CONFIG.js Normal file
View File

@ -0,0 +1,9 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.DEV_PLATFORM_ID = exports.DEV_SYSTEM_ID = exports.DEV_DOMAIN_ID = exports.DEV_WECHATPUPLIC_APPLICATION_ID = exports.DEV_WEB_APPLICATION_ID = exports.DEV_WECHATMP_APPLICATION_ID = void 0;
exports.DEV_WECHATMP_APPLICATION_ID = 'MY_DEV_WECHATMP_APPLICATION_ID';
exports.DEV_WEB_APPLICATION_ID = 'MY_DEV_WEB_APPLICATION_ID';
exports.DEV_WECHATPUPLIC_APPLICATION_ID = 'MY_DEV_WECHATPUPLIC_APPLICATION_ID';
exports.DEV_DOMAIN_ID = 'MY_DEV_DOMAIN_ID';
exports.DEV_SYSTEM_ID = 'MY_DEV_SYSTEM_ID';
exports.DEV_PLATFORM_ID = 'MY_DEV_PLATFORM_ID';

2
lib/data/application.d.ts vendored Normal file
View File

@ -0,0 +1,2 @@
import { CreateOperationData as Application } from '../general-app-domain/Application/Schema';
export declare const applications: Application[];

28
lib/data/application.js Normal file
View File

@ -0,0 +1,28 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.applications = void 0;
var DEV_CONFIG_1 = require("./DEV-CONFIG");
exports.applications = [
{
id: DEV_CONFIG_1.DEV_WECHATMP_APPLICATION_ID,
name: '测试小程序',
type: 'wechatMp',
systemId: DEV_CONFIG_1.DEV_SYSTEM_ID,
config: {
type: 'wechatMp',
appId: '',
appSecret: '',
},
description: '小程序应用指向dev_system',
},
{
id: DEV_CONFIG_1.DEV_WEB_APPLICATION_ID,
name: 'devWeb',
type: 'web',
systemId: DEV_CONFIG_1.DEV_SYSTEM_ID,
config: {
type: 'web',
},
description: 'web应用指向dev_system',
},
];

1
lib/data/area.d.ts vendored Normal file
View File

@ -0,0 +1 @@
export { area, } from './area.dev';

Some files were not shown because too many files have changed in this diff Show More