C = A..B,用..连接,或者C=table.concat({A,B}),后面这种写着麻烦,不过组合大量字符串时效率高。
lua脚本将两个字符串变量相加的方法
Restful 返回数据格式
返回数据的一般格式:
{
“code”: 1,
“mssage”: “返回的信息”,
“data”: {
“list”:[
{
“title”:”xxx”,
“contents”:”xxx”,
},{
“title”:”xxx”,
“contents”:”xxx”,
}
]
“total”:21,
},
“extra”: {},
“pageNum”: 3,
“pageSize”: 20,
“totalSize”: 235
}
code的一般含义
public enum ResultCode { /* 成功状态码 */ SUCCESS(0, "成功"), /* 令牌失效 */ TOKEN_INVALID(401,"令牌失效"), SERVER_ERROR(400, "服务器错误"), /*参数错误 10001-19999 */ PARAM_IS_INVALID(10001, "参数无效"), PARAM_IS_BLANK(10002, "参数为空"), PARAM_TYPE_BIND_ERROR(10003, "参数类型错误"), PARAM_NOT_COMPLETE(10004, "参数缺失"), /* 用户错误:20001-29999*/ USER_NOT_LOGGED_IN(20001, "用户未登录"), USER_LOGIN_ERROR(20002, "账号不存在或密码错误"), USER_ACCOUNT_FORBIDDEN(20003, "账号已被禁用"), USER_NOT_EXIST(20004, "用户不存在"), USER_HAS_EXISTED(20005, "用户已存在"), Cert_HAS_EXISTED(20006, "认证已存在"), /* 业务错误:30001-39999 */ CREATE_FAIL(30001, "创建失败"), /* 系统错误:40001-49999 */ SYSTEM_INNER_ERROR(40001, "系统繁忙,请稍后重试"), /* 数据错误:50001-599999 */ RESULE_DATA_NONE(50001, "数据未找到"), DATA_IS_WRONG(50002, "数据有误"), DATA_ALREADY_EXISTED(50003, "数据已存在"), /* 接口错误:60001-69999 */ INTERFACE_INNER_INVOKE_ERROR(60001, "内部系统接口调用异常"), INTERFACE_OUTTER_INVOKE_ERROR(60002, "外部系统接口调用异常"), INTERFACE_FORBID_VISIT(60003, "该接口禁止访问"), INTERFACE_ADDRESS_INVALID(60004, "接口地址无效"), INTERFACE_REQUEST_TIMEOUT(60005, "接口请求超时"), INTERFACE_EXCEED_LOAD(60006, "接口负载过高"), /* 权限错误:70001-79999 */ PERMISSION_NO_ACCESS(70001, "只有标签 Owner ,才具备删除权限"), PERMISSION_NO_PHONE_ACCESS(70002,"此认证标签已有员工认证,不可以进行删除"); }
Vue3-cli/Ant-design-pro-vue修改运行在子路径上
版本依赖情况:
PS D:\suidian-yuexi\admin> npm list vue npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead. vue-antd-pro@3.0.2 D:\suidian-yuexi\admin +-- @ant-design-vue/pro-layout@1.0.13 | +-- vue-container-query@0.1.0 | | `-- vue@2.7.3 deduped | +-- vue-copy-to-clipboard@1.0.3 | | `-- vue@2.7.3 deduped | `-- vue@2.7.3 deduped +-- @vue/cli-plugin-babel@4.5.19 | `-- @vue/babel-preset-app@4.5.19 | +-- @vue/babel-preset-jsx@1.3.0 | | `-- vue@2.7.3 deduped | `-- vue@2.7.3 deduped +-- @vue/cli-plugin-unit-jest@4.5.19 | `-- vue-jest@3.0.7 | `-- vue@2.7.3 deduped +-- @vue/test-utils@1.3.0 | `-- vue@2.7.3 deduped +-- ant-design-vue@1.7.8 | +-- @ant-design/icons-vue@2.0.0 | `-- vue@2.7.3 deduped +-- viser-vue@2.4.8 | `-- vue@2.7.3 deduped +-- vue-svg-component-runtime@1.0.1 | `-- vue@2.7.3 deduped +-- vue-svg-icon-loader@2.1.1 | +-- vue-svg-component-builder@2.0.3 | | `-- vue@2.7.3 deduped | `-- vue@2.7.3 deduped +-- vue@2.7.3 `-- vuex@3.6.2 `-- vue@2.7.3 deduped PS D:\suidian-yuexi\admin> npm run serve npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead. > vue-antd-pro@3.0.2 serve > vue-cli-service serve
1、修改项目运行路径,打开vue.config.js文件,在vueConfig的json中增加:
publicPath: "/admin2/",
2、修改路由的基础路径,打开index.js文件,在createRouter的new Router对象时传入的json增加:
base: '/admin2',
3、重启服务即可
安装RabbitMQ
一、安装ERLANG
RabbitMQ依赖语言开发包ErLang,到http://www.erlang.org/downloads下载windows版本并安装,安装后需要配置环境变量:
1、增加系统变量:ERLANG_HOME=C:\Program Files\erl-23.0
2、在Path系统变量中增加:%ERLANG_HOME%\bin
然后在CMD中输入指令“erl”即可验证是否配置成功:
二、安装RabbitMQ
到https://www.rabbitmq.com/download.html下载windows版本病安装,安装后需要配置环境变量:
1、增加系统变量:RABBITMQ_SERVER=C:\Program Files\RabbitMQ Server\rabbitmq_server-3.8.3
2、在Path系统变量中增加:%RABBITMQ_SERVER%\sbin
三、激活RabbitMQ的WEB管理界面(可选)
打开CMD执行命令:rabbitmq-plugins.bat enable rabbitmq_management
执行成功后重启RabbitMQ服务(可到“服务”中重启,或在任务栏中也能找到相关菜单),然后访问网址:http://localhost:15672/
默认用户名/密码:guest/guest
登录后出现如下界面:
使用uniapp离线打包底座时获取getApplicationContext()的方法
在对应的类中静态引入以下方法即可:
import static io.dcloud.common.util.ReflectUtils.getApplicationContext;
然后再对应的业务逻辑中直接使用getApplicationContext()即可获取到。
事实上我用jd-gui查看其编译后代码,看见好像这种工具类也能自己写,其代码如下(未验证过):
import android.context.Context; public static Context getApplicationContext(){ Context context = null; try{ Context = (Context)Class.forName("android.app.ActivityThread").getDeclaredMethod("currentApplication",new Class[0]).invoke((Object)null, new Object[0]); }catch(Exception e){ null.printStackTrace(); } }
使用uniapp的安心打包制作ios安装文件时出现PKCS12 import (wrong password?)
假如你确定你的证书密码是对的,就是死活不成功,出现如下提示:
[Info] begin copyFile files to ipa... [Info] begin replace files to ipa... [Info] begin update mobileprovision to ipa... [Info] begin outPut t_entitlements_full plist file... [Info] begin outPut outPutEntitlements plist file... [Info] begin verifyPlistFiles [Info] begin update files to ipa... [Info] begin createKeychain... [Info] begin unlockKeychain... [Info] begin setListKeychains... [Info] begin importAppleCerts... [Info] 1 certificate imported. [Info] 1 certificate imported. [Info] 1 certificate imported. [Info] begin importSecurity... [Error] security: SecKeychainItemImport: MAC verification failed during PKCS12 import (wrong password?) [Error] importSecurity failed [Info] Package make result:Failed. Reason:
那有可能是因为导出p12证书的时候密码过于简单,不符合要求,导致后续证书使用时的安检失败引起的。请重新导出新的、且符合密码强度要求的p12证书。
Android调用原生文件管理器来选择文件
在activity即可:
public class UploadActivity extends Activity { public final static int REQUEST_CODE = 1000; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Intent intent = new Intent(Intent.ACTION_GET_CONTENT); intent.setType("*/*"); //设置类型,任意类型 intent.addCategory(Intent.CATEGORY_OPENABLE); this.startActivityForResult(intent, REQUEST_CODE); } @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); //if (requestCode == REQUEST_CODE && resultCode == 200) { if (data == null) { // 用户未选择任何文件,直接返回 return; } Uri uri = data.getData(); // 获取用户选择文件的URI String path = uri.getPath(); Toast.makeText(this, "path="+path, Toast.LENGTH_SHORT).show(); String truePath = this.getPath(this,uri); Toast.makeText(this, "truePath="+truePath, Toast.LENGTH_SHORT).show(); File file = new File(truePath); Toast.makeText(this, "file.exists()="+file.exists(), Toast.LENGTH_SHORT).show(); Intent intent = new Intent(); intent.putExtra("truePath", truePath); setResult(Activity.RESULT_OK, intent); finish(); } /** * 专为Android4.4设计的从Uri获取文件绝对路径,以前的方法已不好使 */ @SuppressLint("NewApi") public String getPath(final Context context, final Uri uri) { final boolean isKitKat = Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT; // DocumentProvider if (isKitKat && DocumentsContract.isDocumentUri(context, uri)) { // ExternalStorageProvider if (isExternalStorageDocument(uri)) { final String docId = DocumentsContract.getDocumentId(uri); final String[] split = docId.split(":"); final String type = split[0]; if ("primary".equalsIgnoreCase(type)) { return Environment.getExternalStorageDirectory() + "/" + split[1]; } } // DownloadsProvider else if (isDownloadsDocument(uri)) { final String id = DocumentsContract.getDocumentId(uri); final Uri contentUri = ContentUris.withAppendedId( Uri.parse("content://downloads/public_downloads"), Long.valueOf(id)); return getDataColumn(context, contentUri, null, null); } // MediaProvider else if (isMediaDocument(uri)) { final String docId = DocumentsContract.getDocumentId(uri); final String[] split = docId.split(":"); final String type = split[0]; Uri contentUri = null; if ("image".equals(type)) { contentUri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI; } else if ("video".equals(type)) { contentUri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI; } else if ("audio".equals(type)) { contentUri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI; } else if ("document".equals(type)) { contentUri = MediaStore.Files.getContentUri("external"); } final String selection = "_id=?"; final String[] selectionArgs = new String[]{split[1]}; return getDataColumn(context, contentUri, selection, selectionArgs); } } // MediaStore (and general) else if ("content".equalsIgnoreCase(uri.getScheme())) { return getDataColumn(context, uri, null, null); } // File else if ("file".equalsIgnoreCase(uri.getScheme())) { return uri.getPath(); } return null; } /** * Get the value of the data column for this Uri. This is useful for * MediaStore Uris, and other file-based ContentProviders. * * @param context The context. * @param uri The Uri to query. * @param selection (Optional) Filter used in the query. * @param selectionArgs (Optional) Selection arguments used in the query. * @return The value of the _data column, which is typically a file path. */ public String getDataColumn(Context context, Uri uri, String selection, String[] selectionArgs) { Cursor cursor = null; final String column = "_data"; final String[] projection = {column}; try { cursor = context.getContentResolver().query(uri, projection, selection, selectionArgs, null); if (cursor != null && cursor.moveToFirst()) { final int column_index = cursor.getColumnIndexOrThrow(column); return cursor.getString(column_index); } } finally { if (cursor != null) cursor.close(); } return null; } /** * @param uri The Uri to check. * @return Whether the Uri authority is ExternalStorageProvider. */ public boolean isExternalStorageDocument(Uri uri) { return "com.android.externalstorage.documents".equals(uri.getAuthority()); } /** * @param uri The Uri to check. * @return Whether the Uri authority is DownloadsProvider. */ public boolean isDownloadsDocument(Uri uri) { return "com.android.providers.downloads.documents".equals(uri.getAuthority()); } /** * @param uri The Uri to check. * @return Whether the Uri authority is MediaProvider. */ public boolean isMediaDocument(Uri uri) { return "com.android.providers.media.documents".equals(uri.getAuthority()); } }
注意:请记得开启文件读写权限,否则获取到的文件路径为null:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
使用okhttp3时忽略所有证书
1、新建一个SSLSocketClient.java类:
import java.security.SecureRandom; import java.security.cert.X509Certificate; import javax.net.ssl.HostnameVerifier; import javax.net.ssl.SSLContext; import javax.net.ssl.SSLSession; import javax.net.ssl.SSLSocketFactory; import javax.net.ssl.TrustManager; import javax.net.ssl.X509TrustManager; public class SSLSocketClient { //获取这个SSLSocketFactory public static SSLSocketFactory getSSLSocketFactory() { try { SSLContext sslContext = SSLContext.getInstance("SSL"); sslContext.init(null, getTrustManager(), new SecureRandom()); return sslContext.getSocketFactory(); } catch (Exception e) { throw new RuntimeException(e); } } //获取TrustManager private static TrustManager[] getTrustManager() { TrustManager[] trustAllCerts = new TrustManager[]{ new X509TrustManager() { @Override public void checkClientTrusted(X509Certificate[] chain, String authType) { } @Override public void checkServerTrusted(X509Certificate[] chain, String authType) { } @Override public X509Certificate[] getAcceptedIssuers() { return new X509Certificate[]{}; } } }; return trustAllCerts; } //获取HostnameVerifier public static HostnameVerifier getHostnameVerifier() { HostnameVerifier hostnameVerifier = new HostnameVerifier() { @Override public boolean verify(String s, SSLSession sslSession) { return true; } }; return hostnameVerifier; } }
2、使用以下代码来构建okhttp3即可:
OkHttpClient.Builder mBuilder = new OkHttpClient.Builder(); mBuilder.sslSocketFactory(SSLSocketClient.getSSLSocketFactory()); mBuilder.hostnameVerifier(SSLSocketClient.getHostnameVerifier()); OkHttpClient client = mBuilder.build();
12306火车购票优先选下铺的方法
1、先在页面空白地方右击“审查元素”
2、在页面代码编辑区域搜索“优先席别”
3、在网页页面出现席别选择,此时选择硬卧,然后右键“硬卧”选项并审查元素
4、在硬卧的span标签后增加以下代码即可:
<select name="passsenger_1_seat-detail_select" id="passenger_1_seat_detail_select" onchange="setseatDetail('1')"> <option value="0">随机</option> <option value="3">上铺</option> <option value="2">中铺</option> <option value="1">下铺</option> </select>
uni-app使用H5+调起安卓原生Activity
方式一,无需回调结果:
let platform = uni.getSystemInfoSync().platform; if (platform == 'android') { //获取宿主上下文 var main = plus.android.runtimeMainActivity(); var openUrl = "sway://openapi:8848/oauthLogin?appKey=" + this.appKey + "&pkgName=" + this .pkgName; console.log(openUrl); //通过反射获取Android的Uri对象 var Uri = plus.android.importClass("android.net.Uri"); var uri = Uri.parse(openUrl); //通过反射获取Android的Intent对象 var Intent = plus.android.importClass("android.content.Intent"); var intent = plus.android.newObject("android.content.Intent", Intent.ACTION_VIEW, uri); main.startActivity(intent); } else { uni.showToast({ title: "仅支持安卓客户端", icon: 'none', duration: 2000 }); }
方式二,需要回调结果:
let platform = uni.getSystemInfoSync().platform; if (platform == 'android') { //获取宿主上下文 var main = plus.android.runtimeMainActivity(); var openUrl = "sway://openapi:8848/oauthLogin?appKey=" + this.appKey + "&pkgName=" + this .pkgName; console.log(openUrl); //通过反射获取Android的Uri对象 var Uri = plus.android.importClass("android.net.Uri"); var uri = Uri.parse(openUrl); //通过反射获取Android的Intent对象 var Intent = plus.android.importClass("android.content.Intent"); var intent = plus.android.newObject("android.content.Intent", Intent.ACTION_VIEW, uri); //请求码保证了,开始的新界面和返回的是同一个操作 var CODE_REQUEST = 1000 main.startActivityForResult(intent, CODE_REQUEST); //设置原生界面返回后的回调操作 main.onActivityResult = function(requestCode, resultCode, data) { if (requestCode == CODE_REQUEST) { //alert(requestCode); //这个是正确的 1000 //alert(resultCode); //始终都是0 //alert(data); //弹出 undefined plus.android.importClass(data); var bundle = data.getExtras(); plus.android.importClass(bundle); let result = eval('(' + bundle.getString("data") + ')'); } } } else { uni.showToast({ title: "仅支持安卓客户端", icon: 'none', duration: 2000 }); }