From 9ec11da2ff87a5366e1429c9259187b41e9cdf47 Mon Sep 17 00:00:00 2001 From: duqingquan Date: Sat, 12 Oct 2024 16:33:34 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=20UTS=E6=96=B9=E6=B3=95?= =?UTF-8?q?=E8=BF=94=E5=9B=9E=E5=80=BC=E6=98=AFpromise=E7=9A=84=E8=AF=AD?= =?UTF-8?q?=E6=B3=95=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/SyntaxCase/index.uvue | 25 +++++++++++++++++---- pages/SyntaxCase/index.vue | 25 +++++++++++++++++---- uni_modules/uts-syntaxcase/utssdk/index.uts | 18 ++++++++++++++- 3 files changed, 59 insertions(+), 9 deletions(-) diff --git a/pages/SyntaxCase/index.uvue b/pages/SyntaxCase/index.uvue index 8d16dba..660ff53 100644 --- a/pages/SyntaxCase/index.uvue +++ b/pages/SyntaxCase/index.uvue @@ -52,7 +52,8 @@ 测试complete:{{ format(testUtsClassInstanceResult['complete']) }} 测试callback:{{ format(testUtsClassInstanceResult['callback']) }} - 测试setter:{{ format(testUtsClassSetterResult) }} + 测试setter:{{ format(testUtsClassSetterResult) }} + 测试promise返回值:{{ format(testUtsReturnPromiseResult) }} @@ -74,7 +75,8 @@ testAsyncParam3, Test, request, - SetterTest, + SetterTest, + PromiseReturnDemo, } from "../../uni_modules/uts-syntaxcase"; // #endif // #ifdef APP-IOS @@ -143,7 +145,8 @@ complete: null, callback: null }, - testUtsClassSetterResult: null, + testUtsClassSetterResult: null, + testUtsReturnPromiseResult: null, } }, methods: { @@ -169,7 +172,8 @@ this.testUtsClassSyncWithCallback(); this.testUtsClassAsync(); this.testUtsClassInstance(); - this.testUtsClassSetter(); + this.testUtsClassSetter(); + this.testUtsReturnPromise(); }, testUtsSync() { this.testUtsSyncResult = false; @@ -450,6 +454,19 @@ console.error("testUtsClassSetter", e); } }, + testUtsReturnPromise() { + this.testUtsReturnPromiseResult = false; + try { + let demo = new PromiseReturnDemo(); + demo.test1(); + demo.test2(); + if (demo.recordRet == 2) { + this.testUtsReturnPromiseResult = true; + } + } catch (e) { + console.error("testUtsClassSetter", e); + } + }, // #ifdef APP-IOS testPromiseStaticMethod() { testPromiseStaticMethod() diff --git a/pages/SyntaxCase/index.vue b/pages/SyntaxCase/index.vue index 1940464..83885f1 100644 --- a/pages/SyntaxCase/index.vue +++ b/pages/SyntaxCase/index.vue @@ -51,7 +51,8 @@ 测试complete:{{ format(testUtsClassInstanceResult.complete) }} 测试callback:{{ format(testUtsClassInstanceResult.callback) }} - 测试setter:{{ format(testUtsClassSetterResult) }} + 测试setter:{{ format(testUtsClassSetterResult) }} + 测试promise返回值:{{ format(testUtsReturnPromiseResult) }} @@ -65,7 +66,8 @@ testAsyncParam3, Test, request, - SetterTest, + SetterTest, + PromiseReturnDemo, } from "../../uni_modules/uts-syntaxcase"; // #endif let test @@ -129,7 +131,8 @@ complete: null, callback: null }, - testUtsClassSetterResult: null, + testUtsClassSetterResult: null, + testUtsReturnPromiseResult: null, } }, methods: { @@ -149,7 +152,8 @@ this.testUtsClassSyncWithCallback(); this.testUtsClassAsync(); this.testUtsClassInstance(); - this.testUtsClassSetter(); + this.testUtsClassSetter(); + this.testUtsReturnPromise(); }, testUtsSync() { this.testUtsSyncResult = false; @@ -422,6 +426,19 @@ } catch (e) { console.error("testUtsClassSetter", e); } + }, + testUtsReturnPromise() { + this.testUtsReturnPromiseResult = false; + try { + let demo = new PromiseReturnDemo(); + demo.test1(); + demo.test2(); + if (demo.recordRet == 2) { + this.testUtsReturnPromiseResult = true; + } + } catch (e) { + console.error("testUtsClassSetter", e); + } }, } } diff --git a/uni_modules/uts-syntaxcase/utssdk/index.uts b/uni_modules/uts-syntaxcase/utssdk/index.uts index a86c4b3..19342ab 100644 --- a/uni_modules/uts-syntaxcase/utssdk/index.uts +++ b/uni_modules/uts-syntaxcase/utssdk/index.uts @@ -468,4 +468,20 @@ export class myClass { console.log(name); return name! } -} \ No newline at end of file +} + +export class PromiseReturnDemo { + + recordRet:number = 0 + + constructor() { } + test1() : Promise { + this.recordRet += 1 + console.log('test1',this.recordRet) + return Promise.resolve(true); + } + test2() : void { + this.recordRet += 1 + console.log('test2',this.recordRet) + } +} -- GitLab