提交 f9df85a0 编写于 作者: DCloud-yyl's avatar DCloud-yyl

同步代码@HBuilderX4.23

上级 c485ce15
...@@ -269,7 +269,7 @@ export type ReadDirOptions = { ...@@ -269,7 +269,7 @@ export type ReadDirOptions = {
export type AccessOptions = { export type AccessOptions = {
/** /**
* 要删除的目录路径 (本地路径) * 要判断是否存在的文件/目录路径 (本地路径)
*/ */
path : string.URIString, path : string.URIString,
...@@ -1104,7 +1104,7 @@ export interface FileSystemManager { ...@@ -1104,7 +1104,7 @@ export interface FileSystemManager {
access(options : AccessOptions) : void; access(options : AccessOptions) : void;
/** /**
* FileSystemManager.access 的同步版本 * FileSystemManager.access 的同步版本
* @param path 要删除的目录路径 (本地路径) * @param path 要判断是否存在的文件/目录路径 (本地路径)
* @uniPlatform { * @uniPlatform {
* "app": { * "app": {
* "android": { * "android": {
......
...@@ -63,7 +63,7 @@ function getBaseInfo(filterArray : Array<string>) : GetDeviceInfoResult { ...@@ -63,7 +63,7 @@ function getBaseInfo(filterArray : Array<string>) : GetDeviceInfoResult {
result.deviceId = DeviceUtil.getDeviceID(activity); result.deviceId = DeviceUtil.getDeviceID(activity);
} }
if (filterArray.indexOf("devicePixelRatio") != -1) { if (filterArray.indexOf("devicePixelRatio") != -1) {
result.devicePixelRatio = DeviceUtil.getScaledDensity(activity) + ""; result.devicePixelRatio = DeviceUtil.getScaledDensity(activity);
} }
if (filterArray.indexOf("system") != -1) { if (filterArray.indexOf("system") != -1) {
result.system = "Android " + Build.VERSION.RELEASE; result.system = "Android " + Build.VERSION.RELEASE;
......
...@@ -28,15 +28,6 @@ export class DeviceUtil { ...@@ -28,15 +28,6 @@ export class DeviceUtil {
return orientation; return orientation;
} }
public static getScreenScale(): string {
return UIScreen.main.scale.description;
}
public static getIdfa(): string {
return UTSiOS.getGgbs()
}
public static hasRootPrivilege(): boolean { public static hasRootPrivilege(): boolean {
return UTSiOS.isRoot() return UTSiOS.isRoot()
} }
......
...@@ -64,7 +64,7 @@ function getBaseInfo(filterArray : Array<string>) : GetDeviceInfoResult { ...@@ -64,7 +64,7 @@ function getBaseInfo(filterArray : Array<string>) : GetDeviceInfoResult {
result.deviceOrientation = DeviceUtil.getOrientation(); result.deviceOrientation = DeviceUtil.getOrientation();
} }
if (filterArray.indexOf("devicePixelRatio") != -1) { if (filterArray.indexOf("devicePixelRatio") != -1) {
result.devicePixelRatio = DeviceUtil.getScreenScale(); result.devicePixelRatio = Number.from(UIScreen.main.scale);
} }
if (filterArray.indexOf("system") != -1) { if (filterArray.indexOf("system") != -1) {
result.system = String(format = "iOS %@", osVersion); result.system = String(format = "iOS %@", osVersion);
......
...@@ -151,7 +151,7 @@ export type GetDeviceInfoOptions = { ...@@ -151,7 +151,7 @@ export type GetDeviceInfoOptions = {
* } * }
* } * }
*/ */
deviceType?: string, deviceType?: 'phone' | 'pad' | 'tv' | 'watch' | 'pc' | 'undefined' | 'car' | 'vr' | 'appliance',
/** /**
* 设备方向 竖屏 portrait、横屏 landscape * 设备方向 竖屏 portrait、横屏 landscape
* *
...@@ -199,7 +199,7 @@ export type GetDeviceInfoOptions = { ...@@ -199,7 +199,7 @@ export type GetDeviceInfoOptions = {
* } * }
* } * }
*/ */
devicePixelRatio?: string, devicePixelRatio?: number,
/** /**
* 操作系统及版本 * 操作系统及版本
* *
...@@ -247,7 +247,7 @@ export type GetDeviceInfoOptions = { ...@@ -247,7 +247,7 @@ export type GetDeviceInfoOptions = {
* } * }
* } * }
*/ */
platform?: string, platform?: 'ios' | 'android' | 'mac' | 'windows' | 'linux',
/** /**
* 是否root。iOS 为是否越狱 * 是否root。iOS 为是否越狱
* *
......
...@@ -17,8 +17,8 @@ class NetworkRequestListener { ...@@ -17,8 +17,8 @@ class NetworkRequestListener {
} }
interface NetworkUploadFileListener { interface NetworkUploadFileListener {
progressListeners: Array<UploadFileProgressUpdateCallback>; progressListeners : Array<UploadFileProgressUpdateCallback>;
onProgress(progressUpdate: OnProgressUpdateResult): void; onProgress(progressUpdate : OnProgressUpdateResult) : void;
onDataReceived(data : Data) : void; onDataReceived(data : Data) : void;
onFinished(response : HTTPURLResponse) : void; onFinished(response : HTTPURLResponse) : void;
onFail(error : NSError) : void; onFail(error : NSError) : void;
...@@ -26,9 +26,9 @@ interface NetworkUploadFileListener { ...@@ -26,9 +26,9 @@ interface NetworkUploadFileListener {
interface NetworkDownloadFileListener { interface NetworkDownloadFileListener {
options : DownloadFileOptions | null; options : DownloadFileOptions | null;
progressListeners: Array<DownloadFileProgressUpdateCallback>; progressListeners : Array<DownloadFileProgressUpdateCallback>;
onProgress(progressUpdate: OnProgressDownloadResult): void; onProgress(progressUpdate : OnProgressDownloadResult) : void;
onFinished(response : HTTPURLResponse, filePath: string) : void; onFinished(response : HTTPURLResponse, filePath : string) : void;
onFail(error : NSError) : void; onFail(error : NSError) : void;
} }
...@@ -82,11 +82,11 @@ class NetworkManager implements URLSessionDataDelegate { ...@@ -82,11 +82,11 @@ class NetworkManager implements URLSessionDataDelegate {
return requestTask; return requestTask;
} }
public uploadFile(options: UploadFileOptions, listener: NetworkUploadFileListener): UploadTask { public uploadFile(options : UploadFileOptions, listener : NetworkUploadFileListener) : UploadTask {
return UploadController.getInstance().uploadFile(options, listener); return UploadController.getInstance().uploadFile(options, listener);
} }
public downloadFile(options: DownloadFileOptions, listener: NetworkDownloadFileListener): DownloadTask { public downloadFile(options : DownloadFileOptions, listener : NetworkDownloadFileListener) : DownloadTask {
return DownloadController.getInstance().downloadFile(options, listener); return DownloadController.getInstance().downloadFile(options, listener);
} }
...@@ -129,7 +129,9 @@ class NetworkManager implements URLSessionDataDelegate { ...@@ -129,7 +129,9 @@ class NetworkManager implements URLSessionDataDelegate {
let valueStr = ""; let valueStr = "";
if (value instanceof UTSJSONObject) { if (value instanceof UTSJSONObject) {
valueStr = JSON.stringify(value) ?? "" valueStr = JSON.stringify(value) ?? ""
}else{ } else if (value instanceof Map<string, any>) {
valueStr = JSON.stringify(new UTSJSONObject(value)) ?? ""
} else {
valueStr = `${value}` valueStr = `${value}`
} }
request.setValue(valueStr, forHTTPHeaderField = key); request.setValue(valueStr, forHTTPHeaderField = key);
...@@ -149,6 +151,8 @@ class NetworkManager implements URLSessionDataDelegate { ...@@ -149,6 +151,8 @@ class NetworkManager implements URLSessionDataDelegate {
json = JSON.parseObject(data as string); json = JSON.parseObject(data as string);
} else if (data instanceof UTSJSONObject) { } else if (data instanceof UTSJSONObject) {
json = data as UTSJSONObject; json = data as UTSJSONObject;
} else if (data instanceof Map<string, any>) {
json = new UTSJSONObject(data!)
} }
if (json != null) { if (json != null) {
let urlWithQuery = this.stringifyQuery(encodeUrl, json!) let urlWithQuery = this.stringifyQuery(encodeUrl, json!)
...@@ -160,6 +164,23 @@ class NetworkManager implements URLSessionDataDelegate { ...@@ -160,6 +164,23 @@ class NetworkManager implements URLSessionDataDelegate {
let bodyData : Data | null = null; let bodyData : Data | null = null;
if (typeof (param.data) == 'string') { if (typeof (param.data) == 'string') {
bodyData = (param.data as string).data(using = String.Encoding.utf8); bodyData = (param.data as string).data(using = String.Encoding.utf8);
} else if (param.data instanceof Map<string, any>) {
let body : string | null = "";
const contentType = request.value(forHTTPHeaderField = "Content-Type")
const data = new UTSJSONObject(param.data!);
if (contentType != null) {
if (contentType!.indexOf("application/x-www-form-urlencoded") == 0) {
const map : Map<string, any | null> = data.toMap();
const bodyArray = new Array<string>();
map.forEach((value, key) => {
bodyArray.push(key + "=" + `${value ?? "null"}`);
})
body = bodyArray.join("&");
} else {
body = JSON.stringify(data);
}
bodyData = body?.data(using = String.Encoding.utf8);
}
} else if (param.data instanceof UTSJSONObject) { } else if (param.data instanceof UTSJSONObject) {
let body : string | null = ""; let body : string | null = "";
const contentType = request.value(forHTTPHeaderField = "Content-Type") const contentType = request.value(forHTTPHeaderField = "Content-Type")
...@@ -207,7 +228,7 @@ class NetworkManager implements URLSessionDataDelegate { ...@@ -207,7 +228,7 @@ class NetworkManager implements URLSessionDataDelegate {
newUrl = str[0] // http:xxx/xxx newUrl = str[0] // http:xxx/xxx
const pairs = query.split('&') const pairs = query.split('&')
const queryMap = new Map<string, string>(); const queryMap = new Map<string, string>();
pairs.forEach((item: string, index: number) => { pairs.forEach((item : string, index : number) => {
const temp = item.split('=') const temp = item.split('=')
if (temp.length > 1) { if (temp.length > 1) {
queryMap[temp[0]] = temp[1] queryMap[temp[0]] = temp[1]
...@@ -215,13 +236,15 @@ class NetworkManager implements URLSessionDataDelegate { ...@@ -215,13 +236,15 @@ class NetworkManager implements URLSessionDataDelegate {
}); });
const dataMap : Map<string, any | null> = data.toMap(); const dataMap : Map<string, any | null> = data.toMap();
dataMap.forEach((value, key) => { dataMap.forEach((value, key) => {
if(value == null){ if (value == null) {
value = ""; value = "";
} }
let encodeKey = encodeURIComponent(key)! let encodeKey = encodeURIComponent(key)!
if (value instanceof UTSJSONObject || value instanceof Array<any|null>){ if (value instanceof UTSJSONObject || value instanceof Array<any | null>) {
queryMap[encodeKey] = encodeURIComponent(JSON.stringify(value)!)! queryMap[encodeKey] = encodeURIComponent(JSON.stringify(value)!)!
}else{ } else if (value instanceof Map<string, any>) {
queryMap[encodeKey] = encodeURIComponent(JSON.stringify(new UTSJSONObject(value))!)!
} else {
queryMap[encodeKey] = encodeURIComponent(`${value!}`)!; queryMap[encodeKey] = encodeURIComponent(`${value!}`)!;
} }
}) })
...@@ -240,9 +263,9 @@ class NetworkManager implements URLSessionDataDelegate { ...@@ -240,9 +263,9 @@ class NetworkManager implements URLSessionDataDelegate {
return newUrl; return newUrl;
} }
private percentEscapedString(str: string): string { private percentEscapedString(str : string) : string {
//如果url已经有部分经过encode,那么需要先decode再encode。 //如果url已经有部分经过encode,那么需要先decode再encode。
return str.removingPercentEncoding?.addingPercentEncoding(withAllowedCharacters= CharacterSet.urlQueryAllowed) ?? str return str.removingPercentEncoding?.addingPercentEncoding(withAllowedCharacters = CharacterSet.urlQueryAllowed) ?? str
} }
......
...@@ -91,6 +91,8 @@ export class DownloadController implements URLSessionDownloadDelegate { ...@@ -91,6 +91,8 @@ export class DownloadController implements URLSessionDownloadDelegate {
let valueStr = ""; let valueStr = "";
if (value instanceof UTSJSONObject) { if (value instanceof UTSJSONObject) {
valueStr = JSON.stringify(value) ?? "" valueStr = JSON.stringify(value) ?? ""
}else if(value instanceof Map<string, any>){
valueStr = JSON.stringify(new UTSJSONObject(value)) ?? ""
}else{ }else{
valueStr = `${value}` valueStr = `${value}`
} }
......
...@@ -97,6 +97,8 @@ class UploadController implements URLSessionDataDelegate { ...@@ -97,6 +97,8 @@ class UploadController implements URLSessionDataDelegate {
let valueStr = ""; let valueStr = "";
if (value instanceof UTSJSONObject) { if (value instanceof UTSJSONObject) {
valueStr = JSON.stringify(value) ?? "" valueStr = JSON.stringify(value) ?? ""
}else if(value instanceof Map<string, any>){
valueStr = JSON.stringify(new UTSJSONObject(value)) ?? ""
}else{ }else{
valueStr = `${value}` valueStr = `${value}`
} }
...@@ -119,6 +121,11 @@ class UploadController implements URLSessionDataDelegate { ...@@ -119,6 +121,11 @@ class UploadController implements URLSessionDataDelegate {
if (valueStr != null) { if (valueStr != null) {
this.fillTextPart(body, boundary, key, valueStr as string) this.fillTextPart(body, boundary, key, valueStr as string)
} }
}else if(value instanceof Map<string, any>){
let valueStr = JSON.stringify(new UTSJSONObject(value))
if (valueStr != null) {
this.fillTextPart(body, boundary, key, valueStr as string)
}
}else{ }else{
this.fillTextPart(body, boundary, key, `${value}`) this.fillTextPart(body, boundary, key, `${value}`)
} }
......
...@@ -107,7 +107,11 @@ export const setTabBarStyle = defineAsyncApi< ...@@ -107,7 +107,11 @@ export const setTabBarStyle = defineAsyncApi<
['backgroundImage', options.backgroundImage], ['backgroundImage', options.backgroundImage],
['backgroundRepeat', options.backgroundRepeat], ['backgroundRepeat', options.backgroundRepeat],
]) ])
if (isString(options.borderStyle)) { if (isString(options.borderColor)) {
style.set(
'borderStyle', options.borderColor as string,
)
} else if (isString(options.borderStyle)) {
style.set( style.set(
'borderStyle', 'borderStyle',
getTabBarBorderStyle(options.borderStyle as string), getTabBarBorderStyle(options.borderStyle as string),
......
...@@ -235,10 +235,33 @@ export type SetTabBarStyleOptions = { ...@@ -235,10 +235,33 @@ export type SetTabBarStyleOptions = {
* - no-repeat: 背景图片在垂直方向和水平方向都拉伸 * - no-repeat: 背景图片在垂直方向和水平方向都拉伸
*/ */
backgroundRepeat?: 'repeat' | 'repeat-x' | 'repeat-y' | 'no-repeat' backgroundRepeat?: 'repeat' | 'repeat-x' | 'repeat-y' | 'no-repeat'
/**
* tabbar上边框的颜色(优先级高于 borderStyle)
* @tutorial https://doc.dcloud.net.cn/uni-app-x/api/set-tabbar.html#settabbarstyle
* @uniPlatform {
* "app": {
* "android": {
* "osVer": "5.0",
* "uniVer": "x",
* "unixVer": "x"
* },
* "ios": {
* "osVer": "12.0",
* "uniVer": "x",
* "unixVer": "4.23"
* }
* },
* "web": {
* "uniVer": "x",
* "unixVer": "4.23"
* }
* }
*/
borderColor?: string | string.ColorString
/** /**
* tabbar上边框的颜色 * tabbar上边框的颜色
*/ */
borderStyle?: string borderStyle?: 'black' | 'white'
/** /**
* tabbar 中间按钮 仅在 list 项为偶数时有效 * tabbar 中间按钮 仅在 list 项为偶数时有效
* @internal * @internal
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册