From 5aac7fd64838463f689d94863cc3e001eb1b0185 Mon Sep 17 00:00:00 2001 From: fxy060608 Date: Tue, 25 May 2021 19:44:39 +0800 Subject: [PATCH] feat: add unsupported api --- packages/uni-api/src/helpers/api/index.ts | 20 ++ packages/uni-api/src/index.ts | 7 + .../protocols/media/saveImageToPhotosAlbum.ts | 3 + .../protocols/media/saveVideoToPhotosAlbum.ts | 3 + packages/uni-h5/dist/uni-h5.cjs.js | 15 +- packages/uni-h5/dist/uni-h5.es.js | 96 +++++++++- .../src/framework/components/layout/index.tsx | 17 +- packages/uni-h5/src/service/api/index.ts | 2 + packages/uni-h5/src/service/api/todo/index.ts | 175 ++++++++++++++++++ 9 files changed, 328 insertions(+), 10 deletions(-) create mode 100644 packages/uni-api/src/protocols/media/saveImageToPhotosAlbum.ts create mode 100644 packages/uni-api/src/protocols/media/saveVideoToPhotosAlbum.ts create mode 100644 packages/uni-h5/src/service/api/todo/index.ts diff --git a/packages/uni-api/src/helpers/api/index.ts b/packages/uni-api/src/helpers/api/index.ts index 203f927c3..6256e5282 100644 --- a/packages/uni-api/src/helpers/api/index.ts +++ b/packages/uni-api/src/helpers/api/index.ts @@ -233,3 +233,23 @@ export function defineAsyncApi>( wrapperAsyncApi(name, fn as any, __DEV__ ? protocol : undefined, options) ) as AsyncApi

} + +function createUnsupportedMsg(name: string) { + return `method 'uni.${name}' not supported` +} + +export function createUnsupportedSyncApi(name: string) { + return (): any => { + console.error(createUnsupportedMsg(name)) + } +} + +export const createUnsupportedOnApi = createUnsupportedSyncApi +export const createUnsupportedOffApi = createUnsupportedSyncApi +export const createUnsupportedTaskApi = createUnsupportedSyncApi + +export function createUnsupportedAsyncApi(name: string) { + return (_args: unknown, { reject }: { reject: (err?: string) => void }) => { + return reject(createUnsupportedMsg(name)) + } +} diff --git a/packages/uni-api/src/index.ts b/packages/uni-api/src/index.ts index ceba06202..2b8f5dddc 100644 --- a/packages/uni-api/src/index.ts +++ b/packages/uni-api/src/index.ts @@ -45,6 +45,8 @@ export * from './protocols/media/chooseFile' export * from './protocols/media/getImageInfo' export * from './protocols/media/previewImage' export * from './protocols/media/getVideoInfo' +export * from './protocols/media/saveImageToPhotosAlbum' +export * from './protocols/media/saveVideoToPhotosAlbum' export * from './protocols/network/request' export * from './protocols/network/downloadFile' @@ -75,6 +77,11 @@ export { defineTaskApi, defineSyncApi, defineAsyncApi, + createUnsupportedOnApi, + createUnsupportedOffApi, + createUnsupportedTaskApi, + createUnsupportedSyncApi, + createUnsupportedAsyncApi, } from './helpers/api' export { handlePromise } from './helpers/api/promise' diff --git a/packages/uni-api/src/protocols/media/saveImageToPhotosAlbum.ts b/packages/uni-api/src/protocols/media/saveImageToPhotosAlbum.ts new file mode 100644 index 000000000..a517e5847 --- /dev/null +++ b/packages/uni-api/src/protocols/media/saveImageToPhotosAlbum.ts @@ -0,0 +1,3 @@ +export const API_SAVE_IMAGE_TO_PHOTOS_ALBUM = 'saveImageToPhotosAlbum' +export type API_TYPE_SAVE_IMAGE_TO_PHOTOS_ALBUM = + typeof uni.saveImageToPhotosAlbum diff --git a/packages/uni-api/src/protocols/media/saveVideoToPhotosAlbum.ts b/packages/uni-api/src/protocols/media/saveVideoToPhotosAlbum.ts new file mode 100644 index 000000000..e15579aba --- /dev/null +++ b/packages/uni-api/src/protocols/media/saveVideoToPhotosAlbum.ts @@ -0,0 +1,3 @@ +export const API_SAVE_VIDEO_TO_PHOTOS_ALBUM = 'saveVideoToPhotosAlbum' +export type API_TYPE_SAVE_VIDEO_TO_PHOTOS_ALBUM = + typeof uni.saveVideoToPhotosAlbum diff --git a/packages/uni-h5/dist/uni-h5.cjs.js b/packages/uni-h5/dist/uni-h5.cjs.js index c84bc166c..41a0b4bd5 100644 --- a/packages/uni-h5/dist/uni-h5.cjs.js +++ b/packages/uni-h5/dist/uni-h5.cjs.js @@ -10568,8 +10568,8 @@ var LayoutComponent = /* @__PURE__ */ defineSystemComponent({ const { layoutState, windowState - } = __UNI_FEATURE_RESPONSIVE__ ? useState() : {}; - layoutState && useMaxWidth(layoutState, rootRef); + } = useState(); + useMaxWidth(layoutState, rootRef); const topWindow = __UNI_FEATURE_TOPWINDOW__ && useTopWindow(layoutState); const leftWindow = __UNI_FEATURE_LEFTWINDOW__ && useLeftWindow(layoutState); const rightWindow = __UNI_FEATURE_RIGHTWINDOW__ && useRightWindow(layoutState); @@ -10631,6 +10631,17 @@ function useMaxWidth(layoutState, rootRef) { vue.watch([() => route.path], checkMaxWidth); } function useState() { + if (!__UNI_FEATURE_RESPONSIVE__) { + const layoutState2 = vue.reactive({ + marginWidth: 0 + }); + vue.watch(() => layoutState2.marginWidth, (value) => updateCssVar({ + "--window-margin": value + "px" + })); + return { + layoutState: layoutState2 + }; + } const topWindowMediaQuery = vue.ref(false); const leftWindowMediaQuery = vue.ref(false); const rightWindowMediaQuery = vue.ref(false); diff --git a/packages/uni-h5/dist/uni-h5.es.js b/packages/uni-h5/dist/uni-h5.es.js index 32b036619..fefdc2761 100644 --- a/packages/uni-h5/dist/uni-h5.es.js +++ b/packages/uni-h5/dist/uni-h5.es.js @@ -1680,6 +1680,20 @@ function defineSyncApi(name, fn, protocol, options) { function defineAsyncApi(name, fn, protocol, options) { return promisify(wrapperAsyncApi(name, fn, process.env.NODE_ENV !== "production" ? protocol : void 0, options)); } +function createUnsupportedMsg(name) { + return `method 'uni.${name}' not supported`; +} +function createUnsupportedSyncApi(name) { + return () => { + console.error(createUnsupportedMsg(name)); + }; +} +const createUnsupportedOnApi = createUnsupportedSyncApi; +function createUnsupportedAsyncApi(name) { + return (_args, {reject}) => { + return reject(createUnsupportedMsg(name)); + }; +} const API_BASE64_TO_ARRAY_BUFFER = "base64ToArrayBuffer"; const Base64ToArrayBufferProtocol = [ { @@ -11750,6 +11764,8 @@ const GetVideoInfoProtocol = { required: true } }; +const API_SAVE_IMAGE_TO_PHOTOS_ALBUM = "saveImageToPhotosAlbum"; +const API_SAVE_VIDEO_TO_PHOTOS_ALBUM = "saveVideoToPhotosAlbum"; const API_REQUEST = "request"; const dataType = { JSON: "json" @@ -18057,8 +18073,8 @@ var LayoutComponent = /* @__PURE__ */ defineSystemComponent({ const { layoutState, windowState - } = __UNI_FEATURE_RESPONSIVE__ ? useState() : {}; - layoutState && useMaxWidth(layoutState, rootRef); + } = useState(); + useMaxWidth(layoutState, rootRef); const topWindow = __UNI_FEATURE_TOPWINDOW__ && useTopWindow(layoutState); const leftWindow = __UNI_FEATURE_LEFTWINDOW__ && useLeftWindow(layoutState); const rightWindow = __UNI_FEATURE_RIGHTWINDOW__ && useRightWindow(layoutState); @@ -18139,6 +18155,17 @@ function useMaxWidth(layoutState, rootRef) { }); } function useState() { + if (!__UNI_FEATURE_RESPONSIVE__) { + const layoutState2 = reactive({ + marginWidth: 0 + }); + watch(() => layoutState2.marginWidth, (value) => updateCssVar({ + "--window-margin": value + "px" + })); + return { + layoutState: layoutState2 + }; + } const topWindowMediaQuery = ref(false); const leftWindowMediaQuery = ref(false); const rightWindowMediaQuery = ref(false); @@ -18470,6 +18497,46 @@ const setRightWindowStyle = /* @__PURE__ */ defineSyncApi("setRightWindowStyle", state2.rightWindowStyle = style; } }); +const saveImageToPhotosAlbum = /* @__PURE__ */ defineAsyncApi(API_SAVE_IMAGE_TO_PHOTOS_ALBUM, createUnsupportedAsyncApi(API_SAVE_IMAGE_TO_PHOTOS_ALBUM)); +const API_GET_RECORDER_MANAGER = "getRecorderManager"; +const getRecorderManager = /* @__PURE__ */ defineSyncApi(API_GET_RECORDER_MANAGER, createUnsupportedSyncApi(API_GET_RECORDER_MANAGER)); +const saveVideoToPhotosAlbum = /* @__PURE__ */ defineAsyncApi(API_SAVE_VIDEO_TO_PHOTOS_ALBUM, createUnsupportedAsyncApi(API_SAVE_VIDEO_TO_PHOTOS_ALBUM)); +const API_CREATE_CAMERA_CONTEXT = "createCameraContext"; +const createCameraContext = /* @__PURE__ */ defineSyncApi(API_CREATE_CAMERA_CONTEXT, createUnsupportedSyncApi(API_CREATE_CAMERA_CONTEXT)); +const API_CREATE_LIVE_PLAYER_CONTEXT = "createLivePlayerContext"; +const createLivePlayerContext = /* @__PURE__ */ defineSyncApi(API_CREATE_LIVE_PLAYER_CONTEXT, createUnsupportedSyncApi(API_CREATE_LIVE_PLAYER_CONTEXT)); +const API_SAVE_FILE = "saveFile"; +const saveFile = /* @__PURE__ */ defineAsyncApi(API_SAVE_FILE, createUnsupportedAsyncApi(API_SAVE_FILE)); +const API_GET_SAVED_FILE_LIST = "getSavedFileList"; +const getSavedFileList = /* @__PURE__ */ defineAsyncApi(API_GET_SAVED_FILE_LIST, createUnsupportedAsyncApi(API_GET_SAVED_FILE_LIST)); +const API_GET_SAVED_FILE_INFO = "getSavedFileInfo"; +const getSavedFileInfo = /* @__PURE__ */ defineAsyncApi(API_GET_SAVED_FILE_INFO, createUnsupportedAsyncApi(API_GET_SAVED_FILE_INFO)); +const API_REMOVE_SAVED_FILE_INFO = "removeSavedFileInfo"; +const removeSavedFileInfo = /* @__PURE__ */ defineAsyncApi(API_REMOVE_SAVED_FILE_INFO, createUnsupportedAsyncApi(API_REMOVE_SAVED_FILE_INFO)); +const API_ON_MEMORY_WARNING = "onMemoryWarning"; +const onMemoryWarning = /* @__PURE__ */ defineOnApi(API_ON_MEMORY_WARNING, createUnsupportedOnApi(API_ON_MEMORY_WARNING)); +const API_ON_GYROSCOPE_CHANGE = "onGyroscopeChange"; +const onGyroscopeChange = /* @__PURE__ */ defineOnApi(API_ON_GYROSCOPE_CHANGE, createUnsupportedOnApi(API_ON_GYROSCOPE_CHANGE)); +const API_START_GYROSCOPE = "startGyroscope"; +const startGyroscope = /* @__PURE__ */ defineAsyncApi(API_START_GYROSCOPE, createUnsupportedAsyncApi(API_START_GYROSCOPE)); +const API_STOP_GYROSCOPE = "stopGyroscope"; +const stopGyroscope = /* @__PURE__ */ defineAsyncApi(API_STOP_GYROSCOPE, createUnsupportedAsyncApi(API_STOP_GYROSCOPE)); +const API_SCAN_CODE = "scanCode"; +const scanCode = /* @__PURE__ */ defineAsyncApi(API_SCAN_CODE, createUnsupportedAsyncApi(API_SCAN_CODE)); +const API_SET_SCREEN_BRIGHTNESS = "setScreenBrightness"; +const setScreenBrightness = /* @__PURE__ */ defineAsyncApi(API_SET_SCREEN_BRIGHTNESS, createUnsupportedAsyncApi(API_SET_SCREEN_BRIGHTNESS)); +const API_GET_SCREEN_BRIGHTNESS = "getScreenBrightness"; +const getScreenBrightness = /* @__PURE__ */ defineAsyncApi(API_GET_SCREEN_BRIGHTNESS, createUnsupportedAsyncApi(API_GET_SCREEN_BRIGHTNESS)); +const API_SET_KEEP_SCREEN_ON = "setKeepScreenOn"; +const setKeepScreenOn = /* @__PURE__ */ defineAsyncApi(API_SET_KEEP_SCREEN_ON, createUnsupportedAsyncApi(API_SET_KEEP_SCREEN_ON)); +const API_ON_USER_CAPTURE_SCREEN = "onUserCaptureScreen"; +const onUserCaptureScreen = /* @__PURE__ */ defineOnApi(API_ON_USER_CAPTURE_SCREEN, createUnsupportedOnApi(API_ON_USER_CAPTURE_SCREEN)); +const API_ADD_PHONE_CONTACT = "addPhoneContact"; +const addPhoneContact = /* @__PURE__ */ defineAsyncApi(API_ADD_PHONE_CONTACT, createUnsupportedAsyncApi(API_ADD_PHONE_CONTACT)); +const API_LOGIN = "login"; +const login = /* @__PURE__ */ defineAsyncApi(API_LOGIN, createUnsupportedAsyncApi(API_LOGIN)); +const API_GET_PROVIDER = "getProvider"; +const getProvider = /* @__PURE__ */ defineAsyncApi(API_GET_PROVIDER, createUnsupportedAsyncApi(API_GET_PROVIDER)); var api = /* @__PURE__ */ Object.freeze({ __proto__: null, [Symbol.toStringTag]: "Module", @@ -18590,7 +18657,28 @@ var api = /* @__PURE__ */ Object.freeze({ getLeftWindowStyle, setLeftWindowStyle, getRightWindowStyle, - setRightWindowStyle + setRightWindowStyle, + saveImageToPhotosAlbum, + getRecorderManager, + saveVideoToPhotosAlbum, + createCameraContext, + createLivePlayerContext, + saveFile, + getSavedFileList, + getSavedFileInfo, + removeSavedFileInfo, + onMemoryWarning, + onGyroscopeChange, + startGyroscope, + stopGyroscope, + scanCode, + setScreenBrightness, + getScreenBrightness, + setKeepScreenOn, + onUserCaptureScreen, + addPhoneContact, + login, + getProvider }); const CONTEXT_ID = "MAP_LOCATION"; const ICON_PATH = "data:image/png;base64,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"; @@ -20578,4 +20666,4 @@ var index = /* @__PURE__ */ defineSystemComponent({ return openBlock(), createBlock("div", clazz, [loadingVNode]); } }); -export {$emit, $off, $on, $once, index$1 as AsyncErrorComponent, index as AsyncLoadingComponent, _sfc_main$2 as Audio, index$r as Button, index$q as Canvas, index$o as Checkbox, index$p as CheckboxGroup, index$3 as CoverImage, index$4 as CoverView, index$n as Editor, index$t as Form, Friction, index$m as Icon, index$l as Image, Input, index$s as Label, LayoutComponent, Map$1 as Map, MovableArea, MovableView, index$k as Navigator, index$2 as PageComponent, _sfc_main$1 as Picker, PickerView, PickerViewColumn, index$j as Progress, index$h as Radio, index$i as RadioGroup, ResizeSensor, index$g as RichText, ScrollView, Scroller, index$f as Slider, Spring, Swiper, SwiperItem, index$e as Switch, index$d as Text, index$c as Textarea, UniServiceJSBridge$1 as UniServiceJSBridge, UniViewJSBridge$1 as UniViewJSBridge, index$7 as Video, index$b as View, index$6 as WebView, addInterceptor, arrayBufferToBase64, base64ToArrayBuffer, canIUse, canvasGetImageData, canvasPutImageData, canvasToTempFilePath, chooseFile, chooseImage, chooseLocation, chooseVideo, clearStorage, clearStorageSync, closeSocket, connectSocket, createAnimation, createCanvasContext, createInnerAudioContext, createIntersectionObserver, createMapContext, createMediaQueryObserver, createSelectorQuery, createVideoContext, cssBackdropFilter, cssConstant, cssEnv, cssVar, defineBuiltInComponent, defineSystemComponent, disableScrollBounce, downloadFile, getApp$1 as getApp, getContextInfo, getCurrentPages$1 as getCurrentPages, getFileInfo, getImageInfo, getLeftWindowStyle, getLocation, getNetworkType, getRightWindowStyle, getSelectedTextRange, getStorage, getStorageInfo, getStorageInfoSync, getStorageSync, getSystemInfo, getSystemInfoSync, getTopWindowStyle, getVideoInfo, hideKeyboard, hideLeftWindow, hideLoading, hideNavigationBarLoading, hideRightWindow, hideTabBar, hideTabBarRedDot, hideToast, hideTopWindow, initScrollBounce, loadFontFace, makePhoneCall, navigateBack, navigateTo, offAccelerometerChange, offCompassChange, offNetworkStatusChange, offWindowResize, onAccelerometerChange, onCompassChange, onNetworkStatusChange, onSocketClose, onSocketError, onSocketMessage, onSocketOpen, onTabBarMidButtonTap, onWindowResize, openDocument, openLocation, pageScrollTo, index$8 as plugin, preloadPage, previewImage, promiseInterceptor, reLaunch, redirectTo, removeInterceptor, removeStorage, removeStorageSync, removeTabBarBadge, request, sendSocketMessage, setLeftWindowStyle, setNavigationBarColor, setNavigationBarTitle, setRightWindowStyle, setStorage, setStorageSync, setTabBarBadge, setTabBarItem, setTabBarStyle, setTopWindowStyle, setupApp, setupPage, showActionSheet, showLeftWindow, showLoading, showModal, showNavigationBarLoading, showRightWindow, showTabBar, showTabBarRedDot, showToast, showTopWindow, startAccelerometer, startCompass, startPullDownRefresh, stopAccelerometer, stopCompass, stopPullDownRefresh, switchTab, uni$1 as uni, uniFormKey, uploadFile, upx2px, useAttrs, useBooleanAttr, useContextInfo, useCustomEvent, useNativeEvent, useOn, useScroller, useSubscribe, useTouchtrack, useUserAction, vibrateLong, vibrateShort, withWebEvent}; +export {$emit, $off, $on, $once, index$1 as AsyncErrorComponent, index as AsyncLoadingComponent, _sfc_main$2 as Audio, index$r as Button, index$q as Canvas, index$o as Checkbox, index$p as CheckboxGroup, index$3 as CoverImage, index$4 as CoverView, index$n as Editor, index$t as Form, Friction, index$m as Icon, index$l as Image, Input, index$s as Label, LayoutComponent, Map$1 as Map, MovableArea, MovableView, index$k as Navigator, index$2 as PageComponent, _sfc_main$1 as Picker, PickerView, PickerViewColumn, index$j as Progress, index$h as Radio, index$i as RadioGroup, ResizeSensor, index$g as RichText, ScrollView, Scroller, index$f as Slider, Spring, Swiper, SwiperItem, index$e as Switch, index$d as Text, index$c as Textarea, UniServiceJSBridge$1 as UniServiceJSBridge, UniViewJSBridge$1 as UniViewJSBridge, index$7 as Video, index$b as View, index$6 as WebView, addInterceptor, addPhoneContact, arrayBufferToBase64, base64ToArrayBuffer, canIUse, canvasGetImageData, canvasPutImageData, canvasToTempFilePath, chooseFile, chooseImage, chooseLocation, chooseVideo, clearStorage, clearStorageSync, closeSocket, connectSocket, createAnimation, createCameraContext, createCanvasContext, createInnerAudioContext, createIntersectionObserver, createLivePlayerContext, createMapContext, createMediaQueryObserver, createSelectorQuery, createVideoContext, cssBackdropFilter, cssConstant, cssEnv, cssVar, defineBuiltInComponent, defineSystemComponent, disableScrollBounce, downloadFile, getApp$1 as getApp, getContextInfo, getCurrentPages$1 as getCurrentPages, getFileInfo, getImageInfo, getLeftWindowStyle, getLocation, getNetworkType, getProvider, getRecorderManager, getRightWindowStyle, getSavedFileInfo, getSavedFileList, getScreenBrightness, getSelectedTextRange, getStorage, getStorageInfo, getStorageInfoSync, getStorageSync, getSystemInfo, getSystemInfoSync, getTopWindowStyle, getVideoInfo, hideKeyboard, hideLeftWindow, hideLoading, hideNavigationBarLoading, hideRightWindow, hideTabBar, hideTabBarRedDot, hideToast, hideTopWindow, initScrollBounce, loadFontFace, login, makePhoneCall, navigateBack, navigateTo, offAccelerometerChange, offCompassChange, offNetworkStatusChange, offWindowResize, onAccelerometerChange, onCompassChange, onGyroscopeChange, onMemoryWarning, onNetworkStatusChange, onSocketClose, onSocketError, onSocketMessage, onSocketOpen, onTabBarMidButtonTap, onUserCaptureScreen, onWindowResize, openDocument, openLocation, pageScrollTo, index$8 as plugin, preloadPage, previewImage, promiseInterceptor, reLaunch, redirectTo, removeInterceptor, removeSavedFileInfo, removeStorage, removeStorageSync, removeTabBarBadge, request, saveFile, saveImageToPhotosAlbum, saveVideoToPhotosAlbum, scanCode, sendSocketMessage, setKeepScreenOn, setLeftWindowStyle, setNavigationBarColor, setNavigationBarTitle, setRightWindowStyle, setScreenBrightness, setStorage, setStorageSync, setTabBarBadge, setTabBarItem, setTabBarStyle, setTopWindowStyle, setupApp, setupPage, showActionSheet, showLeftWindow, showLoading, showModal, showNavigationBarLoading, showRightWindow, showTabBar, showTabBarRedDot, showToast, showTopWindow, startAccelerometer, startCompass, startGyroscope, startPullDownRefresh, stopAccelerometer, stopCompass, stopGyroscope, stopPullDownRefresh, switchTab, uni$1 as uni, uniFormKey, uploadFile, upx2px, useAttrs, useBooleanAttr, useContextInfo, useCustomEvent, useNativeEvent, useOn, useScroller, useSubscribe, useTouchtrack, useUserAction, vibrateLong, vibrateShort, withWebEvent}; diff --git a/packages/uni-h5/src/framework/components/layout/index.tsx b/packages/uni-h5/src/framework/components/layout/index.tsx index fdff204ed..837df8857 100644 --- a/packages/uni-h5/src/framework/components/layout/index.tsx +++ b/packages/uni-h5/src/framework/components/layout/index.tsx @@ -47,10 +47,8 @@ export default /*#__PURE__*/ defineSystemComponent({ !__NODE_JS__ && initCssVar() const keepAliveRoute = (__UNI_FEATURE_PAGES__ && useKeepAliveRoute()) as KeepAliveRoute - const { layoutState, windowState } = __UNI_FEATURE_RESPONSIVE__ - ? useState() - : ({} as { layoutState: undefined; windowState: undefined }) - layoutState && useMaxWidth(layoutState, rootRef) + const { layoutState, windowState } = useState() + useMaxWidth(layoutState, rootRef) const topWindow = __UNI_FEATURE_TOPWINDOW__ && useTopWindow(layoutState!) const leftWindow = __UNI_FEATURE_LEFTWINDOW__ && useLeftWindow(layoutState!) const rightWindow = @@ -185,6 +183,17 @@ function useMaxWidth( } function useState() { + if (!__UNI_FEATURE_RESPONSIVE__) { + // max width + const layoutState = reactive({ + marginWidth: 0, + }) as LayoutState + watch( + () => layoutState.marginWidth, + (value) => updateCssVar({ '--window-margin': value + 'px' }) + ) + return { layoutState } + } const topWindowMediaQuery = ref(false) const leftWindowMediaQuery = ref(false) const rightWindowMediaQuery = ref(false) diff --git a/packages/uni-h5/src/service/api/index.ts b/packages/uni-h5/src/service/api/index.ts index 0f327a59e..ece642f28 100644 --- a/packages/uni-h5/src/service/api/index.ts +++ b/packages/uni-h5/src/service/api/index.ts @@ -61,6 +61,8 @@ export * from './ui/stopPullDownRefresh' export * from './ui/tabBar' export * from './ui/window' +export * from './todo/index' + export { upx2px, addInterceptor, diff --git a/packages/uni-h5/src/service/api/todo/index.ts b/packages/uni-h5/src/service/api/todo/index.ts new file mode 100644 index 000000000..04ccd0bff --- /dev/null +++ b/packages/uni-h5/src/service/api/todo/index.ts @@ -0,0 +1,175 @@ +import { + API_SAVE_IMAGE_TO_PHOTOS_ALBUM, + API_SAVE_VIDEO_TO_PHOTOS_ALBUM, + API_TYPE_SAVE_IMAGE_TO_PHOTOS_ALBUM, + API_TYPE_SAVE_VIDEO_TO_PHOTOS_ALBUM, + createUnsupportedAsyncApi, + createUnsupportedOnApi, + createUnsupportedSyncApi, + defineAsyncApi, + defineOnApi, + defineSyncApi, +} from '@dcloudio/uni-api' + +export const saveImageToPhotosAlbum = + defineAsyncApi( + API_SAVE_IMAGE_TO_PHOTOS_ALBUM, + createUnsupportedAsyncApi(API_SAVE_IMAGE_TO_PHOTOS_ALBUM) + ) +const API_GET_RECORDER_MANAGER = 'getRecorderManager' +export const getRecorderManager = defineSyncApi( + API_GET_RECORDER_MANAGER, + createUnsupportedSyncApi(API_GET_RECORDER_MANAGER) +) + +export const saveVideoToPhotosAlbum = + defineAsyncApi( + API_SAVE_VIDEO_TO_PHOTOS_ALBUM, + createUnsupportedAsyncApi(API_SAVE_VIDEO_TO_PHOTOS_ALBUM) + ) + +const API_CREATE_CAMERA_CONTEXT = 'createCameraContext' +export const createCameraContext = defineSyncApi< + typeof uni.createCameraContext +>( + API_CREATE_CAMERA_CONTEXT, + createUnsupportedSyncApi(API_CREATE_CAMERA_CONTEXT) +) + +const API_CREATE_LIVE_PLAYER_CONTEXT = 'createLivePlayerContext' +export const createLivePlayerContext = defineSyncApi< + typeof uni.createLivePlayerContext +>( + API_CREATE_LIVE_PLAYER_CONTEXT, + createUnsupportedSyncApi(API_CREATE_LIVE_PLAYER_CONTEXT) +) + +const API_SAVE_FILE = 'saveFile' +export const saveFile = defineAsyncApi( + API_SAVE_FILE, + createUnsupportedAsyncApi(API_SAVE_FILE) +) +const API_GET_SAVED_FILE_LIST = 'getSavedFileList' +export const getSavedFileList = defineAsyncApi( + API_GET_SAVED_FILE_LIST, + createUnsupportedAsyncApi(API_GET_SAVED_FILE_LIST) +) +const API_GET_SAVED_FILE_INFO = 'getSavedFileInfo' +export const getSavedFileInfo = defineAsyncApi( + API_GET_SAVED_FILE_INFO, + createUnsupportedAsyncApi(API_GET_SAVED_FILE_INFO) +) +const API_REMOVE_SAVED_FILE_INFO = 'removeSavedFileInfo' +export const removeSavedFileInfo = defineAsyncApi( + API_REMOVE_SAVED_FILE_INFO, + createUnsupportedAsyncApi(API_REMOVE_SAVED_FILE_INFO) +) + +const API_ON_MEMORY_WARNING = 'onMemoryWarning' +export const onMemoryWarning = defineOnApi( + API_ON_MEMORY_WARNING, + createUnsupportedOnApi(API_ON_MEMORY_WARNING) +) +const API_ON_GYROSCOPE_CHANGE = 'onGyroscopeChange' +export const onGyroscopeChange = defineOnApi( + API_ON_GYROSCOPE_CHANGE, + createUnsupportedOnApi(API_ON_GYROSCOPE_CHANGE) +) +const API_START_GYROSCOPE = 'startGyroscope' +export const startGyroscope = defineAsyncApi( + API_START_GYROSCOPE, + createUnsupportedAsyncApi(API_START_GYROSCOPE) +) +const API_STOP_GYROSCOPE = 'stopGyroscope' +export const stopGyroscope = defineAsyncApi( + API_STOP_GYROSCOPE, + createUnsupportedAsyncApi(API_STOP_GYROSCOPE) +) + +const API_SCAN_CODE = 'scanCode' +export const scanCode = defineAsyncApi( + API_SCAN_CODE, + createUnsupportedAsyncApi(API_SCAN_CODE) +) + +const API_SET_SCREEN_BRIGHTNESS = 'setScreenBrightness' +export const setScreenBrightness = defineAsyncApi< + typeof uni.setScreenBrightness +>( + API_SET_SCREEN_BRIGHTNESS, + createUnsupportedAsyncApi(API_SET_SCREEN_BRIGHTNESS) +) + +const API_GET_SCREEN_BRIGHTNESS = 'getScreenBrightness' +export const getScreenBrightness = defineAsyncApi< + typeof uni.getScreenBrightness +>( + API_GET_SCREEN_BRIGHTNESS, + createUnsupportedAsyncApi(API_GET_SCREEN_BRIGHTNESS) +) + +const API_SET_KEEP_SCREEN_ON = 'setKeepScreenOn' +export const setKeepScreenOn = defineAsyncApi( + API_SET_KEEP_SCREEN_ON, + createUnsupportedAsyncApi(API_SET_KEEP_SCREEN_ON) +) +const API_ON_USER_CAPTURE_SCREEN = 'onUserCaptureScreen' +export const onUserCaptureScreen = defineOnApi( + API_ON_USER_CAPTURE_SCREEN, + createUnsupportedOnApi(API_ON_USER_CAPTURE_SCREEN) +) +const API_ADD_PHONE_CONTACT = 'addPhoneContact' +export const addPhoneContact = defineAsyncApi( + API_ADD_PHONE_CONTACT, + createUnsupportedAsyncApi(API_ADD_PHONE_CONTACT) +) + +const API_LOGIN = 'login' +export const login = defineAsyncApi( + API_LOGIN, + createUnsupportedAsyncApi(API_LOGIN) +) +const API_GET_PROVIDER = 'getProvider' +export const getProvider = defineAsyncApi( + API_GET_PROVIDER, + createUnsupportedAsyncApi(API_GET_PROVIDER) +) + +// TODO... + +// 'openBluetoothAdapter', +// 'startBluetoothDevicesDiscovery', +// 'onBluetoothDeviceFound', +// 'stopBluetoothDevicesDiscovery', +// 'onBluetoothAdapterStateChange', +// 'getConnectedBluetoothDevices', +// 'getBluetoothDevices', +// 'getBluetoothAdapterState', +// 'closeBluetoothAdapter', +// 'writeBLECharacteristicValue', +// 'readBLECharacteristicValue', +// 'onBLEConnectionStateChange', +// 'onBLECharacteristicValueChange', +// 'notifyBLECharacteristicValueChange', +// 'getBLEDeviceServices', +// 'getBLEDeviceCharacteristics', +// 'createBLEConnection', +// 'closeBLEConnection', +// 'onBeaconServiceChange', +// 'onBeaconUpdate', +// 'getBeacons', +// 'startBeaconDiscovery', +// 'stopBeaconDiscovery', +// 'setBackgroundColor', +// 'setBackgroundTextStyle', +// 'checkSession', +// 'getUserInfo', +// 'share', +// 'onShareAppMessage', +// 'showShareMenu', +// 'hideShareMenu', +// 'requestPayment', +// 'subscribePush', +// 'unsubscribePush', +// 'onPush', +// 'offPush' -- GitLab