This commit is contained in:
Xu Chang 2023-06-14 17:02:47 +08:00
commit a03c99b87e
355 changed files with 16712 additions and 19790 deletions

View File

@ -4,7 +4,7 @@ import { EntityDict } from "../general-app-domain";
import { QiniuUploadInfo } from "oak-frontend-base/lib/types/Upload";
import { Config, Origin } from "../types/Config";
import { BackendRuntimeContext } from "../context/BackendRuntimeContext";
declare type GeneralAspectDict<ED extends EntityDict, Cxt extends BackendRuntimeContext<ED>> = {
export declare type GeneralAspectDict<ED extends EntityDict, Cxt extends BackendRuntimeContext<ED>> = {
mergeUser: (params: {
from: string;
to: string;
@ -20,9 +20,10 @@ declare type GeneralAspectDict<ED extends EntityDict, Cxt extends BackendRuntime
mobile: string;
env: WebEnv | WechatMpEnv;
}, context: Cxt) => Promise<string>;
loginWechat: ({ code, env, }: {
loginWechat: ({ code, env, wechatLoginId, }: {
code: string;
env: WebEnv;
wechatLoginId?: string;
}, context: Cxt) => Promise<string>;
logout: ({}: {}, context: Cxt) => Promise<void>;
loginWechatMp: ({ code, env, }: {
@ -72,6 +73,25 @@ declare type GeneralAspectDict<ED extends EntityDict, Cxt extends BackendRuntime
userId: string;
}, context: Cxt) => Promise<void>;
getMpUnlimitWxaCode: (wechatQrCodeId: string, context: Cxt) => Promise<string>;
createWechatLogin: (params: {
type: EntityDict['wechatLogin']['Schema']['type'];
interval: number;
}, context: Cxt) => Promise<string>;
unbindingWechat: (params: {
wechatUserId: string;
captcha?: string;
mobile?: string;
}, context: Cxt) => Promise<void>;
loginByWechat: (params: {
wechatLoginId: string;
env: WebEnv;
}, context: Cxt) => Promise<string>;
getInfoByUrl: (params: {
url: string;
}) => Promise<{
title: string;
publishDate: number | undefined;
imageList: string[];
}>;
};
export declare type AspectDict<ED extends EntityDict, Cxt extends BackendRuntimeContext<ED>> = GeneralAspectDict<ED, Cxt>;
export {};
export default GeneralAspectDict;

View File

@ -10,7 +10,7 @@ export declare function signatureJsSDK<ED extends EntityDict, Cxt extends Backen
url: string;
env: WebEnv;
}, context: Cxt): Promise<{
signature: any;
signature: string;
noncestr: string;
timestamp: number;
appId: string;

View File

@ -7,3 +7,10 @@ export declare function getUploadInfo<ED extends EntityDict, Cxt extends Backend
bucket?: string;
key?: string;
}, context: Cxt): Promise<QiniuUploadInfo>;
export declare function getInfoByUrl(params: {
url: string;
}): Promise<{
title: string;
publishDate: number | undefined;
imageList: string[];
}>;

View File

@ -1,9 +1,10 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getUploadInfo = void 0;
exports.getInfoByUrl = exports.getUploadInfo = void 0;
var tslib_1 = require("tslib");
var getContextConfig_1 = require("../utils/getContextConfig");
var assert_1 = require("oak-domain/lib/utils/assert");
var oak_external_sdk_1 = require("oak-external-sdk");
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;
@ -22,3 +23,18 @@ function getUploadInfo(params, context) {
});
}
exports.getUploadInfo = getUploadInfo;
// 请求链接获取标题,发布时间,图片等信息
function getInfoByUrl(params) {
return tslib_1.__awaiter(this, void 0, void 0, function () {
var url;
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {
case 0:
url = params.url;
return [4 /*yield*/, oak_external_sdk_1.WechatSDK.analyzePublicArticle(url)];
case 1: return [2 /*return*/, _a.sent()];
}
});
});
}
exports.getInfoByUrl = getInfoByUrl;

View File

@ -1,8 +1,10 @@
import { loginByMobile, loginWechat, loginWechatMp, syncUserInfoWechatMp, sendCaptcha, switchTo, refreshWechatPublicUserInfo, getWechatMpUserPhoneNumber, logout } from './token';
import { getUploadInfo } from './extraFile';
import { loginByMobile, loginWechat, loginWechatMp, syncUserInfoWechatMp, sendCaptcha, switchTo, refreshWechatPublicUserInfo, getWechatMpUserPhoneNumber, logout, loginByWechat } from './token';
import { getUploadInfo, getInfoByUrl } from './extraFile';
import { getApplication, signatureJsSDK } from './application';
import { updateConfig, updateApplicationConfig } from './config';
import { mergeUser } from './user';
import { createWechatLogin } from './wechaLogin';
import { unbindingWechat } from './wechatUser';
declare const aspectDict: {
mergeUser: typeof mergeUser;
switchTo: typeof switchTo;
@ -19,5 +21,9 @@ declare const aspectDict: {
getWechatMpUserPhoneNumber: typeof getWechatMpUserPhoneNumber;
logout: typeof logout;
signatureJsSDK: typeof signatureJsSDK;
createWechatLogin: typeof createWechatLogin;
unbindingWechat: typeof unbindingWechat;
loginByWechat: typeof loginByWechat;
getInfoByUrl: typeof getInfoByUrl;
};
export default aspectDict;

View File

@ -5,6 +5,8 @@ var extraFile_1 = require("./extraFile");
var application_1 = require("./application");
var config_1 = require("./config");
var user_1 = require("./user");
var wechaLogin_1 = require("./wechaLogin");
var wechatUser_1 = require("./wechatUser");
var aspectDict = {
mergeUser: user_1.mergeUser,
switchTo: token_1.switchTo,
@ -21,5 +23,9 @@ var aspectDict = {
getWechatMpUserPhoneNumber: token_1.getWechatMpUserPhoneNumber,
logout: token_1.logout,
signatureJsSDK: application_1.signatureJsSDK,
createWechatLogin: wechaLogin_1.createWechatLogin,
unbindingWechat: wechatUser_1.unbindingWechat,
loginByWechat: token_1.loginByWechat,
getInfoByUrl: extraFile_1.getInfoByUrl,
};
exports.default = aspectDict;

View File

@ -9,14 +9,19 @@ export declare function loginByMobile<ED extends EntityDict, Cxt extends Backend
env: WebEnv | WechatMpEnv;
}, context: Cxt): Promise<string>;
export declare function refreshWechatPublicUserInfo<ED extends EntityDict, Cxt extends BackendRuntimeContext<ED>>({}: {}, context: Cxt): Promise<void>;
export declare function loginByWechat<ED extends EntityDict, Cxt extends BackendRuntimeContext<ED>>(params: {
wechatLoginId: string;
env: WebEnv | WechatMpEnv;
}, context: Cxt): Promise<string>;
/**
*
* @param param0
* @param context
*/
export declare function loginWechat<ED extends EntityDict, Cxt extends BackendRuntimeContext<ED>>({ code, env }: {
export declare function loginWechat<ED extends EntityDict, Cxt extends BackendRuntimeContext<ED>>({ code, env, wechatLoginId, }: {
code: string;
env: WebEnv;
wechatLoginId?: string;
}, context: Cxt): Promise<string>;
/**
*

View File

@ -1,6 +1,6 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.logout = exports.getWechatMpUserPhoneNumber = exports.switchTo = exports.sendCaptcha = exports.syncUserInfoWechatMp = exports.loginWechatMp = exports.loginWechat = exports.refreshWechatPublicUserInfo = exports.loginByMobile = void 0;
exports.logout = exports.getWechatMpUserPhoneNumber = exports.switchTo = exports.sendCaptcha = exports.syncUserInfoWechatMp = exports.loginWechatMp = exports.loginWechat = exports.loginByWechat = exports.refreshWechatPublicUserInfo = exports.loginByMobile = void 0;
var tslib_1 = require("tslib");
var uuid_1 = require("oak-domain/lib/utils/uuid");
var oak_external_sdk_1 = require("oak-external-sdk");
@ -202,7 +202,7 @@ createData, user) {
}
return [3 /*break*/, 10];
case 1:
if (currentToken.id === user.id) {
if (currentToken.userId === user.id) {
return [2 /*return*/, currentToken.id];
}
return [4 /*yield*/, (0, user_1.mergeUser)({ from: user.id, to: currentToken.userId }, context, true)];
@ -210,7 +210,7 @@ createData, user) {
_23.sent();
return [2 /*return*/, currentToken.id];
case 3:
(0, assert_1.assert)(currentToken.id !== user.id);
(0, assert_1.assert)(currentToken.userId !== user.id);
return [4 /*yield*/, (0, user_1.mergeUser)({ from: user.id, to: currentToken.userId }, context, true)];
case 4:
_23.sent();
@ -235,7 +235,7 @@ createData, user) {
_23.label = 8;
case 8:
(0, assert_1.assert)(user.refId);
if (user.refId === currentToken.id) {
if (user.refId === currentToken.userId) {
return [2 /*return*/, currentToken.id];
}
// 说明一个用户被其他用户merge了现在还是暂时先merge后面再说
@ -414,10 +414,11 @@ createData, user) {
_19), {}]))];
case 40:
_23.sent();
(0, assert_1.assert)(entityId || createData.id, 'entityId和createData必须存在一项');
tokenData.userId = userData.id;
tokenData.playerId = userData.id;
tokenData.entity = entity;
tokenData.entityId = createData.id;
tokenData.entityId = entityId || createData.id;
_2 = (_1 = context).operate;
_3 = ['token'];
_20 = {};
@ -471,10 +472,10 @@ createData, user) {
}
function setupMobile(mobile, env, context) {
return tslib_1.__awaiter(this, void 0, void 0, function () {
var result2, _a, mobileRow, user, _b, _c;
var _d;
return tslib_1.__generator(this, function (_e) {
switch (_e.label) {
var result2, _a, mobileRow, user, _b, userState, ref, _c, _d;
var _e;
return tslib_1.__generator(this, function (_f) {
switch (_f.label) {
case 0: return [4 /*yield*/, context.select('mobile', {
data: {
id: 1,
@ -485,6 +486,11 @@ function setupMobile(mobile, env, context) {
id: 1,
userState: 1,
refId: 1,
ref: {
id: 1,
userState: 1,
refId: 1,
},
wechatUser$user: {
$entity: 'wechatUser',
data: {
@ -506,25 +512,29 @@ function setupMobile(mobile, env, context) {
}
}, { dontCollect: true })];
case 1:
result2 = _e.sent();
if (!(result2.length > 0)) return [3 /*break*/, 3];
result2 = _f.sent();
if (!(result2.length > 0)) return [3 /*break*/, 5];
// 此手机号已经存在
(0, assert_1.assert)(result2.length === 1);
_a = tslib_1.__read(result2, 1), mobileRow = _a[0];
user = mobileRow.user;
return [4 /*yield*/, setUpTokenAndUser(env, context, 'mobile', mobileRow.id, undefined, user)];
case 2: return [2 /*return*/, _e.sent()];
case 3:
_b = setUpTokenAndUser;
_c = [env, context, 'mobile', undefined];
_d = {};
_b = user, userState = _b.userState, ref = _b.ref;
if (!(userState === 'merged')) return [3 /*break*/, 3];
return [4 /*yield*/, setUpTokenAndUser(env, context, 'mobile', mobileRow.id, undefined, ref)];
case 2: return [2 /*return*/, _f.sent()];
case 3: return [4 /*yield*/, setUpTokenAndUser(env, context, 'mobile', mobileRow.id, undefined, user)];
case 4: return [2 /*return*/, _f.sent()];
case 5:
_c = setUpTokenAndUser;
_d = [env, context, 'mobile', undefined];
_e = {};
return [4 /*yield*/, (0, uuid_1.generateNewIdAsync)()];
case 4: return [4 /*yield*/, _b.apply(void 0, _c.concat([(_d.id = _e.sent(),
_d.mobile = mobile,
_d)]))];
case 5:
case 6: return [4 /*yield*/, _c.apply(void 0, _d.concat([(_e.id = _f.sent(),
_e.mobile = mobile,
_e)]))];
case 7:
//此手机号不存在
return [2 /*return*/, _e.sent()];
return [2 /*return*/, _f.sent()];
}
});
});
@ -867,12 +877,75 @@ function refreshWechatPublicUserInfo(_a, context) {
});
}
exports.refreshWechatPublicUserInfo = refreshWechatPublicUserInfo;
function loginFromWechatEnv(code, env, context) {
// 用户在微信端授权登录后在web端触发该方法
function loginByWechat(params, context) {
return tslib_1.__awaiter(this, void 0, void 0, function () {
var application, _a, type, config, systemId, appId, appSecret, config2, config2, config2, wechatInstance, _b, isSnapshotUser, openId, unionId, wechatUserData, OriginMap, _c, wechatUser, tokenId_1, wechatUserUpdateData, _d, _e, _f, _g, wechatUser3, wechatUserCreateData_1, tokenId_2, _h, _j, _k, wechatUserCreateData, tokenId;
var _l, _m, _o, _p;
return tslib_1.__generator(this, function (_q) {
switch (_q.label) {
var wechatLoginId, env, _a, wechatLoginData, _b, wechatUserLogin, tokenId;
return tslib_1.__generator(this, function (_c) {
switch (_c.label) {
case 0:
wechatLoginId = params.wechatLoginId, env = params.env;
return [4 /*yield*/, context.select('wechatLogin', {
data: {
id: 1,
userId: 1,
type: 1,
},
filter: {
id: wechatLoginId,
}
}, {
dontCollect: true,
})];
case 1:
_a = tslib_1.__read.apply(void 0, [_c.sent(), 1]), wechatLoginData = _a[0];
return [4 /*yield*/, context.select('wechatUser', {
data: {
id: 1,
userId: 1,
user: {
id: 1,
name: 1,
nickname: 1,
userState: 1,
refId: 1,
userRole$user: {
$entity: 'userRole',
data: {
id: 1,
userId: 1,
roleId: 1,
},
}
},
},
filter: {
userId: wechatLoginData.userId,
}
}, {
dontCollect: true,
})];
case 2:
_b = tslib_1.__read.apply(void 0, [_c.sent(), 1]), wechatUserLogin = _b[0];
return [4 /*yield*/, setUpTokenAndUser(env, context, 'wechatUser', wechatUserLogin.id, undefined, wechatUserLogin.user)];
case 3:
tokenId = _c.sent();
return [4 /*yield*/, loadTokenInfo(tokenId, context)];
case 4:
_c.sent();
return [2 /*return*/, tokenId];
}
});
});
}
exports.loginByWechat = loginByWechat;
function loginFromWechatEnv(code, env, context, wechatLoginId) {
return tslib_1.__awaiter(this, void 0, void 0, function () {
var application, _a, type, config, systemId, appId, appSecret, config2, config2, config2, wechatInstance, _b, isSnapshotUser, openId, unionId, wechatUserData, OriginMap, createWechatUserAndReturnTokenId, _c, wechatUser, updateWechatLogin, _d, wechatLoginData, _e, wechatUserLogin, _f, _g, _h, tokenId, tokenId, tokenId, userId, userData, _j, _k, _l, tokenId, tokenId, wechatUserUpdateData, _m, _o, _p, _q, wechatUser3, wechatUserCreateData, tokenId, _r, _s, _t;
var _u, _v, _w, _x, _y;
var _this = this;
return tslib_1.__generator(this, function (_z) {
switch (_z.label) {
case 0:
application = context.getApplication();
_a = application, type = _a.type, config = _a.config, systemId = _a.systemId;
@ -896,7 +969,7 @@ function loginFromWechatEnv(code, env, context) {
wechatInstance = oak_external_sdk_1.WechatSDK.getInstance(appId, type, appSecret);
return [4 /*yield*/, wechatInstance.code2Session(code)];
case 1:
_b = _q.sent(), isSnapshotUser = _b.isSnapshotUser, openId = _b.openId, unionId = _b.unionId, wechatUserData = tslib_1.__rest(_b, ["isSnapshotUser", "openId", "unionId"]);
_b = _z.sent(), isSnapshotUser = _b.isSnapshotUser, openId = _b.openId, unionId = _b.unionId, wechatUserData = tslib_1.__rest(_b, ["isSnapshotUser", "openId", "unionId"]);
if (isSnapshotUser) {
throw new types_1.OakUserException('请使用完整服务后再进行登录操作');
}
@ -905,6 +978,23 @@ function loginFromWechatEnv(code, env, context) {
'wechatPublic': 'public',
'wechatMp': 'mp',
};
createWechatUserAndReturnTokenId = function (user) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
var wechatUserCreateData, tokenId;
var _a;
return tslib_1.__generator(this, function (_b) {
switch (_b.label) {
case 0:
_a = {};
return [4 /*yield*/, (0, uuid_1.generateNewIdAsync)()];
case 1:
wechatUserCreateData = tslib_1.__assign.apply(void 0, [(_a.id = _b.sent(), _a.unionId = unionId, _a.origin = OriginMap[type], _a.openId = openId, _a.applicationId = application.id, _a), wechatUserData]);
return [4 /*yield*/, setUpTokenAndUser(env, context, 'wechatUser', undefined, wechatUserCreateData, user)];
case 2:
tokenId = _b.sent();
return [2 /*return*/, tokenId];
}
});
}); };
return [4 /*yield*/, context.select('wechatUser', {
data: {
id: 1,
@ -935,33 +1025,184 @@ function loginFromWechatEnv(code, env, context) {
dontCollect: true,
})];
case 2:
_c = tslib_1.__read.apply(void 0, [_q.sent(), 1]), wechatUser = _c[0];
if (!wechatUser) return [3 /*break*/, 6];
return [4 /*yield*/, setUpTokenAndUser(env, context, 'wechatUser', wechatUser.id, undefined, wechatUser.user)];
_c = tslib_1.__read.apply(void 0, [_z.sent(), 1]), wechatUser = _c[0];
if (!wechatLoginId) return [3 /*break*/, 23];
updateWechatLogin = function (updateData) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
var _a, _b, _c;
var _d;
return tslib_1.__generator(this, function (_e) {
switch (_e.label) {
case 0:
_b = (_a = context).operate;
_c = ['wechatLogin'];
_d = {};
return [4 /*yield*/, (0, uuid_1.generateNewIdAsync)()];
case 1: return [4 /*yield*/, _b.apply(_a, _c.concat([(_d.id = _e.sent(),
_d.action = 'update',
_d.data = updateData,
_d.filter = {
id: wechatLoginId,
},
_d), { dontCollect: true }]))];
case 2:
_e.sent();
return [2 /*return*/];
}
});
}); };
return [4 /*yield*/, context.select('wechatLogin', {
data: {
id: 1,
userId: 1,
type: 1,
user: {
id: 1,
name: 1,
nickname: 1,
userState: 1,
refId: 1,
userRole$user: {
$entity: 'userRole',
data: {
id: 1,
userId: 1,
roleId: 1,
},
}
},
},
filter: {
id: wechatLoginId,
}
}, {
dontCollect: true,
})];
case 3:
tokenId_1 = _q.sent();
_d = tslib_1.__read.apply(void 0, [_z.sent(), 1]), wechatLoginData = _d[0];
if (!(wechatLoginData && wechatLoginData.type === "bind")) return [3 /*break*/, 13];
return [4 /*yield*/, context.select('wechatUser', {
data: {
id: 1,
userId: 1,
user: {
id: 1,
name: 1,
nickname: 1,
userState: 1,
refId: 1,
userRole$user: {
$entity: 'userRole',
data: {
id: 1,
userId: 1,
roleId: 1,
},
}
},
},
filter: {
userId: wechatLoginData.userId,
}
}, {
dontCollect: true,
})];
case 4:
_e = tslib_1.__read.apply(void 0, [_z.sent(), 1]), wechatUserLogin = _e[0];
// 已绑定
(0, assert_1.assert)(!wechatUserLogin, '登录者已经绑定微信公众号');
if (!wechatUser) return [3 /*break*/, 9];
_g = (_f = context).operate;
_h = ['wechatUser'];
_u = {};
return [4 /*yield*/, (0, uuid_1.generateNewIdAsync)()];
case 5: return [4 /*yield*/, _g.apply(_f, _h.concat([(_u.id = _z.sent(),
_u.action = 'update',
_u.data = {
userId: wechatLoginData.userId,
},
_u.filter = {
id: wechatUser.id,
},
_u), { dontCollect: true }]))];
case 6:
_z.sent();
return [4 /*yield*/, setUpTokenAndUser(env, context, 'wechatUser', wechatUser.id, undefined, wechatUserLogin.user)];
case 7:
tokenId = _z.sent();
return [4 /*yield*/, updateWechatLogin({ successed: true })];
case 8:
_z.sent();
return [2 /*return*/, tokenId];
case 9: return [4 /*yield*/, createWechatUserAndReturnTokenId(wechatLoginData.user)];
case 10:
tokenId = _z.sent();
return [4 /*yield*/, updateWechatLogin({ successed: true })];
case 11:
_z.sent();
return [2 /*return*/, tokenId];
case 12: return [3 /*break*/, 22];
case 13:
if (!(wechatLoginData.type === 'login')) return [3 /*break*/, 22];
if (!wechatUser) return [3 /*break*/, 16];
return [4 /*yield*/, setUpTokenAndUser(env, context, 'wechatUser', wechatUser.id, undefined, wechatUser.user)];
case 14:
tokenId = _z.sent();
return [4 /*yield*/, updateWechatLogin({ successed: true })];
case 15:
_z.sent();
return [2 /*return*/, tokenId];
case 16: return [4 /*yield*/, (0, uuid_1.generateNewIdAsync)()];
case 17:
userId = _z.sent();
userData = {
id: userId,
userState: 'normal',
};
_k = (_j = context).operate;
_l = ['user'];
_v = {};
return [4 /*yield*/, (0, uuid_1.generateNewIdAsync)()];
case 18: return [4 /*yield*/, _k.apply(_j, _l.concat([(_v.id = _z.sent(),
_v.action = 'create',
_v.data = userData,
_v), {}]))];
case 19:
_z.sent();
return [4 /*yield*/, createWechatUserAndReturnTokenId(userData)];
case 20:
tokenId = _z.sent();
return [4 /*yield*/, updateWechatLogin({ userId: userId, successed: true })];
case 21:
_z.sent();
return [2 /*return*/, tokenId];
case 22: return [3 /*break*/, 34];
case 23:
if (!wechatUser) return [3 /*break*/, 27];
return [4 /*yield*/, setUpTokenAndUser(env, context, 'wechatUser', wechatUser.id, undefined, wechatUser.user)];
case 24:
tokenId = _z.sent();
wechatUserUpdateData = wechatUserData;
if (unionId !== wechatUser.unionId) {
Object.assign(wechatUserUpdateData, {
unionId: unionId,
});
}
_e = (_d = context).operate;
_f = ['wechatUser'];
_l = {};
_o = (_m = context).operate;
_p = ['wechatUser'];
_w = {};
return [4 /*yield*/, (0, uuid_1.generateNewIdAsync)()];
case 4: return [4 /*yield*/, _e.apply(_d, _f.concat([(_l.id = _q.sent(),
_l.action = 'update',
_l.data = wechatUserUpdateData,
_l.filter = {
case 25: return [4 /*yield*/, _o.apply(_m, _p.concat([(_w.id = _z.sent(),
_w.action = 'update',
_w.data = wechatUserUpdateData,
_w.filter = {
id: wechatUser.id,
},
_l), { dontCollect: true }]))];
case 5:
_q.sent();
return [2 /*return*/, tokenId_1];
case 6:
if (!unionId) return [3 /*break*/, 13];
_w), { dontCollect: true }]))];
case 26:
_z.sent();
return [2 /*return*/, tokenId];
case 27:
if (!unionId) return [3 /*break*/, 34];
return [4 /*yield*/, context.select('wechatUser', {
data: {
id: 1,
@ -982,46 +1223,41 @@ function loginFromWechatEnv(code, env, context) {
}, {
dontCollect: true,
})];
case 7:
_g = tslib_1.__read.apply(void 0, [_q.sent(), 1]), wechatUser3 = _g[0];
if (!wechatUser3) return [3 /*break*/, 13];
_m = {};
case 28:
_q = tslib_1.__read.apply(void 0, [_z.sent(), 1]), wechatUser3 = _q[0];
if (!wechatUser3) return [3 /*break*/, 34];
_x = {};
return [4 /*yield*/, (0, uuid_1.generateNewIdAsync)()];
case 8:
wechatUserCreateData_1 = tslib_1.__assign.apply(void 0, [(_m.id = _q.sent(), _m.unionId = unionId, _m.origin = OriginMap[type], _m.openId = openId, _m.applicationId = application.id, _m), wechatUserData]);
return [4 /*yield*/, setUpTokenAndUser(env, context, 'wechatUser', undefined, wechatUserCreateData_1, wechatUser3.user)];
case 9:
tokenId_2 = _q.sent();
if (!!wechatUser3.userId) return [3 /*break*/, 12];
_j = (_h = context).operate;
_k = ['wechatUser'];
_o = {};
case 29:
wechatUserCreateData = tslib_1.__assign.apply(void 0, [(_x.id = _z.sent(), _x.unionId = unionId, _x.origin = OriginMap[type], _x.openId = openId, _x.applicationId = application.id, _x), wechatUserData]);
return [4 /*yield*/, setUpTokenAndUser(env, context, 'wechatUser', undefined, wechatUserCreateData, wechatUser3.user)];
case 30:
tokenId = _z.sent();
if (!!wechatUser3.userId) return [3 /*break*/, 33];
_s = (_r = context).operate;
_t = ['wechatUser'];
_y = {};
return [4 /*yield*/, (0, uuid_1.generateNewIdAsync)()];
case 10:
case 31:
// 这里顺便帮其它wechatUser数据也补上相应的userId
return [4 /*yield*/, _j.apply(_h, _k.concat([(_o.id = _q.sent(),
_o.action = 'update',
_o.data = {
userId: wechatUserCreateData_1.userId, // 在setUpTokenAndUser内赋上值
return [4 /*yield*/, _s.apply(_r, _t.concat([(_y.id = _z.sent(),
_y.action = 'update',
_y.data = {
userId: wechatUserCreateData.userId, // 在setUpTokenAndUser内赋上值
},
_o.filter = {
_y.filter = {
id: wechatUser3.id,
},
_o), { dontCollect: true }]))];
case 11:
_y), { dontCollect: true }]))];
case 32:
// 这里顺便帮其它wechatUser数据也补上相应的userId
_q.sent();
_q.label = 12;
case 12: return [2 /*return*/, tokenId_2];
case 13:
_p = {};
return [4 /*yield*/, (0, uuid_1.generateNewIdAsync)()];
case 14:
wechatUserCreateData = tslib_1.__assign.apply(void 0, [(_p.id = _q.sent(), _p.unionId = unionId, _p.origin = OriginMap[type], _p.openId = openId, _p.applicationId = application.id, _p), wechatUserData]);
return [4 /*yield*/, setUpTokenAndUser(env, context, 'wechatUser', undefined, wechatUserCreateData, undefined)];
case 15:
tokenId = _q.sent();
return [2 /*return*/, tokenId];
_z.sent();
_z.label = 33;
case 33: return [2 /*return*/, tokenId];
case 34: return [4 /*yield*/, createWechatUserAndReturnTokenId()];
case 35:
// 到这里都是要同时创建wechatUser和user对象了
return [2 /*return*/, _z.sent()];
}
});
});
@ -1032,12 +1268,12 @@ function loginFromWechatEnv(code, env, context) {
* @param context
*/
function loginWechat(_a, context) {
var code = _a.code, env = _a.env;
var code = _a.code, env = _a.env, wechatLoginId = _a.wechatLoginId;
return tslib_1.__awaiter(this, void 0, void 0, function () {
var tokenId, _b, tokenInfo;
return tslib_1.__generator(this, function (_c) {
switch (_c.label) {
case 0: return [4 /*yield*/, loginFromWechatEnv(code, env, context)];
case 0: return [4 /*yield*/, loginFromWechatEnv(code, env, context, wechatLoginId)];
case 1:
tokenId = _c.sent();
return [4 /*yield*/, loadTokenInfo(tokenId, context)];

View File

@ -18,6 +18,7 @@ function mergeUser(params, context, innerLogic) {
from = params.from, to = params.to;
(0, assert_1.default)(from);
(0, assert_1.default)(to);
(0, assert_1.default)(from !== to, '不能merge到相同user');
schema = context.getSchema();
_b = (_a = context).operate;
_c = ['token'];
@ -65,6 +66,7 @@ function mergeUser(params, context, innerLogic) {
_g.action = 'disable',
_g.data = {},
_g.filter = {
ableState: 'enabled',
playerId: from, // todo 这里是playerId, root如果正在扮演该用户待处理
},
_g), { dontCollect: true }]))];

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

@ -0,0 +1,6 @@
import { EntityDict } from "../general-app-domain";
import { BackendRuntimeContext } from "../context/BackendRuntimeContext";
export declare function createWechatLogin<ED extends EntityDict, Cxt extends BackendRuntimeContext<ED>>(params: {
type: EntityDict['wechatLogin']['Schema']['type'];
interval: number;
}, context: Cxt): Promise<string>;

50
lib/aspects/wechaLogin.js Normal file
View File

@ -0,0 +1,50 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.createWechatLogin = void 0;
var tslib_1 = require("tslib");
var uuid_1 = require("oak-domain/lib/utils/uuid");
function createWechatLogin(params, context) {
return tslib_1.__awaiter(this, void 0, void 0, function () {
var type, interval, userId, id, createData, _a, _b, _c;
var _d;
return tslib_1.__generator(this, function (_e) {
switch (_e.label) {
case 0:
type = params.type, interval = params.interval;
if (type === 'bind') {
userId = context.getCurrentUserId();
}
return [4 /*yield*/, (0, uuid_1.generateNewIdAsync)()];
case 1:
id = _e.sent();
createData = {
id: id,
type: type,
expiresAt: Date.now() + interval,
expired: false,
qrCodeType: 'wechatPublic',
successed: false,
};
if (userId) {
Object.assign(createData, {
userId: userId,
});
}
_b = (_a = context).operate;
_c = ['wechatLogin'];
_d = {};
return [4 /*yield*/, (0, uuid_1.generateNewIdAsync)()];
case 2: return [4 /*yield*/, _b.apply(_a, _c.concat([(_d.id = _e.sent(),
_d.action = 'create',
_d.data = createData,
_d), {
dontCollect: true,
}]))];
case 3:
_e.sent();
return [2 /*return*/, id];
}
});
});
}
exports.createWechatLogin = createWechatLogin;

7
lib/aspects/wechatUser.d.ts vendored Normal file
View File

@ -0,0 +1,7 @@
import { EntityDict } from "../general-app-domain";
import { BackendRuntimeContext } from "../context/BackendRuntimeContext";
export declare function unbindingWechat<ED extends EntityDict, Cxt extends BackendRuntimeContext<ED>>(params: {
wechatUserId: string;
captcha?: string;
mobile?: string;
}, context: Cxt): Promise<void>;

96
lib/aspects/wechatUser.js Normal file
View File

@ -0,0 +1,96 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.unbindingWechat = void 0;
var tslib_1 = require("tslib");
var types_1 = require("oak-domain/lib/types");
var uuid_1 = require("oak-domain/lib/utils/uuid");
var assert_1 = tslib_1.__importDefault(require("assert"));
function unbindingWechat(params, context) {
return tslib_1.__awaiter(this, void 0, void 0, function () {
var wechatUserId, captcha, mobile, fn, result, _a, captchaRow;
var _this = this;
return tslib_1.__generator(this, function (_b) {
switch (_b.label) {
case 0:
wechatUserId = params.wechatUserId, captcha = params.captcha, mobile = params.mobile;
fn = function () { return tslib_1.__awaiter(_this, void 0, void 0, function () {
var userId, _a, wechatUser, _b, _c, _d;
var _e;
return tslib_1.__generator(this, function (_f) {
switch (_f.label) {
case 0:
userId = context.getCurrentUserId();
return [4 /*yield*/, context.select('wechatUser', {
data: {
id: 1,
userId: 1,
},
filter: {
id: wechatUserId,
}
}, {})];
case 1:
_a = tslib_1.__read.apply(void 0, [_f.sent(), 1]), wechatUser = _a[0];
(0, assert_1.default)(wechatUser.userId === userId, '查询到的wechatUser.userId与当前登录者不相同');
_c = (_b = context).operate;
_d = ['wechatUser'];
_e = {};
return [4 /*yield*/, (0, uuid_1.generateNewIdAsync)()];
case 2: return [4 /*yield*/, _c.apply(_b, _d.concat([(_e.id = _f.sent(),
_e.action = 'update',
_e.data = {
userId: null,
},
_e.filter = {
id: wechatUserId,
},
_e), {
dontCollect: true,
}]))];
case 3:
_f.sent();
return [2 /*return*/];
}
});
}); };
if (!(mobile && captcha)) return [3 /*break*/, 2];
return [4 /*yield*/, context.select('captcha', {
data: {
id: 1,
expired: 1,
},
filter: {
mobile: mobile,
code: captcha,
},
sorter: [{
$attr: {
$$createAt$$: 1,
},
$direction: 'desc',
}],
indexFrom: 0,
count: 1,
}, { dontCollect: true })];
case 1:
result = _b.sent();
if (result.length > 0) {
_a = tslib_1.__read(result, 1), captchaRow = _a[0];
if (captchaRow.expired) {
throw new types_1.OakUserException('验证码已经过期');
}
fn();
}
else {
throw new types_1.OakUserException('验证码无效');
}
return [3 /*break*/, 3];
case 2:
fn();
_b.label = 3;
case 3: return [2 /*return*/];
}
});
});
}
exports.unbindingWechat = unbindingWechat;

View File

@ -1,5 +1,6 @@
import React from 'react';
import './index.less';
import { EntityDict } from '../../../general-app-domain';
declare type IQrCodeProps = {
filename?: string;
expiresAt?: number;
@ -9,6 +10,9 @@ declare type IQrCodeProps = {
size?: number;
url: string;
loading?: boolean;
disableDownload?: boolean;
successed?: boolean;
type?: EntityDict['wechatLogin']['Schema']['type'];
};
declare function QrCode(props: IQrCodeProps): JSX.Element;
export default QrCode;

View File

@ -7,12 +7,14 @@ var icons_1 = require("@ant-design/icons");
var dayjs_1 = tslib_1.__importDefault(require("dayjs"));
var qrcode_react_1 = require("qrcode.react");
require("./index.less");
var react_i18next_1 = require("react-i18next");
function isBase64(url) {
return /data:image\/[\w|\W]+(;base64,)[\w|\W]*/.test(url);
}
function QrCode(props) {
var _a = props.filename, filename = _a === void 0 ? 'qrCode.png' : _a, expiresAt = props.expiresAt, tips = props.tips, onDownload = props.onDownload, onRefresh = props.onRefresh, _b = props.size, size = _b === void 0 ? 280 : _b, url = props.url, _c = props.loading, loading = _c === void 0 ? false : _c;
var _a = props.filename, filename = _a === void 0 ? 'qrCode.png' : _a, expiresAt = props.expiresAt, tips = props.tips, onDownload = props.onDownload, onRefresh = props.onRefresh, _b = props.size, size = _b === void 0 ? 280 : _b, url = props.url, _c = props.loading, loading = _c === void 0 ? false : _c, _d = props.disableDownload, disableDownload = _d === void 0 ? false : _d, successed = props.successed, type = props.type;
var prefixCls = 'oak';
var t = (0, react_i18next_1.useTranslation)().t;
var V;
if (expiresAt) {
var diff = (0, dayjs_1.default)(expiresAt).diff((0, dayjs_1.default)(), 'days');
@ -31,11 +33,15 @@ function QrCode(props) {
}
}
}
if (successed) {
return ((0, jsx_runtime_1.jsx)("div", tslib_1.__assign({ className: "".concat(prefixCls, "-qrCodeBox") }, { children: (0, jsx_runtime_1.jsx)(antd_1.Result, { status: "success", title: type === 'bind' ? t('weChat-account-successfully-bound') : t('weChat-authorization-login-successful') }) })));
}
return ((0, jsx_runtime_1.jsxs)("div", tslib_1.__assign({ id: "oakQrCode", className: "".concat(prefixCls, "-qrCodeBox") }, { children: [(0, jsx_runtime_1.jsx)("div", tslib_1.__assign({ className: "".concat(prefixCls, "-qrCodeBox_imgBox"), style: {
width: size,
height: size,
marginBottom: 10,
} }, { children: isBase64(url) ? ((0, jsx_runtime_1.jsx)("img", { src: url, alt: "qrCode", width: size, height: size })) : url ? ((0, jsx_runtime_1.jsx)(qrcode_react_1.QRCodeCanvas, { value: url, size: size })) : null })), V, tips, (0, jsx_runtime_1.jsxs)(antd_1.Space, tslib_1.__assign({ className: "".concat(prefixCls, "-qrCodeBox_actions") }, { children: [!!url && ((0, jsx_runtime_1.jsx)(antd_1.Button, tslib_1.__assign({ type: "text", onClick: function () {
marginBottom: 16,
marginTop: 16,
} }, { children: (0, jsx_runtime_1.jsx)(antd_1.Spin, tslib_1.__assign({ spinning: loading }, { children: isBase64(url) ? ((0, jsx_runtime_1.jsx)("img", { src: url, alt: "qrCode", width: size, height: size })) : url ? ((0, jsx_runtime_1.jsx)(qrcode_react_1.QRCodeCanvas, { value: url, size: size })) : null })) })), V, tips, (0, jsx_runtime_1.jsxs)(antd_1.Space, tslib_1.__assign({ className: "".concat(prefixCls, "-qrCodeBox_actions") }, { children: [!!url && !disableDownload && ((0, jsx_runtime_1.jsx)(antd_1.Button, tslib_1.__assign({ type: "text", onClick: function () {
var _a;
if (typeof onDownload === 'function') {
onDownload(url, filename);

View File

@ -0,0 +1,4 @@
{
"weChat-account-successfully-bound": "微信账号绑定成功",
"weChat-authorization-login-successful": "微信授权登录成功"
}

View File

@ -7,15 +7,21 @@ var web_module_less_1 = tslib_1.__importDefault(require("./web.module.less"));
function Web(props) {
var _a, _b, _c, _d;
var config = props.config, setValue = props.setValue;
var _e = tslib_1.__read(antd_1.message.useMessage(), 1), messageApi = _e[0];
return ((0, jsx_runtime_1.jsxs)(antd_1.Space, tslib_1.__assign({ direction: "vertical", size: "middle", style: { display: 'flex' } }, { children: [(0, jsx_runtime_1.jsx)(antd_1.Row, { children: (0, jsx_runtime_1.jsx)(antd_1.Card, tslib_1.__assign({ className: web_module_less_1.default.tips }, { children: "\u6BCF\u79CD\u5747\u53EF\u914D\u7F6E\u4E00\u4E2A\uFF0C\u76F8\u5E94\u7684\u670D\u52A1\u6240\u4F7F\u7528\u7684\u5E10\u53F7\u8BF7\u51C6\u786E\u5BF9\u5E94" })) }), (0, jsx_runtime_1.jsxs)(antd_1.Col, tslib_1.__assign({ flex: "auto" }, { children: [(0, jsx_runtime_1.jsx)(antd_1.Divider, tslib_1.__assign({ orientation: "left", className: web_module_less_1.default.title }, { children: "\u7F51\u7AD9-\u5FAE\u4FE1\u626B\u7801" })), (0, jsx_runtime_1.jsxs)(antd_1.Form, tslib_1.__assign({ colon: true, labelAlign: "left", layout: "vertical", style: { marginTop: 10 } }, { children: [(0, jsx_runtime_1.jsx)(antd_1.Form.Item, tslib_1.__assign({ label: "appId", name: "appId" }, { children: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsx)(antd_1.Input, { placeholder: "\u8BF7\u8F93\u5165appId", type: "text", value: (_a = config === null || config === void 0 ? void 0 : config.wechat) === null || _a === void 0 ? void 0 : _a.appId, onChange: function (e) {
return setValue("wechat.appId", e.target.value);
} }) }) })), (0, jsx_runtime_1.jsx)(antd_1.Form.Item, tslib_1.__assign({ label: "appSecret", name: "appSecret" }, { children: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsx)(antd_1.Input, { placeholder: "\u8BF7\u8F93\u5165appSecret", type: "text", value: (_b = config === null || config === void 0 ? void 0 : config.wechat) === null || _b === void 0 ? void 0 : _b.appSecret, onChange: function (e) {
return setValue("wechat.appSecret", e.target.value);
} }) }) })), (0, jsx_runtime_1.jsx)(antd_1.Form.Item, tslib_1.__assign({ label: "\u6388\u6743\u56DE\u8C03\u57DF", name: "domain", tooltip: "\u6388\u6743\u56DE\u8C03\u57DF\u53EF\u9009\u586B\uFF0C\u672A\u586B\u5199\u7684\u8BDD\uFF0C\u4F7F\u7528\u7F51\u9875\u8BBF\u95EE\u7684\u57DF\u540D\u5F53\u4F5C\u6388\u6743\u56DE\u8C03\u57DF" }, { children: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsx)(antd_1.Input, { placeholder: "\u8BF7\u8F93\u5165\u6388\u6743\u56DE\u8C03\u57DF", type: "text", value: (_c = config === null || config === void 0 ? void 0 : config.wechat) === null || _c === void 0 ? void 0 : _c.domain, onChange: function (e) {
return setValue("wechat.domain", e.target.value);
} }) }) })), (0, jsx_runtime_1.jsx)(antd_1.Form.Item, tslib_1.__assign({ label: "\u662F\u5426\u5F00\u542F", name: "enable", tooltip: "\u7F51\u9875\u5FAE\u4FE1\u626B\u7801\u767B\u5F55\u662F\u5426\u5F00\u542F\uFF0C\u5982\u679C\u4E0D\u5F00\u542F\uFF0C\u767B\u5F55\u9875\u4E0D\u4F1A\u51FA\u73B0\u5FAE\u4FE1\u626B\u7801\u5165\u53E3" }, { children: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsx)(antd_1.Switch, { checkedChildren: "\u662F", unCheckedChildren: "\u5426", checked: (_d = config === null || config === void 0 ? void 0 : config.wechat) === null || _d === void 0 ? void 0 : _d.enable, onChange: function (checked) {
} }) }) })), (0, jsx_runtime_1.jsx)(antd_1.Form.Item, tslib_1.__assign({ label: "\u5FAE\u4FE1\u7F51\u7AD9\u5E94\u7528\u6388\u6743\u767B\u5F55", name: "enable", tooltip: "\u5F00\u542F\u540E\uFF0C\u767B\u5F55\u9875\u663E\u793A\u5FAE\u4FE1\u626B\u7801\u5165\u53E3\uFF0C\u5FAE\u4FE1\u626B\u7801\u540E\u4F7F\u7528\u5FAE\u4FE1\u7F51\u7AD9\u5E94\u7528\u6388\u6743\u767B\u5F55", help: "\u5F00\u542F\u5F53\u524D\u767B\u5F55\u65B9\u5F0F\u65F6\uFF0C\u5C06\u540C\u65F6\u5173\u95ED\u5FAE\u4FE1\u516C\u4F17\u53F7\u626B\u7801\u767B\u5F55" }, { children: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsx)(antd_1.Switch, { checkedChildren: "\u662F", unCheckedChildren: "\u5426", checked: (_d = config === null || config === void 0 ? void 0 : config.wechat) === null || _d === void 0 ? void 0 : _d.enable, onChange: function (checked) {
return setValue("wechat.enable", checked);
} }) }) }))] }))] })), (0, jsx_runtime_1.jsxs)(antd_1.Col, tslib_1.__assign({ flex: "auto" }, { children: [(0, jsx_runtime_1.jsx)(antd_1.Divider, tslib_1.__assign({ orientation: "left", className: web_module_less_1.default.title }, { children: "\u7F51\u7AD9-\u6388\u6743\u65B9\u5F0F" })), (0, jsx_runtime_1.jsx)(antd_1.Form, tslib_1.__assign({ colon: true, labelAlign: "left", layout: "vertical", style: { marginTop: 10 } }, { children: (0, jsx_runtime_1.jsx)(antd_1.Form.Item, tslib_1.__assign({ label: "passport", name: "passport" }, { children: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsx)(antd_1.Select, { mode: "multiple", allowClear: true, style: { width: '100%' }, placeholder: "\u8BF7\u9009\u62E9\u6388\u6743\u65B9\u5F0F", value: config === null || config === void 0 ? void 0 : config.passport, onChange: function (value) {
if (value.includes('wechat') && value.includes('wechatPublic')) {
// messageApi.warning('微信网站和微信公众号中,只能选择一个');
antd_1.message.warning('微信网站和微信公众号中,只能选择一个');
return;
}
setValue("passport", value);
}, options: [
{
@ -27,9 +33,13 @@ function Web(props) {
value: 'mobile',
},
{
label: '微信二维码',
label: '微信网站',
value: 'wechat',
},
{
label: '微信公众号',
value: 'wechatPublic',
},
] }) }) })) }))] }))] })));
}
exports.default = Web;

View File

@ -19,7 +19,31 @@ function WechatPublic(props) {
return setValue("originalId", e.target.value);
} }) }) })), isService && ((0, jsx_runtime_1.jsx)(antd_1.Form.Item, tslib_1.__assign({ label: "\u662F\u5426\u4E3A\u670D\u52A1\u53F7", name: "isService" }, { children: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsx)(antd_1.Switch, { checkedChildren: "\u662F", unCheckedChildren: "\u5426", checked: config === null || config === void 0 ? void 0 : config.isService, onChange: function (checked) {
return setValue("isService", checked);
} }) }) })))] }))] })), (0, jsx_runtime_1.jsxs)(antd_1.Col, tslib_1.__assign({ flex: "auto" }, { children: [(0, jsx_runtime_1.jsx)(antd_1.Divider, tslib_1.__assign({ orientation: "left", className: web_module_less_1.default.title }, { children: "\u5FAE\u4FE1\u516C\u4F17\u53F7-\u8DF3\u8F6C\u5C0F\u7A0B\u5E8F-\u5C0F\u7A0B\u5E8F\u914D\u7F6E" })), (0, jsx_runtime_1.jsxs)(antd_1.Form, tslib_1.__assign({ colon: true, labelAlign: "left", layout: "vertical", style: { marginTop: 10 } }, { children: [(0, jsx_runtime_1.jsx)(antd_1.Form.Item, tslib_1.__assign({ label: "appId", name: "appId" }, { children: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsx)(antd_1.Input, { placeholder: "\u8BF7\u8F93\u5165appId", type: "text", value: (_a = config === null || config === void 0 ? void 0 : config.wechatMp) === null || _a === void 0 ? void 0 : _a.appId, onChange: function (e) {
} }) }) })))] }))] })), (0, jsx_runtime_1.jsxs)(antd_1.Col, tslib_1.__assign({ flex: "auto" }, { children: [(0, jsx_runtime_1.jsx)(antd_1.Divider, tslib_1.__assign({ orientation: "left", className: web_module_less_1.default.title }, { children: "\u7F51\u7AD9-\u6388\u6743\u65B9\u5F0F" })), (0, jsx_runtime_1.jsx)(antd_1.Form, tslib_1.__assign({ colon: true, labelAlign: "left", layout: "vertical", style: { marginTop: 10 } }, { children: (0, jsx_runtime_1.jsx)(antd_1.Form.Item, tslib_1.__assign({ label: "passport", name: "passport" }, { children: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsx)(antd_1.Select, { mode: "multiple", allowClear: true, style: { width: '100%' }, placeholder: "\u8BF7\u9009\u62E9\u6388\u6743\u65B9\u5F0F", value: config === null || config === void 0 ? void 0 : config.passport, onChange: function (value) {
if (value.includes('wechat') && value.includes('wechatPublic')) {
// messageApi.warning('微信网站和微信公众号中,只能选择一个');
antd_1.message.warning('微信网站和微信公众号中,只能选择一个');
return;
}
setValue("passport", value);
}, options: [
{
label: '邮箱',
value: 'email',
},
{
label: '手机号',
value: 'mobile',
},
{
label: '微信网站',
value: 'wechat',
},
{
label: '微信公众号',
value: 'wechatPublic',
},
] }) }) })) }))] })), (0, jsx_runtime_1.jsxs)(antd_1.Col, tslib_1.__assign({ flex: "auto" }, { children: [(0, jsx_runtime_1.jsx)(antd_1.Divider, tslib_1.__assign({ orientation: "left", className: web_module_less_1.default.title }, { children: "\u5FAE\u4FE1\u516C\u4F17\u53F7-\u8DF3\u8F6C\u5C0F\u7A0B\u5E8F-\u5C0F\u7A0B\u5E8F\u914D\u7F6E" })), (0, jsx_runtime_1.jsxs)(antd_1.Form, tslib_1.__assign({ colon: true, labelAlign: "left", layout: "vertical", style: { marginTop: 10 } }, { children: [(0, jsx_runtime_1.jsx)(antd_1.Form.Item, tslib_1.__assign({ label: "appId", name: "appId" }, { children: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsx)(antd_1.Input, { placeholder: "\u8BF7\u8F93\u5165appId", type: "text", value: (_a = config === null || config === void 0 ? void 0 : config.wechatMp) === null || _a === void 0 ? void 0 : _a.appId, onChange: function (e) {
return setValue("wechatMp.appId", e.target.value);
} }) }) })), (0, jsx_runtime_1.jsx)(antd_1.Form.Item, tslib_1.__assign({ label: "\u539F\u59CBID", name: "originalId", tooltip: "\u539F\u59CBID" }, { children: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsx)(antd_1.Input, { placeholder: "\u8BF7\u8F93\u5165\u539F\u59CBID", type: "text", value: (_b = config === null || config === void 0 ? void 0 : config.wechatMp) === null || _b === void 0 ? void 0 : _b.originalId, onChange: function (e) {
return setValue("wechatMp.originalId", e.target.value);

View File

@ -0,0 +1,13 @@
import { EntityDict } from '../../../general-app-domain';
import { EntityDict as BaseEntityDict } from 'oak-domain/lib/types/Entity';
import { ReactComponentProps } from 'oak-frontend-base/lib/types/Page';
declare const _default: <ED2 extends EntityDict & BaseEntityDict, T2 extends keyof ED2>(props: ReactComponentProps<ED2, T2, true, {
type: string;
origin: string;
tag1: string;
tag2: string;
entity: keyof ED2;
entityId: string;
imgUrls: string[];
}>) => React.ReactElement;
export default _default;

View File

@ -0,0 +1,293 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var uuid_1 = require("oak-domain/lib/utils/uuid");
var assert_1 = tslib_1.__importDefault(require("assert"));
var lodash_1 = require("oak-domain/lib/utils/lodash");
exports.default = OakComponent({
entity: 'extraFile',
isList: true,
projection: {
id: 1,
tag1: 1,
tag2: 1,
origin: 1,
bucket: 1,
objectId: 1,
filename: 1,
extra1: 1,
extension: 1,
type: 1,
entity: 1,
entityId: 1,
fileType: 1,
sort: 1,
isBridge: 1,
},
filters: [
{
filter: function () {
var _a = this.props, tag1 = _a.tag1, tag2 = _a.tag2;
var filter1 = {};
if (tag1) {
Object.assign(filter1, { tag1: tag1 });
}
if (tag2) {
Object.assign(filter1, { tag2: tag2 });
}
return filter1;
},
},
],
formData: function (_a) {
var _this = this;
var _b, _c;
var originalFiles = _a.data, features = _a.features;
var file;
var notDeleteFiles = originalFiles === null || originalFiles === void 0 ? void 0 : originalFiles.filter(function (ele) { return !ele.$$deleteAt$$; });
if (this.props.tag1) {
file = (_b = notDeleteFiles === null || notDeleteFiles === void 0 ? void 0 : notDeleteFiles.filter(function (ele) { return (ele === null || ele === void 0 ? void 0 : ele.tag1) === _this.props.tag1; })) === null || _b === void 0 ? void 0 : _b[0];
}
if (this.props.tag2) {
file = (_c = notDeleteFiles === null || notDeleteFiles === void 0 ? void 0 : notDeleteFiles.filter(function (ele) { return (ele === null || ele === void 0 ? void 0 : ele.tag2) === _this.props.tag2; })) === null || _c === void 0 ? void 0 : _c[0];
}
return {
file: file,
src: features.extraFile.getUrl(file),
isBridge: file === null || file === void 0 ? void 0 : file.isBridge,
};
},
data: {
isModalOpen: false,
isModalOpen1: false,
renderImgs: [],
methodsType: '',
bridgeUrl: '',
selectedId: -1,
},
properties: {
type: '',
tag1: '',
tag2: '',
entity: '',
entityId: '',
imgUrls: [],
},
lifetimes: {},
listeners: {
imgUrls: function (prev, next) {
return tslib_1.__awaiter(this, void 0, void 0, function () {
return tslib_1.__generator(this, function (_a) {
// 因为imgUrls是从请求来的 它有可能比上边的src listener中的getBridgeUrl慢
// 所以此处增加前后项imgUrls里都有值且不等的条件再去clean
if ((prev === null || prev === void 0 ? void 0 : prev.imgUrls.length) && (next === null || next === void 0 ? void 0 : next.imgUrls.length) && !(0, lodash_1.isEqual)(prev.imgUrls, next.imgUrls)) {
this.clean();
}
return [2 /*return*/];
});
});
}
},
methods: {
chooseMethod: function (method) {
return tslib_1.__awaiter(this, void 0, void 0, function () {
var fileInput_1, imgElement, imgUrls, renderImgs, renderImgs2, i, renderUrl, isWechatUrl;
var _this = this;
return tslib_1.__generator(this, function (_a) {
switch (method) {
case 'uploadLocalImg':
fileInput_1 = document.createElement('input');
imgElement = document.getElementById('previewImg');
fileInput_1.type = 'file';
fileInput_1.accept = 'image/png, image/jpeg';
fileInput_1.style.display = 'none';
fileInput_1.addEventListener('change', function (e) {
if (!fileInput_1.files || fileInput_1.files.length === 0) {
return;
}
_this.myUpdateItem(fileInput_1.files[0]);
});
fileInput_1.click();
this.setState({
methodsType: method
});
this.setSelectedId(-1);
break;
case 'url':
this.setState({
isModalOpen: true,
methodsType: method
});
break;
case 'original':
this.setState({
isModalOpen1: true,
methodsType: method
});
imgUrls = this.props.imgUrls;
renderImgs = this.state.renderImgs;
renderImgs2 = new (Array.bind.apply(Array, tslib_1.__spreadArray([void 0], tslib_1.__read(renderImgs), false)))();
if (imgUrls && imgUrls.length) {
for (i = 0; i < imgUrls.length; i++) {
if (renderImgs2[i] && renderImgs2[i].originUrl === imgUrls[i]) {
return [2 /*return*/];
}
else if (renderImgs2[i] && renderImgs2[i].originUrl !== imgUrls[i]) {
renderImgs2 = [];
}
renderUrl = void 0;
isWechatUrl = this.isWechatUrlFn(imgUrls[i]);
if (isWechatUrl) {
renderUrl = this.features.extraFile.getUrl({ isBridge: true, extra1: imgUrls[i] });
}
else {
renderUrl = imgUrls[i];
}
renderImgs2.push({
renderUrl: renderUrl,
originUrl: imgUrls[i],
id: i,
isBridge: isWechatUrl
});
}
this.setState({
renderImgs: renderImgs2,
});
}
break;
}
return [2 /*return*/];
});
});
},
closeModal: function () {
this.setState({
isModalOpen: false,
});
},
closeModal1: function () {
this.setState({
isModalOpen1: false,
});
},
createExtraFileData: function (params) {
var methodsType = this.state.methodsType;
var _a = this.props, tag1 = _a.tag1, tag2 = _a.tag2, entity = _a.entity, entityId = _a.entityId;
var extension = '';
var filename = '';
var createData = {
extra1: params,
entity: entity,
entityId: entityId,
type: 'image',
tag1: tag1,
tag2: tag2,
objectId: (0, uuid_1.generateNewId)(),
bucket: '',
id: (0, uuid_1.generateNewId)(),
};
(0, assert_1.default)(entity, '必须传入entity');
switch (methodsType) {
case 'uploadLocalImg':
var _b = params, name_1 = _b.name, size = _b.size, type = _b.type;
extension = name_1.substring(name_1.lastIndexOf('.') + 1);
filename = name_1.substring(0, name_1.lastIndexOf('.'));
Object.assign(createData, {
origin: 'qiniu',
extension: extension,
filename: filename,
size: size,
fileType: type,
});
break;
case 'url':
Object.assign(createData, {
origin: 'unknown',
extension: extension,
filename: filename,
isBridge: this.isWechatUrlFn(params)
});
break;
case 'original':
Object.assign(createData, {
origin: 'unknown',
extension: extension,
filename: filename,
isBridge: this.isWechatUrlFn(params)
});
break;
}
return createData;
},
myAddItem: function (createData) {
return tslib_1.__awaiter(this, void 0, void 0, function () {
var methodsType;
var _this = this;
return tslib_1.__generator(this, function (_a) {
methodsType = this.state.methodsType;
this.addItem(createData, function () { return tslib_1.__awaiter(_this, void 0, void 0, function () {
var bucket;
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {
case 0:
if (createData.bucket) {
// 说明本函数已经执行过了
return [2 /*return*/];
}
if (!(methodsType === 'uploadLocalImg')) return [3 /*break*/, 2];
return [4 /*yield*/, this.features.extraFile.upload(createData)];
case 1:
bucket = (_a.sent()).bucket;
Object.assign(createData, {
bucket: bucket,
extra1: null,
});
_a.label = 2;
case 2: return [2 /*return*/];
}
});
}); });
return [2 /*return*/];
});
});
},
myUpdateItem: function (params) {
return tslib_1.__awaiter(this, void 0, void 0, function () {
var file, createData;
return tslib_1.__generator(this, function (_a) {
file = this.state.file;
if (file) {
this.removeItem(file.id);
}
if (!!params) {
createData = this.createExtraFileData(params);
this.myAddItem(createData);
}
return [2 /*return*/];
});
});
},
onModalConfirm: function (value) {
var reg = new RegExp(/(http|https):\/\/(\w+:{0,1}\w*)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%!\-\/]))?/);
if (!reg.test(value)) {
return;
}
this.myUpdateItem(value);
this.setSelectedId(-1);
},
onModal1Confirm: function (value) {
var renderImgs = this.state.renderImgs;
var img = renderImgs.find(function (ele) { return ele.id === value; });
this.myUpdateItem(img === null || img === void 0 ? void 0 : img.originUrl);
this.closeModal1();
},
isWechatUrlFn: function (url) {
return (url.startsWith('https://mmbiz.qpic.cn') || url.startsWith('http://mmbiz.qpic.cn'));
},
setSelectedId: function (id) {
this.setState({
selectedId: id
});
}
}
});

View File

@ -0,0 +1,8 @@
{
"component": true,
"usingComponents": {
"l-icon": "@oak-frontend-base/miniprogram_npm/lin-ui/icon/index",
"l-button": "@oak-frontend-base/miniprogram_npm/lin-ui/button/index",
"oak-display": "../display/index"
}
}

View File

@ -0,0 +1,7 @@
{
"original": "从原文中选取",
"url": "图片链接",
"uploadLocalImg": "上传本地图片",
"fillInImageLink": "填写图片链接",
"chooseImage": "选择图片"
}

View File

@ -0,0 +1,23 @@
import { WebComponentProps } from "oak-frontend-base";
import { EntityDict } from "../../../general-app-domain";
declare type MethodsType = 'original' | 'url' | 'uploadLocalImg';
export default function render(props: WebComponentProps<EntityDict, "extraFile", true, {
src: string;
bridgeUrl: string;
isModalOpen: boolean;
isModalOpen1: boolean;
renderImgs: {
renderUrl: string;
originUrl: string;
id: number;
}[];
selectedId: number;
}, {
onModalConfirm: (value: string) => void;
chooseMethod: (method: MethodsType) => void;
closeModal1: () => void;
closeModal: () => void;
onModal1Confirm: (value: number) => void;
setSelectedId: (id: number) => void;
}>): JSX.Element;
export {};

View File

@ -0,0 +1,44 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var jsx_runtime_1 = require("react/jsx-runtime");
var antd_1 = require("antd");
var icons_1 = require("@ant-design/icons");
var web_module_less_1 = tslib_1.__importDefault(require("./web.module.less"));
var imgBox_1 = tslib_1.__importDefault(require("oak-frontend-base/src/components/imgBox"));
function render(props) {
var _a = props.data, isModalOpen = _a.isModalOpen, isModalOpen1 = _a.isModalOpen1, renderImgs = _a.renderImgs, src = _a.src, bridgeUrl = _a.bridgeUrl, selectedId = _a.selectedId;
var _b = props.methods, t = _b.t, onModalConfirm = _b.onModalConfirm, chooseMethod = _b.chooseMethod, closeModal1 = _b.closeModal1, closeModal = _b.closeModal, onModal1Confirm = _b.onModal1Confirm, setSelectedId = _b.setSelectedId;
var methods = ['original', 'url', 'uploadLocalImg'];
var _c = tslib_1.__read(antd_1.Form.useForm(), 1), form = _c[0];
var handleOk = function () {
onModalConfirm(form.getFieldValue('url'));
form.setFieldValue('url', '');
closeModal();
};
return ((0, jsx_runtime_1.jsxs)("div", tslib_1.__assign({ className: web_module_less_1.default.imgBox }, { children: [(0, jsx_runtime_1.jsxs)(antd_1.Space, tslib_1.__assign({ direction: "vertical", size: 4 }, { children: [(0, jsx_runtime_1.jsx)(icons_1.PlusOutlined, {}), (0, jsx_runtime_1.jsx)("div", { children: "\u9009\u62E9\u5C01\u9762" })] })), (0, jsx_runtime_1.jsx)("img", { id: "previewImg", src: src, alt: "previewImg", className: web_module_less_1.default.previewImg, style: { display: src ? 'inline-block' : 'none' } }), (0, jsx_runtime_1.jsx)("div", tslib_1.__assign({ className: web_module_less_1.default.methodList }, { children: methods && methods.map(function (ele) { return ((0, jsx_runtime_1.jsx)("div", tslib_1.__assign({ className: web_module_less_1.default.methodListItem, onClick: function () {
chooseMethod(ele);
} }, { children: t(ele) }))); }) })), (0, jsx_runtime_1.jsx)(antd_1.Modal, tslib_1.__assign({ title: t('fillInImageLink'), open: isModalOpen, onOk: handleOk, onCancel: closeModal }, { children: (0, jsx_runtime_1.jsx)(antd_1.Form, tslib_1.__assign({ form: form, className: web_module_less_1.default.formMT }, { children: (0, jsx_runtime_1.jsx)(antd_1.Form.Item, tslib_1.__assign({ name: "url", rules: [
{
required: true,
message: '外部链接不能为空',
},
{
pattern: /(http|https):\/\/(\w+:{0,1}\w*)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%!\-\/]))?/,
message: '请输入正确的外链',
}
] }, { children: (0, jsx_runtime_1.jsx)(antd_1.Input, { onChange: function (_a) {
var value = _a.target.value;
form.setFieldValue('url', value);
}, placeholder: '\u5982\uFF1Ahttps://www.xxx.com' }) })) })) })), (0, jsx_runtime_1.jsx)(antd_1.Modal, tslib_1.__assign({ width: 800, title: t('chooseImage'), open: isModalOpen1, onOk: function () { return onModal1Confirm(selectedId); }, onCancel: closeModal1 }, { children: (renderImgs && renderImgs.length) ? ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsx)(antd_1.Row, tslib_1.__assign({ gutter: [4, 4] }, { children: renderImgs.map(function (img) {
return (0, jsx_runtime_1.jsx)(antd_1.Col, tslib_1.__assign({ span: 4 }, { children: (0, jsx_runtime_1.jsx)(imgBox_1.default, { width: "100%", bordered: true, mode: "select", src: img.renderUrl, selected: selectedId === img.id, onClick: function () {
if (selectedId === img.id) {
setSelectedId(-1);
}
else {
setSelectedId(img.id);
}
} }, img.id) }));
}) })) })) : ((0, jsx_runtime_1.jsx)(antd_1.Empty, { image: antd_1.Empty.PRESENTED_IMAGE_SIMPLE })) }))] })));
}
exports.default = render;

View File

@ -0,0 +1,59 @@
.imgBox {
width: 220px;
height: 100px;
position: relative;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
cursor: pointer;
color: #888;
box-sizing: border-box;
border: 2px dashed #EBEBEB;
border-radius: 8px;
text-align: center;
transition: all 0.1s;
}
.methodList {
width: 160px;
padding: 8px 0px;
border-radius: 8px;
position: absolute;
top: 50%;
left: 50%;
transform: translateX(-50%);
display: none;
flex-direction: column;
box-shadow: 0px 3px 3px -2px rgba(0,0,0,0.2),0px 3px 4px 0px rgba(0,0,0,0.14),0px 1px 8px 0px rgba(0,0,0,0.12);
background-color: #fff;
z-index: 10;
.methodListItem {
cursor: pointer;
padding: 4px 0px;
}
.methodListItem:hover {
background-color: #f6f7f8;
}
}
.imgBox:hover .methodList,
.methodList:hover {
display: flex;
}
.previewImg {
width: 100%;
height: 100px;
object-fit: contain;
position: absolute;
top: 50%;
transform: translateY(-50%);
right: 0;
left: 0;
bottom: 0;
}
.formMT {
margin-top: 16px;
}

View File

@ -21,11 +21,13 @@ exports.default = OakComponent({
entity: 1,
entityId: 1,
fileType: 1,
sort: 1,
isBridge: 1,
},
formData: function (_a) {
var _this = this;
var originalFiles = _a.data, features = _a.features;
var files = originalFiles === null || originalFiles === void 0 ? void 0 : originalFiles.filter(function (ele) { return !ele.$$deleteAt$$; });
var files = originalFiles === null || originalFiles === void 0 ? void 0 : originalFiles.filter(function (ele) { return !ele.$$deleteAt$$; }).sort(function (ele1, ele2) { return ele1.sort - ele2.sort; });
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; });
}
@ -257,27 +259,32 @@ exports.default = OakComponent({
},
onPickByWeb: function (uploadFiles, callback) {
return tslib_1.__awaiter(this, void 0, void 0, function () {
var files, currentSort;
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, type, size, originFileObj;
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {
case 0:
name = uploadFile.name, type = uploadFile.type, size = uploadFile.size, originFileObj = uploadFile.originFileObj;
return [4 /*yield*/, this.pushExtraFile({
name: name,
fileType: type,
size: size,
extra1: originFileObj,
}, callback)];
case 1:
_a.sent();
return [2 /*return*/];
}
});
}); }))];
case 0:
files = this.state.files;
currentSort = (files === null || files === void 0 ? void 0 : files.length) ? files[files.length - 1].sort : 0;
return [4 /*yield*/, Promise.all(uploadFiles.map(function (uploadFile, index) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
var name, type, size, originFileObj;
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {
case 0:
name = uploadFile.name, type = uploadFile.type, size = uploadFile.size, originFileObj = uploadFile.originFileObj;
return [4 /*yield*/, this.pushExtraFile({
name: name,
fileType: type,
size: size,
extra1: originFileObj,
sort: currentSort + (index + 1) * 100
}, callback)];
case 1:
_a.sent();
return [2 /*return*/];
}
});
}); }))];
case 1:
_a.sent();
return [2 /*return*/];
@ -287,13 +294,13 @@ exports.default = OakComponent({
},
pushExtraFile: function (options, callback) {
return tslib_1.__awaiter(this, void 0, void 0, function () {
var _a, type, origin, tag1, tag2, entity, entityId, autoUpload, name, extra1, fileType, size, extension, filename, updateData, bucket, error_1;
var _a, type, origin, tag1, tag2, entity, entityId, autoUpload, name, extra1, fileType, size, sort, extension, filename, updateData, bucket, error_1;
var _this = this;
return tslib_1.__generator(this, function (_b) {
switch (_b.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;
name = options.name, extra1 = options.extra1, fileType = options.fileType, size = options.size, sort = options.sort;
extension = name.substring(name.lastIndexOf('.') + 1);
filename = name.substring(0, name.lastIndexOf('.'));
(0, assert_1.default)(entity, '必须传入entity');
@ -312,6 +319,7 @@ exports.default = OakComponent({
fileType: fileType,
id: (0, uuid_1.generateNewId)(),
entityId: entityId,
sort: sort
};
if (!autoUpload) return [3 /*break*/, 6];
if (callback) {

View File

@ -1,8 +1,8 @@
import { UploadFile } from 'antd';
import { WebComponentProps } from 'oak-frontend-base';
import { EntityDict } from '../../../general-app-domain';
declare type Theme = 'file' | 'image' | 'image-flow' | 'custom';
export default function render(props: WebComponentProps<EntityDict, 'extraFile', true, {
import { UploadFile } from "antd";
import { WebComponentProps } from "oak-frontend-base";
import { EntityDict } from "../../../general-app-domain";
declare type Theme = "file" | "image" | "image-flow" | "custom";
export default function render(props: WebComponentProps<EntityDict, "extraFile", true, {
accept?: string;
maxNumber?: number;
multiple?: boolean;
@ -18,7 +18,7 @@ export default function render(props: WebComponentProps<EntityDict, 'extraFile',
onDownload?: (file: UploadFile<any>) => void;
showUploadList?: boolean;
children?: JSX.Element;
files?: EntityDict['extraFile']['OpSchema'][];
files?: EntityDict["extraFile"]["OpSchema"][];
disableInsert?: boolean;
disableAdd?: boolean;
disableDownload?: boolean;

View File

@ -2,26 +2,61 @@
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_1 = tslib_1.__importStar(require("react"));
var antd_1 = require("antd");
var icons_1 = require("@ant-design/icons");
var utils_1 = require("antd/es/upload/utils");
var classnames_1 = tslib_1.__importDefault(require("classnames"));
var web_module_less_1 = tslib_1.__importDefault(require("./web.module.less"));
var useFeatures_1 = tslib_1.__importDefault(require("../../../hooks/useFeatures"));
var react_dnd_1 = require("react-dnd");
var react_dnd_html5_backend_1 = require("react-dnd-html5-backend");
var react_dnd_touch_backend_1 = require("react-dnd-touch-backend");
var utils_2 = require("../../../../../oak-frontend-base/lib/utils/utils");
function getListType(theme) {
var themeMap = {
file: 'text',
image: 'picture-card',
'image-flow': 'picture',
custom: 'text',
file: "text",
image: "picture-card",
"image-flow": "picture",
custom: "text",
};
return themeMap[theme];
}
var type = "DragableUploadList";
var DragableUploadListItem = function (_a) {
var originNode = _a.originNode, moveRow = _a.moveRow, file = _a.file, fileList = _a.fileList;
var ref = react_1.default.useRef(null);
var index = fileList.indexOf(file);
var _b = tslib_1.__read((0, react_dnd_1.useDrop)({
accept: type,
collect: function (monitor) {
var dragIndex = (monitor.getItem() || {}).index;
if (dragIndex === index) {
return {};
}
return {
isOver: monitor.isOver(),
dropClassName: dragIndex < index ? " drop-over-downward" : " drop-over-upward",
};
},
drop: function (item) {
moveRow(item.index, index);
},
}), 2), _c = _b[0], isOver = _c.isOver, dropClassName = _c.dropClassName, drop = _b[1];
var _d = tslib_1.__read((0, react_dnd_1.useDrag)({
type: type,
item: { index: index },
collect: function (monitor) { return ({
isDragging: monitor.isDragging(),
}); },
}), 2), drag = _d[1];
drop(drag(ref));
return ((0, jsx_runtime_1.jsx)("div", tslib_1.__assign({ ref: ref, className: "ant-upload-draggable-list-item ".concat(isOver ? dropClassName : ""), style: { cursor: "move", height: "100%" } }, { children: originNode })));
};
function render(props) {
var _this = this;
var _a = props.data, _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 ? maxNumber !== 1 : _d, _e = _a.draggable, draggable = _e === void 0 ? false : _e, _f = _a.theme, theme = _f === void 0 ? 'image' : _f, tips = _a.tips, beforeUpload = _a.beforeUpload, disabled = _a.disabled, style = _a.style, className = _a.className, _g = _a.directory, directory = _g === void 0 ? false : _g, onPreview = _a.onPreview, onDownload = _a.onDownload, children = _a.children, _h = _a.showUploadList, showUploadList = _h === void 0 ? true : _h, files = _a.files, _j = _a.disableInsert, disableInsert = _j === void 0 ? false : _j, _k = _a.disableAdd, disableAdd = _k === void 0 ? false : _k, _l = _a.disableDownload, disableDownload = _l === void 0 ? false : _l, _m = _a.disableDelete, disableDelete = _m === void 0 ? false : _m, _o = _a.preview, preview = _o === void 0 ? true : _o;
var _p = props.methods, onPickByWeb = _p.onPickByWeb, onDeleteByWeb = _p.onDeleteByWeb;
var _a = props.data, _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 ? maxNumber !== 1 : _d, _e = _a.draggable, draggable = _e === void 0 ? false : _e, _f = _a.theme, theme = _f === void 0 ? "image" : _f, tips = _a.tips, beforeUpload = _a.beforeUpload, disabled = _a.disabled, style = _a.style, className = _a.className, _g = _a.directory, directory = _g === void 0 ? false : _g, onPreview = _a.onPreview, onDownload = _a.onDownload, children = _a.children, _h = _a.showUploadList, showUploadList = _h === void 0 ? true : _h, files = _a.files, _j = _a.disableInsert, disableInsert = _j === void 0 ? false : _j, _k = _a.disableAdd, disableAdd = _k === void 0 ? false : _k, _l = _a.disableDownload, disableDownload = _l === void 0 ? false : _l, _m = _a.disableDelete, disableDelete = _m === void 0 ? false : _m, _o = _a.preview, preview = _o === void 0 ? true : _o;
var _p = props.methods, onPickByWeb = _p.onPickByWeb, onDeleteByWeb = _p.onDeleteByWeb, updateItem = _p.updateItem;
var features = (0, useFeatures_1.default)();
var _q = tslib_1.__read((0, react_1.useState)([]), 2), newFiles = _q[0], setNewFiles = _q[1];
var _r = tslib_1.__read((0, react_1.useState)([]), 2), newUploadFiles = _r[0], setNewUploadFiles = _r[1];
@ -67,100 +102,134 @@ function render(props) {
if (children) {
return children;
}
if (listType === 'picture-card') {
if (listType === "picture-card") {
return ((0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)(icons_1.PlusOutlined, {}), (0, jsx_runtime_1.jsx)("div", tslib_1.__assign({ style: { marginTop: 8 } }, { children: "\u8BF7\u9009\u62E9\u56FE\u7247" }))] }));
}
return (0, jsx_runtime_1.jsx)(antd_1.Button, tslib_1.__assign({ type: "default" }, { children: "\u9009\u62E9\u6587\u4EF6" }));
};
return ((0, jsx_runtime_1.jsxs)(antd_1.Space, tslib_1.__assign({ direction: "vertical", className: web_module_less_1.default['oak-upload'], style: { width: '100%' } }, { children: [(0, jsx_runtime_1.jsx)(antd_1.Upload, tslib_1.__assign({ className: (0, classnames_1.default)(web_module_less_1.default['oak-upload__upload'], className), style: style, disabled: disabled, directory: directory, showUploadList: showUploadList
? {
showPreviewIcon: preview,
showRemoveIcon: !disableDelete,
showDownloadIcon: !disableDownload,
}
: false, beforeUpload: function (file) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
var result;
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {
case 0:
if (!(typeof beforeUpload === 'function')) return [3 /*break*/, 2];
return [4 /*yield*/, beforeUpload(file)];
case 1:
result = _a.sent();
if (result) {
return [2 /*return*/, false];
}
_a.label = 2;
case 2: return [2 /*return*/, false];
var checkLimit = function (num) {
var pattern = /^\d+\.(?:9+)$/;
return pattern.test(num.toString());
};
var moveRow = (0, react_1.useCallback)(function (dragIndex, hoverIndex) {
var dragRow = newFiles[dragIndex];
var sort;
if (hoverIndex === dragIndex) {
return;
}
else if (hoverIndex > dragIndex) {
if (hoverIndex === newFiles.length - 1) {
sort = newFiles[hoverIndex].sort + 100;
}
else {
sort = (newFiles[hoverIndex].sort + newFiles[hoverIndex + 1].sort) / 2;
}
}
else {
if (hoverIndex === 0) {
sort = newFiles[hoverIndex].sort / 2;
}
else {
sort = (newFiles[hoverIndex].sort + newFiles[hoverIndex - 1].sort) / 2;
}
}
if (checkLimit(sort)) {
alert("当前的sort值为:" + sort);
return;
}
updateItem({ sort: sort }, dragRow.id);
}, [newFiles]);
return ((0, jsx_runtime_1.jsxs)(antd_1.Space, tslib_1.__assign({ direction: "vertical", className: web_module_less_1.default["oak-upload"], style: { width: "100%" } }, { children: [(0, jsx_runtime_1.jsx)(react_dnd_1.DndProvider, tslib_1.__assign({ backend: utils_2.isPc ? react_dnd_html5_backend_1.HTML5Backend : react_dnd_touch_backend_1.TouchBackend }, { children: (0, jsx_runtime_1.jsx)(antd_1.Upload, tslib_1.__assign({ className: (0, classnames_1.default)(web_module_less_1.default["oak-upload__upload"], className), style: style, disabled: disabled, directory: directory, showUploadList: showUploadList
? {
showPreviewIcon: preview,
showRemoveIcon: !disableDelete,
showDownloadIcon: !disableDownload,
}
});
}); }, multiple: multiple, maxCount: maxNumber, accept: accept, listType: listType, fileList: theme === 'custom'
? []
: newFiles === null || newFiles === void 0 ? void 0 : newFiles.map(function (ele) { return extraFileToUploadFile(ele); }), onChange: function (_a) {
var file = _a.file, fileList = _a.fileList, event = _a.event;
// id不存在就是file对象
if (!file.id) {
if (theme !== 'custom') {
onPickByWeb([(0, utils_1.file2Obj)(file)]);
: false, beforeUpload: function (file) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
var result;
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {
case 0:
if (!(typeof beforeUpload === "function")) return [3 /*break*/, 2];
return [4 /*yield*/, beforeUpload(file)];
case 1:
result = _a.sent();
if (result) {
return [2 /*return*/, false];
}
_a.label = 2;
case 2: return [2 /*return*/, false];
}
});
}); }, multiple: multiple, maxCount: maxNumber, accept: accept, listType: listType, fileList: theme === "custom"
? []
: newFiles === null || newFiles === void 0 ? void 0 : newFiles.map(function (ele) { return extraFileToUploadFile(ele); }), onChange: function (_a) {
var file = _a.file, fileList = _a.fileList, event = _a.event;
// id不存在就是file对象
if (!file.id) {
if (theme !== "custom") {
onPickByWeb([(0, utils_1.file2Obj)(file)]);
}
else {
setNewUploadFiles([(0, utils_1.file2Obj)(file)]);
}
}
else {
setNewUploadFiles([(0, utils_1.file2Obj)(file)]);
}
}
}, onRemove: function (file) {
onDeleteByWeb(file);
}, onPreview: onPreview, onDownload: onDownload }, { children: !disableInsert && !disableAdd ? getUploadButton() : null })), tips && ((0, jsx_runtime_1.jsx)("small", tslib_1.__assign({ className: web_module_less_1.default['oak-upload__tips'] }, { children: tips }))), theme === 'custom' && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(antd_1.Table, { dataSource: newUploadFiles || [], rowKey: "id", columns: [
}, onRemove: function (file) {
onDeleteByWeb(file);
}, onPreview: onPreview, onDownload: onDownload, itemRender: function (originNode, currentFile, currentFileList) {
return ((0, jsx_runtime_1.jsx)(DragableUploadListItem, { originNode: originNode, file: currentFile, fileList: currentFileList, moveRow: moveRow }));
} }, { children: !disableInsert && !disableAdd ? getUploadButton() : null })) })), tips && (0, jsx_runtime_1.jsx)("small", tslib_1.__assign({ className: web_module_less_1.default["oak-upload__tips"] }, { children: tips })), theme === "custom" && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(antd_1.Table, { dataSource: newUploadFiles || [], rowKey: "id", columns: [
{
align: 'center',
dataIndex: 'tableIndex',
title: '序号',
align: "center",
dataIndex: "tableIndex",
title: "序号",
render: function (value, record, index) { return index + 1; },
width: 100,
},
{
dataIndex: 'name',
title: '文件名',
dataIndex: "name",
title: "文件名",
},
{
dataIndex: 'size',
title: '文件大小',
dataIndex: "size",
title: "文件大小",
render: function (value, record, index) {
return features.extraFile.formatBytes(value);
},
},
{
dataIndex: 'status',
title: '状态',
dataIndex: "status",
title: "状态",
render: function (value, record, index) {
var cpn;
switch (value) {
case 'success':
cpn = ((0, jsx_runtime_1.jsx)(antd_1.Tag, tslib_1.__assign({ color: "success" }, { children: "success" })));
case "success":
cpn = (0, jsx_runtime_1.jsx)(antd_1.Tag, tslib_1.__assign({ color: "success" }, { children: "success" }));
break;
case 'uploading':
cpn = ((0, jsx_runtime_1.jsx)(antd_1.Tag, tslib_1.__assign({ color: "processing" }, { children: "uploading" })));
case "uploading":
cpn = (0, jsx_runtime_1.jsx)(antd_1.Tag, tslib_1.__assign({ color: "processing" }, { children: "uploading" }));
break;
default:
cpn = ((0, jsx_runtime_1.jsx)(antd_1.Tag, tslib_1.__assign({ color: "warning" }, { children: "waiting" })));
cpn = (0, jsx_runtime_1.jsx)(antd_1.Tag, tslib_1.__assign({ color: "warning" }, { children: "waiting" }));
break;
}
return cpn;
},
},
{
dataIndex: 'op',
dataIndex: "op",
width: 300,
title: '操作',
align: 'center',
title: "操作",
align: "center",
render: function (value, record, index) {
// 只处理state的文件 这时候可以直接删除
return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: !record.id && ((0, jsx_runtime_1.jsx)(antd_1.Button, tslib_1.__assign({ type: "link", onClick: function () {
customDelete(index);
} }, { children: "\u5220\u9664" }))) }));
},
fixed: 'right',
fixed: "right",
},
] }), (0, jsx_runtime_1.jsx)("div", tslib_1.__assign({ style: { display: 'flex', justifyContent: 'flex-end' } }, { children: (0, jsx_runtime_1.jsxs)(antd_1.Space, { children: [(0, jsx_runtime_1.jsx)(antd_1.Button, tslib_1.__assign({ danger: true, type: "default", onClick: function () { return setNewUploadFiles([]); } }, { children: "\u6E05\u7A7A" })), (0, jsx_runtime_1.jsx)(antd_1.Button, tslib_1.__assign({ type: "primary", onClick: function () {
] }), (0, jsx_runtime_1.jsx)("div", tslib_1.__assign({ style: { display: "flex", justifyContent: "flex-end" } }, { children: (0, jsx_runtime_1.jsxs)(antd_1.Space, { children: [(0, jsx_runtime_1.jsx)(antd_1.Button, tslib_1.__assign({ danger: true, type: "default", onClick: function () { return setNewUploadFiles([]); } }, { children: "\u6E05\u7A7A" })), (0, jsx_runtime_1.jsx)(antd_1.Button, tslib_1.__assign({ type: "primary", onClick: function () {
onPickByWeb(newUploadFiles, function (file, status) {
setNewUploadFilesByStatus(file, status);
});

File diff suppressed because it is too large Load Diff

View File

@ -1,9 +0,0 @@
/// <reference types="react" />
declare const _default: (props: import("oak-frontend-base").ReactComponentProps<import("../../general-app-domain").EntityDict, keyof import("../../general-app-domain").EntityDict, false, {
type: string;
size: string | number;
color: string;
name: string;
larger: string;
}>) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;
export default _default;

View File

@ -1,12 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = OakComponent({
isList: false,
properties: {
type: 'fas',
size: 0,
color: 'primary',
name: '',
larger: '1x',
},
});

View File

@ -1,3 +0,0 @@
{
"component": true
}

View File

@ -1,22 +0,0 @@
@import './fontawesome.less';
@import '../../config/styles/mp/index.less';
.primary {
color: @oak-color-primary;
}
.error {
color: @oak-color-error;
}
.warning {
color: @oak-color-warning;
}
.success {
color: @oak-color-success;
}
.info {
color: @oak-color-info;
}

View File

@ -1,9 +0,0 @@
<block wx:if="{{type==='far' || type==='fas'}}">
<text
class="fa {{type}} fa-{{name}} fa-{{larger || '1x'}} {{color || 'primary'}}"
style="{{ size ? 'font-size:'+size+'rpx;':''}}{{ color && color !== 'primary' && color !== 'info'&& color !== 'error'&& color !== 'success'&& color !== 'warning' ? 'color:' + color+';' : '' }}">
</text>
</block>
<block wx:else>
<text>不支持的icon类型{{type}}</text>
</block>

View File

@ -1,24 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var jsx_runtime_1 = require("react/jsx-runtime");
require("./web.less");
function Render(props) {
var data = props.data;
var name = data.name, type = data.type, _a = data.color, color = _a === void 0 ? 'primary' : _a, size = data.size, className = data.className, _b = data.larger, larger = _b === void 0 ? '1x' : _b;
var isColor = ['primary', 'info', 'success', 'error', 'warning'].includes(color);
if (['far', 'fas'].includes(type)) {
var class_name = type + ' ' + 'fa-' + name;
if (className) {
class_name += ' ' + className;
}
if (larger) {
class_name += ' ' + 'fa-' + larger;
}
if (isColor) {
class_name += ' ' + 'oak-icon__' + color;
}
return ((0, jsx_runtime_1.jsx)("span", { className: class_name, style: Object.assign({}, size && { fontSize: size }, !isColor && { color: color }) }));
}
return (0, jsx_runtime_1.jsxs)("span", { children: ["\u4E0D\u652F\u6301\u7684icon\u7C7B\u578B", type] });
}
exports.default = Render;

View File

@ -1,21 +0,0 @@
@import './fontawesome.less';
.oak-icon__primary {
color: var(--oak-color-primary);
}
.oak-icon__error {
color: var(--oak-color-error);
}
.oak-icon__warning {
color: var(--oak-color-warning);
}
.oak-icon__success {
color: var(--oak-color-success);
}
.oak-icon__info {
color: var(--oak-color-info);
}

View File

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

View File

@ -1,32 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
exports.default = OakComponent({
entity: 'message',
isList: false,
formData: function (_a) {
var data = _a.data;
return {};
},
actions: ['visit'],
methods: {
tapAction: function (action) {
return tslib_1.__awaiter(this, void 0, void 0, function () {
var id;
return tslib_1.__generator(this, function (_a) {
id = this.props.oakId;
switch (action) {
case 'visit': {
this.execute('visit', false);
break;
}
default: {
break;
}
}
return [2 /*return*/];
});
});
},
},
});

View File

@ -1,29 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var jsx_runtime_1 = require("react/jsx-runtime");
var antd_1 = require("antd");
function Render(props) {
var data = props.data, methods = props.methods;
var t = methods.t, tapAction = methods.tapAction;
var oakLegalActions = data.oakLegalActions;
return oakLegalActions && (oakLegalActions === null || oakLegalActions === void 0 ? void 0 : oakLegalActions.length) > 0
? oakLegalActions.map(function (ele) {
return ((0, jsx_runtime_1.jsx)(antd_1.Button, tslib_1.__assign({ type: "link", onClick: function (event) {
var modal = antd_1.Modal.confirm({
title: "\u786E\u8BA4\u8BE5\u6D88\u606F\u6807\u4E3A\u5DF2\u8BFB\u5417\uFF1F",
okText: '确定',
cancelText: '取消',
onOk: function (e) {
tapAction(ele);
modal.destroy();
},
onCancel: function (e) {
modal.destroy();
},
});
} }, { children: "\u6807\u4E3A\u5DF2\u8BFB" })));
})
: null;
}
exports.default = Render;

View File

@ -0,0 +1,8 @@
/// <reference types="react" />
declare const _default: (props: import("oak-frontend-base").ReactComponentProps<import("../../../general-app-domain").EntityDict, keyof import("../../../general-app-domain").EntityDict, true, {
areaId: string | null | undefined;
onCancel: (() => void) | undefined;
onConfirm: ((stationIds: string[]) => void) | undefined;
selectIds: string[] | undefined;
}>) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;
export default _default;

View File

@ -0,0 +1,173 @@
"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: true,
lifetimes: {
ready: function () {
var _a, _b;
return tslib_1.__awaiter(this, void 0, void 0, function () {
var areas, areaId, subways;
return tslib_1.__generator(this, function (_c) {
switch (_c.label) {
case 0: return [4 /*yield*/, this.features.cache.refresh('area', {
data: {
id: 1,
name: 1,
level: 1,
},
filter: {
id: {
$in: {
entity: 'subway',
data: {
areaId: 1,
},
},
},
level: 'city',
},
})];
case 1:
areas = (_c.sent()).data;
areaId = this.props.areaId || areas[0].id;
return [4 /*yield*/, this.features.cache.refresh('subway', {
data: {
id: 1,
name: 1,
},
filter: {
areaId: areaId,
},
})];
case 2:
subways = (_c.sent()).data;
this.setState({
areas: areas,
subways: subways,
subwayId: (_a = subways[0]) === null || _a === void 0 ? void 0 : _a.id,
});
this.getStations((_b = subways[0]) === null || _b === void 0 ? void 0 : _b.id);
return [2 /*return*/];
}
});
});
},
},
data: {
open: false,
stationIds: [],
},
properties: {
areaId: '',
onCancel: undefined,
onConfirm: undefined,
selectIds: [],
},
methods: {
setAeraId: function (areaId) {
this.setState({
areaId: areaId,
});
},
setCheckedList: function (value, flag) {
var stationIds = this.state.stationIds;
if (flag) {
this.setState({
stationIds: stationIds.concat(value),
});
// stationIds.push(value);
}
else {
var index = stationIds.indexOf(value);
// stationIds.splice(index, 1);
this.setState({
stationIds: (0, lodash_1.pull)(stationIds, value),
});
}
},
getSubways: function (areaId) {
return tslib_1.__awaiter(this, void 0, void 0, function () {
var subways;
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {
case 0:
this.setState({
areaId: areaId,
});
return [4 /*yield*/, this.features.cache.refresh('subway', {
data: {
id: 1,
name: 1,
},
filter: {
areaId: areaId,
},
})];
case 1:
subways = (_a.sent()).data;
this.getStations(subways[0].id);
this.setState({
subways: subways,
});
return [2 /*return*/];
}
});
});
},
getStations: function (subwayId) {
return tslib_1.__awaiter(this, void 0, void 0, function () {
var subwayStations, stations;
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {
case 0:
this.setState({
subwayId: subwayId,
});
return [4 /*yield*/, this.features.cache.refresh('subwayStation', {
data: {
id: 1,
subwayId: 1,
stationId: 1,
station: {
id: 1,
name: 1,
},
},
filter: {
subwayId: subwayId,
},
})];
case 1:
subwayStations = (_a.sent()).data;
stations = subwayStations === null || subwayStations === void 0 ? void 0 : subwayStations.map(function (ele) { return ({
label: ele.station.name,
value: ele.station.id,
}); });
this.setState({
stations: stations,
});
return [2 /*return*/];
}
});
});
},
cancel: function () {
this.setState({
stationIds: [],
});
if (this.props.onCancel) {
this.props.onCancel();
}
},
confirm: function () {
if (this.props.onConfirm) {
this.props.onConfirm(this.state.stationIds);
}
this.setState({
stationIds: [],
});
},
},
});

19
lib/components/subwayLine/list/web.d.ts vendored Normal file
View File

@ -0,0 +1,19 @@
import { WebComponentProps } from 'oak-frontend-base';
import { EntityDict } from '../../../general-app-domain';
export default function render(props: WebComponentProps<EntityDict, 'area', true, {
subways: EntityDict['subway']['Schema'][];
areas: EntityDict['area']['Schema'][];
stations: {
label: string;
value: string;
}[];
areaId: string;
stationIds: string[];
selectIds: string[];
}, {
getStations: (subwayId: string) => void;
getSubways: (areaId: string) => void;
setCheckedList: (station: string, flag: boolean) => void;
cancel: () => void;
confirm: () => void;
}>): JSX.Element;

View File

@ -0,0 +1,39 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var jsx_runtime_1 = require("react/jsx-runtime");
var antd_1 = require("antd");
var web_module_less_1 = tslib_1.__importDefault(require("./web.module.less"));
function render(props) {
var _this = this;
var data = props.data, methods = props.methods;
var t = methods.t, getStations = methods.getStations, getSubways = methods.getSubways, setCheckedList = methods.setCheckedList, cancel = methods.cancel, confirm = methods.confirm;
var subways = data.subways, stations = data.stations, areaId = data.areaId, areas = data.areas, stationIds = data.stationIds, selectIds = data.selectIds;
return ((0, jsx_runtime_1.jsxs)("div", tslib_1.__assign({ className: web_module_less_1.default.container }, { children: [(0, jsx_runtime_1.jsx)(antd_1.Tabs, { style: { minHeight: '40vh' }, tabPosition: 'left', type: "card", defaultActiveKey: areaId, onChange: function (value) {
getSubways(value);
}, items: areas === null || areas === void 0 ? void 0 : areas.map(function (ele) { return ({
key: ele.id,
label: ele.name,
children: ((0, jsx_runtime_1.jsx)(antd_1.Tabs, { tabPosition: 'top', onChange: function (value) {
getStations(value);
}, items: subways === null || subways === void 0 ? void 0 : subways.map(function (ele) { return ({
key: ele.id,
label: ele.name,
children: ((0, jsx_runtime_1.jsx)(antd_1.Space, tslib_1.__assign({ size: [0, 16], wrap: true }, { children: stations === null || stations === void 0 ? void 0 : stations.map(function (ele) {
return ((0, jsx_runtime_1.jsx)(antd_1.Checkbox, tslib_1.__assign({ disabled: selectIds === null || selectIds === void 0 ? void 0 : selectIds.includes(ele.value), onChange: function (e) {
setCheckedList(e.target.value, e.target.checked);
}, checked: stationIds
.concat(selectIds || [])
.includes(ele.value), value: ele.value }, { children: ele.label })));
}) }))),
}); }) })),
}); }) }), (0, jsx_runtime_1.jsx)("div", tslib_1.__assign({ style: { textAlign: 'center', marginTop: 16 } }, { children: (0, jsx_runtime_1.jsxs)(antd_1.Space, { children: [(0, jsx_runtime_1.jsx)(antd_1.Button, tslib_1.__assign({ onClick: function () {
cancel();
} }, { children: "\u53D6\u6D88" })), (0, jsx_runtime_1.jsx)(antd_1.Button, tslib_1.__assign({ type: "primary", onClick: function () { return tslib_1.__awaiter(_this, void 0, void 0, function () {
return tslib_1.__generator(this, function (_a) {
confirm();
return [2 /*return*/];
});
}); } }, { children: "\u786E\u5B9A" }))] }) }))] })));
}
exports.default = render;

View File

@ -0,0 +1,5 @@
/** index.wxss **/
.container {
background: var(--oak-bg-color-container);
}

View File

@ -0,0 +1,7 @@
import React from 'react';
interface IProps {
defaultValue?: number | string;
onChange: (color: string) => void;
}
declare const _default: React.MemoExoticComponent<(props: IProps) => JSX.Element>;
export default _default;

View File

@ -0,0 +1,11 @@
"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 color_1 = require("./color");
var radioColor_module_less_1 = tslib_1.__importDefault(require("./radioColor.module.less"));
var RadioColor = function (props) { return ((0, jsx_runtime_1.jsx)("div", tslib_1.__assign({ className: radioColor_module_less_1.default.panel }, { children: color_1.defaultColor.map(function (color, index) { return ((0, jsx_runtime_1.jsx)("div", tslib_1.__assign({ onClick: function () { return props === null || props === void 0 ? void 0 : props.onChange(color); }, className: radioColor_module_less_1.default.box, style: {
borderColor: props.defaultValue === color ? color : 'transparent',
} }, { children: (0, jsx_runtime_1.jsx)("div", { className: radioColor_module_less_1.default.item, style: { backgroundColor: color } }) }), index)); }) }))); };
exports.default = react_1.default.memo(RadioColor);

View File

@ -0,0 +1,13 @@
import React from 'react';
interface IOption {
value?: any;
image: JSX.Element | string;
name?: string;
}
interface IProps {
defaultValue?: number | string;
onChange: (value?: any) => void;
options: IOption[];
}
declare const _default: React.MemoExoticComponent<(props: IProps) => JSX.Element>;
export default _default;

View File

@ -0,0 +1,24 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var jsx_runtime_1 = require("react/jsx-runtime");
var react_1 = require("react");
var classnames_1 = tslib_1.__importDefault(require("classnames"));
var radioRect_module_less_1 = tslib_1.__importDefault(require("./radioRect.module.less"));
exports.default = (0, react_1.memo)(function (props) {
var _a = tslib_1.__read((0, react_1.useState)(props.defaultValue), 2), selectValue = _a[0], setSelectValue = _a[1];
var handleClick = function (option) {
setSelectValue(option.value);
props === null || props === void 0 ? void 0 : props.onChange(option.value);
};
return ((0, jsx_runtime_1.jsx)("div", tslib_1.__assign({ className: radioRect_module_less_1.default.radioRectPanel }, { children: props.options.map(function (item, index) {
var _a;
var ImageItem = item.image;
if (typeof item.image === 'string') {
ImageItem = ((0, jsx_runtime_1.jsx)("div", { className: radioRect_module_less_1.default.rectImg, style: { backgroundImage: "url(".concat(item.image, ")") } }));
}
return ((0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)("div", tslib_1.__assign({ className: (0, classnames_1.default)(radioRect_module_less_1.default.rectItem, (_a = {},
_a[radioRect_module_less_1.default.rectItemSelected] = selectValue === item.value,
_a)), onClick: function () { return handleClick(item); } }, { children: ImageItem })), item.name && ((0, jsx_runtime_1.jsx)("div", tslib_1.__assign({ className: radioRect_module_less_1.default.rectText }, { children: item.name })))] }, index));
}) })));
});

View File

@ -0,0 +1,13 @@
<svg width="88" height="48" viewBox="0 0 88 48" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M0 0H88V48H0V0Z" fill="var(--td-component-border)"/>
<path d="M42.8627 14.0518V16.7601H44.4877V14.0518H42.8627Z" fill="var(--td-text-color-primary)"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M38.3488 23.9824C38.3488 21.0407 40.7335 18.656 43.6752 18.656C46.6168 18.656 49.0015 21.0407 49.0015 23.9824C49.0015 26.9241 46.6168 29.3088 43.6752 29.3088C40.7335 29.3088 38.3488 26.9241 38.3488 23.9824ZM43.6752 20.281C41.6309 20.281 39.9738 21.9382 39.9738 23.9824C39.9738 26.0266 41.6309 27.6838 43.6752 27.6838C45.7194 27.6838 47.3766 26.0266 47.3766 23.9824C47.3766 21.9382 45.7194 20.281 43.6752 20.281Z" fill="var(--td-text-color-primary)"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M52.208 26.781H49.5867L47.5262 33.48L49.0794 33.9577L49.5903 32.2968H52.2045L52.7154 33.9577L54.2686 33.48L52.208 26.781ZM51.7047 30.6718L51.0077 28.406H50.787L50.0901 30.6718H51.7047Z" fill="var(--td-text-color-primary)"/>
<path d="M48.2077 18.3009L50.1225 16.3861L51.2715 17.5351L49.3567 19.4499L48.2077 18.3009Z" fill="var(--td-text-color-primary)"/>
<path d="M53.6057 23.1699H50.8974V24.7949H53.6057V23.1699Z" fill="var(--td-text-color-primary)"/>
<path d="M44.4877 31.2045V33.9129H42.8627V31.2045H44.4877Z" fill="var(--td-text-color-primary)"/>
<path d="M37.2279 31.5786L39.1427 29.6638L37.9936 28.5147L36.0788 30.4295L37.2279 31.5786Z" fill="var(--td-text-color-primary)"/>
<path d="M36.453 24.7949H33.7446V23.1699H36.453V24.7949Z" fill="var(--td-text-color-primary)"/>
<path d="M36.0788 17.5351L37.9936 19.4499L39.1427 18.3009L37.2279 16.3861L36.0788 17.5351Z" fill="var(--td-text-color-primary)"/>
</svg>

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

@ -0,0 +1,5 @@
<svg width="88" height="48" viewBox="0 0 88 48" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M0 0H88V48H0V0Z" fill="#13161B"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M52.5327 26.8699C52.0346 26.9554 51.5225 26.9999 51 26.9999C46.0294 26.9999 42 22.9705 42 17.9999C42 16.9964 42.1642 16.0313 42.4673 15.1299C38.2268 15.8574 35 19.5518 35 23.9999C35 28.9705 39.0294 32.9999 44 32.9999C47.9671 32.9999 51.3346 30.4332 52.5327 26.8699Z" fill="#949EAA"/>
</svg>

After

Width:  |  Height:  |  Size: 495 B

View File

@ -0,0 +1,13 @@
<svg width="88" height="48" viewBox="0 0 88 48" fill="none" xmlns="http://www.w3.org/2000/svg">
<rect width="88" height="48" fill="var(--td-component-border)"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M43.9999 20.583C42.1129 20.583 40.5832 22.1127 40.5832 23.9997C40.5832 25.8867 42.1129 27.4163 43.9999 27.4163C45.8869 27.4163 47.4166 25.8867 47.4166 23.9997C47.4166 22.1127 45.8869 20.583 43.9999 20.583ZM39.0832 23.9997C39.0832 21.2843 41.2845 19.083 43.9999 19.083C46.7153 19.083 48.9166 21.2843 48.9166 23.9997C48.9166 26.7151 46.7153 28.9163 43.9999 28.9163C41.2845 28.9163 39.0832 26.7151 39.0832 23.9997Z" fill="var(--td-text-color-primary)"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M43.2499 17.333V14.833H44.7499V17.333H43.2499Z" fill="var(--td-text-color-primary)"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M48.1838 18.7552L49.9513 16.9877L51.0119 18.0483L49.2444 19.8158L48.1838 18.7552Z" fill="var(--td-text-color-primary)"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M50.6666 23.2497H53.1666V24.7497H50.6666V23.2497Z" fill="var(--td-text-color-primary)"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M49.2444 28.1835L51.0119 29.951L49.9513 31.0117L48.1838 29.2442L49.2444 28.1835Z" fill="var(--td-text-color-primary)"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M44.7499 30.6663V33.1663H43.2499V30.6663H44.7499Z" fill="var(--td-text-color-primary)"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M39.8162 29.2442L38.0487 31.0117L36.988 29.951L38.7555 28.1835L39.8162 29.2442Z" fill="var(--td-text-color-primary)"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M37.3333 24.7497H34.8333V23.2497H37.3333V24.7497Z" fill="var(--td-text-color-primary)"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M38.7555 19.8158L36.988 18.0483L38.0487 16.9877L39.8162 18.7552L38.7555 19.8158Z" fill="var(--td-text-color-primary)"/>
</svg>

After

Width:  |  Height:  |  Size: 1.9 KiB

View File

@ -0,0 +1,5 @@
export declare const defaultColor: string[];
export declare const darkColor: string[];
export declare const colorMap: {
[key: string]: string;
};

View File

@ -0,0 +1,42 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.colorMap = exports.darkColor = exports.defaultColor = void 0;
exports.defaultColor = [
'#0052d9',
'#0594fa',
'#00a870',
'#ebb105',
'#ed7b2f',
'#e34d59',
'#ed49b4',
'#834ec2',
];
exports.darkColor = [
'#4582e6',
'#29a4fb',
'#03a56f',
'#ca8d03',
'#ed7b2f',
'#ea7b84',
'#f172c5',
'#ab87d5',
];
// todo 写法可优化
exports.colorMap = {
'#0052d9': '',
'#0594fa': 'cyan',
'#00a870': 'green',
'#ebb105': 'yellow',
'#ed7b2f': 'orange',
'#e34d59': 'red',
'#ed49b4': 'pink',
'#834ec2': 'purple',
// dark
'#4582e6': '',
'#29a4fb': 'cyan',
'#03a56f': 'green',
'#ca8d03': 'yellow',
'#ea7b84': 'red',
'#f172c5': 'pink',
'#ab87d5': 'purple',
};

View File

@ -0,0 +1 @@
export default function Render(this: any): JSX.Element;

View File

@ -0,0 +1,62 @@
"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 themeState_1 = require("../../../types/themeState");
var useFeatures_1 = tslib_1.__importDefault(require("../../../hooks/useFeatures"));
var RadioColor_1 = tslib_1.__importDefault(require("./RadioColor"));
var RadioRect_1 = tslib_1.__importDefault(require("./RadioRect"));
var assets_setting_light_svg_1 = require("./assets/svg/assets-setting-light.svg");
var assets_setting_dark_svg_1 = require("./assets/svg/assets-setting-dark.svg");
var assets_setting_auto_svg_1 = require("./assets/svg/assets-setting-auto.svg");
var index_module_less_1 = tslib_1.__importDefault(require("./index.module.less"));
var ESettingTheme;
(function (ESettingTheme) {
ESettingTheme[ESettingTheme["system"] = 0] = "system";
})(ESettingTheme || (ESettingTheme = {}));
var themeList = [
{
value: themeState_1.ETheme.light,
image: (0, jsx_runtime_1.jsx)(assets_setting_light_svg_1.ReactComponent, {}),
name: '明亮',
},
{
value: themeState_1.ETheme.dark,
image: (0, jsx_runtime_1.jsx)(assets_setting_dark_svg_1.ReactComponent, {}),
name: '黑暗',
},
{
value: ESettingTheme.system,
image: (0, jsx_runtime_1.jsx)(assets_setting_auto_svg_1.ReactComponent, {}),
name: '跟随系统',
},
];
function Render() {
var features = (0, useFeatures_1.default)();
var themeState = features.theme.get();
var _a = tslib_1.__read((0, react_1.useState)(themeState === null || themeState === void 0 ? void 0 : themeState.systemTheme), 2), systemTheme = _a[0], setSystemTheme = _a[1];
var _b = tslib_1.__read((0, react_1.useState)(themeState === null || themeState === void 0 ? void 0 : themeState.theme), 2), theme = _b[0], setTheme = _b[1];
var _c = tslib_1.__read((0, react_1.useState)(themeState === null || themeState === void 0 ? void 0 : themeState.color), 2), color = _c[0], setColor = _c[1];
var handleThemeSwitch = function (value) {
if (value === ESettingTheme.system) {
features.theme.openSystemTheme();
}
else {
features.theme.switchTheme(value);
}
};
(0, react_1.useEffect)(function () {
var themeUnsub = features.theme.subscribe(function () {
var themeState = features.theme.get();
setSystemTheme(themeState.systemTheme);
setTheme(themeState.theme);
setColor(themeState.color);
});
return function () {
themeUnsub();
};
}, []);
return ((0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)("div", tslib_1.__assign({ className: index_module_less_1.default.settingTitle }, { children: "\u4E3B\u9898\u6A21\u5F0F" })), (0, jsx_runtime_1.jsx)(RadioRect_1.default, { defaultValue: systemTheme ? ESettingTheme.system : theme, onChange: handleThemeSwitch, options: themeList }), (0, jsx_runtime_1.jsx)("div", tslib_1.__assign({ className: index_module_less_1.default.settingTitle }, { children: "\u4E3B\u9898\u8272" })), (0, jsx_runtime_1.jsx)(RadioColor_1.default, { defaultValue: color, onChange: function (value) { return features.theme.switchColor(value); } })] }));
}
exports.default = Render;

View File

@ -0,0 +1,13 @@
.settingTitle {
margin: 32px 0 24px 0;
color: var(--oak-text-color-primary);
font-size: 14px;
line-height: 22px;
font-weight: 500;
}
.settingSubTitle {
font-size: 14px;
line-height: 21px;
margin-bottom: 24px;
}

View File

@ -0,0 +1,17 @@
.panel {
display: flex;
justify-content: space-between;
}
.box {
cursor: pointer;
border: 2px solid;
padding: 4px;
border-radius: 50%;
}
.item {
width: 24px;
height: 24px;
border-radius: 50%;
}

View File

@ -0,0 +1,28 @@
.radioRectPanel {
display: flex;
justify-content: space-between;
}
.rectItem {
border: 2px solid #e3e6eb;
padding: 8px;
border-radius: 3px;
cursor: pointer;
}
.rectItemSelected {
border-color: var(--oak-color-primary);
}
.rectText {
text-align: center;
font-size: 14px;
margin-top: 8px;
line-height: 21px;
}
.rectImg {
width: 88px;
height: 48px;
background-size: 100% 100%;
}

View File

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

View File

@ -1,44 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
exports.default = OakComponent({
entity: 'userEntityGrant',
isList: false,
formData: function (_a) {
var data = _a.data;
return {};
},
actions: ['disable'],
methods: {
tapAction: function (action) {
return tslib_1.__awaiter(this, void 0, void 0, function () {
var id, _a;
return tslib_1.__generator(this, function (_b) {
switch (_b.label) {
case 0:
id = this.props.oakId;
_a = action;
switch (_a) {
case 'disable': return [3 /*break*/, 1];
}
return [3 /*break*/, 3];
case 1:
this.update({
expired: true,
}, 'disable');
return [4 /*yield*/, this.execute()];
case 2:
_b.sent();
return [3 /*break*/, 4];
case 3:
{
return [3 /*break*/, 4];
}
_b.label = 4;
case 4: return [2 /*return*/];
}
});
});
},
},
});

View File

@ -1,41 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var jsx_runtime_1 = require("react/jsx-runtime");
var antd_1 = require("antd");
function Render(props) {
var _this = this;
var data = props.data, methods = props.methods;
var oakLegalActions = data.oakLegalActions;
var tapAction = methods.tapAction, t = methods.t;
return (oakLegalActions === null || oakLegalActions === void 0 ? void 0 : oakLegalActions.length) > 0
? oakLegalActions.map(function (ele) {
var btnName = t("userEntityGrant:action.".concat(ele));
if (ele === 'remove') {
btnName = t("common:action.".concat(ele));
}
return ((0, jsx_runtime_1.jsx)(antd_1.Button, tslib_1.__assign({ type: "link", onClick: function (event) {
var modal = antd_1.Modal.confirm({
title: "\u786E\u8BA4".concat(btnName, "\u8BE5\u6388\u6743\u8BB0\u5F55\u5417\uFF1F"),
okText: '确定',
cancelText: '取消',
onOk: function (e) { 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*/, tapAction(ele)];
case 1:
_a.sent();
modal.destroy();
return [2 /*return*/];
}
});
}); },
onCancel: function (e) {
modal.destroy();
},
});
} }, { children: btnName })));
})
: null;
}
exports.default = Render;

View File

@ -0,0 +1,8 @@
/// <reference types="react" />
import { EntityDict } from '../../../general-app-domain';
declare const _default: (props: import("oak-frontend-base").ReactComponentProps<EntityDict, keyof EntityDict, false, {
type: "bind" | "login";
backUrl: string;
isGoBack: boolean;
}>) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;
export default _default;

View File

@ -0,0 +1,216 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var Interval = 2 * 60 * 1000;
exports.default = OakComponent({
isList: false,
lifetimes: {
attached: function () {
return tslib_1.__awaiter(this, void 0, void 0, function () {
var type;
var _this = this;
return tslib_1.__generator(this, function (_a) {
type = this.props.type;
this.createWechatLogin();
this.createTimer = setInterval(function () {
_this.createWechatLogin();
}, Interval);
this.intervalId = setInterval(function () {
_this.getWechatLogin2();
}, 1000);
return [2 /*return*/];
});
});
},
detached: function () {
return tslib_1.__awaiter(this, void 0, void 0, function () {
return tslib_1.__generator(this, function (_a) {
if (this.createTimer) {
clearInterval(this.createTimer);
}
if (this.intervalId) {
clearInterval(this.intervalId);
}
return [2 /*return*/];
});
});
},
},
data: {
intervalId: '',
loading: false,
successed: false,
},
properties: {
type: 'bind',
backUrl: '',
isGoBack: false,
},
methods: {
createWechatLogin: function () {
return tslib_1.__awaiter(this, void 0, void 0, function () {
var _a, type, wechatLoginId;
var _this = this;
return tslib_1.__generator(this, function (_b) {
switch (_b.label) {
case 0:
_a = this.props.type, type = _a === void 0 ? 'bind' : _a;
return [4 /*yield*/, this.features.cache.exec('createWechatLogin', {
type: type,
interval: Interval,
})];
case 1:
wechatLoginId = (_b.sent()).result;
this.setState({
wechatLoginId: wechatLoginId,
}, function () {
_this.getWechatLogin();
});
return [2 /*return*/];
}
});
});
},
getWechatLogin: function () {
var _a, _b;
return tslib_1.__awaiter(this, void 0, void 0, function () {
var wechatLoginId, _c, wechatLogin, qrCodeUrl, buffer, newBuffer, newBufferToUint16, i, base64Str, binary, bytes, len, i, base64Str;
return tslib_1.__generator(this, function (_d) {
switch (_d.label) {
case 0:
wechatLoginId = this.state.wechatLoginId;
this.setState({
loading: true
});
return [4 /*yield*/, this.features.cache.refresh('wechatLogin', {
data: {
id: 1,
userId: 1,
type: 1,
qrCodeType: 1,
remark: 1,
expired: 1,
expiresAt: 1,
successed: 1,
wechatQrCode$entity: {
$entity: 'wechatQrCode',
data: {
id: 1,
entity: 1,
entityId: 1,
type: 1,
ticket: 1,
url: 1,
buffer: 1,
expired: 1,
expiresAt: 1,
applicationId: 1,
},
filter: {
entity: 'wechatLogin',
},
indexFrom: 0,
count: 1,
},
},
filter: {
id: wechatLoginId,
},
})];
case 1:
_c = tslib_1.__read.apply(void 0, [(_d.sent()).data, 1]), wechatLogin = _c[0];
qrCodeUrl = (_a = wechatLogin === null || wechatLogin === void 0 ? void 0 : wechatLogin.wechatQrCode$entity[0]) === null || _a === void 0 ? void 0 : _a.url;
buffer = (_b = wechatLogin === null || wechatLogin === void 0 ? void 0 : wechatLogin.wechatQrCode$entity[0]) === null || _b === void 0 ? void 0 : _b.buffer;
if (buffer) {
newBuffer = new ArrayBuffer(buffer.length * 2);
newBufferToUint16 = new Uint16Array(newBuffer);
for (i = 0; i < buffer.length; i++) {
newBufferToUint16[i] = buffer.charCodeAt(i);
}
if (process.env.OAK_PLATFORM === 'wechatMp') {
base64Str = wx.arrayBufferToBase64(newBufferToUint16);
qrCodeUrl = 'data:image/png;base64,' + base64Str;
}
else {
binary = '';
bytes = new Uint8Array(newBufferToUint16);
len = bytes.byteLength;
for (i = 0; i < len; i++) {
binary += String.fromCharCode(bytes[i]);
}
base64Str = window.btoa(binary);
// const buffer2 = Buffer.from(newBufferToUint16, 'base64');
// const base64Str = buffer2.toString('base64');
qrCodeUrl = 'data:image/png;base64,' + base64Str;
}
}
this.setState({
qrCodeUrl: qrCodeUrl,
loading: false,
});
return [2 /*return*/];
}
});
});
},
// 每秒调取下面方法,监听用户是否已在微信端授权登录或绑定
getWechatLogin2: function () {
return tslib_1.__awaiter(this, void 0, void 0, function () {
var wechatLoginId, _a, wechatLogin, successed, type;
var _this = this;
return tslib_1.__generator(this, function (_b) {
switch (_b.label) {
case 0:
wechatLoginId = this.state.wechatLoginId;
return [4 /*yield*/, this.features.cache.refresh('wechatLogin', {
data: {
id: 1,
userId: 1,
type: 1,
qrCodeType: 1,
remark: 1,
expired: 1,
expiresAt: 1,
successed: 1,
},
filter: {
id: wechatLoginId,
},
})];
case 1:
_a = tslib_1.__read.apply(void 0, [(_b.sent()).data, 1]), wechatLogin = _a[0];
successed = wechatLogin.successed, type = wechatLogin.type;
this.setState({
successed: successed,
type: type,
}, function () { return tslib_1.__awaiter(_this, void 0, void 0, function () {
var _a, backUrl, isGoBack;
return tslib_1.__generator(this, function (_b) {
switch (_b.label) {
case 0:
if (!(successed && type === 'login')) return [3 /*break*/, 2];
return [4 /*yield*/, this.features.token.loginByWechatInWebEnv(wechatLoginId)];
case 1:
_b.sent();
_a = this.props, backUrl = _a.backUrl, isGoBack = _a.isGoBack;
if (isGoBack) {
this.navigateBack();
return [2 /*return*/];
}
else if (backUrl) {
this.redirectTo({
url: backUrl,
});
}
_b.label = 2;
case 2: return [2 /*return*/];
}
});
}); });
return [2 /*return*/];
}
});
});
}
},
});

View File

@ -0,0 +1,9 @@
import { EntityDict } from '../../../general-app-domain';
import { WebComponentProps } from 'oak-frontend-base';
export default function Render(props: WebComponentProps<EntityDict, 'wechatLogin', true, {
wechatLoginId: string;
qrCodeUrl: string;
loading: boolean;
successed: boolean;
type: EntityDict['wechatLogin']['Schema']['type'];
}, {}>): JSX.Element;

View File

@ -0,0 +1,10 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var jsx_runtime_1 = require("react/jsx-runtime");
var qrCode_1 = tslib_1.__importDefault(require("../../../components/common/qrCode"));
function Render(props) {
var _a = props.data, oakFullpath = _a.oakFullpath, qrCodeUrl = _a.qrCodeUrl, loading = _a.loading, successed = _a.successed, type = _a.type;
return ((0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsx)(qrCode_1.default, { loading: loading, url: qrCodeUrl, disableDownload: true, tips: (0, jsx_runtime_1.jsx)("div", { children: "\u5FAE\u4FE1\u626B\u4E00\u626B" }), successed: successed, type: type }) }));
}
exports.default = Render;

View File

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

View File

@ -0,0 +1,4 @@
/// <reference types="react" />
import { EntityDict } from '../../../general-app-domain';
declare const _default: (props: import("oak-frontend-base").ReactComponentProps<EntityDict, "wechatUser", true, {}>) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;
export default _default;

View File

@ -0,0 +1,19 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = OakComponent({
entity: 'wechatUser',
isList: true,
projection: {
id: 1,
},
formData: function (_a) {
var data = _a.data;
return {
wechatUsers: data === null || data === void 0 ? void 0 : data.filter(function (ele) { return !!ele.userId; }),
};
},
lifetimes: {},
data: {},
properties: {},
methods: {},
});

View File

@ -1,5 +1,5 @@
import { WebComponentProps } from 'oak-frontend-base';
import { EntityDict } from '../../../general-app-domain';
export default function Render(props: WebComponentProps<EntityDict, 'message', false, {}, {
tapAction: (action: string) => void;
}>): JSX.Element[] | null;
import { WebComponentProps } from 'oak-frontend-base';
export default function Render(props: WebComponentProps<EntityDict, 'wechatUser', true, {
wechatUsers: EntityDict['wechatUser']['Schema'][];
}, {}>): JSX.Element;

View File

@ -0,0 +1,11 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var jsx_runtime_1 = require("react/jsx-runtime");
var antd_1 = require("antd");
var unbindBtn_1 = tslib_1.__importDefault(require("../unbindBtn"));
function Render(props) {
var _a = props.data, wechatUsers = _a.wechatUsers, oakFullpath = _a.oakFullpath;
return ((0, jsx_runtime_1.jsx)(antd_1.Space, { children: wechatUsers && wechatUsers.map(function (ele) { return ((0, jsx_runtime_1.jsx)(unbindBtn_1.default, { oakId: ele.id, oakPath: oakFullpath ? "".concat(oakFullpath, ".").concat(ele.id) : undefined })); }) }));
}
exports.default = Render;

View File

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

View File

@ -0,0 +1,4 @@
/// <reference types="react" />
import { EntityDict } from '../../../general-app-domain';
declare const _default: (props: import("oak-frontend-base").ReactComponentProps<EntityDict, "wechatUser", false, {}>) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;
export default _default;

View File

@ -0,0 +1,20 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = OakComponent({
entity: 'wechatUser',
isList: false,
projection: {
id: 1,
userId: 1,
},
formData: function (_a) {
var data = _a.data;
return {
id: data === null || data === void 0 ? void 0 : data.id,
};
},
lifetimes: {},
data: {},
properties: {},
methods: {},
});

View File

@ -0,0 +1,4 @@
{
"unbind": "解绑",
"unbindingWechat": "确定解绑该微信账号"
}

View File

@ -1,7 +1,7 @@
import { EntityDict } from '../../../general-app-domain';
import { WebComponentProps } from 'oak-frontend-base';
export default function Render(props: WebComponentProps<EntityDict, 'userEntityGrant', true, {
oakLegalActions: string[];
}, {
tapAction: (action: string) => Promise<void>;
}>): JSX.Element[] | null;
export default function Render(props: WebComponentProps<EntityDict, 'wechatUser', false, {
wechatLoginId: string;
qrCodeUrl: string;
loading: boolean;
}, {}>): JSX.Element;

View File

@ -0,0 +1,42 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var jsx_runtime_1 = require("react/jsx-runtime");
var antd_1 = require("antd");
var confirm = antd_1.Modal.confirm;
function Render(props) {
var data = props.data, methods = props.methods;
var oakFullpath = data.oakFullpath, qrCodeUrl = data.qrCodeUrl, loading = data.loading;
var t = methods.t;
return ((0, jsx_runtime_1.jsx)(antd_1.Button, tslib_1.__assign({ size: "small", onClick: function () {
// 解绑不做手机号验证
// if (mobile) {
// setOpen3(true)
// }
// else {
// confirm({
// title: t('unbindingWechat'),
// onOk() {
// unbunding();
// },
// });
// }
confirm({
title: '解绑微信账号',
content: '解绑后,您将无法使用该微信扫码登录',
okText: t('common:action.confirm'),
cancelText: t('common:action.cancel'),
onOk: function () {
methods.update({
userId: null,
});
methods.execute();
methods.setMessage({
content: '解绑成功',
type: 'success',
});
},
});
} }, { children: "\u89E3\u7ED1" })));
}
exports.default = Render;

View File

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

View File

@ -2,7 +2,9 @@ export declare const IgnoredForeignKeyMap: {
message: string[];
system: string[];
};
export declare const IgnoredRelationPathMap: {};
export declare const IgnoredRelationPathMap: {
token: string[];
};
export declare const DeducedRelationMap: {
extraFile: string;
};

View File

@ -7,7 +7,9 @@ exports.IgnoredForeignKeyMap = {
system: ['park'],
};
// 此对象所标识的路径不参与relation的路径判定以减少relation的路径数量
exports.IgnoredRelationPathMap = {};
exports.IgnoredRelationPathMap = {
token: ['wechatUser.application'],
};
// 此对象所标识的entity的权限由其外键指向的父对象判定
exports.DeducedRelationMap = {
extraFile: 'entity',

View File

@ -8,6 +8,7 @@ var Exception_2 = require("oak-domain/lib/types/Exception");
var constants_1 = require("../constants");
var AsyncRowStore_1 = require("oak-domain/lib/store/AsyncRowStore");
var uuid_1 = require("oak-domain/lib/utils/uuid");
var projection_1 = require("../types/projection");
var wechatQrCode_1 = require("../aspects/wechatQrCode");
/**
* general数据结构要求的后台上下文
@ -98,13 +99,8 @@ var BackendRuntimeContext = /** @class */ (function (_super) {
case 0: return [4 /*yield*/, this.select('token', {
data: {
id: 1,
userId: 1,
playerId: 1,
player: {
id: 1,
userState: 1,
isRoot: 1,
},
userState: 1,
isRoot: 1,
ableState: 1,
user: {
id: 1,
@ -148,28 +144,7 @@ var BackendRuntimeContext = /** @class */ (function (_super) {
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.select('application', {
data: {
id: 1,
name: 1,
config: 1,
type: 1,
systemId: 1,
style: 1,
system: {
id: 1,
name: 1,
config: 1,
platformId: 1,
style: 1,
folder: 1,
super: 1,
platform: {
id: 1,
config: 1,
style: 1,
},
},
},
data: projection_1.applicationProjection,
filter: {
id: appId,
},
@ -277,7 +252,8 @@ var BackendRuntimeContext = /** @class */ (function (_super) {
}
if (this.token) {
var userState = this.token.user.userState;
if (['disabled', 'merged'].includes(userState) && !this.isReallyRoot()) {
if (['disabled', 'merged'].includes(userState) &&
!this.isReallyRoot()) {
throw new Exception_1.OakUserDisabledException();
}
}

View File

@ -2,7 +2,7 @@ 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 GeneralAspectDict from '../aspects/AspectDict';
import { CommonAspectDict } from 'oak-common-aspect';
import { SyncContext, SyncRowStore } from 'oak-domain/lib/store/SyncRowStore';
import { BackendRuntimeContext } from './BackendRuntimeContext';

3
lib/data/index.d.ts vendored
View File

@ -25,5 +25,8 @@ declare const _default: {
coordinate: number[];
};
})[];
subway: import("../general-app-domain/Subway/Schema").CreateOperationData[];
station: import("../general-app-domain/Station/Schema").CreateOperationData[];
subwayStation: import("../general-app-domain/SubwayStation/Schema").CreateOperationData[];
};
export default _default;

View File

@ -2,9 +2,15 @@
Object.defineProperty(exports, "__esModule", { value: true });
var userRole_1 = require("./userRole");
var area_1 = require("./area");
var subway_1 = require("./subway");
var station_1 = require("./station");
var subwayStation_1 = require("./subwayStation");
exports.default = {
user: userRole_1.users,
mobile: userRole_1.mobiles,
token: userRole_1.tokens,
area: area_1.area,
subway: subway_1.subway,
station: station_1.station,
subwayStation: subwayStation_1.subwayStation,
};

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

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

1545
lib/data/station.js Normal file

File diff suppressed because it is too large Load Diff

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

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

80
lib/data/subway.js Normal file
View File

@ -0,0 +1,80 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.subway = void 0;
exports.subway = [
{
id: '330100023133',
name: '1号线',
areaId: '330100',
},
{
id: '900000150789',
name: '绍兴1号线',
areaId: '330100',
},
{
id: '330100020003',
name: '2号线',
areaId: '330100',
},
{
id: '900000092651',
name: '3号线',
areaId: '330100',
},
{
id: '900000029624',
name: '4号线',
areaId: '330100',
},
{
id: '900000065767',
name: '5号线',
areaId: '330100',
},
{
id: '900000073754',
name: '6号线',
areaId: '330100',
},
{
id: '900000099060',
name: '7号线',
areaId: '330100',
},
{
id: '900000099066',
name: '8号线',
areaId: '330100',
},
{
id: '900000166808',
name: '9号线',
areaId: '330100',
},
{
id: '900000122963',
name: '10号线',
areaId: '330100',
},
{
id: '900000130963',
name: '16号线',
areaId: '330100',
},
{
id: '900000101230',
name: '19号线',
areaId: '330100',
},
{
id: '900000150702',
name: '杭海城际',
areaId: '330100',
},
{
id: '900000109349',
name: 'S1线',
areaId: '330300',
},
];

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

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

1795
lib/data/subwayStation.js Normal file

File diff suppressed because it is too large Load Diff

View File

@ -104,10 +104,10 @@ function setUserUnsubscribed(openId, context) {
}
function setUserSubscribed(openId, eventKey, context) {
return tslib_1.__awaiter(this, void 0, void 0, function () {
var _a, applicationId, applicationType, list, now, data, doUpdate, sceneStr, wcqId, _b, wechatQrCode, application, _c, type, config, systemId, _d, appId, appSecret, wechatInstance, expired, entity, entityId, _e, _f, userEntityGrant, _g, id, granter, expired_1, entity2, qrCodeType, name_1, _h, appMp, config_1, appId_1, url, content, _j, domain, url;
var _a, applicationId, applicationType, list, now, data, doUpdate, sceneStr, wcqId, _b, wechatQrCode, application, _c, type, config, systemId, _d, appId, appSecret, wechatInstance, expired, entity, entityId, _e, _f, userEntityGrant, _g, id, granter, expired_1, entity2, qrCodeType, name_1, _h, appMp, config_1, appId_1, url, content, _j, domain, url, _k, wechatLogin, qrCodeType, expired_2, userId, type_1, successed, _l, domain, url, title, description;
var _this = this;
return tslib_1.__generator(this, function (_k) {
switch (_k.label) {
return tslib_1.__generator(this, function (_m) {
switch (_m.label) {
case 0:
_a = context.getApplication(), applicationId = _a.id, applicationType = _a.type;
return [4 /*yield*/, context.select('wechatUser', {
@ -124,7 +124,7 @@ function setUserSubscribed(openId, eventKey, context) {
count: 1,
}, { dontCollect: true })];
case 1:
list = _k.sent();
list = _m.sent();
now = Date.now();
data = {
// activeAt: now,
@ -196,7 +196,7 @@ function setUserSubscribed(openId, eventKey, context) {
}
});
}); };
if (!eventKey) return [3 /*break*/, 11];
if (!eventKey) return [3 /*break*/, 18];
sceneStr = void 0;
if (eventKey.startsWith('qrscene_')) {
sceneStr = eventKey.slice(eventKey.indexOf('qrscene_') + 8);
@ -219,8 +219,8 @@ function setUserSubscribed(openId, eventKey, context) {
count: 10,
}, { dontCollect: true })];
case 2:
_b = tslib_1.__read.apply(void 0, [_k.sent(), 1]), wechatQrCode = _b[0];
if (!wechatQrCode) return [3 /*break*/, 10];
_b = tslib_1.__read.apply(void 0, [_m.sent(), 1]), wechatQrCode = _b[0];
if (!wechatQrCode) return [3 /*break*/, 17];
application = context.getApplication();
_c = application, type = _c.type, config = _c.config, systemId = _c.systemId;
(0, assert_1.default)(type === 'wechatPublic');
@ -241,17 +241,18 @@ function setUserSubscribed(openId, eventKey, context) {
switch (_e) {
case 'user': return [3 /*break*/, 3];
case 'userEntityGrant': return [3 /*break*/, 4];
case 'wechatLogin': return [3 /*break*/, 10];
}
return [3 /*break*/, 9];
return [3 /*break*/, 15];
case 3:
{
// 裂变获得的用户
if (list[0] && !list[0].userId) {
Object.assign(data, { userId: entityId });
}
return [3 /*break*/, 9];
return [3 /*break*/, 16];
}
_k.label = 4;
_m.label = 4;
case 4: return [4 /*yield*/, context.select('userEntityGrant', {
data: {
id: 1,
@ -266,10 +267,10 @@ function setUserSubscribed(openId, eventKey, context) {
},
filter: {
id: entityId,
}
},
}, { dontCollect: true })];
case 5:
_f = tslib_1.__read.apply(void 0, [_k.sent(), 1]), userEntityGrant = _f[0];
_f = tslib_1.__read.apply(void 0, [_m.sent(), 1]), userEntityGrant = _f[0];
_g = userEntityGrant, id = _g.id, granter = _g.granter, expired_1 = _g.expired, entity2 = _g.entity, qrCodeType = _g.qrCodeType;
name_1 = (granter === null || granter === void 0 ? void 0 : granter.name) || (granter === null || granter === void 0 ? void 0 : granter.nickname) || '某用户';
if (!(qrCodeType === 'wechatPublicForMp')) return [3 /*break*/, 7];
@ -284,7 +285,7 @@ function setUserSubscribed(openId, eventKey, context) {
},
}, { dontCollect: true })];
case 6:
_h = tslib_1.__read.apply(void 0, [_k.sent(), 1]), appMp = _h[0];
_h = tslib_1.__read.apply(void 0, [_m.sent(), 1]), appMp = _h[0];
(0, assert_1.default)(appMp, '公众号推送小程序码时找不到关联的小程序');
config_1 = appMp.config;
appId_1 = config_1.appId;
@ -293,7 +294,6 @@ function setUserSubscribed(openId, eventKey, context) {
time: "".concat(Date.now()),
});
content = "".concat(name_1, "\u4E3A\u60A8\u521B\u5EFA\u4E86\u4E00\u4E2A\u6388\u6743\uFF0C<a href='#' data-miniprogram-appid='").concat(appId_1, "' data-miniprogram-path='").concat(url, "'>\u8BF7\u70B9\u51FB\u9886\u53D6</a>");
// assert(!expired); // 如果生成的wechatQrCode没过期userEntityGrant就不可能过期。
if (!expired_1) {
wechatInstance.sendServeMessage({
openId: openId,
@ -326,19 +326,18 @@ function setUserSubscribed(openId, eventKey, context) {
},
filter: {
id: applicationId,
}
}
}
}
},
},
},
},
}, { dontCollect: true })];
case 8:
_j = tslib_1.__read.apply(void 0, [_k.sent(), 1]), domain = _j[0];
_j = tslib_1.__read.apply(void 0, [_m.sent(), 1]), domain = _j[0];
(0, assert_1.default)(domain, "\u5904\u7406userEntityGrant\u65F6\uFF0C\u627E\u4E0D\u5230\u5BF9\u5E94\u7684domain\uFF0CapplicationId\u662F\u300C".concat(applicationId, "\u300D"));
url = (0, domain_1.composeDomainUrl)(domain, 'wechatQrCode/scan', {
scene: sceneStr,
time: "".concat(Date.now()),
});
// assert(!expired); // 如果生成的wechatQrCode没过期userEntityGrant就不可能过期。
if (!expired_1) {
wechatInstance.sendServeMessage({
openId: openId,
@ -356,14 +355,88 @@ function setUserSubscribed(openId, eventKey, context) {
content: '您好,您扫描的二维码已经过期,请联系管理员重新获取',
});
}
_k.label = 9;
case 9: return [3 /*break*/, 11];
case 10:
_m.label = 9;
case 9: return [3 /*break*/, 16];
case 10: return [4 /*yield*/, context.select('wechatLogin', {
data: {
id: 1,
qrCodeType: 1,
expired: 1,
userId: 1,
type: 1,
successed: 1,
},
filter: {
id: entityId,
},
}, { dontCollect: true })];
case 11:
_k = tslib_1.__read.apply(void 0, [_m.sent(), 1]), wechatLogin = _k[0];
qrCodeType = wechatLogin.qrCodeType, expired_2 = wechatLogin.expired, userId = wechatLogin.userId, type_1 = wechatLogin.type, successed = wechatLogin.successed;
if (!(qrCodeType === 'wechatPublicForMp')) return [3 /*break*/, 12];
return [3 /*break*/, 14];
case 12: return [4 /*yield*/, context.select('domain', {
data: {
id: 1,
url: 1,
apiPath: 1,
protocol: 1,
port: 1,
},
filter: {
systemId: {
$in: {
entity: 'application',
data: {
systemId: 1,
},
filter: {
id: applicationId,
},
},
},
},
}, { dontCollect: true })];
case 13:
_l = tslib_1.__read.apply(void 0, [_m.sent(), 1]), domain = _l[0];
(0, assert_1.default)(domain, "\u5904\u7406wechatLogin\u65F6\uFF0C\u627E\u4E0D\u5230\u5BF9\u5E94\u7684domain\uFF0CapplicationId\u662F\u300C".concat(applicationId, "\u300D"));
url = (0, domain_1.composeDomainUrl)(domain, 'wechatQrCode/scan', {
scene: sceneStr,
time: "".concat(Date.now()),
});
title = type_1 === 'bind' ? '扫码绑定' : '扫码登录';
description = type_1 === 'bind' ? '去绑定' : '去登录';
if (!expired_2) {
wechatInstance.sendServeMessage({
openId: openId,
type: 'news',
url: url,
title: title,
description: description,
picurl: 'http://img95.699pic.com/element/40018/2473.png_860.png',
});
}
else {
wechatInstance.sendServeMessage({
openId: openId,
type: 'text',
content: '您好,您扫描的二维码已经过期,请重新生成',
});
}
_m.label = 14;
case 14: return [3 /*break*/, 16];
case 15:
{
return [3 /*break*/, 16];
}
_m.label = 16;
case 16: return [3 /*break*/, 18];
case 17:
console.warn("\u7EBF\u4E0A\u6709\u626B\u63CF\u4E8C\u7EF4\u7801\u573A\u666F\u503C\uFF0C\u4F46\u627E\u4E0D\u5230\u5BF9\u5E94\u7684qrCode\uFF0CeventKey\u662F".concat(eventKey));
_k.label = 11;
case 11: return [4 /*yield*/, doUpdate()];
case 12:
_k.sent();
_m.label = 18;
case 18: return [4 /*yield*/, doUpdate()];
case 19:
_m.sent();
return [2 /*return*/];
}
});

View File

@ -1,16 +1,18 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
;
var locale = {
zh_CN: {
name: '地址',
attr: {
detail: '详细地址',
area: '所在地区',
phone: '联系电话',
name: '姓名',
default: '是否默认',
remark: '备注',
var entityDesc = {
locales: {
zh_CN: {
name: '地址',
attr: {
detail: '详细地址',
area: '所在地区',
phone: '联系电话',
name: '姓名',
default: '是否默认',
remark: '备注',
},
},
},
};

View File

@ -2,7 +2,7 @@ import { String, Text } from 'oak-domain/lib/types/DataType';
import { EntityShape } from 'oak-domain/lib/types/Entity';
import { Schema as System } from './System';
import { Style } from '../types/Style';
export declare type Passport = 'email' | 'mobile' | 'wechat';
export declare type Passport = 'email' | 'mobile' | 'wechat' | 'wechatPublic';
export declare type AppType = 'web' | 'wechatMp' | 'wechatPublic';
export declare type WechatMpConfig = {
type: 'wechatMp';
@ -17,6 +17,7 @@ export declare type WechatMpConfig = {
mode: 'clear' | 'compatible' | 'safe';
dataFormat: 'json' | 'xml';
};
passport?: Passport[];
};
export declare type WebConfig = {
type: 'web';
@ -26,7 +27,7 @@ export declare type WebConfig = {
domain?: string;
enable?: boolean;
};
passport: Passport[];
passport?: Passport[];
};
export declare type WechatPublicTemplateMsgsConfig = Record<string, string>;
export declare type WechatPublicConfig = {
@ -35,6 +36,7 @@ export declare type WechatPublicConfig = {
appId: string;
appSecret: string;
originalId?: string;
enable?: boolean;
templateMsgs?: WechatPublicTemplateMsgsConfig;
server?: {
url?: string;
@ -46,6 +48,7 @@ export declare type WechatPublicConfig = {
appId: string;
originalId: string;
};
passport?: Passport[];
};
export interface Schema extends EntityShape {
name: String<32>;

View File

@ -1,23 +1,25 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
;
var locale = {
zh_CN: {
name: '应用',
attr: {
description: '描述',
type: '类型',
system: '系统',
name: '名称',
config: '设置',
style: '样式',
},
v: {
type: {
web: '网站',
wechatPublic: '微信公众号',
wechatMp: '微信小程序',
var entityDesc = {
locales: {
zh_CN: {
name: '应用',
attr: {
description: '描述',
type: '类型',
system: '系统',
name: '名称',
config: '设置',
style: '样式',
},
v: {
type: {
web: '网站',
wechatPublic: '微信公众号',
wechatMp: '微信小程序',
}
}
}
},
},
}
};

View File

@ -1,29 +1,31 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
;
var config = {
actionType: 'readOnly',
static: true,
};
var locale = {
zh_CN: {
name: '地区',
attr: {
level: '层级',
depth: '深度',
parent: '上级地区',
name: '名称',
code: '地区编码',
center: '中心坐标',
},
v: {
level: {
country: '国家',
province: '省',
city: '市',
district: '区',
street: '街道',
var entityDesc = {
locales: {
zh_CN: {
name: '地区',
attr: {
level: '层级',
depth: '深度',
parent: '上级地区',
name: '名称',
code: '地区编码',
center: '中心坐标',
},
v: {
level: {
country: '国家',
province: '省',
city: '市',
district: '区',
street: '街道',
}
}
}
},
},
configuration: {
actionType: 'readOnly',
static: true,
},
};

View File

@ -8,31 +8,33 @@ var IActionDef = {
},
is: 'offline',
};
var locale = {
zh_CN: {
name: '文章',
attr: {
title: '标题',
author: '作者',
abstract: '简介',
content: '正文',
files: '封面图',
iState: '状态',
url: '外部链接',
entity: '关联对象',
entityId: '关联对象id',
sign: '唯一标志',
},
action: {
online: '上架',
offline: '下架',
disabled: '禁用',
},
v: {
iState: {
online: '已上架',
offline: '已下架',
disabled: '已禁用',
var entityDesc = {
locales: {
zh_CN: {
name: '文章',
attr: {
title: '标题',
author: '作者',
abstract: '简介',
content: '正文',
files: '封面图',
iState: '状态',
url: '外部链接',
entity: '关联对象',
entityId: '关联对象id',
sign: '唯一标志',
},
action: {
online: '上架',
offline: '下架',
disabled: '禁用',
},
v: {
iState: {
online: '已上架',
offline: '已下架',
disabled: '已禁用',
},
},
},
},

View File

@ -9,50 +9,52 @@ var IActionDef = {
},
is: 'unsent',
};
var indexes = [
{
name: 'index_mobile_code',
attributes: [
{
name: 'mobile',
direction: 'ASC',
var entityDesc = {
locales: {
zh_CN: {
name: '验证码',
attr: {
mobile: '手机号',
code: '验证码',
visitorId: '用户标识',
reason: '失败原因',
env: '用户环境',
expired: '是否过期',
expiresAt: '过期时间',
iState: '状态',
},
{
name: 'code',
direction: 'ASC',
action: {
send: '发送',
fail: '失败',
success: '成功',
},
v: {
iState: {
unsent: '未发送',
sending: '发送中',
sent: '已发送',
failure: '已失败',
}
},
{
name: '$$createAt$$',
direction: 'DESC',
}
],
},
];
var locale = {
zh_CN: {
name: '验证码',
attr: {
mobile: '手机号',
code: '验证码',
visitorId: '用户标识',
reason: '失败原因',
env: '用户环境',
expired: '是否过期',
expiresAt: '过期时间',
iState: '状态',
},
action: {
send: '发送',
fail: '失败',
success: '成功',
},
v: {
iState: {
unsent: '未发送',
sending: '发送中',
sent: '已发送',
failure: '已失败',
}
},
},
indexes: [
{
name: 'index_mobile_code',
attributes: [
{
name: 'mobile',
direction: 'ASC',
},
{
name: 'code',
direction: 'ASC',
},
{
name: '$$createAt$$',
direction: 'DESC',
}
],
},
]
};

View File

@ -1,21 +1,23 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
;
var locale = {
zh_CN: {
name: '域名',
attr: {
url: '域名',
apiPath: 'api路径',
protocol: '协议',
port: '端口',
system: '系统',
},
v: {
protocol: {
http: 'http',
https: 'https',
var entityDesc = {
locales: {
zh_CN: {
name: '域名',
attr: {
url: '域名',
apiPath: 'api路径',
protocol: '协议',
port: '端口',
system: '系统',
},
v: {
protocol: {
http: 'http',
https: 'https',
}
}
}
},
},
};

View File

@ -3,39 +3,41 @@ Object.defineProperty(exports, "__esModule", { value: true });
var action_1 = require("oak-domain/lib/actions/action");
;
var AbleActionDef = (0, action_1.makeAbleActionDef)('enabled');
var indexes = [
{
name: 'index_email_ableState',
attributes: [
{
name: 'email',
direction: 'ASC',
var entityDesc = {
locales: {
zh_CN: {
name: '邮箱',
attr: {
ableState: '是否可用',
email: '邮箱',
user: '关联用户',
tokens: '相关令牌',
},
{
name: 'ableState',
direction: 'ASC',
action: {
enable: '启用',
disable: '禁用',
},
v: {
ableState: {
enabled: '可用的',
disabled: '禁用的',
}
}
],
},
];
var locale = {
zh_CN: {
name: '邮箱',
attr: {
ableState: '是否可用',
email: '邮箱',
user: '关联用户',
tokens: '相关令牌',
},
action: {
enable: '启用',
disable: '禁用',
},
v: {
ableState: {
enabled: '可用的',
disabled: '禁用的',
}
}
},
indexes: [
{
name: 'index_email_ableState',
attributes: [
{
name: 'email',
direction: 'ASC',
},
{
name: 'ableState',
direction: 'ASC',
}
],
},
],
};

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