script中对area的处理

This commit is contained in:
Xu Chang 2022-10-19 13:20:35 +08:00
parent f2eb4d06ea
commit 6fd08f7b28
1088 changed files with 173 additions and 42888 deletions

View File

@ -1,48 +0,0 @@
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

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

View File

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

View File

@ -1,6 +0,0 @@
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

@ -1,43 +0,0 @@
"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

@ -1,7 +0,0 @@
"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;

View File

@ -1,6 +0,0 @@
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

@ -1,45 +0,0 @@
"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;

View File

@ -1,8 +0,0 @@
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>;

View File

@ -1,34 +0,0 @@
"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;

View File

@ -1,9 +0,0 @@
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>;

View File

@ -1,24 +0,0 @@
"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;

View File

@ -1,13 +0,0 @@
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;
};

View File

@ -1,19 +0,0 @@
"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>;

View File

@ -1,45 +0,0 @@
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>;

File diff suppressed because it is too large Load Diff

View File

@ -1,35 +0,0 @@
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;
})>;

View File

@ -1,145 +0,0 @@
"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;

View File

@ -1,5 +0,0 @@
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;

View File

@ -1,39 +0,0 @@
"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;

View File

@ -1,2 +0,0 @@
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;

View File

@ -1,12 +0,0 @@
"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;

View File

@ -1,5 +0,0 @@
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;

View File

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

View File

@ -1,5 +0,0 @@
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;

View File

@ -1,83 +0,0 @@
"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;

View File

@ -1,5 +0,0 @@
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

@ -1,57 +0,0 @@
"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;

View File

@ -1,5 +0,0 @@
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

@ -1,19 +0,0 @@
"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;

View File

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

View File

@ -1,8 +0,0 @@
"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

@ -1,10 +0,0 @@
/// <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

@ -1,35 +0,0 @@
"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;
});

View File

@ -1,38 +0,0 @@
/// <reference types="@uiw/react-amap-types" />
import React from 'react';
import { DialogProps } from 'tdesign-react';
import { GeolocationProps } from '@uiw/react-amap';
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

@ -1,199 +0,0 @@
"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"));
var index_module_less_1 = tslib_1.__importDefault(require("./index.module.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 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.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: index_module_less_1.default.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({ header: (0, jsx_runtime_1.jsxs)("div", tslib_1.__assign({ className: index_module_less_1.default.searchBox }, { 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" })))] })), className: index_module_less_1.default.list }, { 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: index_module_less_1.default.check, 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: index_module_less_1.default.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: index_module_less_1.default.check, 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: index_module_less_1.default.noData }, { children: "\u65E0\u641C\u7D20\u7ED3\u679C" })))] }))] })) }) }))] }) })));
};
exports.default = Location;

View File

@ -1,37 +0,0 @@
.map {
width: 100%;
height: 500px;
}
.list {
height: 500px;
}
.check {
color: var(--td-brand-color);
}
.searchBox {
display: flex;
flex-direction: row;
align-items: center;
}
.loadingBox {
display: flex;
flex-direction: row;
justify-content: center;
min-height: 100px;
}
.noData {
display: flex;
flex-direction: row;
justify-content: center;
min-height: 100px;
align-items: center;
color: var(--td-text-color-placeholder);
align-self: center;
}

View File

@ -1,30 +0,0 @@
/// <reference types="@uiw/react-amap-types" />
import React from 'react';
import { MapProps, APILoaderConfig } from '@uiw/react-amap';
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

@ -1,31 +0,0 @@
"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"));
var index_module_less_1 = tslib_1.__importDefault(require("./index.module.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;
(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)(index_module_less_1.default.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;

View File

@ -1,5 +0,0 @@
.map {
width: 500px;
height: 500px;
}

View File

@ -1,52 +0,0 @@
"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

@ -1 +0,0 @@
{}

View File

@ -1,28 +0,0 @@
/** index.wxss **/
.page-body {
display: flex;
flex-direction: column;
align-items: stretch;
color: #aaa;
}
.label-bar {
padding: 20rpx;
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-between;
}
.label-bar text {
margin-right: 20rpx;
width: 200rpx;
}
.label-bar input {
flex: 1;
}
.usermotto {
margin-top: 200px;
}

View File

@ -1,7 +0,0 @@
<!-- index.wxml -->
<view class="page-body">
<view class="label-bar">
<text>地区名称</text>
<input placeholder="请输入名称" value="{{name}}" type="string" data-path="name" bindinput="setUpdateData" />
</view>
</view>

View File

@ -1,7 +0,0 @@
/// <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

@ -1,33 +0,0 @@
"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

@ -1,16 +0,0 @@
.label {
color: var(--td-text-color-primary);
font-size: var(--td-font-size-headline-medium);
line-height: var(--td-line-height-headline-medium);
}
.tips {
color: var(--td-gray-color-6);
font-size: var(--td-font-size-mark-small);
}
.title {
margin-bottom: 0px;
margin-top:36px;
}

View File

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

View File

@ -1,75 +0,0 @@
"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

@ -1,38 +0,0 @@
.container {
background: var(--td-bg-color-container);
box-shadow: 0 2px 3px #0000001a;
border-radius: 3px;
padding: 30px 32px;
}
.padding {
background-color: var(--td-bg-color-page);
width: 100%;
height: 77px;
}
.ctrl {
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: center;
padding: 10px;
border: solid 0.4px;
border-radius: 3px;
border-color: var(--td-component-border);
position: absolute;
z-index: 10;
background-color: var(--td-bg-color-container-hover);
width: calc(100vw - 138px);
top: 85px;
height: 55px;
text {
color: var(--td-text-color-secondary);
.weight {
font-weight: bold;
color: var(--td-text-color-primary);
text-decoration: underline;
}
}
}

View File

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

View File

@ -1,20 +0,0 @@
"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

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

View File

@ -1,35 +0,0 @@
"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

@ -1 +0,0 @@
{}

View File

@ -1,11 +0,0 @@
/** index.wxss **/
.image {
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
border: 1rpx solid #eee;
border-radius: 4rpx;
}

View File

@ -1,2 +0,0 @@
<!-- index.wxml -->
<image src="{{src}}" mode="{{mode}}" class="image l-class"/>

View File

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

View File

@ -1,7 +0,0 @@
"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

@ -1,9 +0,0 @@
.container {
height: 100vh;
display: flex;
flex-direction: column;
justify-content: 'center';
align-items: 'center';
}

View File

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

View File

@ -1,523 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var assert_1 = tslib_1.__importDefault(require("assert"));
var types_1 = require("oak-domain/lib/types");
var mockId_1 = require("oak-frontend-base/lib/utils/mockId");
var index_1 = tslib_1.__importDefault(require("../../../utils/dialog/index"));
var extraFile_1 = require("../../../utils/extraFile");
exports.default = OakComponent({
entity: 'extraFile',
isList: true,
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: [],
},
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) {
name = uploadFile.name, fileType = uploadFile.type, size = uploadFile.size, raw = uploadFile.raw;
this.pushExtraFile({
name: name,
fileType: fileType,
size: size,
extra1: raw,
}, callback);
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, _b, _c, _d, ele, error_1, err_2, ele;
var _e, _f;
var _this = this;
return tslib_1.__generator(this, function (_g) {
switch (_g.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', '目前只支持七牛上传'); // 目前只支持七牛上传
_e = {
extra1: extra1,
origin: origin,
type: type || 'file',
tag1: tag1,
tag2: tag2
};
return [4 /*yield*/, generateNewId()];
case 1:
updateData = (_e.objectId = _g.sent(),
_e.entity = entity,
_e.filename = filename,
_e.size = size,
_e.extension = extension,
_e.fileType = fileType,
_e);
if (!autoUpload) return [3 /*break*/, 11];
_g.label = 2;
case 2:
_g.trys.push([2, 9, , 10]);
if (callback) {
callback(updateData, 'uploading');
}
return [4 /*yield*/, this.features.extraFile.upload(updateData)];
case 3:
bucket = (_g.sent()).bucket;
_g.label = 4;
case 4:
_g.trys.push([4, 7, , 8]);
_c = (_b = Object).assign;
_d = [updateData];
_f = {
bucket: bucket,
extra1: null
};
return [4 /*yield*/, generateNewId()];
case 5:
_c.apply(_b, _d.concat([(_f.id = _g.sent(),
_f.entityId = entityId,
_f)]));
return [4 /*yield*/, this.addExtraFile(updateData)];
case 6:
_g.sent();
if (callback) {
callback(updateData, 'success');
}
ele = {
updateData: updateData,
};
this.pushNode(undefined, ele);
return [3 /*break*/, 8];
case 7:
error_1 = _g.sent();
if (callback) {
callback(updateData, 'failed');
}
return [3 /*break*/, 8];
case 8: return [3 /*break*/, 10];
case 9:
err_2 = _g.sent();
if (callback) {
callback(updateData, 'failed');
}
return [3 /*break*/, 10];
case 10: return [3 /*break*/, 12];
case 11:
ele = {
updateData: updateData,
beforeExecute: function (updateData) { 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*/];
}
});
}); },
};
this.pushNode(undefined, ele);
_g.label = 12;
case 12: 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 originalFiles, _a, value, index, id, findIndex, result, confirm_1;
return tslib_1.__generator(this, function (_b) {
switch (_b.label) {
case 0:
originalFiles = this.state.originalFiles;
_a = event.currentTarget.dataset, value = _a.value, index = _a.index;
id = value.id;
findIndex = originalFiles === null || originalFiles === void 0 ? void 0 : originalFiles.findIndex(function (ele) { return (ele === null || ele === void 0 ? void 0 : ele.id) === id; });
if (!(0, mockId_1.isMockId)(id)) return [3 /*break*/, 1];
this.removeNode('', "".concat(findIndex));
return [3 /*break*/, 3];
case 1: return [4 /*yield*/, wx.showModal({
title: '确认删除吗',
content: '删除现有文件',
})];
case 2:
result = _b.sent();
confirm_1 = result.confirm;
if (confirm_1) {
this.removeNode('', "".concat(findIndex));
}
_b.label = 3;
case 3: return [2 /*return*/];
}
});
});
},
onWebDelete: function (value) {
return tslib_1.__awaiter(this, void 0, void 0, function () {
var originalFiles, id, findIndex, confirm_2;
var _this = this;
return tslib_1.__generator(this, function (_a) {
originalFiles = this.state.originalFiles;
id = value.id;
findIndex = originalFiles === null || originalFiles === void 0 ? void 0 : originalFiles.findIndex(function (ele) { return (ele === null || ele === void 0 ? void 0 : ele.id) === id; });
if ((0, mockId_1.isMockId)(id)) {
this.removeNode('', "".concat(findIndex));
}
else {
confirm_2 = index_1.default.confirm({
header: '确认删除当前文件?',
body: '删除后,文件不可恢复',
title: '确认删除当前文件?',
content: '删除后,文件不可恢复',
cancelBtn: '取消',
confirmBtn: '确定',
onConfirm: function () {
_this.removeNode('', "".concat(findIndex));
confirm_2.hide();
},
onCancel: function () {
confirm_2.hide();
},
onClose: function () {
confirm_2.hide();
},
});
}
return [2 /*return*/];
});
});
},
addExtraFile: function (extraFile) {
return tslib_1.__awaiter(this, void 0, void 0, function () {
var result, _a, _b, _c, error_2;
var _d;
return tslib_1.__generator(this, function (_e) {
switch (_e.label) {
case 0:
_e.trys.push([0, 3, , 4]);
_b = (_a = this.features.cache).operate;
_c = ['extraFile'];
_d = {
action: 'create',
data: extraFile
};
return [4 /*yield*/, generateNewId()];
case 1: return [4 /*yield*/, _b.apply(_a, _c.concat([(_d.id = _e.sent(),
_d)]))];
case 2:
result = _e.sent();
return [2 /*return*/, result];
case 3:
error_2 = _e.sent();
if (error_2.constructor.name ===
types_1.OakUnloggedInException.name) {
this.navigateTo({
url: '/login',
}, undefined);
return [2 /*return*/];
}
throw error_2;
case 4: 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

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

View File

@ -1,110 +0,0 @@
@import "../../../config/styles/_base.less";
@import "../../../config/styles/_mixins.less";
.file-list__container {
position: relative;
display: flex;
flex-wrap: wrap;
}
.file-list__item {
position: relative;
width: 220rpx;
padding-bottom: 220rpx;
height: 0;
}
// size 不同时,对应的图片间距设置
// size 仅支持 1-10
each(range(2, 10), {
@valuePlusOne : @value+1;
.file-list__item--@{value}:nth-of-type(n+@{valuePlusOne}) {
margin-top : 20rpx;
}
.file-list__item--@{value}:not(:nth-of-type(@{value}n+1)) {
margin-left : 20rpx;
}
}) // 当 size 为 null每行会显示 3 张图片
.file-list__item--null:nth-of-type(n+4) {
margin-top: 20rpx;
}
.file-list__item--null:not(:nth-of-type(3n+1)) {
margin-left: 20rpx;
}
.file-list__image {
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
border: 1rpx solid #eee;
border-radius: 4rpx;
}
.file-list__item--selected {
width: 100%;
height: 100%;
z-index: 10;
background-color: #000;
filter: Alpha(Opacity=50);
opacity: 0.5;
position: absolute;
display: flex;
flex-direction: column;
align-items: center;
justify-content: space-around;
}
.file-list__remove {
position: absolute;
right: 10rpx;
top: 10rpx;
height: 40rpx;
width: 40rpx;
border-radius: 50%;
background: rgb(0 0 0 / 40%);
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
box-sizing: border-box;
}
.file-list__item--add {
border: 1rpx solid #eee;
border-radius: 4rpx;
background-color: white;
}
.file-list__image--add {
visibility: hidden;
position: absolute;
width: 50%;
height: 50%;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
align-items: center;
justify-content: center;
display: flex;
}
.file-list__item-slot-wrapper {
display: flex;
justify-content: center;
align-items: center;
position: absolute;
width: 100%;
height: 100%;
top: 0;
left: 0;
}
.file-list__item-slot-wrapper:empty+.file-list__image--add {
visibility: visible;
}

View File

@ -1,20 +0,0 @@
<view class="file-list__container l-class">
<block wx:for="{{files}}" wx:key="index">
<block wx:if="{{item}}">
<view class="file-list__item file-list__item--{{size}} l-item-class" style="{{itemSizePercentage?'width:'+itemSizePercentage+'padding-bottom:'+itemSizePercentage:'xxx'}}">
<item data-index="{{index}}" bind:tap="onItemTapped" mode="{{mode}}" oakValue="{{item}}" oakPath="{{index}}" oakParent="{{oakFullpath}}" />
<view wx:if="{{!disableDelete}}" mut-bind:tap="onDelete" class="file-list__remove" data-value="{{item}}" data-index="{{ index }}">
<t-icon name="close" color="#ffffff" size="18" />
</view>
</view>
</block>
</block>
<view class="file-list__item file-list__item--add file-list__item--{{size}} l-item-class" style="{{itemSizePercentage?'width:'+itemSizePercentage+'padding-bottom:'+itemSizePercentage:''}}" wx:if="{{!disableInsert}}" bind:tap="onPick">
<view class="file-list__item-slot-wrapper">
<slot />
</view>
<view class="file-list__image--add">
<t-icon name="add" size="80" />
</view>
</view>
</view>

View File

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

View File

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

View File

@ -1,101 +0,0 @@
"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

@ -1,9 +0,0 @@
.container {
height: 100vh;
display: flex;
flex-direction: column;
justify-content: 'center';
align-items: 'center';
}

View File

@ -1,36 +0,0 @@
"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

@ -1,10 +0,0 @@
{
"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

@ -1,55 +0,0 @@
@import "../../../config/styles/_base.less";
@import "../../../config/styles/_mixins.less";
.grid {
display: grid;
grid-template-columns: 1fr 1fr 1fr 1fr;
}
.grid-item {
min-width: 25%;
padding: 20rpx;
display: flex;
flex-direction: column;
justify-content: center;
box-sizing: border-box;
}
.block {
width: 176rpx;
height: 176rpx;
background: #fff;
color: #333;
display: flex;
}
.block--bottom {
width: 100vw;
height: 35vh;
border-top-left-radius: 16rpx;
border-top-right-radius: 16rpx;
}
.btn-box {
display: flex;
flex: 1;
flex-direction: column;
padding: 32rpx;
}
.five-grid {
position: unset;
}
.external-class-content {
padding: 32rpx 0 !important;
}
.image-icon {
width: 96rpx !important;
height: 96rpx !important;
}
.image {
width: 100%;
height: 100%;
}

View File

@ -1,13 +0,0 @@
<t-popup placement="bottom" visible="{{show}}" bind:visible-change="closeDrawer" close-btn="true">
<view class="block block--bottom">
<view class="btn-box">
<t-grid t-class="five-grid" column="{{5}}">
<block wx:for="{{actionss}}" wx:key="index">
<t-grid-item bind:tap="onClick" data-index="{{index}}" text="{{item.label}}" t-class-text="text" t-class-image="image-icon" t-class-content="external-class-content">
<t-icon class="image" name="{{item.icon.name}}" slot="image" />
</t-grid-item>
</block>
</t-grid>
</view>
</view>
</t-popup>

View File

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

View File

@ -1,65 +0,0 @@
"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

@ -1,8 +0,0 @@
{
"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

@ -1,35 +0,0 @@
.btn-popup {
position: fixed !important;
bottom: 10rpx;
// bottom: constant(safe-area-inset-bottom) !important;
// /* 兼容 iOS < 11.2 */
// bottom: env(safe-area-inset-bottom) !important;
right: 45%;
}
.block {
width: 176rpx;
height: 176rpx;
background: #fff;
color: #333;
display: flex;
}
.block--bottom {
width: 100vw;
height: 35vh;
border-top-left-radius: 16rpx;
border-top-right-radius: 16rpx;
}
.btn-box {
display: flex;
flex-direction: row;
padding: 32rpx;
flex-wrap: wrap;
}
.btn-item {
margin-top: 32rpx;
margin-right: 32rpx !important;
}

View File

@ -1,12 +0,0 @@
<t-button bind:tap="handlePopup" t-class="btn-popup" variant="text" theme="primary" icon="chevron-up" shape="circle"></t-button>
<t-popup visible="{{visible}}" bind:visible-change="onVisibleChange" placement="bottom" close-btn="true">
<view class="block block--bottom">
<view class="btn-box">
<t-button bind:tap="printRunningTree" t-class="btn-item" theme="primary" size="small" shape="circle">R</t-button>
<t-button bind:tap="printDebugStore" t-class="btn-item" theme="primary" size="small" shape="circle">S</t-button>
<t-button bind:tap="printCachedStore" t-class="btn-item" theme="primary" size="small" shape="circle">C</t-button>
<t-button bind:tap="showDialog" t-class="btn-item" theme="danger" size="small" shape="circle">Reset</t-button>
</view>
</view>
</t-popup>
<t-dialog visible="{{dialogVisible}}" title="重置数据" content="重置后,原来的数据不可恢复" cancel-btn="取消" confirm-btn="确定" bind:cancel="closeDialog" bind:confirm="handleReset" />

View File

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

View File

@ -1,68 +0,0 @@
"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;

View File

@ -1,9 +0,0 @@
.container {
height: 100vh;
display: flex;
flex-direction: column;
justify-content: 'center';
align-items: 'center';
}

View File

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

View File

@ -1,30 +0,0 @@
"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

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

View File

@ -1,3 +0,0 @@
.container {
display: flex;
}

View File

@ -1,2 +0,0 @@
<t-message id="t-message" />

View File

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

View File

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

View File

@ -1,9 +0,0 @@
.container {
height: 100vh;
display: flex;
flex-direction: column;
justify-content: 'center';
align-items: 'center';
}

View File

@ -1 +0,0 @@
@import "../../miniprogram_npm/tdesign/common/style/_variables.less";

View File

@ -1,7 +0,0 @@
// 解决全屏幕机型底部适配问题
.safe-area-inset-bottom() {
padding-bottom: constant(safe-area-inset-bottom) !important; /* 兼容 iOS < 11.2 */
padding-bottom: env(safe-area-inset-bottom) !important; /* 兼容 iOS >= 11.2 */
}

9
lib/constants.d.ts vendored
View File

@ -1,9 +0,0 @@
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;
};
};

View File

@ -1,12 +0,0 @@
"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,
},
};

View File

@ -1,41 +0,0 @@
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

@ -1,177 +0,0 @@
"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;
(0, assert_1.default)(result.length > 0, "\u6784\u5EFABackendRuntimeContext\u5BF9\u5E94tokenValue\u300C".concat(tokenValue, "\u627E\u4E0D\u5230\u76F8\u5173\u7684user"));
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;

View File

@ -1,113 +0,0 @@
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;
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

@ -1,108 +0,0 @@
"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;
;

View File

@ -1,28 +0,0 @@
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>;
}

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