const val STATE_OPENED = 1 //打开状态 const val STATE_CLOSED = 2 //关闭状态 const val STATE_DRAG = 3 // 拖拽中 const val STATE_FLING = 4 // 飞一会儿 转换成java
时间: 2023-10-11 11:05:40 浏览: 131
public static final int STATE_OPENED = 1; //打开状态
public static final int STATE_CLOSED = 2; //关闭状态
public static final int STATE_DRAG = 3; // 拖拽中
public static final int STATE_FLING = 4; // 飞一会儿
相关问题
帮我优化以下 const val LOAD_H5_SUCCESS="appLoadH5Success" //H5加载完成 const val APP_START_ACTIVITY="appStartActivity" const val GET_GAODE_LOCATION = "appGetGaoDeLocation" //获取定位 const val BARCODESCANNER_SCAN = "appBarcodescannerScan" //扫码 const val APP_GET_FILE_BASE64 = "appGetFileBase64" const val CAMERA_UPLOAD = "appCameraUpload" //调取拍照的功能 const val CREDENTIALS_CAMERA_UPLOAD = "appCredentialsCameraUpload" //调取证件拍照的功能 const val SCAN_BLUETOOTH = "appScanBluetooth" const val APP_DISCONNECT_BLE="appDisConnectBle" const val TH_PRINT = "appThPrint" const val GET_TH_WEIGHT = "appGetThWeight" const val GET_SJ_WEIGHT = "appGetSjWeight" const val PDA_PRINT = "appPdaPrint" const val GALLERY_UPLOAD = "appGalleryUpload" //上传文件 const val CREDENTIALS_GALLERY_UPLOAD = "appCredentialsGalleryUpload" //证件本地文件上传 const val FILE_UPLOAD = "appFileUpload" const val CLEAR_CACHE = "appClearCache" //清理缓存 const val GET_CACHE_SIZE = "appGetCacheSize" //获取缓存 const val DOWNLOAD_FILE = "appDownloadFile" const val PHONE_DEVICE = "appPhoneDevice" //H5获取手机设备信息 const val MEDIA_START_RECORD = "appMediaStartRecord" //开启录音 const val MEDIA_STOP_RECORD = "appMediaStopRecord" //结束录音 const val PDA_SCAN = "appPdaScan" const val APP_BLE_CONNECTED = "appBleConnected" const val APP_BLE_CONNECTED_BY_PARAMS = "appBleConnectedByParams" const val APP_USB_CONNECTED = "appUsbConnected" const val APP_CONNECT_USB = "appConnectUsb" const val APP_BACK_PAGE = "appBackPage" const val APP_LOGOUT="appLogout" //退出登录 const val APP_LOGOUT_MESSAGE="appLogoutMessage" //402 401 提示 const val APP_TOKEN_TIMEOUT="appTokenTimeOut" //token过期 const val APP_TO_BACKLOG="appToBacklog" //返回工作台 const val APP_REFRESH_BACKLOG="appRefreshBacklog" //刷新工作台 const val APP_REFRESH_BACKLOG_NUM="appRefreshBacklogNum" //刷新工作台数量 const val APP_CLOSE_MULTI_CHOOSE="appCloseMultiChoose" const val APP_SET_ORG_DATA="appSetOrgData"
可以将这些常量放在一个公共的类中,以便全局使用,如下所示:
```
object AppConstants {
const val LOAD_H5_SUCCESS="appLoadH5Success" //H5加载完成
const val APP_START_ACTIVITY="appStartActivity"
const val GET_GAODE_LOCATION = "appGetGaoDeLocation" //获取定位
const val BARCODESCANNER_SCAN = "appBarcodescannerScan" //扫码
const val APP_GET_FILE_BASE64 = "appGetFileBase64"
const val CAMERA_UPLOAD = "appCameraUpload" //调取拍照的功能
const val CREDENTIALS_CAMERA_UPLOAD = "appCredentialsCameraUpload" //调取证件拍照的功能
const val SCAN_BLUETOOTH = "appScanBluetooth"
const val APP_DISCONNECT_BLE="appDisConnectBle"
const val TH_PRINT = "appThPrint"
const val GET_TH_WEIGHT = "appGetThWeight"
const val GET_SJ_WEIGHT = "appGetSjWeight"
const val PDA_PRINT = "appPdaPrint"
const val GALLERY_UPLOAD = "appGalleryUpload" //上传文件
const val CREDENTIALS_GALLERY_UPLOAD = "appCredentialsGalleryUpload" //证件本地文件上传
const val FILE_UPLOAD = "appFileUpload"
const val CLEAR_CACHE = "appClearCache" //清理缓存
const val GET_CACHE_SIZE = "appGetCacheSize" //获取缓存
const val DOWNLOAD_FILE = "appDownloadFile"
const val PHONE_DEVICE = "appPhoneDevice" //H5获取手机设备信息
const val MEDIA_START_RECORD = "appMediaStartRecord" //开启录音
const val MEDIA_STOP_RECORD = "appMediaStopRecord" //结束录音
const val PDA_SCAN = "appPdaScan"
const val APP_BLE_CONNECTED = "appBleConnected"
const val APP_BLE_CONNECTED_BY_PARAMS = "appBleConnectedByParams"
const val APP_USB_CONNECTED = "appUsbConnected"
const val APP_CONNECT_USB = "appConnectUsb"
const val APP_BACK_PAGE = "appBackPage"
const val APP_LOGOUT="appLogout" //退出登录
const val APP_LOGOUT_MESSAGE="appLogoutMessage" //402 401 提示
const val APP_TOKEN_TIMEOUT="appTokenTimeOut" //token过期
const val APP_TO_BACKLOG="appToBacklog" //返回工作台
const val APP_REFRESH_BACKLOG="appRefreshBacklog" //刷新工作台
const val APP_REFRESH_BACKLOG_NUM="appRefreshBacklogNum" //刷新工作台数量
const val APP_CLOSE_MULTI_CHOOSE="appCloseMultiChoose"
const val APP_SET_ORG_DATA="appSetOrgData"
}
```
使用时只需通过类名调用即可,如 `AppConstants.LOAD_H5_SUCCESS`。这样做的好处是方便管理和维护,同时也可以避免命名冲突。
const mutations = { changeToken(state, token) { state.token = token // 并且把token存入缓存 setToken(token) }, setUserInfo(state, userInfo) { state.userInfo = userInfo }, getKey(state, num) { state.key = num }, getToken(state, val) { state.token = val }, removeToken(state) { // 清除state中的token state.token = null // 同时也要清除缓存中的token removeToken() } }
这段代码是在 Vuex 中定义了一些 mutation,用于修改 state 中的数据。其中,changeToken 用于修改 token,并将其存入缓存;setUserInfo 用于设置用户信息;getKey 用于设置 key;getToken 用于设置 token;removeToken 用于清除 token 并从缓存中移除。在使用这些 mutation 时,需要通过 commit 方法来触发对应的 mutation。例如:`this.$store.commit('changeToken', token)`。
阅读全文