This commit is contained in:
Wang Kejun 2023-09-09 09:52:27 +08:00
parent c75ecb688b
commit 454220ae0a
31 changed files with 47 additions and 156 deletions

View File

@ -1,5 +1,5 @@
import { assert } from 'oak-domain/lib/utils/assert';
import { applicationProjection } from '../types/projection';
import { applicationProjection } from '../types/Projection';
import { WechatSDK, } from 'oak-external-sdk';
export async function getApplication(params, context) {
const { type, domain } = params;

View File

@ -5,7 +5,7 @@ import { OakRowInconsistencyException, OakUnloggedInException, OakUserException,
import { composeFileUrl, decomposeFileUrl } from '../utils/extraFile';
import { OakChangeLoginWayException, OakDistinguishUserException, OakUserDisabledException, } from '../types/Exception';
import { encryptPasswordSha1 } from '../utils/password';
import { tokenProjection } from '../types/projection';
import { tokenProjection } from '../types/Projection';
import { sendSms } from '../utils/sms';
import { mergeUser } from './user';
import { pick } from 'oak-domain/lib/utils/lodash';

View File

@ -1,6 +1,6 @@
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { useState, useEffect } from 'react';
import { ETheme } from '../../../types/themeState';
import { ETheme } from '../../../types/Theme';
import useFeatures from '../../../hooks/useFeatures';
import RadioColor from './RadioColor';
import RadioRect from './RadioRect';

View File

@ -4,7 +4,7 @@ import { OakUnloggedInException, } from 'oak-domain/lib/types/Exception';
import { ROOT_TOKEN_ID, ROOT_USER_ID } from '../constants';
import { AsyncContext } from 'oak-domain/lib/store/AsyncRowStore';
import { generateNewIdAsync } from 'oak-domain/lib/utils/uuid';
import { applicationProjection } from '../types/projection';
import { applicationProjection } from '../types/Projection';
import { getMpUnlimitWxaCode } from '../aspects/wechatQrCode';
/**
* general数据结构要求的后台上下文

View File

@ -2,7 +2,7 @@ import { LOCAL_STORAGE_KEYS } from '../config/constants';
import { Feature } from 'oak-frontend-base';
import { assert } from 'oak-domain/lib/utils/assert';
import { merge } from 'oak-domain/lib/utils/lodash';
import { applicationProjection } from '../types/projection';
import { applicationProjection } from '../types/Projection';
export class Application extends Feature {
type;
domain; //域名

View File

@ -6,7 +6,7 @@ import { LocalStorage } from 'oak-frontend-base/es/features/localStorage';
import AspectDict from '../aspects/AspectDict';
import { BackendRuntimeContext } from '../context/BackendRuntimeContext';
import { FrontendRuntimeContext } from '../context/FrontendRuntimeContext';
import { ETheme, IThemeState } from '../types/themeState';
import { ETheme, IThemeState } from '../types/Theme';
export default class Theme<ED extends EntityDict, Cxt extends BackendRuntimeContext<ED>, FrontCxt extends FrontendRuntimeContext<ED, Cxt, AD>, AD extends AspectDict<ED, Cxt> & CommonAspectDict<ED, Cxt>> extends Feature {
private cache;
private themeState;

View File

@ -1,6 +1,6 @@
import { LOCAL_STORAGE_KEYS } from '../config/constants';
import { Feature } from 'oak-frontend-base';
import { ETheme } from '../types/themeState';
import { ETheme } from '../types/Theme';
const defaultTheme = ETheme.light;
const initialThemeState = {
setting: false,

View File

@ -1,6 +1,6 @@
import { Feature } from 'oak-frontend-base';
import { OakRowInconsistencyException, OakUnloggedInException, OakUserUnpermittedException, } from 'oak-domain/lib/types/Exception';
import { tokenProjection } from '../types/projection';
import { tokenProjection } from '../types/Projection';
import { OakUserInfoLoadingException } from '../types/Exception';
import { LOCAL_STORAGE_KEYS } from '../config/constants';
export class Token extends Feature {

View File

@ -20,11 +20,10 @@ export default OakComponent({
});
const { features } = this;
const token = features.token.getToken(true);
// 解析url
const url = window.location.href;
const urlObj = URL.parse(url, true);
const urlParse = URL.parse(url, true);
//格式 xx?code=xx&state=/xx/xx?d=xx
const query = urlObj?.query;
const query = urlParse?.query;
const code = query?.code;
const state = query?.state;
const wechatLoginId = query?.wechatLoginId;
@ -56,7 +55,6 @@ export default OakComponent({
this.go(state);
}
catch (err) {
console.warn(err);
this.setState({
error: '微信登录失败',
loading: false,

View File

@ -1,4 +0,0 @@
import { EntityDict } from '../oak-app-domain';
export declare const userProjection: EntityDict['user']['Selection']['data'];
export declare const tokenProjection: EntityDict['token']['Selection']['data'];
export declare const applicationProjection: EntityDict['application']['Selection']['data'];

View File

@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
exports.signatureJsSDK = exports.getApplication = void 0;
var tslib_1 = require("tslib");
var assert_1 = require("oak-domain/lib/utils/assert");
var projection_1 = require("../types/projection");
var Projection_1 = require("../types/Projection");
var oak_external_sdk_1 = require("oak-external-sdk");
function getApplication(params, context) {
return tslib_1.__awaiter(this, void 0, void 0, function () {
@ -15,7 +15,7 @@ function getApplication(params, context) {
url = context.getHeader('host');
console.log('url is', url);
return [4 /*yield*/, context.select('application', {
data: projection_1.applicationProjection,
data: Projection_1.applicationProjection,
filter: {
type: type,
system: {
@ -34,7 +34,7 @@ function getApplication(params, context) {
if (!(type === 'wechatPublic')) return [3 /*break*/, 5];
if (!!application) return [3 /*break*/, 4];
return [4 /*yield*/, context.select('application', {
data: projection_1.applicationProjection,
data: Projection_1.applicationProjection,
filter: {
type: 'web',
system: {

View File

@ -9,7 +9,7 @@ var types_1 = require("oak-domain/lib/types");
var extraFile_1 = require("../utils/extraFile");
var Exception_1 = require("../types/Exception");
var password_1 = require("../utils/password");
var projection_1 = require("../types/projection");
var Projection_1 = require("../types/Projection");
var sms_1 = require("../utils/sms");
var user_1 = require("./user");
var lodash_1 = require("oak-domain/lib/utils/lodash");
@ -552,7 +552,7 @@ function loadTokenInfo(tokenId, context) {
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, context.select('token', {
data: projection_1.tokenProjection,
data: Projection_1.tokenProjection,
filter: {
id: tokenId,
},

View File

@ -3,7 +3,7 @@ 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 Theme_1 = require("../../../types/Theme");
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"));
@ -17,12 +17,12 @@ var ESettingTheme;
})(ESettingTheme || (ESettingTheme = {}));
var themeList = [
{
value: themeState_1.ETheme.light,
value: Theme_1.ETheme.light,
image: (0, jsx_runtime_1.jsx)(assets_setting_light_svg_1.ReactComponent, {}),
name: '明亮',
},
{
value: themeState_1.ETheme.dark,
value: Theme_1.ETheme.dark,
image: (0, jsx_runtime_1.jsx)(assets_setting_dark_svg_1.ReactComponent, {}),
name: '黑暗',
},

View File

@ -8,7 +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 Projection_1 = require("../types/Projection");
var wechatQrCode_1 = require("../aspects/wechatQrCode");
/**
* general数据结构要求的后台上下文
@ -147,7 +147,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: projection_1.applicationProjection,
data: Projection_1.applicationProjection,
filter: {
id: appId,
},

View File

@ -6,7 +6,7 @@ var constants_1 = require("../config/constants");
var oak_frontend_base_1 = require("oak-frontend-base");
var assert_1 = require("oak-domain/lib/utils/assert");
var lodash_1 = require("oak-domain/lib/utils/lodash");
var projection_1 = require("../types/projection");
var Projection_1 = require("../types/Projection");
var Application = /** @class */ (function (_super) {
tslib_1.__extends(Application, _super);
function Application(type, domain, cache, storage) {
@ -17,7 +17,7 @@ var Application = /** @class */ (function (_super) {
_this.applicationId = applicationId;
_this.type = type;
_this.domain = domain;
_this.projection = projection_1.applicationProjection;
_this.projection = Projection_1.applicationProjection;
return _this;
}
Application.prototype.refresh = function () {

View File

@ -6,7 +6,7 @@ import { LocalStorage } from 'oak-frontend-base/es/features/localStorage';
import AspectDict from '../aspects/AspectDict';
import { BackendRuntimeContext } from '../context/BackendRuntimeContext';
import { FrontendRuntimeContext } from '../context/FrontendRuntimeContext';
import { ETheme, IThemeState } from '../types/themeState';
import { ETheme, IThemeState } from '../types/Theme';
export default class Theme<ED extends EntityDict, Cxt extends BackendRuntimeContext<ED>, FrontCxt extends FrontendRuntimeContext<ED, Cxt, AD>, AD extends AspectDict<ED, Cxt> & CommonAspectDict<ED, Cxt>> extends Feature {
private cache;
private themeState;

View File

@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var constants_1 = require("../config/constants");
var oak_frontend_base_1 = require("oak-frontend-base");
var themeState_1 = require("../types/themeState");
var defaultTheme = themeState_1.ETheme.light;
var Theme_1 = require("../types/Theme");
var defaultTheme = Theme_1.ETheme.light;
var initialThemeState = {
setting: false,
theme: defaultTheme,
@ -61,7 +61,7 @@ var Theme = /** @class */ (function (_super) {
var state = this.themeState;
var media = window.matchMedia('(prefers-color-scheme:dark)');
if (media.matches) {
var finalTheme = media.matches ? themeState_1.ETheme.dark : themeState_1.ETheme.light;
var finalTheme = media.matches ? Theme_1.ETheme.dark : Theme_1.ETheme.light;
// 切换主题颜色
state.theme = finalTheme;
state.systemTheme = true;

View File

@ -4,7 +4,7 @@ exports.Token = void 0;
var tslib_1 = require("tslib");
var oak_frontend_base_1 = require("oak-frontend-base");
var Exception_1 = require("oak-domain/lib/types/Exception");
var projection_1 = require("../types/projection");
var Projection_1 = require("../types/Projection");
var Exception_2 = require("../types/Exception");
var constants_1 = require("../config/constants");
var Token = /** @class */ (function (_super) {
@ -38,7 +38,7 @@ var Token = /** @class */ (function (_super) {
if (!(this.tokenValue && !this.isLoading)) return [3 /*break*/, 2];
this.isLoading = true;
return [4 /*yield*/, this.cache.refresh('token', {
data: projection_1.tokenProjection,
data: Projection_1.tokenProjection,
filter: {
id: this.tokenValue,
},
@ -193,7 +193,7 @@ var Token = /** @class */ (function (_super) {
Token.prototype.getToken = function (allowUnloggedIn) {
if (this.tokenValue) {
var token = this.cache.get('token', {
data: projection_1.tokenProjection,
data: Projection_1.tokenProjection,
filter: {
id: this.tokenValue,
},

View File

@ -19,7 +19,7 @@ exports.default = OakComponent({
methods: {
login: function () {
return tslib_1.__awaiter(this, void 0, void 0, function () {
var features, token, url, urlObj, query, code, state, wechatLoginId, err_1;
var features, token, url, urlParse, query, code, state, wechatLoginId, err_1;
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {
case 0:
@ -29,8 +29,8 @@ exports.default = OakComponent({
features = this.features;
token = features.token.getToken(true);
url = window.location.href;
urlObj = url_1.default.parse(url, true);
query = urlObj === null || urlObj === void 0 ? void 0 : urlObj.query;
urlParse = url_1.default.parse(url, true);
query = urlParse === null || urlParse === void 0 ? void 0 : urlParse.query;
code = query === null || query === void 0 ? void 0 : query.code;
state = query === null || query === void 0 ? void 0 : query.state;
wechatLoginId = query === null || query === void 0 ? void 0 : query.wechatLoginId;
@ -68,7 +68,6 @@ exports.default = OakComponent({
return [3 /*break*/, 5];
case 4:
err_1 = _a.sent();
console.warn(err_1);
this.setState({
error: '微信登录失败',
loading: false,

View File

@ -1,4 +0,0 @@
import { EntityDict } from '../oak-app-domain';
export declare const userProjection: EntityDict['user']['Selection']['data'];
export declare const tokenProjection: EntityDict['token']['Selection']['data'];
export declare const applicationProjection: EntityDict['application']['Selection']['data'];

View File

@ -1,104 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.applicationProjection = exports.tokenProjection = exports.userProjection = void 0;
exports.userProjection = {
id: 1,
nickname: 1,
name: 1,
userState: 1,
refId: 1,
idState: 1,
gender: 1,
birth: 1,
isRoot: 1,
extraFile$entity: {
$entity: 'extraFile',
data: {
id: 1,
tag1: 1,
origin: 1,
bucket: 1,
objectId: 1,
filename: 1,
extra1: 1,
type: 1,
entity: 1,
entityId: 1,
extension: 1,
},
filter: {
tag1: 'avatar',
},
indexFrom: 0,
count: 1,
},
mobile$user: {
$entity: 'mobile',
data: {
id: 1,
mobile: 1,
userId: 1,
},
},
};
exports.tokenProjection = {
id: 1,
applicationId: 1,
userId: 1,
user: exports.userProjection,
ableState: 1,
playerId: 1,
player: {
id: 1,
isRoot: 1,
},
entity: 1,
entityId: 1,
mobile: {
id: 1,
mobile: 1,
userId: 1,
ableState: 1,
user: {
id: 1,
userState: 1,
refId: 1,
},
},
wechatUser: {
id: 1,
userId: 1,
user: {
id: 1,
userState: 1,
refId: 1,
},
},
};
exports.applicationProjection = {
id: 1,
name: 1,
config: 1,
type: 1,
systemId: 1,
style: 1,
description: 1,
system: {
id: 1,
name: 1,
config: 1,
platformId: 1,
style: 1,
folder: 1,
super: 1,
entity: 1,
entityId: 1,
platform: {
id: 1,
config: 1,
style: 1,
entity: 1,
entityId: 1,
},
},
};

View File

@ -2,7 +2,7 @@ import { assert } from 'oak-domain/lib/utils/assert';
import { EntityDict } from "../oak-app-domain";
import { AppType, WechatPublicConfig } from "../oak-app-domain/Application/Schema";
import { BackendRuntimeContext } from "../context/BackendRuntimeContext";
import { applicationProjection } from '../types/projection';
import { applicationProjection } from '../types/Projection';
import {
WebEnv,
} from 'oak-domain/lib/types/Environment';

View File

@ -32,7 +32,7 @@ import {
} from '../types/Exception';
import { encryptPasswordSha1 } from '../utils/password';
import { BackendRuntimeContext } from '../context/BackendRuntimeContext';
import { tokenProjection } from '../types/projection';
import { tokenProjection } from '../types/Projection';
import { sendSms } from '../utils/sms';
import { mergeUser } from './user';
import { pick } from 'oak-domain/lib/utils/lodash';

View File

@ -15,7 +15,7 @@ import { ROOT_TOKEN_ID, ROOT_USER_ID } from '../constants';
import { AsyncContext } from 'oak-domain/lib/store/AsyncRowStore';
import { generateNewIdAsync } from 'oak-domain/lib/utils/uuid';
import { SelectOpResult } from 'oak-domain/lib/types';
import { applicationProjection } from '../types/projection';
import { applicationProjection } from '../types/Projection';
import { getMpUnlimitWxaCode } from '../aspects/wechatQrCode';
/**
* general数据结构要求的后台上下文

View File

@ -12,7 +12,7 @@ import AspectDict from '../aspects/AspectDict';
import { BackendRuntimeContext } from '../context/BackendRuntimeContext';
import { FrontendRuntimeContext } from '../context/FrontendRuntimeContext';
import { applicationProjection } from '../types/projection';
import { applicationProjection } from '../types/Projection';
export class Application<
ED extends EntityDict,

View File

@ -13,7 +13,7 @@ import { EntityDict } from '../oak-app-domain';
import AspectDict from '../aspects/AspectDict';
import { BackendRuntimeContext } from '../context/BackendRuntimeContext';
import { FrontendRuntimeContext } from '../context/FrontendRuntimeContext';
import { tokenProjection } from '../types/projection';
import { tokenProjection } from '../types/Projection';
import { OakUserInfoLoadingException } from '../types/Exception';
import { LOCAL_STORAGE_KEYS } from '../config/constants';

View File

@ -1,4 +1,9 @@
export const userProjection = {
import { ROOT_ROLE_ID } from '../constants';
import { EntityDict } from '../oak-app-domain';
export const userProjection: EntityDict['user']['Selection']['data'] = {
id: 1,
nickname: 1,
name: 1,
@ -38,7 +43,7 @@ export const userProjection = {
},
},
};
export const tokenProjection = {
export const tokenProjection: EntityDict['token']['Selection']['data'] = {
id: 1,
applicationId: 1,
userId: 1,
@ -72,7 +77,8 @@ export const tokenProjection = {
},
},
};
export const applicationProjection = {
export const applicationProjection: EntityDict['application']['Selection']['data'] = {
id: 1,
name: 1,
config: 1,
@ -98,4 +104,4 @@ export const applicationProjection = {
entityId: 1,
},
},
};
};