提交 e4a5786a 编写于 作者: fxy060608's avatar fxy060608

chore: merge

......@@ -10,7 +10,12 @@ const SCENE: Parameters<API_TYPE_SHARE>[0]['scene'][] = [
export const SahreOptions: ApiOptions<API_TYPE_SHARE> = {
formatArgs: {
scene(value, params) {
if (params.provider === 'weixin' && (!value || !SCENE.includes(value))) {
const { provider, openCustomerServiceChat } = params
if (
provider === 'weixin' &&
!openCustomerServiceChat &&
(!value || !SCENE.includes(value))
) {
return `分享到微信时,scene必须为以下其中一个:${SCENE.join('')}`
}
},
......@@ -39,6 +44,16 @@ export const SahreOptions: ApiOptions<API_TYPE_SHARE> = {
return '分享小程序时,miniProgram必填'
}
},
corpid(value, params) {
if (params.openCustomerServiceChat && !value) {
return `使用打开客服功能时 corpid 必填`
}
},
customerUrl(value, params) {
if (params.openCustomerServiceChat && !value) {
return `使用打开客服功能时 customerUrl 必填`
}
},
},
}
export const ShareProtocols: ApiProtocol<API_TYPE_SHARE> = {
......
......@@ -1062,6 +1062,37 @@ uni-input[hidden] {
.uni-label-pointer {
cursor: pointer;
}
uni-live-pusher {
width: 320px;
height: 240px;
display: inline-block;
line-height: 0;
overflow: hidden;
position: relative;
}
uni-live-pusher[hidden] {
display: none;
}
.uni-live-pusher-container {
width: 100%;
height: 100%;
position: absolute;
top: 0;
left: 0;
overflow: hidden;
background-color: black;
}
.uni-live-pusher-slot {
position: absolute;
top: 0;
width: 100%;
height: 100%;
overflow: hidden;
pointer-events: none;
}
uni-map {
width: 300px;
height: 225px;
......
......@@ -13290,7 +13290,7 @@
tempCanvas.height = height;
return tempCanvas;
}
var props$l = {
var props$m = {
canvasId: {
type: String,
default: ""
......@@ -13310,7 +13310,7 @@
compatConfig: {
MODE: 3
},
props: props$l,
props: props$m,
computed: {
id() {
return this.canvasId;
......@@ -13792,7 +13792,7 @@
});
}
var uniCheckGroupKey = PolySymbol("ucg");
var props$k = {
var props$l = {
name: {
type: String,
default: ""
......@@ -13800,7 +13800,7 @@
};
var CheckboxGroup = /* @__PURE__ */ defineBuiltInComponent({
name: "CheckboxGroup",
props: props$k,
props: props$l,
emits: ["change"],
setup(props2, _ref) {
var {
......@@ -13853,7 +13853,7 @@
}
return getFieldsValue;
}
var props$j = {
var props$k = {
checked: {
type: [Boolean, String],
default: false
......@@ -13877,7 +13877,7 @@
};
var Checkbox = /* @__PURE__ */ defineBuiltInComponent({
name: "Checkbox",
props: props$j,
props: props$k,
setup(props2, _ref) {
var {
slots
......@@ -14025,7 +14025,7 @@
});
}
}
var props$i = {
var props$j = {
cursorSpacing: {
type: [Number, String],
default: 0
......@@ -14864,7 +14864,7 @@
}
}, id2, true);
}
var props$h = /* @__PURE__ */ extend({}, props$i, {
var props$i = /* @__PURE__ */ extend({}, props$j, {
id: {
type: String,
default: ""
......@@ -14892,7 +14892,7 @@
});
var Editor = /* @__PURE__ */ defineBuiltInComponent({
name: "Editor",
props: props$h,
props: props$i,
emit: ["ready", "focus", "blur", "input", "statuschange", ...emit$1],
setup(props2, _ref) {
var {
......@@ -14980,7 +14980,7 @@
};
}
});
var props$g = {
var props$h = {
src: {
type: String,
default: ""
......@@ -15019,7 +15019,7 @@
};
var Image$1 = /* @__PURE__ */ defineBuiltInComponent({
name: "Image",
props: props$g,
props: props$h,
setup(props2, _ref) {
var {
emit: emit2
......@@ -15341,7 +15341,7 @@
}
return value === null ? "" : String(value);
}
var props$f = /* @__PURE__ */ extend({}, {
var props$g = /* @__PURE__ */ extend({}, {
name: {
type: String,
default: ""
......@@ -15410,7 +15410,7 @@
type: Boolean,
default: false
}
}, props$i);
}, props$j);
var emit = ["input", "focus", "blur", "update:value", "update:modelValue", "update:focus", ...emit$1];
function useBase(props2, rootRef, emit2) {
var fieldRef = ref(null);
......@@ -15625,7 +15625,7 @@
trigger: trigger2
};
}
var props$e = /* @__PURE__ */ extend({}, props$f, {
var props$f = /* @__PURE__ */ extend({}, props$g, {
placeholderClass: {
type: String,
default: "input-placeholder"
......@@ -15637,7 +15637,7 @@
});
var Input = /* @__PURE__ */ defineBuiltInComponent({
name: "Input",
props: props$e,
props: props$f,
emits: ["confirm", ...emit],
setup(props2, _ref) {
var {
......@@ -16113,6 +16113,7 @@
var y1 = 0;
var fn = function($event, state, x, y) {
if (method({
cancelable: $event.cancelable,
target: $event.target,
currentTarget: $event.currentTarget,
preventDefault: $event.preventDefault.bind($event),
......@@ -17987,13 +17988,15 @@
if (scroller.onTouchStart) {
scroller.onTouchStart();
}
event.preventDefault();
if (typeof event.cancelable !== "boolean" || event.cancelable)
event.preventDefault();
}
function handleTouchMove(event) {
var touchtrackEvent = event;
var mouseEvent = event;
if (touchInfo.trackingID !== -1) {
event.preventDefault();
if (typeof event.cancelable !== "boolean" || event.cancelable)
event.preventDefault();
var delta = findDelta(event);
if (delta) {
for (touchInfo.maxDy = Math.max(touchInfo.maxDy, Math.abs(delta.y)), touchInfo.maxDx = Math.max(touchInfo.maxDx, Math.abs(delta.x)), touchInfo.historyX.push(delta.x), touchInfo.historyY.push(delta.y), touchInfo.historyTime.push(touchtrackEvent.detail.timeStamp || mouseEvent.timeStamp); touchInfo.historyTime.length > 10; ) {
......@@ -18387,7 +18390,7 @@
}
}
var uniRadioGroupKey = PolySymbol("ucg");
var props$d = {
var props$e = {
name: {
type: String,
default: ""
......@@ -18395,7 +18398,7 @@
};
var RadioGroup = /* @__PURE__ */ defineBuiltInComponent({
name: "RadioGroup",
props: props$d,
props: props$e,
setup(props2, _ref) {
var {
emit: emit2,
......@@ -18479,7 +18482,7 @@
}
return fields2;
}
var props$c = {
var props$d = {
checked: {
type: [Boolean, String],
default: false
......@@ -18503,7 +18506,7 @@
};
var Radio = /* @__PURE__ */ defineBuiltInComponent({
name: "Radio",
props: props$c,
props: props$d,
setup(props2, _ref) {
var {
slots
......@@ -18838,7 +18841,7 @@
});
return results.children;
}
var props$b = {
var props$c = {
nodes: {
type: [Array, String],
default: function() {
......@@ -18851,7 +18854,7 @@
compatConfig: {
MODE: 3
},
props: props$b,
props: props$c,
emits: ["click", "touchstart", "touchmove", "touchcancel", "touchend", "longpress"],
setup(props2, _ref) {
var {
......@@ -18888,7 +18891,7 @@
}
});
var passiveOptions = /* @__PURE__ */ passive(true);
var props$a = {
var props$b = {
scrollX: {
type: [Boolean, String],
default: false
......@@ -18951,7 +18954,7 @@
compatConfig: {
MODE: 3
},
props: props$a,
props: props$b,
emits: ["scroll", "scrolltoupper", "scrolltolower", "refresherrefresh", "refresherrestore", "refresherpulling", "refresherabort", "update:refresherTriggered"],
setup(props2, _ref) {
var {
......@@ -19378,7 +19381,7 @@
}
});
}
var props$9 = {
var props$a = {
name: {
type: String,
default: ""
......@@ -19434,7 +19437,7 @@
};
var Slider = /* @__PURE__ */ defineBuiltInComponent({
name: "Slider",
props: props$9,
props: props$a,
emits: ["changing", "change"],
setup(props2, _ref) {
var {
......@@ -19603,7 +19606,7 @@
return Number(s1.replace(".", "")) * Number(s2.replace(".", "")) / Math.pow(10, m);
}
};
var props$8 = {
var props$9 = {
indicatorDots: {
type: [Boolean, String],
default: false
......@@ -20087,7 +20090,7 @@
}
var Swiper = /* @__PURE__ */ defineBuiltInComponent({
name: "Swiper",
props: props$8,
props: props$9,
emits: ["change", "transition", "animationfinish", "update:current", "update:currentItemId"],
setup(props2, _ref) {
var {
......@@ -20195,7 +20198,7 @@
};
}
});
var props$7 = {
var props$8 = {
itemId: {
type: String,
default: ""
......@@ -20203,7 +20206,7 @@
};
var SwiperItem = /* @__PURE__ */ defineBuiltInComponent({
name: "SwiperItem",
props: props$7,
props: props$8,
setup(props2, _ref) {
var {
slots
......@@ -20253,7 +20256,7 @@
};
}
});
var props$6 = {
var props$7 = {
name: {
type: String,
default: ""
......@@ -20281,7 +20284,7 @@
};
var Switch = /* @__PURE__ */ defineBuiltInComponent({
name: "Switch",
props: props$6,
props: props$7,
emits: ["change"],
setup(props2, _ref) {
var {
......@@ -20386,7 +20389,7 @@
}
return text2.replace(/&nbsp;/g, SPACE_UNICODE.nbsp).replace(/&ensp;/g, SPACE_UNICODE.ensp).replace(/&emsp;/g, SPACE_UNICODE.emsp).replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&amp;/g, "&").replace(/&quot;/g, '"').replace(/&apos;/g, "'");
}
var props$5 = /* @__PURE__ */ extend({}, props$f, {
var props$6 = /* @__PURE__ */ extend({}, props$g, {
placeholderClass: {
type: String,
default: "input-placeholder"
......@@ -20407,7 +20410,7 @@
}
var Textarea = /* @__PURE__ */ defineBuiltInComponent({
name: "Textarea",
props: props$5,
props: props$6,
emit: ["confirm", "linechange", ...emit],
setup(props2, _ref) {
var {
......@@ -21397,7 +21400,7 @@
});
}
var TEMP_PATH = "_doc/uniapp_temp/";
var props$4 = {
var props$5 = {
src: {
type: String,
default: ""
......@@ -21469,7 +21472,7 @@
}
var CoverImage = /* @__PURE__ */ defineBuiltInComponent({
name: "CoverImage",
props: props$4,
props: props$5,
emits: ["click", "load", "error"],
setup(props2, _ref2) {
var {
......@@ -21582,9 +21585,113 @@
super(id2, "uni-live-player", parentNodeId, refNodeId);
}
}
class UniLivePusher extends UniTodoNode {
constructor(id2, parentNodeId, refNodeId) {
super(id2, "uni-live-pusher", parentNodeId, refNodeId);
var livePusher = "";
var props$4 = {
id: {
type: String,
default: ""
},
url: {
type: String,
default: ""
},
mode: {
type: String,
default: "SD"
},
muted: {
type: [Boolean, String],
default: false
},
enableCamera: {
type: [Boolean, String],
default: true
},
autoFocus: {
type: [Boolean, String],
default: true
},
beauty: {
type: [Number, String],
default: 0
},
whiteness: {
type: [Number, String],
default: 0
},
aspect: {
type: [String],
default: "3:2"
},
minBitrate: {
type: [Number],
default: 200
}
};
var emits$1 = ["statechange", "netstatus", "error"];
var LivePusher = /* @__PURE__ */ defineBuiltInComponent({
name: "LivePusher",
props: props$4,
emits: emits$1,
setup(props2, _ref) {
var {
emit: emit2
} = _ref;
var rootRef = ref(null);
var trigger2 = useCustomEvent(rootRef, emit2);
var containerRef = ref(null);
var attrs2 = useNativeAttrs(props2, ["id"]);
var {
position,
hidden,
onParentReady
} = useNative(containerRef);
var livePusher2;
onParentReady(() => {
livePusher2 = new plus.video.LivePusher("livePusher" + Date.now(), Object.assign({}, attrs2.value, position));
plus.webview.currentWebview().append(livePusher2);
emits$1.forEach((key2) => {
livePusher2.addEventListener(key2, (event) => {
trigger2(key2, {}, event.detail);
});
});
watch(() => attrs2.value, (attrs3) => livePusher2.setStyles(attrs3), {
deep: true
});
watch(() => position, (position2) => livePusher2.setStyles(position2), {
deep: true
});
watch(() => hidden.value, (val) => {
if (!val) {
livePusher2.setStyles(position);
}
});
});
var id2 = useContextInfo();
useSubscribe((type, data) => {
if (livePusher2) {
livePusher2[type](data);
}
}, id2, true);
onBeforeUnmount(() => {
if (livePusher2) {
livePusher2.close();
}
});
return () => {
return createVNode("uni-live-pusher", {
"ref": rootRef,
"id": props2.id
}, [createVNode("div", {
"ref": containerRef,
"class": "uni-live-pusher-container"
}, null, 512)], 8, ["id"]);
};
}
});
class UniLivePusher extends UniComponent {
constructor(id2, parentNodeId, refNodeId, nodeJson) {
super(id2, "uni-live-pusher", LivePusher, parentNodeId, refNodeId, nodeJson, ".uni-live-pusher-slot");
}
}
var map = "";
......
......@@ -12431,7 +12431,10 @@ const SCENE = [
const SahreOptions = {
formatArgs: {
scene(value, params) {
if (params.provider === 'weixin' && (!value || !SCENE.includes(value))) {
const { provider, openCustomerServiceChat } = params;
if (provider === 'weixin' &&
!openCustomerServiceChat &&
(!value || !SCENE.includes(value))) {
return `分享到微信时,scene必须为以下其中一个:${SCENE.join('、')}`;
}
},
......@@ -12460,6 +12463,16 @@ const SahreOptions = {
return '分享小程序时,miniProgram必填';
}
},
corpid(value, params) {
if (params.openCustomerServiceChat && !value) {
return `使用打开客服功能时 corpid 必填`;
}
},
customerUrl(value, params) {
if (params.openCustomerServiceChat && !value) {
return `使用打开客服功能时 customerUrl 必填`;
}
},
},
};
const ShareProtocols = {
......@@ -15473,15 +15486,56 @@ class LivePusherContext {
return invokeVmMethodWithoutArgs(this.ctx, 'stopPreview', args);
}
}
const createLivePusherContext = defineSyncApi(API_CREATE_LIVE_PUSHER_CONTEXT, (id, vm) => {
if (!vm) {
return console.warn('uni.createLivePusherContext: 2 arguments required, but only 1 present');
// TODO
function publishToView(livePusherId, pageId, type, data) {
UniServiceJSBridge.invokeViewMethod('livepusher.' + livePusherId, {
livePusherId,
type,
data,
}, pageId);
}
class LivePusherContextVue {
constructor(id, pageId) {
this.id = id;
this.pageId = pageId;
}
const elm = findElmById(id, vm);
if (!elm) {
return console.warn('Can not find `' + id + '`');
start() {
publishToView(this.id, this.pageId, 'start');
}
stop() {
publishToView(this.id, this.pageId, 'stop');
}
pause() {
publishToView(this.id, this.pageId, 'pause');
}
resume() {
publishToView(this.id, this.pageId, 'resume');
}
switchCamera() {
publishToView(this.id, this.pageId, 'switchCamera');
}
return new LivePusherContext(id, elm);
startPreview() {
publishToView(this.id, this.pageId, 'preview');
}
stopPreview() {
publishToView(this.id, this.pageId, 'stop');
}
snapshot() {
publishToView(this.id, this.pageId, 'snapshot');
}
}
const createLivePusherContext = defineSyncApi(API_CREATE_LIVE_PUSHER_CONTEXT, (id, vm) => {
if (vm.$page.meta.isNVue) {
if (!vm) {
return console.warn('uni.createLivePusherContext: 2 arguments required, but only 1 present');
}
const elm = findElmById(id, vm);
if (!elm) {
return console.warn('Can not find `' + id + '`');
}
return new LivePusherContext(id, elm);
}
return new LivePusherContextVue(id, vm.$page.id);
}, CreateLivePusherContextProtocol);
const PI = 3.1415926535897932384626;
......@@ -16223,7 +16277,8 @@ function getService(provider) {
const login = defineAsyncApi(API_LOGIN, (params, { resolve, reject }) => {
const provider = params.provider || 'weixin';
const errorCallback = warpPlusErrorCallback(reject);
const authOptions = provider === 'apple'
const isAppleLogin = provider === 'apple';
const authOptions = isAppleLogin
? { scope: 'email' }
: params.univerifyStyle
? {
......@@ -16244,15 +16299,17 @@ const login = defineAsyncApi(API_LOGIN, (params, { resolve, reject }) => {
}
service.login((res) => {
const authResult = res.target.authResult;
const appleInfo = res.target.appleInfo;
resolve({
code: authResult.code,
authResult: authResult,
appleInfo,
});
}, errorCallback, authOptions);
}
// 先注销再登录
// apple登录logout之后无法重新触发获取email,fullname;一键登录无logout
if (provider === 'apple' || provider === 'univerify') {
if (isAppleLogin || provider === 'univerify') {
login();
}
else {
......@@ -16385,16 +16442,16 @@ class UniverifyManager {
this.eventName = 'api.univerifyButtonsClick';
}
close() {
closeAuthView();
return closeAuthView();
}
login(options) {
login(this._getOptions(options));
return login(this._getOptions(options));
}
getCheckBoxState(options) {
getCheckBoxState(options);
return getCheckBoxState(options);
}
preLogin(options) {
preLogin(this._getOptions(options));
return preLogin(this._getOptions(options));
}
onButtonsClick(callback) {
UniServiceJSBridge.on(this.eventName, callback);
......@@ -16447,7 +16504,7 @@ const TYPES = {
};
const parseParams = (args) => {
args.type = args.type || 0;
let { provider, type, title, summary: content, href, imageUrl, mediaUrl: media, scene, miniProgram, } = args;
let { provider, type, title, summary: content, href, imageUrl, mediaUrl: media, scene, miniProgram, openCustomerServiceChat, corpid, customerUrl: url, } = args;
if (typeof imageUrl === 'string' && imageUrl) {
imageUrl = getRealPath(imageUrl);
}
......@@ -16466,6 +16523,9 @@ const parseParams = (args) => {
extra: {
scene,
},
openCustomerServiceChat,
corpid,
url,
};
if (provider === 'weixin' && (type === 1 || type === 2)) {
delete sendMsg.thumbs;
......@@ -16476,30 +16536,38 @@ const parseParams = (args) => {
};
const sendShareMsg = function (service, params, resolve, reject, method = 'share') {
const errorCallback = warpPlusErrorCallback(reject);
service.send(params, () => {
resolve();
}, errorCallback);
const serviceMethod = params.openCustomerServiceChat
? 'openCustomerServiceChat'
: 'send';
try {
// @ts-expect-error openCustomerServiceChat
service[serviceMethod](params, () => {
resolve();
}, errorCallback);
}
catch (error) {
errorCallback({
message: `${params.provider} ${serviceMethod} 方法调用失败`,
});
}
};
const share = defineAsyncApi(API_SHREA, (params, { resolve, reject }) => {
const res = parseParams(params);
const parsedParams = parseParams(params);
const errorCallback = warpPlusErrorCallback(reject);
if (typeof res === 'string') {
return reject(res);
}
else {
params = res;
if (typeof parsedParams === 'string') {
return reject(parsedParams);
}
plus.share.getServices((services) => {
const service = services.find(({ id }) => id === params.provider);
const service = services.find(({ id }) => id === parsedParams.provider);
if (!service) {
reject('service not found');
}
else {
if (service.authenticated) {
sendShareMsg(service, params, resolve, reject);
sendShareMsg(service, parsedParams, resolve, reject);
}
else {
service.authorize(() => sendShareMsg(service, params, resolve, reject), errorCallback);
service.authorize(() => sendShareMsg(service, parsedParams, resolve, reject), errorCallback);
}
}
}, errorCallback);
......
......@@ -79,20 +79,82 @@ class LivePusherContext implements UniApp.LivePusherContext {
'setMICVolume': () => {}
}
// TODO
function publishToView(
livePusherId: string,
pageId: number,
type: string,
data?: unknown
) {
UniServiceJSBridge.invokeViewMethod(
'livepusher.' + livePusherId,
{
livePusherId,
type,
data,
},
pageId
)
}
class LivePusherContextVue {
private id: string
private pageId: number
constructor(id: string, pageId: number) {
this.id = id
this.pageId = pageId
}
start() {
publishToView(this.id, this.pageId, 'start')
}
stop() {
publishToView(this.id, this.pageId, 'stop')
}
pause() {
publishToView(this.id, this.pageId, 'pause')
}
resume() {
publishToView(this.id, this.pageId, 'resume')
}
switchCamera() {
publishToView(this.id, this.pageId, 'switchCamera')
}
startPreview() {
publishToView(this.id, this.pageId, 'preview')
}
stopPreview() {
publishToView(this.id, this.pageId, 'stop')
}
snapshot() {
publishToView(this.id, this.pageId, 'snapshot')
}
}
export const createLivePusherContext =
defineSyncApi<API_TYPE_CREATE_LIVE_PUSHER_CONTEXT>(
API_CREATE_LIVE_PUSHER_CONTEXT,
(id, vm) => {
if (!vm) {
return console.warn(
'uni.createLivePusherContext: 2 arguments required, but only 1 present'
)
}
const elm = findElmById(id, vm)
if (!elm) {
return console.warn('Can not find `' + id + '`')
if (vm.$page.meta.isNVue) {
if (!vm) {
return console.warn(
'uni.createLivePusherContext: 2 arguments required, but only 1 present'
)
}
const elm = findElmById(id, vm)
if (!elm) {
return console.warn('Can not find `' + id + '`')
}
return new LivePusherContext(id, elm)
}
return new LivePusherContext(id, elm)
return new LivePusherContextVue(id, vm.$page.id)
},
CreateLivePusherContextProtocol
)
......@@ -49,17 +49,17 @@ export const login = defineAsyncApi<API_TYPE_LOGIN>(
(params, { resolve, reject }) => {
const provider = params.provider || 'weixin'
const errorCallback = warpPlusErrorCallback(reject)
const authOptions =
provider === 'apple'
? { scope: 'email' }
: params.univerifyStyle
? {
univerifyStyle: univerifyButtonsClickHandling(
params.univerifyStyle,
errorCallback
),
}
: {}
const isAppleLogin = provider === 'apple'
const authOptions = isAppleLogin
? { scope: 'email' }
: params.univerifyStyle
? {
univerifyStyle: univerifyButtonsClickHandling(
params.univerifyStyle,
errorCallback
),
}
: {}
getService(provider)
.then((service) => {
......@@ -76,9 +76,11 @@ export const login = defineAsyncApi<API_TYPE_LOGIN>(
service.login(
(res) => {
const authResult = res.target.authResult
const appleInfo = res.target.appleInfo
resolve({
code: authResult.code,
authResult: authResult,
appleInfo,
})
},
errorCallback,
......@@ -87,7 +89,7 @@ export const login = defineAsyncApi<API_TYPE_LOGIN>(
}
// 先注销再登录
// apple登录logout之后无法重新触发获取email,fullname;一键登录无logout
if (provider === 'apple' || provider === 'univerify') {
if (isAppleLogin || provider === 'univerify') {
login()
} else {
service.logout(login, login)
......@@ -261,19 +263,19 @@ class UniverifyManager implements UniApp.UniverifyManager {
eventName: string = 'api.univerifyButtonsClick'
close() {
closeAuthView()
return closeAuthView()
}
login(options: UniApp.UniverifyLoginOptions) {
login(this._getOptions(options))
return login(this._getOptions(options))
}
getCheckBoxState(options: UniApp.GetCheckBoxStateOptions) {
getCheckBoxState(options)
return getCheckBoxState(options)
}
preLogin(options?: UniApp.CallBackOptions) {
preLogin(this._getOptions(options))
return preLogin(this._getOptions(options))
}
onButtonsClick(callback: UniApp.CallbackFunction) {
......
......@@ -40,7 +40,7 @@ const TYPES = {
},
}
const parseParams = <T extends Data>(args: UniApp.ShareOptions): T | string => {
const parseParams = (args: UniApp.ShareOptions) => {
args.type = args.type || 0
let {
......@@ -53,6 +53,9 @@ const parseParams = <T extends Data>(args: UniApp.ShareOptions): T | string => {
mediaUrl: media,
scene,
miniProgram,
openCustomerServiceChat,
corpid,
customerUrl: url,
} = args
if (typeof imageUrl === 'string' && imageUrl) {
......@@ -74,55 +77,66 @@ const parseParams = <T extends Data>(args: UniApp.ShareOptions): T | string => {
extra: {
scene,
},
openCustomerServiceChat,
corpid,
url,
}
if (provider === 'weixin' && (type === 1 || type === 2)) {
delete sendMsg.thumbs
}
return sendMsg as unknown as T
return sendMsg
}
return '分享参数 type 不正确'
}
type ParseParams = ReturnType<typeof parseParams>
const sendShareMsg = function (
service: PlusShareShareService,
params: Data,
params: Exclude<ParseParams, string>,
resolve: (args?: any) => void,
reject: (errMsg: string, errRes?: any) => void,
method = 'share'
) {
const errorCallback = warpPlusErrorCallback(reject)
service.send(
params,
() => {
resolve()
},
errorCallback
)
const serviceMethod = params.openCustomerServiceChat
? 'openCustomerServiceChat'
: 'send'
try {
// @ts-expect-error openCustomerServiceChat
service[serviceMethod](
params,
() => {
resolve()
},
errorCallback
)
} catch (error) {
errorCallback({
message: `${params.provider} ${serviceMethod} 方法调用失败`,
})
}
}
export const share = defineAsyncApi<API_TYPE_SHARE>(
API_SHREA,
(params, { resolve, reject }) => {
const res = parseParams<typeof params>(params)
const parsedParams = parseParams(params)
const errorCallback = warpPlusErrorCallback(reject)
if (typeof res === 'string') {
return reject(res)
} else {
params = res
if (typeof parsedParams === 'string') {
return reject(parsedParams)
}
plus.share.getServices((services) => {
const service = services.find(({ id }) => id === params.provider)
const service = services.find(({ id }) => id === parsedParams.provider)
if (!service) {
reject('service not found')
} else {
if (service.authenticated) {
sendShareMsg(service, params, resolve, reject)
sendShareMsg(service, parsedParams, resolve, reject)
} else {
service.authorize(
() => sendShareMsg(service, params, resolve, reject),
() => sendShareMsg(service, parsedParams, resolve, reject),
errorCallback
)
}
......
import { Ref, ref, watch, onBeforeUnmount } from 'vue'
import {
defineBuiltInComponent,
useCustomEvent,
EmitEvent,
useSubscribe,
useContextInfo,
} from '@dcloudio/uni-components'
import { useNativeAttrs, useNative } from '../../../helpers/useNative'
const props = {
id: {
type: String,
default: '',
},
url: {
type: String,
default: '',
},
mode: {
type: String,
default: 'SD',
},
muted: {
type: [Boolean, String],
default: false,
},
enableCamera: {
type: [Boolean, String],
default: true,
},
autoFocus: {
type: [Boolean, String],
default: true,
},
beauty: {
type: [Number, String],
default: 0,
},
whiteness: {
type: [Number, String],
default: 0,
},
aspect: {
type: [String],
default: '3:2',
},
minBitrate: {
type: [Number],
default: 200,
},
}
type EventName = 'statechange' | 'netstatus' | 'error'
const emits: EventName[] = ['statechange', 'netstatus', 'error']
export default /*#__PURE__*/ defineBuiltInComponent({
name: 'LivePusher',
props,
emits,
setup(props, { emit }) {
const rootRef: Ref<HTMLElement | null> = ref(null)
const trigger = useCustomEvent<EmitEvent<typeof emit>>(rootRef, emit)
const containerRef: Ref<HTMLElement | null> = ref(null)
const attrs = useNativeAttrs(props, ['id'])
const { position, hidden, onParentReady } = useNative(containerRef)
let livePusher: PlusVideoLivePusher
onParentReady(() => {
livePusher = new plus.video.LivePusher!(
'livePusher' + Date.now(),
Object.assign({}, attrs.value, position)
)
plus.webview.currentWebview().append(livePusher as any)
emits.forEach((key) => {
livePusher.addEventListener(key, (event) => {
trigger(key, {} as Event, event.detail)
})
})
watch(
() => attrs.value,
(attrs) => livePusher.setStyles(attrs as any),
{ deep: true }
)
watch(
() => position,
(position) => livePusher.setStyles(position),
{ deep: true }
)
watch(
() => hidden.value,
(val) => {
// iOS 隐藏状态设置 setStyles 不生效
if (!val) {
livePusher.setStyles(position)
}
}
)
})
const id = useContextInfo()
useSubscribe(
(type: string, data: any) => {
if (livePusher) {
// @ts-expect-error
livePusher[type as any](data)
}
},
id,
true
)
onBeforeUnmount(() => {
if (livePusher) {
livePusher.close()
}
})
return () => {
return (
<uni-live-pusher ref={rootRef} id={props.id}>
<div ref={containerRef} class="uni-live-pusher-container" />
</uni-live-pusher>
)
}
},
})
import { UniTodoNode } from '../elements/UniTodoNode'
import { UniNodeJSON } from '@dcloudio/uni-shared'
import '../../../../../style/live-pusher.css'
import LivePusher from '../../../components/live-pusher'
export class UniLivePusher extends UniTodoNode {
constructor(id: number, parentNodeId: number, refNodeId: number) {
super(id, 'uni-live-pusher', parentNodeId, refNodeId)
import { UniComponent } from './UniComponent'
export class UniLivePusher extends UniComponent {
constructor(
id: number,
parentNodeId: number,
refNodeId: number,
nodeJson: Partial<UniNodeJSON>
) {
super(
id,
'uni-live-pusher',
LivePusher,
parentNodeId,
refNodeId,
nodeJson,
'.uni-live-pusher-slot'
)
}
}
uni-live-pusher {
width: 320px;
height: 240px;
display: inline-block;
line-height: 0;
overflow: hidden;
position: relative;
}
uni-live-pusher[hidden] {
display: none;
}
.uni-live-pusher-container {
width: 100%;
height: 100%;
position: absolute;
top: 0;
left: 0;
overflow: hidden;
background-color: black;
}
.uni-live-pusher-slot {
position: absolute;
top: 0;
width: 100%;
height: 100%;
overflow: hidden;
pointer-events: none;
}
{
"name": "@dcloudio/uni-cli-nvue",
"version": "3.0.0-alpha-3040220220310001",
"description": "uni-cli-nvue",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"files": [
"dist",
"lib"
],
"repository": {
"type": "git",
"url": "git+https://github.com/dcloudio/uni-app.git",
"directory": "packages/uni-cli-nvue"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"license": "Apache-2.0",
"gitHead": "33e807d66e1fe47e2ee08ad9c59247e37b8884da",
"dependencies": {
"@babel/core": "^7.17.2",
"@babel/preset-env": "^7.16.5",
"@dcloudio/uni-cli-shared": "3.0.0-alpha-3040220220310001",
"@dcloudio/uni-shared": "3.0.0-alpha-3040220220310001",
"@vue/shared": "3.2.31",
"acorn": "^5.2.1",
"babel-loader": "^8.2.2",
"consolidate": "^0.15.1",
"css": "~2.2.1",
"cssesc": "^3.0.0",
"de-indent": "^1.0.2",
"escodegen": "^1.8.1",
"file-loader": "^6.2.0",
"hash-sum": "^2.0.0",
"he": "^1.1.0",
"indexes-of": "^1.0.1",
"less-loader": "^10.0.1",
"loader-utils": "^1.1.0",
"lru-cache": "^4.1.2",
"merge-source-map": "^1.1.0",
"module-alias": "^2.2.2",
"postcss": "^8.4.6",
"postcss-comment": "^2.0.0",
"postcss-import": "^14.0.2",
"postcss-loader": "^6.1.1",
"postcss-selector-parser": "^6.0.6",
"prettier": "^1.18.2",
"sass-loader": "^12.1.0",
"source-map": "^0.6.1",
"stylus-loader": "^6.1.0",
"terser-webpack-plugin": "^5.1.4",
"uniq": "^1.0.1",
"vue-hot-reload-api": "^2.3.0",
"vue-style-loader": "^4.1.0",
"vue-template-es2015-compiler": "^1.9.0",
"webpack": "^5.48.0",
"webpack-sources": "^3.1.2"
},
"devDependencies": {
"@types/loader-utils": "^2.0.3",
"@types/module-alias": "^2.0.1",
"@types/terser-webpack-plugin": "^5.0.4",
"@types/webpack-sources": "^2.1.1",
"vue-template-compiler": "^2.6.14"
}
}
......@@ -56,13 +56,17 @@ export function useScroller(element: HTMLElement, options: Options) {
if (scroller.onTouchStart) {
scroller.onTouchStart()
}
event.preventDefault()
// @ts-expect-error
if (typeof event.cancelable !== 'boolean' || event.cancelable)
event.preventDefault()
}
function handleTouchMove(event: TouchtrackEvent | MouseEvent) {
const touchtrackEvent: TouchtrackEvent = event as TouchtrackEvent
const mouseEvent: MouseEvent = event as MouseEvent
if (touchInfo.trackingID !== -1) {
event.preventDefault()
// @ts-expect-error
if (typeof event.cancelable !== 'boolean' || event.cancelable)
event.preventDefault()
const delta = findDelta(event)
if (delta) {
for (
......
......@@ -73,6 +73,8 @@ export function useTouchtrack(
) {
if (
method({
// @ts-expect-error
cancelable: $event.cancelable,
target: $event.target,
currentTarget: $event.currentTarget,
preventDefault: $event.preventDefault.bind($event),
......
......@@ -9071,6 +9071,7 @@ function useTouchtrack(element, method, useCancel) {
let y1 = 0;
const fn = function($event, state2, x, y) {
if (method({
cancelable: $event.cancelable,
target: $event.target,
currentTarget: $event.currentTarget,
preventDefault: $event.preventDefault.bind($event),
......@@ -10947,13 +10948,15 @@ function useScroller(element, options) {
if (scroller.onTouchStart) {
scroller.onTouchStart();
}
event.preventDefault();
if (typeof event.cancelable !== "boolean" || event.cancelable)
event.preventDefault();
}
function handleTouchMove(event) {
const touchtrackEvent = event;
const mouseEvent = event;
if (touchInfo.trackingID !== -1) {
event.preventDefault();
if (typeof event.cancelable !== "boolean" || event.cancelable)
event.preventDefault();
const delta = findDelta(event);
if (delta) {
for (touchInfo.maxDy = Math.max(touchInfo.maxDy, Math.abs(delta.y)), touchInfo.maxDx = Math.max(touchInfo.maxDx, Math.abs(delta.x)), touchInfo.historyX.push(delta.x), touchInfo.historyY.push(delta.y), touchInfo.historyTime.push(touchtrackEvent.detail.timeStamp || mouseEvent.timeStamp); touchInfo.historyTime.length > 10; ) {
......
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册