Skip to content

Commit

Permalink
chore: 同步 uts.js
Browse files Browse the repository at this point in the history
  • Loading branch information
fxy060608 committed Jan 19, 2024
1 parent d07e37c commit e59d78c
Showing 1 changed file with 22 additions and 19 deletions.
41 changes: 22 additions & 19 deletions src/platforms/app-plus/service/api/plugin/uts.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ function initUTSInstanceMethod(async, opts, instanceId, proxy) {
}
function getProxy() {
if (!proxy) {
proxy = uni.requireNativePlugin('UTS-Proxy');
{
proxy = uni.requireNativePlugin('UTS-Proxy');
}
}
return proxy;
}
Expand Down Expand Up @@ -144,7 +146,7 @@ function initProxyFunction(async, { moduleName, moduleType, package: pkg, class:
}
function initUTSStaticMethod(async, opts) {
if (opts.main && !opts.method) {
if (typeof plus !== 'undefined' && plus.os.name === 'iOS') {
if (isUTSiOS()) {
opts.method = 's_' + opts.name;
}
}
Expand Down Expand Up @@ -187,7 +189,7 @@ function initUTSProxyClass(options) {
staticProps = options.staticProps;
}
// iOS 需要为 ByJs 的 class 构造函数(如果包含JSONObject或UTSCallback类型)补充最后一个参数
if (typeof plus !== 'undefined' && plus.os.name === 'iOS') {
if (isUTSiOS()) {
if (constructorParams.find((p) => p.type === 'UTSCallback' || p.type.indexOf('JSONObject') > 0)) {
constructorParams.push({ name: '_byJs', type: 'boolean' });
}
Expand All @@ -213,6 +215,10 @@ function initUTSProxyClass(options) {
const instance = this;
const proxy = new Proxy(instance, {
get(_, name) {
// 重要:禁止响应式
if (name === '__v_skip') {
return true;
}
if (!target[name]) {
//实例方法
name = parseClassMethodName(name, methods);
Expand Down Expand Up @@ -261,32 +267,29 @@ function initUTSProxyClass(options) {
},
});
}
function isUTSAndroid() {
return typeof plus !== 'undefined' && plus.os.name === 'Android';
}
function isUTSiOS() {
return !isUTSAndroid();
}
function initUTSPackageName(name, is_uni_modules) {
if (typeof plus !== 'undefined' && plus.os.name === 'Android') {
if (isUTSAndroid()) {
return 'uts.sdk.' + (is_uni_modules ? 'modules.' : '') + name;
}
return '';
}
function initUTSIndexClassName(moduleName, is_uni_modules) {
if (typeof plus === 'undefined') {
return '';
}
return initUTSClassName(moduleName, plus.os.name === 'iOS' ? 'IndexSwift' : 'IndexKt', is_uni_modules);
return initUTSClassName(moduleName, isUTSAndroid() ? 'IndexKt' : 'IndexSwift', is_uni_modules);
}
function initUTSClassName(moduleName, className, is_uni_modules) {
if (typeof plus === 'undefined') {
return '';
}
if (plus.os.name === 'Android') {
if (isUTSAndroid()) {
return className;
}
if (plus.os.name === 'iOS') {
return ('UTSSDK' +
(is_uni_modules ? 'Modules' : '') +
capitalize(moduleName) +
capitalize(className));
}
return '';
return ('UTSSDK' +
(is_uni_modules ? 'Modules' : '') +
capitalize(moduleName) +
capitalize(className));
}
const interfaceDefines = {};
function registerUTSInterface(name, define) {
Expand Down

0 comments on commit e59d78c

Please sign in to comment.