diff --git a/lib/aspects/token.js b/lib/aspects/token.js index b2f6a8d86..6d2b4cde7 100644 --- a/lib/aspects/token.js +++ b/lib/aspects/token.js @@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) { }; Object.defineProperty(exports, "__esModule", { value: true }); exports.syncUserInfoWechatMp = exports.loginWechatMp = exports.loginByPassword = exports.loginMp = void 0; -const oak_wechat_sdk_1 = __importDefault(require("oak-wechat-sdk")); +const oak_wechat_sdk_1 = require("oak-wechat-sdk"); const assert_1 = __importDefault(require("assert")); const lodash_1 = require("lodash"); const extraFile_1 = require("../utils/extraFile"); @@ -32,7 +32,7 @@ async function loginWechatMp({ code, env }, context) { (0, assert_1.default)(type === 'wechatMp' || config.type === 'wechatMp'); const config2 = config; const { appId, appSecret } = config2; - const wechatInstance = oak_wechat_sdk_1.default.getInstance(appId, appSecret, 'wechatMp'); + const wechatInstance = oak_wechat_sdk_1.WechatSDK.getInstance(appId, appSecret, 'wechatMp'); const { sessionKey, openId, unionId } = await wechatInstance.code2Session(code); const { result: [wechatUser] } = await rowStore.select('wechatUser', { data: { diff --git a/lib/entities/System.d.ts b/lib/entities/System.d.ts index 9132d53dd..ccc8d7ede 100644 --- a/lib/entities/System.d.ts +++ b/lib/entities/System.d.ts @@ -1,8 +1,21 @@ import { String, Text } from 'oak-domain/lib/types/DataType'; import { EntityShape } from 'oak-domain/lib/types/Entity'; +export declare type SystemConfig = { + Cos: { + qiniu: { + appKey: string; + appSecret: string; + }; + }; + Map: { + amap: { + webApiKey: string; + }; + }; +}; export interface Schema extends EntityShape { name: String<32>; description: Text; - config: Object; + config: SystemConfig; } export declare type Relation = 'owner'; diff --git a/lib/features/token.d.ts b/lib/features/token.d.ts index 9a150269a..859e3fd9f 100644 --- a/lib/features/token.d.ts +++ b/lib/features/token.d.ts @@ -1,13 +1,17 @@ import { EntityDict } from 'oak-app-domain'; import { Feature } from 'oak-frontend-base'; import { Aspect, Context } from 'oak-domain/lib/types'; +import { Cache } from 'oak-frontend-base'; export declare class Token, AD extends Record>> extends Feature { private token?; private rwLock; + private cache?; constructor(); loginByPassword(mobile: string, password: string, scene: string): Promise; loginWechatMp(scene: string): Promise; syncUserInfoWechatMp(scene: string): Promise; logout(): Promise; getToken(): Promise; + setCache(cache: Cache): void; + getUserId(): Promise<("userId" extends keyof ED["token"]["Schema"] ? ED["token"]["Selection"]["data"][keyof ED["token"]["Schema"] & "userId"] extends 1 | undefined ? ED["token"]["Schema"][keyof ED["token"]["Schema"] & "userId"] : ED["token"]["Selection"]["data"][keyof ED["token"]["Schema"] & "userId"] extends import("oak-domain/lib/types").OtmSubProjection ? never[] | import("oak-domain/lib/types").SelectRowShape[keyof ED["token"]["Schema"] & "userId"][0], ED["token"]["Selection"]["data"][keyof ED["token"]["Schema"] & "userId"]["data"]>[] : keyof ED["token"]["Schema"] & "userId" extends import("oak-domain/lib/types").OptionalKeys ? import("oak-domain/lib/types").SelectRowShape[import("oak-domain/lib/types").OptionalKeys & keyof ED["token"]["Schema"] & "userId"]>, ED["token"]["Selection"]["data"][import("oak-domain/lib/types").OptionalKeys & keyof ED["token"]["Schema"] & "userId"]> | null : import("oak-domain/lib/types").SelectRowShape[keyof ED["token"]["Schema"] & "userId"]>, ED["token"]["Selection"]["data"][keyof ED["token"]["Schema"] & "userId"]> : never) | undefined>; } diff --git a/lib/features/token.js b/lib/features/token.js index 2001b78c7..8dfe76f64 100644 --- a/lib/features/token.js +++ b/lib/features/token.js @@ -13,6 +13,7 @@ const concurrent_1 = require("oak-domain/lib/utils/concurrent"); class Token extends oak_frontend_base_1.Feature { token; rwLock; + cache; constructor() { super(); this.rwLock = new concurrent_1.RWLock(); @@ -88,6 +89,22 @@ class Token extends oak_frontend_base_1.Feature { throw err; } } + setCache(cache) { + this.cache = cache; + } + async getUserId() { + const token = await this.getToken(); + const result = await this.cache.get('token', { + data: { + id: 1, + userId: 1, + }, + filter: { + id: token, + } + }, 'token:getUserId'); + return result[0].userId; + } } __decorate([ oak_frontend_base_1.Action diff --git a/src/entities/System.ts b/src/entities/System.ts index 0b2bcde77..7b6afeb6e 100644 --- a/src/entities/System.ts +++ b/src/entities/System.ts @@ -1,10 +1,24 @@ import { String, Int, Datetime, Image, Boolean, Text } from 'oak-domain/lib/types/DataType'; import { EntityShape } from 'oak-domain/lib/types/Entity'; +export type SystemConfig = { + Cos: { + qiniu: { + appKey: string; + appSecret: string; + } + }, + Map: { + amap: { + webApiKey: string; // 高德访问rest服务接口的key + } + } +} + export interface Schema extends EntityShape { name: String<32>; description: Text; - config: Object; + config: SystemConfig; }; export type Relation = 'owner'; \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json index 991a93201..36ebcc2f7 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -77,7 +77,7 @@ "node_modules", "**/*.spec.ts", "test", - "scripts",/* - "wechatMp" */ + "scripts", + "wechatMp" ] } \ No newline at end of file diff --git a/wechatMp/components/Func/file-list/index.ts b/wechatMp/components/Func/file-list/index.ts index 8408025a2..67af9f3c8 100644 --- a/wechatMp/components/Func/file-list/index.ts +++ b/wechatMp/components/Func/file-list/index.ts @@ -25,7 +25,7 @@ Component({ }, methods: { - async onAdd() { + async onPick() { const { selectCount, mediaType, sourceType, oakUpdateData } = this.data; try { const { errMsg, tempFiles } = await wx.chooseMedia({ @@ -40,8 +40,9 @@ Component({ }); } else { - // this.triggerEvent('add', tempFiles); - this.createData(tempFiles); + const result = this.triggerEvent('pick', tempFiles); + // console.log(result); + // this.properties.createData(tempFiles); /* const { globalData: { features } } = getApp(); const { oakFullpath } = this.data; for (const file of tempFiles) { @@ -74,7 +75,6 @@ Component({ }, async setFullpath(oakParent: string) { const { globalData: { features }} = getApp(); - console.log(this.data); if (oakParent) { const oakFullpath = `${oakParent}.${this.data.oakPath}`; await features.runningNode.createNode({ @@ -85,6 +85,12 @@ Component({ oakFullpath, }); } + }, + add(options: any[]) { + const { globalData: { features }} = getApp(); + options.forEach( + ele => features.runningNode.addNode(this.data.oakFullpath, ele) + ); } }, diff --git a/wechatMp/components/Func/file-list/index.wxml b/wechatMp/components/Func/file-list/index.wxml index 1835ee03e..57bd391a4 100644 --- a/wechatMp/components/Func/file-list/index.wxml +++ b/wechatMp/components/Func/file-list/index.wxml @@ -2,7 +2,7 @@ - + \ No newline at end of file