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

chore: format log

上级 cf17189f
......@@ -3,7 +3,7 @@ import { ComponentCustomProperties, ComponentInternalInstance } from 'vue'
declare module '@vue/runtime-core' {
interface ComponentCustomProperties {
$scope: {
$getAppWebview: () => PlusWebviewWebviewObject
$getAppWebview?: () => PlusWebviewWebviewObject
}
$page: Page.PageInstance['$page']
__isTabBar: boolean
......
......@@ -565,6 +565,12 @@ var serviceContext = (function (vue) {
return encode$3(arrayBuffer);
}, ArrayBufferToBase64Protocol);
function formatLog(module, ...args) {
return `[${Date.now()}][${module}]:${args
.map((arg) => JSON.stringify(arg))
.join(' ')}`;
}
const encode$2 = encodeURIComponent;
function stringifyQuery$1(obj, encodeStr = encode$2) {
const res = obj
......@@ -1399,7 +1405,7 @@ var serviceContext = (function (vue) {
},
subscribeHandler(event, args, pageId) {
if ((process.env.NODE_ENV !== 'production')) {
console.log(`[subscribeHandler][${Date.now()}]:${subscribeNamespace}.${event}, ${JSON.stringify(args)}, ${pageId}`);
console.log(formatLog(subscribeNamespace, 'subscribeHandler', pageId, event, args));
}
emitter.emit(`${subscribeNamespace}.${event}`, args, pageId);
},
......@@ -4709,9 +4715,6 @@ var serviceContext = (function (vue) {
function getLocationSuccess(type, position, resolve) {
const coords = position.coords;
if (type !== position.coordsType) {
if ((process.env.NODE_ENV !== 'production')) {
console.log(`UNIAPP[location]:before[${position.coordsType}][lng:${coords.longitude},lat:${coords.latitude}]`);
}
let coordArray;
if (type === 'wgs84') {
coordArray = gcj02towgs84(coords.longitude, coords.latitude);
......@@ -4722,9 +4725,6 @@ var serviceContext = (function (vue) {
if (coordArray) {
coords.longitude = coordArray[0];
coords.latitude = coordArray[1];
if ((process.env.NODE_ENV !== 'production')) {
console.log(`UNIAPP[location]:after[${type}][lng:${coords.longitude},lat:${coords.latitude}]`);
}
}
}
resolve({
......@@ -5562,7 +5562,7 @@ var serviceContext = (function (vue) {
}
function subscribePlusMessage({ data, }) {
if ((process.env.NODE_ENV !== 'production')) {
console.log('plusMessage:' + JSON.stringify(data));
console.log(formatLog('plusMessage', data));
}
if (data && data.type) {
UniServiceJSBridge.subscribeHandler('plusMessage.' + data.type, data.args);
......@@ -5812,7 +5812,7 @@ var serviceContext = (function (vue) {
const curWebviewStyle = parseWebviewStyle(path, routeOptions.meta);
curWebviewStyle.uniPageUrl = initUniPageUrl(path, query);
if ((process.env.NODE_ENV !== 'production')) {
console.log('[uni-app] createWebview', curWebviewId, path, curWebviewStyle);
console.log(formatLog('createNVueWebview', curWebviewId, path, curWebviewStyle));
}
curWebviewStyle.isTab = !!routeOptions.meta.isTabBar;
return plus.webview.create('', String(curWebviewId), curWebviewStyle, extend({
......@@ -5832,7 +5832,7 @@ var serviceContext = (function (vue) {
webviewStyle.isTab = isTabBar;
}
if ((process.env.NODE_ENV !== 'production')) {
console.log('[uni-app] updateWebview', webviewStyle);
console.log(formatLog('updateWebview', webviewStyle));
}
webview.setStyle(webviewStyle);
}
......@@ -5858,7 +5858,7 @@ var serviceContext = (function (vue) {
// 不存在,或已被使用
preloadWebview = plus.webview.create(VIEW_WEBVIEW_PATH, String(genWebviewId()));
if ((process.env.NODE_ENV !== 'production')) {
console.log(`[uni-app] preloadWebview[${preloadWebview.id}]`);
console.log(formatLog('createPreloadWebview', preloadWebview.id));
}
}
return preloadWebview;
......@@ -5951,7 +5951,7 @@ var serviceContext = (function (vue) {
}
function registerApp(appVm) {
if ((process.env.NODE_ENV !== 'production')) {
console.log('registerApp');
console.log(formatLog('registerApp'));
}
appCtx = appVm;
appCtx.$vm = appVm;
......@@ -6386,7 +6386,7 @@ var serviceContext = (function (vue) {
callback,
};
if ((process.env.NODE_ENV !== 'production')) {
console.log(`nextNavigator:${path} ${msg}`);
console.log(formatLog('setPendingNavigator', path, msg));
}
}
function navigate(path, callback, isAppLaunch) {
......@@ -6421,7 +6421,7 @@ var serviceContext = (function (vue) {
}
const { callback } = pendingNavigator;
if ((process.env.NODE_ENV !== 'production')) {
console.log(`pendingNavigate:${pendingNavigator.path}`);
console.log(formatLog('pendingNavigate', pendingNavigator.path));
}
pendingNavigator = false;
return callback();
......@@ -6439,7 +6439,7 @@ var serviceContext = (function (vue) {
// 创建预加载
const preloadWebview = createPreloadWebview();
if ((process.env.NODE_ENV !== 'production')) {
console.log(`navigateFinish.preloadWebview:${preloadWebview.id}`);
console.log(formatLog('navigateFinish', 'preloadWebview', preloadWebview.id));
}
if (!pendingNavigator) {
return;
......@@ -6457,12 +6457,12 @@ var serviceContext = (function (vue) {
delay = webview.nvue ? 0 : 100;
}
if ((process.env.NODE_ENV !== 'production')) {
console.log(`[show][${Date.now()}]`, delay);
console.log(formatLog('showWebview', 'delay', delay));
}
const execShowCallback = function () {
if (execShowCallback._called) {
if ((process.env.NODE_ENV !== 'production')) {
console.log('execShowCallback.prevent');
console.log(formatLog('execShowCallback', 'prevent'));
}
return;
}
......@@ -6474,13 +6474,13 @@ var serviceContext = (function (vue) {
setTimeout(() => {
const timer = setTimeout(() => {
if ((process.env.NODE_ENV !== 'production')) {
console.log(`[show.callback.timer][${Date.now()}]`);
console.log(formatLog('showWebview', 'callback', 'timer'));
}
execShowCallback();
}, animationDuration + 150);
webview.show(animationType, animationDuration, () => {
if ((process.env.NODE_ENV !== 'production')) {
console.log(`[show.callback][${Date.now()}]`);
console.log(formatLog('showWebview', 'callback'));
}
if (!execShowCallback._called) {
clearTimeout(timer);
......@@ -6624,7 +6624,7 @@ var serviceContext = (function (vue) {
const oldSetup = component.setup;
component.setup = (_props, ctx) => {
if ((process.env.NODE_ENV !== 'production')) {
console.log(`${pagePath} setup`);
console.log(formatLog(pagePath, 'setup'));
}
const instance = vue.getCurrentInstance();
const pageVm = instance.proxy;
......@@ -6713,7 +6713,7 @@ var serviceContext = (function (vue) {
tabBar$1.append(webview);
}
if ((process.env.NODE_ENV !== 'production')) {
console.log(`[uni-app] registerPage(${path},${webview.id})`);
console.log(formatLog('registerPage', path, webview.id));
}
initWebview(webview, path, query, routeOptions.meta);
const route = path.substr(1);
......@@ -6895,7 +6895,7 @@ var serviceContext = (function (vue) {
function publishHandler(event, args, pageIds) {
args = JSON.stringify(args);
if ((process.env.NODE_ENV !== 'production')) {
console.log(`UNIAPP[publishHandler]:[${+new Date()}]`, event, args, pageIds);
console.log(formatLog('publishHandler', event, args, pageIds));
}
if (!isArray(pageIds)) {
pageIds = [pageIds];
......
......@@ -5286,6 +5286,9 @@
})(dist);
var wrapper = /* @__PURE__ */ getDefaultExportFromCjs(dist.exports);
var button = "uni-button {\n position: relative;\n display: block;\n margin-left: auto;\n margin-right: auto;\n padding-left: 14px;\n padding-right: 14px;\n box-sizing: border-box;\n font-size: 18px;\n text-align: center;\n text-decoration: none;\n line-height: 2.55555556;\n border-radius: 5px;\n -webkit-tap-highlight-color: transparent;\n overflow: hidden;\n color: #000000;\n background-color: #f8f8f8;\n cursor: pointer;\n}\n\nuni-button[hidden] {\n display: none !important;\n}\n\nuni-button:after {\n content: ' ';\n width: 200%;\n height: 200%;\n position: absolute;\n top: 0;\n left: 0;\n border: 1px solid rgba(0, 0, 0, 0.2);\n transform: scale(0.5);\n transform-origin: 0 0;\n box-sizing: border-box;\n border-radius: 10px;\n}\n\nuni-button[native] {\n padding-left: 0;\n padding-right: 0;\n}\n\nuni-button[native] .uni-button-cover-view-wrapper {\n border: inherit;\n border-color: inherit;\n border-radius: inherit;\n background-color: inherit;\n}\n\nuni-button[native] .uni-button-cover-view-inner {\n padding-left: 14px;\n padding-right: 14px;\n}\n\nuni-button uni-cover-view {\n line-height: inherit;\n white-space: inherit;\n}\n\nuni-button[type='default'] {\n color: #000000;\n background-color: #f8f8f8;\n}\n\nuni-button[type='primary'] {\n color: #ffffff;\n background-color: #007aff;\n}\n\nuni-button[type='warn'] {\n color: #ffffff;\n background-color: #e64340;\n}\n\nuni-button[disabled] {\n color: rgba(255, 255, 255, 0.6);\n cursor: not-allowed;\n}\n\nuni-button[disabled][type='default'],\nuni-button[disabled]:not([type]) {\n color: rgba(0, 0, 0, 0.3);\n background-color: #f7f7f7;\n}\n\nuni-button[disabled][type='primary'] {\n background-color: rgba(0, 122, 255, 0.6);\n}\n\nuni-button[disabled][type='warn'] {\n background-color: #ec8b89;\n}\n\nuni-button[type='primary'][plain] {\n color: #007aff;\n border: 1px solid #007aff;\n background-color: transparent;\n}\n\nuni-button[type='primary'][plain][disabled] {\n color: rgba(0, 0, 0, 0.2);\n border-color: rgba(0, 0, 0, 0.2);\n}\n\nuni-button[type='primary'][plain]:after {\n border-width: 0;\n}\n\nuni-button[type='default'][plain] {\n color: #353535;\n border: 1px solid #353535;\n background-color: transparent;\n}\n\nuni-button[type='default'][plain][disabled] {\n color: rgba(0, 0, 0, 0.2);\n border-color: rgba(0, 0, 0, 0.2);\n}\n\nuni-button[type='default'][plain]:after {\n border-width: 0;\n}\n\nuni-button[plain] {\n color: #353535;\n border: 1px solid #353535;\n background-color: transparent;\n}\n\nuni-button[plain][disabled] {\n color: rgba(0, 0, 0, 0.2);\n border-color: rgba(0, 0, 0, 0.2);\n}\n\nuni-button[plain]:after {\n border-width: 0;\n}\n\nuni-button[plain][native] .uni-button-cover-view-inner {\n padding: 0;\n}\n\nuni-button[type='warn'][plain] {\n color: #e64340;\n border: 1px solid #e64340;\n background-color: transparent;\n}\n\nuni-button[type='warn'][plain][disabled] {\n color: rgba(0, 0, 0, 0.2);\n border-color: rgba(0, 0, 0, 0.2);\n}\n\nuni-button[type='warn'][plain]:after {\n border-width: 0;\n}\n\nuni-button[size='mini'] {\n display: inline-block;\n line-height: 2.3;\n font-size: 13px;\n padding: 0 1.34em;\n}\n\nuni-button[size='mini'][native] {\n padding: 0;\n}\n\nuni-button[size='mini'][native] .uni-button-cover-view-inner {\n padding: 0 1.34em;\n}\n\nuni-button[loading]:not([disabled]) {\n cursor: progress;\n}\n\nuni-button[loading]:before {\n content: ' ';\n display: inline-block;\n width: 18px;\n height: 18px;\n vertical-align: middle;\n animation: uni-loading 1s steps(12, end) infinite;\n background-size: 100%;\n}\n\nuni-button[loading][type='primary'] {\n color: rgba(255, 255, 255, 0.6);\n background-color: #0062cc;\n}\n\nuni-button[loading][type='primary'][plain] {\n color: #007aff;\n background-color: transparent;\n}\n\nuni-button[loading][type='default'] {\n color: rgba(0, 0, 0, 0.6);\n background-color: #dedede;\n}\n\nuni-button[loading][type='default'][plain] {\n color: #353535;\n background-color: transparent;\n}\n\nuni-button[loading][type='warn'] {\n color: rgba(255, 255, 255, 0.6);\n background-color: #ce3c39;\n}\n\nuni-button[loading][type='warn'][plain] {\n color: #e64340;\n background-color: transparent;\n}\n\nuni-button[loading][native]:before {\n content: none;\n}\n\n.button-hover {\n color: rgba(0, 0, 0, 0.6);\n background-color: #dedede;\n}\n\n.button-hover[plain] {\n color: rgba(53, 53, 53, 0.6);\n border-color: rgba(53, 53, 53, 0.6);\n background-color: transparent;\n}\n\n.button-hover[type='primary'] {\n color: rgba(255, 255, 255, 0.6);\n background-color: #0062cc;\n}\n\n.button-hover[type='primary'][plain] {\n color: rgba(26, 173, 25, 0.6);\n border-color: rgba(26, 173, 25, 0.6);\n background-color: transparent;\n}\n\n.button-hover[type='default'] {\n color: rgba(0, 0, 0, 0.6);\n background-color: #dedede;\n}\n\n.button-hover[type='default'][plain] {\n color: rgba(53, 53, 53, 0.6);\n border-color: rgba(53, 53, 53, 0.6);\n background-color: transparent;\n}\n\n.button-hover[type='warn'] {\n color: rgba(255, 255, 255, 0.6);\n background-color: #ce3c39;\n}\n\n.button-hover[type='warn'][plain] {\n color: rgba(230, 67, 64, 0.6);\n border-color: rgba(230, 67, 64, 0.6);\n background-color: transparent;\n}\n";
function formatLog(module, ...args) {
return `[${Date.now()}][${module}]\uFF1A${args.map((arg) => JSON.stringify(arg)).join(" ")}`;
}
function getCustomDataset(el) {
return extend({}, el.dataset, el.__uniDataset);
}
......@@ -5627,11 +5630,11 @@
unsubscribe(event, callback) {
emitter.off(`${subscribeNamespace}.${event}`, callback);
},
subscribeHandler(event, args, pageId) {
subscribeHandler(event, args, pageId2) {
{
console.log(`[subscribeHandler][${Date.now()}]:${subscribeNamespace}.${event}, ${JSON.stringify(args)}, ${pageId}`);
console.log(formatLog(subscribeNamespace, "subscribeHandler", pageId2, event, args));
}
emitter.emit(`${subscribeNamespace}.${event}`, args, pageId);
emitter.emit(`${subscribeNamespace}.${event}`, args, pageId2);
}
};
}
......@@ -5943,7 +5946,7 @@
});
}
function _addListeners(id, listeners, watch2) {
const pageId = useCurrentPageId();
const pageId2 = useCurrentPageId();
if (watch2 && !id) {
return;
}
......@@ -5953,19 +5956,19 @@
Object.keys(listeners).forEach((name) => {
if (watch2) {
if (name.indexOf("@") !== 0 && name.indexOf("uni-") !== 0) {
UniViewJSBridge.on(`uni-${name}-${pageId}-${id}`, listeners[name]);
UniViewJSBridge.on(`uni-${name}-${pageId2}-${id}`, listeners[name]);
}
} else {
if (name.indexOf("uni-") === 0) {
UniViewJSBridge.on(name, listeners[name]);
} else if (id) {
UniViewJSBridge.on(`uni-${name}-${pageId}-${id}`, listeners[name]);
UniViewJSBridge.on(`uni-${name}-${pageId2}-${id}`, listeners[name]);
}
}
});
}
function _removeListeners(id, listeners, watch2) {
const pageId = useCurrentPageId();
const pageId2 = useCurrentPageId();
if (watch2 && !id) {
return;
}
......@@ -5975,13 +5978,13 @@
Object.keys(listeners).forEach((name) => {
if (watch2) {
if (name.indexOf("@") !== 0 && name.indexOf("uni-") !== 0) {
UniViewJSBridge.off(`uni-${name}-${pageId}-${id}`, listeners[name]);
UniViewJSBridge.off(`uni-${name}-${pageId2}-${id}`, listeners[name]);
}
} else {
if (name.indexOf("uni-") === 0) {
UniViewJSBridge.off(name, listeners[name]);
} else if (id) {
UniViewJSBridge.off(`uni-${name}-${pageId}-${id}`, listeners[name]);
UniViewJSBridge.off(`uni-${name}-${pageId2}-${id}`, listeners[name]);
}
}
});
......@@ -6593,10 +6596,13 @@
const UniViewJSBridge$1 = /* @__PURE__ */ extend(ViewJSBridge, {
publishHandler
});
let pageId;
function publishHandler(event, args = {}) {
const pageId = plus.webview.currentWebview().id;
if (!pageId) {
pageId = plus.webview.currentWebview().id;
}
{
console.log(`[VIEW][${Date.now()}]:`, event, args, pageId);
console.log(`[${Date.now()}][View]: ` + pageId + " " + event + " " + JSON.stringify(args));
}
plus.webview.postMessageToUniNView({
type: "subscribeHandler",
......
import { extend } from '@vue/shared'
import { formatLog } from '@dcloudio/uni-shared'
import { getRouteOptions } from '@dcloudio/uni-core'
interface PlusResult extends Record<string, any> {
code?: number
......@@ -103,7 +104,7 @@ export function isTabBarPage(path = '') {
return route && route.meta.isTabBar
} catch (e) {
if (__DEV__) {
console.log('getCurrentPages is not ready')
console.error(formatLog('isTabBarPage', e))
}
}
return false
......
......@@ -15,11 +15,6 @@ function getLocationSuccess(
) {
const coords = position.coords
if (type !== position.coordsType) {
if (__DEV__) {
console.log(
`UNIAPP[location]:before[${position.coordsType}][lng:${coords.longitude},lat:${coords.latitude}]`
)
}
let coordArray
if (type === 'wgs84') {
coordArray = gcj02towgs84(coords.longitude, coords.latitude)
......@@ -29,11 +24,6 @@ function getLocationSuccess(
if (coordArray) {
coords.longitude = coordArray[0]
coords.latitude = coordArray[1]
if (__DEV__) {
console.log(
`UNIAPP[location]:after[${type}][lng:${coords.longitude},lat:${coords.latitude}]`
)
}
}
}
......
import { getRouteMeta } from '@dcloudio/uni-core'
import { formatLog } from '@dcloudio/uni-shared'
import {
createPreloadWebview,
onWebviewReady,
......@@ -20,7 +21,7 @@ function setPendingNavigator(path: string, callback: Function, msg: string) {
callback,
}
if (__DEV__) {
console.log(`nextNavigator:${path} ${msg}`)
console.log(formatLog('setPendingNavigator', path, msg))
}
}
......@@ -68,7 +69,7 @@ function pendingNavigate() {
}
const { callback } = pendingNavigator
if (__DEV__) {
console.log(`pendingNavigate:${pendingNavigator.path}`)
console.log(formatLog('pendingNavigate', pendingNavigator.path))
}
pendingNavigator = false
return callback()
......@@ -87,7 +88,9 @@ export function navigateFinish() {
// 创建预加载
const preloadWebview = createPreloadWebview()
if (__DEV__) {
console.log(`navigateFinish.preloadWebview:${preloadWebview.id}`)
console.log(
formatLog('navigateFinish', 'preloadWebview', preloadWebview.id)
)
}
if (!pendingNavigator) {
return
......
import { formatLog } from '@dcloudio/uni-shared'
import { navigateFinish } from './utils'
export function closeWebview(
......@@ -23,12 +24,12 @@ export function showWebview(
}
if (__DEV__) {
console.log(`[show][${Date.now()}]`, delay)
console.log(formatLog('showWebview', 'delay', delay))
}
const execShowCallback = function () {
if (execShowCallback._called) {
if (__DEV__) {
console.log('execShowCallback.prevent')
console.log(formatLog('execShowCallback', 'prevent'))
}
return
}
......@@ -40,14 +41,14 @@ export function showWebview(
setTimeout(() => {
const timer = setTimeout(() => {
if (__DEV__) {
console.log(`[show.callback.timer][${Date.now()}]`)
console.log(formatLog('showWebview', 'callback', 'timer'))
}
execShowCallback()
}, animationDuration + 150)
webview.show(animationType as any, animationDuration, () => {
if (__DEV__) {
console.log(`[show.callback][${Date.now()}]`)
console.log(formatLog('showWebview', 'callback'))
}
if (!execShowCallback._called) {
clearTimeout(timer)
......
import { extend, isArray } from '@vue/shared'
import { ServiceJSBridge } from '@dcloudio/uni-core'
import { formatLog } from '@dcloudio/uni-shared'
export const UniServiceJSBridge = /*#__PURE__*/ extend(ServiceJSBridge, {
publishHandler,
......@@ -13,7 +14,7 @@ function publishHandler(
) {
args = JSON.stringify(args)
if (__DEV__) {
console.log(`UNIAPP[publishHandler]:[${+new Date()}]`, event, args, pageIds)
console.log(formatLog('publishHandler', event, args, pageIds))
}
if (!isArray(pageIds)) {
pageIds = [pageIds]
......
import { ComponentPublicInstance } from 'vue'
import { extend } from '@vue/shared'
import { formatLog } from '@dcloudio/uni-shared'
import { initService } from '@dcloudio/uni-core'
import { initEntry } from './initEntry'
......@@ -31,7 +31,7 @@ export function getApp({ allowDefault = false } = {}) {
export function registerApp(appVm: ComponentPublicInstance) {
if (__DEV__) {
console.log('registerApp')
console.log(formatLog('registerApp'))
}
appCtx = appVm
appCtx.$vm = appVm
......
import { formatLog } from '@dcloudio/uni-shared'
import { backbuttonListener } from './utils'
export function initGlobalEvent() {
......@@ -42,7 +43,7 @@ function subscribePlusMessage({
data: { type: string; args: Record<string, any> }
}) {
if (__DEV__) {
console.log('plusMessage:' + JSON.stringify(data))
console.log(formatLog('plusMessage', data))
}
if (data && data.type) {
UniServiceJSBridge.subscribeHandler('plusMessage.' + data.type, data.args)
......
import { hasOwn } from '@vue/shared'
import { NAVBAR_HEIGHT, ON_REACH_BOTTOM_DISTANCE } from '@dcloudio/uni-shared'
import {
formatLog,
NAVBAR_HEIGHT,
ON_REACH_BOTTOM_DISTANCE,
} from '@dcloudio/uni-shared'
import { initEntry } from '../app/initEntry'
import { initRouteOptions } from './routeOptions'
import { createWebview, initWebview } from '../webview'
......@@ -60,7 +64,7 @@ export function registerPage({
}
if (__DEV__) {
console.log(`[uni-app] registerPage(${path},${webview.id})`)
console.log(formatLog('registerPage', path, webview.id))
}
initWebview(webview, path, query, routeOptions.meta)
......
import { formatLog } from '@dcloudio/uni-shared'
import { ComponentPublicInstance, getCurrentInstance } from 'vue'
import { PageProps, VueComponent } from './define'
import { addCurrentPage } from './getCurrentPages'
......@@ -9,7 +10,7 @@ export function setupPage(
const oldSetup = component.setup
component.setup = (_props, ctx) => {
if (__DEV__) {
console.log(`${pagePath} setup`)
console.log(formatLog(pagePath, 'setup'))
}
const instance = getCurrentInstance()!
const pageVm = instance.proxy!
......
import { formatLog } from '@dcloudio/uni-shared'
export function onWebviewClose(webview: PlusWebviewWebviewObject) {
const { popupSubNVueWebviews } = webview as any
if (!popupSubNVueWebviews) {
......@@ -7,7 +9,13 @@ export function onWebviewClose(webview: PlusWebviewWebviewObject) {
Object.keys(popupSubNVueWebviews).forEach((id) => {
if (__DEV__) {
console.log(
`UNIAPP[webview][${webview.id}]:popupSubNVueWebview[${id}].close`
formatLog(
'onWebviewClose',
webview.id,
'popupSubNVueWebview',
id,
'close'
)
)
}
popupSubNVueWebviews[id].close('none')
......
import { formatLog } from '@dcloudio/uni-shared'
import { parseWebviewStyle } from '../style'
import { initUniPageUrl, initDebugRefresh } from '../utils'
......@@ -17,7 +18,7 @@ export function initWebviewStyle(
webviewStyle.isTab = isTabBar
}
if (__DEV__) {
console.log('[uni-app] updateWebview', webviewStyle)
console.log(formatLog('updateWebview', webviewStyle))
}
webview.setStyle(webviewStyle)
}
import { formatLog } from '@dcloudio/uni-shared'
import { extend } from '@vue/shared'
import { CreateWebviewOptions } from '.'
......@@ -14,7 +15,9 @@ export function createNVueWebview({
const curWebviewStyle = parseWebviewStyle(path, routeOptions.meta)
;(curWebviewStyle as any).uniPageUrl = initUniPageUrl(path, query)
if (__DEV__) {
console.log('[uni-app] createWebview', curWebviewId, path, curWebviewStyle)
console.log(
formatLog('createNVueWebview', curWebviewId, path, curWebviewStyle)
)
}
// android 需要使用
;(curWebviewStyle as any).isTab = !!routeOptions.meta.isTabBar
......
import { formatLog } from '@dcloudio/uni-shared'
import { VIEW_WEBVIEW_PATH } from '../../constants'
import { genWebviewId } from './utils'
......@@ -18,7 +19,7 @@ export function createPreloadWebview() {
String(genWebviewId())
)
if (__DEV__) {
console.log(`[uni-app] preloadWebview[${preloadWebview.id}]`)
console.log(formatLog('createPreloadWebview', preloadWebview.id))
}
}
return preloadWebview
......
......@@ -8,10 +8,20 @@ export const UniViewJSBridge = /*#__PURE__*/ extend(ViewJSBridge, {
publishHandler,
})
let pageId: string
function publishHandler(event: string, args: unknown = {}) {
const pageId = plus.webview.currentWebview().id
if (!pageId) {
pageId = plus.webview.currentWebview().id!
}
if (__DEV__) {
console.log(`[VIEW][${Date.now()}]:`, event, args, pageId)
console.log(
`[${Date.now()}][View]: ` +
pageId +
' ' +
event +
' ' +
JSON.stringify(args)
)
}
;(plus.webview as any).postMessageToUniNView(
{
......
// TODO 等待 vue3 的兼容模式自带emitter
import { formatLog } from '@dcloudio/uni-shared'
import E from './TinyEmitter'
export function initBridge(
......@@ -28,9 +29,7 @@ export function initBridge(
subscribeHandler(event: string, args: unknown, pageId?: number): void {
if (__DEV__) {
console.log(
`[subscribeHandler][${Date.now()}]:${subscribeNamespace}.${event}, ${JSON.stringify(
args
)}, ${pageId}`
formatLog(subscribeNamespace, 'subscribeHandler', pageId, event, args)
)
}
emitter.emit(`${subscribeNamespace}.${event}`, args, pageId)
......
......@@ -374,7 +374,7 @@ function initBridge(subscribeNamespace) {
},
subscribeHandler(event, args, pageId) {
if (process.env.NODE_ENV !== "production") {
console.log(`[subscribeHandler][${Date.now()}]:${subscribeNamespace}.${event}, ${JSON.stringify(args)}, ${pageId}`);
console.log(uniShared.formatLog(subscribeNamespace, "subscribeHandler", pageId, event, args));
}
emitter.emit(`${subscribeNamespace}.${event}`, args, pageId);
}
......
import { isFunction, extend, isString, hyphenate, isPlainObject, isArray, hasOwn, isObject, capitalize, toRawType, makeMap as makeMap$1, isPromise, invokeArrayFns as invokeArrayFns$1 } from "@vue/shared";
import { once, passive, initCustomDataset, invokeArrayFns, normalizeTarget, isBuiltInComponent, SCHEME_RE, DATA_RE, getCustomDataset, callOptions, PRIMARY_COLOR, removeLeadingSlash, getLen, debounce, NAVBAR_HEIGHT, parseQuery, ON_REACH_BOTTOM_DISTANCE, decodedQuery, WEB_INVOKE_APPSERVICE, updateElementStyle, parseUrl, addFont, scrollTo, RESPONSIVE_MIN_WIDTH, formatDateTime } from "@dcloudio/uni-shared";
import { once, formatLog, passive, initCustomDataset, invokeArrayFns, normalizeTarget, isBuiltInComponent, SCHEME_RE, DATA_RE, getCustomDataset, callOptions, PRIMARY_COLOR, removeLeadingSlash, getLen, debounce, NAVBAR_HEIGHT, parseQuery, ON_REACH_BOTTOM_DISTANCE, decodedQuery, WEB_INVOKE_APPSERVICE, updateElementStyle, parseUrl, addFont, scrollTo, RESPONSIVE_MIN_WIDTH, formatDateTime } from "@dcloudio/uni-shared";
import { openBlock, createBlock, mergeProps, createVNode, toDisplayString, withModifiers, getCurrentInstance, defineComponent, ref, provide, computed, watch, onUnmounted, inject, onBeforeUnmount, reactive, onActivated, onMounted, nextTick, onBeforeMount, withDirectives, vShow, shallowRef, watchEffect, isVNode, Fragment, markRaw, createTextVNode, injectHook, onBeforeActivate, onBeforeDeactivate, renderList, onDeactivated, createApp, Transition, withCtx, KeepAlive, resolveDynamicComponent, renderSlot } from "vue";
import { initVueI18n, LOCALE_EN, LOCALE_ES, LOCALE_FR, LOCALE_ZH_HANS, LOCALE_ZH_HANT } from "@dcloudio/uni-i18n";
import { useRoute, createRouter, createWebHistory, createWebHashHistory, useRouter, isNavigationFailure, RouterView } from "vue-router";
......@@ -463,7 +463,7 @@ function initBridge(subscribeNamespace) {
},
subscribeHandler(event, args, pageId) {
if (process.env.NODE_ENV !== "production") {
console.log(`[subscribeHandler][${Date.now()}]:${subscribeNamespace}.${event}, ${JSON.stringify(args)}, ${pageId}`);
console.log(formatLog(subscribeNamespace, "subscribeHandler", pageId, event, args));
}
emitter2.emit(`${subscribeNamespace}.${event}`, args, pageId);
}
......
......@@ -71,7 +71,7 @@ function initVm(
// 父组件已经初始化,直接初始化子,否则放到父组件的 didMount 中处理
// 初始化 vue 实例
mpInstance.$vm = createComponent(relationOptions.parent)
handleRef.call(relationOptions.parent.$scope, mpInstance)
handleRef.call(relationOptions.parent.$scope as any, mpInstance)
initChildVues(mpInstance)
mpInstance.$vm.$callHook('mounted')
}
......
......@@ -109,7 +109,7 @@ export function initChildVues(
initSpecialMethods(childMPInstance)
if (relationOptions.parent) {
handleRef.call(relationOptions.parent.$scope, childMPInstance)
handleRef.call(relationOptions.parent.$scope as any, childMPInstance)
}
initChildVues(childMPInstance)
......
declare module '@vue/runtime-core' {
interface ComponentCustomProperties {
$scope: WechatMiniprogram.App.Instance<any>
$vm: ComponentPublicInstance
globalData: Record<string, any>
$callHook: (hook: string, args?: unknown) => unknown
......
......@@ -4,6 +4,12 @@ Object.defineProperty(exports, '__esModule', { value: true });
var shared = require('@vue/shared');
function formatLog(module, ...args) {
return `[${Date.now()}][${module}]:${args
.map((arg) => JSON.stringify(arg))
.join(' ')}`;
}
function formatKey(key) {
return shared.camelize(key.substring(5));
}
......@@ -943,6 +949,7 @@ exports.defaultRpx2Unit = defaultRpx2Unit;
exports.encodeAttr = encodeAttr;
exports.encodeTag = encodeTag;
exports.formatDateTime = formatDateTime;
exports.formatLog = formatLog;
exports.getCustomDataset = getCustomDataset;
exports.getEnvLocale = getEnvLocale;
exports.getLen = getLen;
......
......@@ -62,6 +62,8 @@ export declare function formatDateTime({ date, mode }: {
mode?: string | undefined;
}): string;
export declare function formatLog(module: string, ...args: any[]): string;
export declare function getCustomDataset(el: HTMLElement | HTMLElementWithDataset): DOMStringMap & Record<string, any>;
export declare function getEnvLocale(): string;
......
import { camelize, extend, isString, isPlainObject, isArray, isHTMLTag, isSVGTag, capitalize } from '@vue/shared';
function formatLog(module, ...args) {
return `[${Date.now()}][${module}]:${args
.map((arg) => JSON.stringify(arg))
.join(' ')}`;
}
function formatKey(key) {
return camelize(key.substring(5));
}
......@@ -892,4 +898,4 @@ function getEnvLocale() {
return (lang && lang.replace(/[.:].*/, '')) || 'en';
}
export { BACKGROUND_COLOR, BUILT_IN_TAGS, COMPONENT_NAME_PREFIX, COMPONENT_PREFIX, COMPONENT_SELECTOR_PREFIX, DATA_RE, NAVBAR_HEIGHT, NODE_TYPE_COMMENT, NODE_TYPE_ELEMENT, NODE_TYPE_PAGE, NODE_TYPE_TEXT, ON_REACH_BOTTOM_DISTANCE, PLUS_RE, PRIMARY_COLOR, RESPONSIVE_MIN_WIDTH, SCHEME_RE, SELECTED_COLOR, TABBAR_HEIGHT, TAGS, UNI_SSR, UNI_SSR_DATA, UNI_SSR_GLOBAL_DATA, UNI_SSR_STORE, UNI_SSR_TITLE, UniBaseNode, UniCommentNode, UniElement, UniEvent, UniInputElement, UniNode, UniTextAreaElement, UniTextNode, WEB_INVOKE_APPSERVICE, addFont, cache, cacheStringFunction, callOptions, createRpx2Unit, debounce, decode, decodeAttr, decodeTag, decodedQuery, defaultRpx2Unit, encodeAttr, encodeTag, formatDateTime, getCustomDataset, getEnvLocale, getLen, initCustomDataset, invokeArrayFns, isBuiltInComponent, isCustomElement, isNativeTag, isServiceCustomElement, isServiceNativeTag, normalizeDataset, normalizeTarget, once, parseQuery, parseUrl, passive, plusReady, removeLeadingSlash, sanitise, scrollTo, stringifyQuery, updateElementStyle };
export { BACKGROUND_COLOR, BUILT_IN_TAGS, COMPONENT_NAME_PREFIX, COMPONENT_PREFIX, COMPONENT_SELECTOR_PREFIX, DATA_RE, NAVBAR_HEIGHT, NODE_TYPE_COMMENT, NODE_TYPE_ELEMENT, NODE_TYPE_PAGE, NODE_TYPE_TEXT, ON_REACH_BOTTOM_DISTANCE, PLUS_RE, PRIMARY_COLOR, RESPONSIVE_MIN_WIDTH, SCHEME_RE, SELECTED_COLOR, TABBAR_HEIGHT, TAGS, UNI_SSR, UNI_SSR_DATA, UNI_SSR_GLOBAL_DATA, UNI_SSR_STORE, UNI_SSR_TITLE, UniBaseNode, UniCommentNode, UniElement, UniEvent, UniInputElement, UniNode, UniTextAreaElement, UniTextNode, WEB_INVOKE_APPSERVICE, addFont, cache, cacheStringFunction, callOptions, createRpx2Unit, debounce, decode, decodeAttr, decodeTag, decodedQuery, defaultRpx2Unit, encodeAttr, encodeTag, formatDateTime, formatLog, getCustomDataset, getEnvLocale, getLen, initCustomDataset, invokeArrayFns, isBuiltInComponent, isCustomElement, isNativeTag, isServiceCustomElement, isServiceNativeTag, normalizeDataset, normalizeTarget, once, parseQuery, parseUrl, passive, plusReady, removeLeadingSlash, sanitise, scrollTo, stringifyQuery, updateElementStyle };
export * from './log'
export * from './dom'
export * from './url'
export * from './plus'
......
export function formatLog(module: string, ...args: any[]) {
return `[${Date.now()}][${module}]:${args
.map((arg) => JSON.stringify(arg))
.join(' ')}`
}
......@@ -23,4 +23,4 @@ if (debugIndex > 0) {
}
}
}
require('../dist/cli')
require('../dist/cli/index.js')
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册