@@ -41,10 +41,38 @@ const toggleClass = (target, cls, toggle = false) => {
41
41
// 触发键盘事件
42
42
const keyEvent = ( key , ctrlKey = false , altKey = false , shiftKey = false ) => {
43
43
const ke = new KeyboardEvent ( 'keydown' , { ctrlKey, altKey, shiftKey, detail : 1 , view : window } ) ;
44
+ // key是键盘对应键的code值
44
45
Object . defineProperty ( ke , 'key' , { value : key } ) ;
45
46
document . dispatchEvent ( ke ) ;
46
47
} ;
47
- // 从localStorage获取值(值是整型或布尔型)
48
+ // 通过浏览器协议打开工具
49
+ const openProtocol = ( protocolName ) => {
50
+ const winFeatures = [
51
+ 'left=0' , // 新窗口距离屏幕左侧的像素数
52
+ 'top=-50' , // 新窗口距离屏幕上侧的像素数
53
+ 'width=0' , // 新窗口的宽度
54
+ 'height=0' , // 新窗口的高度
55
+ 'innerWidth=0' , // 新窗口的内部宽度
56
+ 'innerHeight=0' , // 新窗口的内部高度
57
+ 'outerWidth=0' , // 新窗口的外部宽度
58
+ 'outerHeight=0' , // 新窗口的外部高度
59
+ 'centerscreen=no' , // 是否在屏幕中央打开
60
+ 'fullscreen=no' , // 是否全屏
61
+ 'titlebar=no' , // 是否显示标题栏
62
+ 'toolbar=no' , // 是否显示工具栏
63
+ 'menubar=no' , // 是否显示菜单栏
64
+ 'location=no' , // 是否显示地址栏
65
+ 'status=no' , // 是否显示是否显示状态栏
66
+ 'scrollbars=no' , // 是否显示滚动条
67
+ 'resizable=no' , // 窗口是否可调整大小
68
+ 'director=no' , // 是否显示目录栏
69
+ 'help=no' , // 是否显示帮助按钮
70
+ 'minimizedbutton=no' , // 是否显示最小化按钮
71
+ 'maximizedbutton=no' , // 是否显示最大化按钮
72
+ ] ;
73
+ window . open ( `${ protocolName } ://` , protocolName , winFeatures . join ( ',' ) ) . close ( ) ;
74
+ } ;
75
+ // 从localStorage获取值(值是整型或布尔型),没有或异常时取默认值
48
76
const getLocalByDefault = ( key , defaultValue ) => {
49
77
let value = localStorage . getItem ( key ) ;
50
78
try {
@@ -150,9 +178,11 @@ const wtConfirm = (content) => window.Pedestal.callMethod('method://pedestal/con
150
178
* @returns {Promise<void> }
151
179
*/
152
180
const wtNotifyPrompt = async ( { title, inputType = 'text' , inputTestId, placeholders, defaultValue, maxLength = 1e5 , callback } ) => {
153
- const newProc = new Promise ( ( resolve , reject ) => {
181
+ const newProc = new Promise ( ( resolve ) => {
154
182
const d = window . Pedestal . callMethod ( 'method://pedestal/notifyPrompt' , {
155
- dialogId : Date . now ( ) , title, inputParam : { inputType, placeholders, inputTestId, maxLength, defaultValue } ,
183
+ dialogId : Date . now ( ) ,
184
+ title,
185
+ inputParam : { inputType, placeholders, inputTestId, maxLength, defaultValue } ,
156
186
} ) ;
157
187
setTimeout ( ( ) => {
158
188
if ( inputTestId ) {
@@ -202,3 +232,16 @@ const openExternal = (url) => {
202
232
} catch ( e ) { }
203
233
} ;
204
234
// endregion
235
+ // region 特性方法
236
+ // 生成资源默认路径
237
+ const basePath = ( index , path = 'assets/' , padPath = '../' ) => path . padStart ( index * padPath . length + path . length , padPath ) ;
238
+ // 生成样式表路径
239
+ const stylePath = ( index , viewID ) => `${ basePath ( index ) } css/${ viewID } .css` ;
240
+ // 视频背景列表
241
+ let videoList = [ ] ;
242
+ // 获取视频显示名
243
+ const setVideoName = ( langCode , video ) => {
244
+ video . name = langCode === DEFAULT_LANGUAGE_CODE ? video . cnName : video . enName ;
245
+ ! video . name && ( video . name = video . fileName ) ;
246
+ } ;
247
+ // endregion
0 commit comments