Android中浏览器或者应用通过scheme唤起目标应用,打开目标页面的实现,及多次唤起时目标应用的拦截页面未执行问题

本文主要是介绍Android中浏览器或者应用通过scheme唤起目标应用,打开目标页面的实现,及多次唤起时目标应用的拦截页面未执行问题,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

 本文模拟的是appA唤起appB,打开指定的BActivity页面的情况,两个应用的页面结构如下图所示:

浏览器或者其它应用,通过scheme配置唤起目标应用,需要约定的uri,如示例代码中的

String uri = "appb://com.windfallsheng.myapplicationb/sign?type=1&targetPage=BActivity&userName=windfallsheng";

在appA中只需要根据

package com.windfallsheng.myapplicationa;import androidx.appcompat.app.AppCompatActivity;
import android.annotation.SuppressLint;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;public class MainActivity extends AppCompatActivity {@SuppressLint("NewApi")@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);}public void launchAPPB(View view) {String uri = "appb://com.windfallsheng.myapplicationb/sign?type=1&targetPage=BActivity&userName=windfallsheng";Intent intent = new Intent();intent.setData(Uri.parse(uri));intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);startActivity(intent);}
}
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"xmlns:app="http://schemas.android.com/apk/res-auto"xmlns:tools="http://schemas.android.com/tools"android:layout_width="match_parent"android:layout_height="match_parent"android:background="#f2f2f2"tools:context=".MainActivity"><TextViewandroid:id="@+id/textView"android:layout_width="0dp"android:layout_height="0dp"android:gravity="center"android:textSize="35sp"android:background="@drawable/selector_item_background"app:layout_constraintHorizontal_bias="0.5"app:layout_constraintVertical_bias="0.5"app:layout_constraintWidth_percent="0.7"app:layout_constraintHeight_percent="0.15"android:paddingRight="10dp"android:paddingLeft="10dp"android:text="唤起B应用"android:onClick="launchAPPB"app:layout_constraintBottom_toBottomOf="parent"app:layout_constraintLeft_toLeftOf="parent"app:layout_constraintRight_toRightOf="parent"app:layout_constraintTop_toTopOf="parent" /></androidx.constraintlayout.widget.ConstraintLayout>

在appB的拦截页面配置:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"package="com.windfallsheng.myapplicationb"><applicationandroid:allowBackup="true"android:icon="@mipmap/ic_launcher"android:label="@string/app_name"android:roundIcon="@mipmap/ic_launcher_round"android:supportsRtl="true"android:theme="@style/AppTheme"><activityandroid:name=".WelcomeActivity"><intent-filter><action android:name="android.intent.action.MAIN" /><category android:name="android.intent.category.LAUNCHER" /></intent-filter><intent-filter><!--接收外部跳转--><action android:name="android.intent.action.VIEW" /><!--该页面可以被隐式调用--><category android:name="android.intent.category.DEFAULT" /><!--应用可以通过浏览器启动--><category android:name="android.intent.category.BROWSABLE" /><data android:scheme="appb" /></intent-filter></activity><activityandroid:name=".MainActivity"android:launchMode="singleTask"></activity><activity android:name=".BActivity"></activity><activity android:name=".CActivity"></activity></application></manifest>
package com.windfallsheng.myapplicationb;import android.annotation.SuppressLint;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.os.CountDownTimer;
import android.os.Handler;
import android.text.TextUtils;
import android.util.Log;
import android.widget.TextView;
import androidx.appcompat.app.AppCompatActivity;public class WelcomeActivity extends AppCompatActivity {CodeReqCountDownTimer codeReqCountDownTimer;String type;@Overrideprotected void onNewIntent(Intent intent) {super.onNewIntent(intent);Log.d("appB", "WelcomeActivity#onNewIntent");}@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_welcome);Uri data = getIntent().getData();Log.d("appB", "WelcomeActivity#onCreate#data=" + data);if (data != null) {String userName = data.getQueryParameter("userName");String targetPage = data.getQueryParameter("targetPage");type = data.getQueryParameter("type");Log.d("appB", "WelcomeActivity#onCreate#type=" + type + ", targetPage=" + targetPage + ", userName=" + userName);}TextView tv = findViewById(R.id.textView);codeReqCountDownTimer = new CodeReqCountDownTimer(tv, 4 * 1000, 1000);codeReqCountDownTimer.start();}/*** 时间倒计时*/class CodeReqCountDownTimer extends CountDownTimer {private TextView tv;public CodeReqCountDownTimer(TextView textView, long millisInFuture, long countDownInterval) {super(millisInFuture, countDownInterval);this.tv = textView;}@Overridepublic void onTick(long l) {String timeStr = l / 1000 + "s";tv.setText(timeStr);  //设置倒计时时间}@Overridepublic void onFinish() {if (TextUtils.equals("1", type)) {tv.setText("即将进入B页面");} else {tv.setText("即将进入主页");}new Handler().postDelayed(new Runnable() {@SuppressLint("NewApi")@Overridepublic void run() {if (TextUtils.equals("1", type)) { // 经scheme唤起应用;startActivity(new Intent(WelcomeActivity.this, BActivity.class));} else {// 正常启动应用;startActivity(new Intent(WelcomeActivity.this, MainActivity.class));}WelcomeActivity.this.finish();}}, 1000);}}@Overrideprotected void onDestroy() {super.onDestroy();codeReqCountDownTimer.cancel();codeReqCountDownTimer = null;}
}

目前的配置是可以实现目标应用appB被唤起,但是有一个问题,如果appB是在被首次唤醒启动后再次唤起,或者appB是被桌面图标首先启动,则拦截界面不会启动;

 

       正常的业务需求应该是每次从浏览器唤起应用后,都会经过应用启动页,之后再跳转向目标分享页面,同时应用如果在后台运行,则不会重启应用,正如下面图中演示的情况;

appA首次唤起appB的情况,如下图: 

appA首次唤起appB后,再多次唤起的情况,如下图:

 要解决一开始的问题,实现这样的业务情况,需要在唤起的应用B中做处理:

将应用B的拦截页面的Activity启动模式改为 :

android:launchMode="singleTask"

其它的启动模式是无效的。

解决应用被三方唤起后,再通过桌面图标启动,会引起应用重启的问题的解决方法是在启动页加入如下的代码:

if (!this.isTaskRoot()) {Intent intent = getIntent();if (intent != null) {String action = intent.getAction();if (intent.hasCategory(Intent.CATEGORY_LAUNCHER) && Intent.ACTION_MAIN.equals(action)) {Log.d("appB", "WelcomeActivity#onCreate#finish");finish();}}
}

完整的代码示例如下:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"package="com.windfallsheng.myapplicationb"><applicationandroid:allowBackup="true"android:icon="@mipmap/ic_launcher"android:label="@string/app_name"android:roundIcon="@mipmap/ic_launcher_round"android:supportsRtl="true"android:theme="@style/AppTheme"><activityandroid:name=".WelcomeActivity"android:launchMode="singleTask"><intent-filter><action android:name="android.intent.action.MAIN" /><category android:name="android.intent.category.LAUNCHER" /></intent-filter><intent-filter><!--接收外部跳转--><action android:name="android.intent.action.VIEW" /><!--表示该页面可以被隐式调用,必须加上该项--><category android:name="android.intent.category.DEFAULT" /><!--如果希望该应用可以通过浏览器的连接启动,则添加该项--><category android:name="android.intent.category.BROWSABLE" /><data android:scheme="appb" /></intent-filter></activity><activityandroid:name=".MainActivity"android:launchMode="singleTask"></activity><activity android:name=".BActivity"></activity><activity android:name=".CActivity"></activity></application></manifest>
package com.windfallsheng.myapplicationb;import android.annotation.SuppressLint;
import android.app.ActivityManager;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.os.CountDownTimer;
import android.os.Handler;
import android.text.TextUtils;
import android.util.Log;
import android.widget.TextView;
import java.util.List;
import androidx.appcompat.app.AppCompatActivity;public class WelcomeActivity extends AppCompatActivity {CodeReqCountDownTimer codeReqCountDownTimer;String type;@Overrideprotected void onNewIntent(Intent intent) {super.onNewIntent(intent);Log.d("appB", "WelcomeActivity#onNewIntent");}@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_welcome);if (!this.isTaskRoot()) {Intent intent = getIntent();if (intent != null) {String action = intent.getAction();if (intent.hasCategory(Intent.CATEGORY_LAUNCHER) && Intent.ACTION_MAIN.equals(action)) {Log.d("appB", "WelcomeActivity#onCreate#finish");finish();}}}Uri data = getIntent().getData();Log.d("appB", "WelcomeActivity#onCreate#data=" + data);if (data != null) {String userName = data.getQueryParameter("userName");String targetPage = data.getQueryParameter("targetPage");type = data.getQueryParameter("type");Log.d("appB", "WelcomeActivity#onCreate#type=" + type + ", targetPage=" + targetPage+", userName=" + userName);}TextView tv = findViewById(R.id.textView);codeReqCountDownTimer = new CodeReqCountDownTimer(tv, 4 * 1000, 1000);codeReqCountDownTimer.start();}/*** 时间倒计时*/class CodeReqCountDownTimer extends CountDownTimer {private TextView tv;public CodeReqCountDownTimer(TextView textView, long millisInFuture, long countDownInterval) {super(millisInFuture, countDownInterval);this.tv = textView;}@Overridepublic void onTick(long l) {String timeStr = l / 1000 + "s";tv.setText(timeStr);  //设置倒计时时间}@Overridepublic void onFinish() {if (TextUtils.equals("1", type)) {tv.setText("即将进入B页面");} else {tv.setText("即将进入主页");}new Handler().postDelayed(new Runnable() {@SuppressLint("NewApi")@Overridepublic void run() {if (TextUtils.equals("1", type)) { // 经scheme唤起应用;ActivityManager activityManager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);//获取activity任务栈,获取任务栈列表List<ActivityManager.AppTask> tasks = activityManager.getAppTasks();tasks.stream().forEach(task -> {ActivityManager.RecentTaskInfo info = task.getTaskInfo();
//            int taskId = info.taskId;int activityCount = info.numActivities; //栈内Activity数量String topActivity = info.topActivity.getClassName(); //栈顶ActivityString baseActivity = info.baseActivity.getClassName(); //栈底ActivityLog.d("appB", "WelcomeActivity#activityCount=" + activityCount + ", topActivity=" + topActivity + ", baseActivity=" + baseActivity);});if (tasks.size() == 1) {int activityCount = tasks.get(0).getTaskInfo().numActivities;Log.d("appB", "WelcomeActivity#activityCount=" + activityCount);if (activityCount > 1) {// 目标应用已经被唤起的情况;startActivity(new Intent(WelcomeActivity.this, BActivity.class));} else { // 目标应用首次被唤起的情况;Intent mainIntent = new Intent(WelcomeActivity.this, MainActivity.class);Intent bIntent = new Intent(WelcomeActivity.this, BActivity.class);//注意此处的顺序startActivities(new Intent[]{mainIntent, bIntent});}} else {// 目标应用已经被唤起的情况;startActivity(new Intent(WelcomeActivity.this, BActivity.class));}} else {// 正常启动应用;startActivity(new Intent(WelcomeActivity.this, MainActivity.class));}WelcomeActivity.this.finish();}}, 1000);}}@Overrideprotected void onDestroy() {super.onDestroy();codeReqCountDownTimer.cancel();codeReqCountDownTimer = null;}
}

启动页中的:
startActivities(new Intent[]{mainIntent, bIntent});

这个方法是为了解决浏览器首次唤起应用后,直接打开了目标分享页面,用户返回时没有返回到B应用的主页问题。

package com.windfallsheng.myapplicationb;import androidx.appcompat.app.AppCompatActivity;import android.annotation.SuppressLint;
import android.app.ActivityManager;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;import java.util.List;public class MainActivity extends AppCompatActivity {@SuppressLint("NewApi")@Overrideprotected void onNewIntent(Intent intent) {super.onNewIntent(intent);Log.d("appB", "MainActivity#onNewIntent");// 获取activity任务栈ActivityManager activityManager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);//获取任务栈列表List<ActivityManager.AppTask> tasks = activityManager.getAppTasks();tasks.stream().forEach(task -> {ActivityManager.RecentTaskInfo info = task.getTaskInfo();
//            int taskId = info.taskId;int activityCount = info.numActivities; //栈内Activity数量String topActivity = info.topActivity.getClassName(); //栈顶ActivityString baseActivity = info.baseActivity.getClassName(); //栈底ActivityLog.d("appB", "MainActivity#onNewIntent#activityCount=" + activityCount + ", topActivity=" + topActivity + ", baseActivity=" + baseActivity);});}@SuppressLint("NewApi")@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);Log.d("appB", "MainActivity#onCreate");// 获取activity任务栈ActivityManager activityManager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);//获取任务栈列表List<ActivityManager.AppTask> tasks = activityManager.getAppTasks();tasks.stream().forEach(task -> {ActivityManager.RecentTaskInfo info = task.getTaskInfo();
//            int taskId = info.taskId;int activityCount = info.numActivities; //栈内Activity数量String topActivity = info.topActivity.getClassName(); //栈顶ActivityString baseActivity = info.baseActivity.getClassName(); //栈底ActivityLog.d("appB", "MainActivity#onCreate#activityCount=" + activityCount + ", topActivity=" + topActivity + ", baseActivity=" + baseActivity);});}public void goToPageB(View view) {startActivity(new Intent(this, BActivity.class));}
}
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"xmlns:app="http://schemas.android.com/apk/res-auto"xmlns:tools="http://schemas.android.com/tools"android:layout_width="match_parent"android:layout_height="match_parent"android:background="#f2f2f2"tools:context=".MainActivity"><TextViewandroid:id="@+id/textView"android:layout_width="0dp"android:layout_height="0dp"android:background="@drawable/selector_item_background"android:gravity="center"android:onClick="goToPageB"android:paddingLeft="10dp"android:paddingRight="10dp"android:text="打开B页面"android:textSize="35sp"app:layout_constraintBottom_toBottomOf="parent"app:layout_constraintHeight_percent="0.15"app:layout_constraintHorizontal_bias="0.5"app:layout_constraintLeft_toLeftOf="parent"app:layout_constraintRight_toRightOf="parent"app:layout_constraintTop_toTopOf="parent"app:layout_constraintVertical_bias="0.5"app:layout_constraintWidth_percent="0.7" /><TextViewandroid:id="@+id/textView2"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_marginTop="62dp"android:text="Main_Activity"android:textSize="30sp"app:layout_constraintEnd_toEndOf="parent"app:layout_constraintStart_toStartOf="parent"app:layout_constraintTop_toTopOf="parent" /></androidx.constraintlayout.widget.ConstraintLayout>

 

package com.windfallsheng.myapplicationb;import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;import androidx.appcompat.app.AppCompatActivity;public class BActivity extends AppCompatActivity {@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_b);Log.d("appB", "BActivity#onCreate");}public void goToPageC(View view) {startActivity(new Intent(this, CActivity.class));}
}
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"xmlns:app="http://schemas.android.com/apk/res-auto"xmlns:tools="http://schemas.android.com/tools"android:layout_width="match_parent"android:layout_height="match_parent"android:background="#f2f2f2"tools:context=".BActivity"><TextViewandroid:id="@+id/textView"android:layout_width="0dp"android:layout_height="0dp"android:background="@drawable/selector_item_background"app:layout_constraintHorizontal_bias="0.5"app:layout_constraintVertical_bias="0.5"app:layout_constraintWidth_percent="0.7"app:layout_constraintHeight_percent="0.15"android:paddingRight="10dp"android:paddingLeft="10dp"android:onClick="goToPageC"android:gravity="center"android:text="打开C页面"android:textSize="35sp"app:layout_constraintBottom_toBottomOf="parent"app:layout_constraintLeft_toLeftOf="parent"app:layout_constraintRight_toRightOf="parent"app:layout_constraintTop_toTopOf="parent" /><TextViewandroid:id="@+id/textView2"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_marginTop="62dp"android:text="B_Activity"android:textSize="30sp"app:layout_constraintEnd_toEndOf="parent"app:layout_constraintStart_toStartOf="parent"app:layout_constraintTop_toTopOf="parent" /></androidx.constraintlayout.widget.ConstraintLayout>

 

package com.windfallsheng.myapplicationb;import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import android.view.View;import androidx.appcompat.app.AppCompatActivity;public class CActivity extends AppCompatActivity {@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_c);Log.d("appB", "CActivity#onCreate");}public void goToPageMain(View view) {startActivity(new Intent(this, MainActivity.class));}public void goToPageB(View view) {startActivity(new Intent(this, BActivity.class));}public void goToPageWelcome(View view) {startActivity(new Intent(this, WelcomeActivity.class));}
}
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"xmlns:app="http://schemas.android.com/apk/res-auto"xmlns:tools="http://schemas.android.com/tools"android:layout_width="match_parent"android:layout_height="match_parent"android:background="#f2f2f2"tools:context=".CActivity"><TextViewandroid:id="@+id/textView"android:layout_width="0dp"android:layout_height="0dp"android:layout_marginBottom="36dp"android:background="@drawable/selector_item_background"android:gravity="center"android:onClick="goToPageMain"android:paddingLeft="10dp"android:paddingRight="10dp"android:text="打开Main页面"android:textSize="35sp"app:layout_constraintBottom_toTopOf="@+id/textView3"app:layout_constraintEnd_toEndOf="parent"app:layout_constraintHeight_percent="0.15"app:layout_constraintStart_toStartOf="parent"app:layout_constraintTop_toBottomOf="@+id/textView2"app:layout_constraintWidth_percent="0.7" /><TextViewandroid:id="@+id/textView3"android:layout_width="0dp"android:layout_height="0dp"android:layout_marginBottom="37dp"android:background="@drawable/selector_item_background"android:gravity="center"android:onClick="goToPageB"android:paddingLeft="10dp"android:paddingRight="10dp"android:text="打开B页面"android:textSize="35sp"app:layout_constraintBottom_toTopOf="@+id/textView4"app:layout_constraintEnd_toEndOf="parent"app:layout_constraintHeight_percent="0.15"app:layout_constraintStart_toStartOf="parent"app:layout_constraintTop_toBottomOf="@+id/textView"app:layout_constraintWidth_percent="0.7" /><TextViewandroid:id="@+id/textView4"android:layout_width="0dp"android:layout_height="0dp"android:layout_marginBottom="59dp"android:background="@drawable/selector_item_background"android:gravity="center"android:onClick="goToPageWelcome"android:paddingLeft="10dp"android:paddingRight="10dp"android:text="打开Welcome页面"android:textSize="35sp"app:layout_constraintBottom_toBottomOf="parent"app:layout_constraintEnd_toEndOf="parent"app:layout_constraintHeight_percent="0.15"app:layout_constraintStart_toStartOf="parent"app:layout_constraintTop_toBottomOf="@+id/textView3"app:layout_constraintWidth_percent="0.7" /><TextViewandroid:id="@+id/textView2"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_marginTop="62dp"android:layout_marginBottom="58dp"android:paddingLeft="10dp"android:paddingRight="10dp"android:text="C_Activity"android:textSize="30sp"app:layout_constraintBottom_toTopOf="@+id/textView"app:layout_constraintEnd_toEndOf="parent"app:layout_constraintHeight_percent="0.15"app:layout_constraintStart_toStartOf="parent"app:layout_constraintTop_toTopOf="parent"app:layout_constraintWidth_percent="0.7" /></androidx.constraintlayout.widget.ConstraintLayout>
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android"><item android:drawable="@drawable/shape_checked" android:state_checked="true"/><item android:drawable="@drawable/shape_checked" android:state_selected="true"/><item android:drawable="@drawable/shape_checked" android:state_focused="true"/><item android:drawable="@drawable/shape_normal" /></selector>

 

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"android:shape="rectangle"><corners android:radius="10dp"></corners><solid android:color="#F6F6F6" />
</shape>
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"android:shape="rectangle"><corners android:radius="10dp"></corners><solid android:color="#FFF" />
</shape>

 

 

由于作者水平有限,语言描述及代码实现中难免有纰漏,望各位看官多提宝贵意见!

Hello , World !

感谢所有!

 

这篇关于Android中浏览器或者应用通过scheme唤起目标应用,打开目标页面的实现,及多次唤起时目标应用的拦截页面未执行问题的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/496857

相关文章

如何解决mmcv无法安装或安装之后报错问题

《如何解决mmcv无法安装或安装之后报错问题》:本文主要介绍如何解决mmcv无法安装或安装之后报错问题,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录mmcv无法安装或安装之后报错问题1.当我们运行YOwww.chinasem.cnLO时遇到2.找到下图所示这里3.

浅谈配置MMCV环境,解决报错,版本不匹配问题

《浅谈配置MMCV环境,解决报错,版本不匹配问题》:本文主要介绍浅谈配置MMCV环境,解决报错,版本不匹配问题,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录配置MMCV环境,解决报错,版本不匹配错误示例正确示例总结配置MMCV环境,解决报错,版本不匹配在col

Python实现AVIF图片与其他图片格式间的批量转换

《Python实现AVIF图片与其他图片格式间的批量转换》这篇文章主要为大家详细介绍了如何使用Pillow库实现AVIF与其他格式的相互转换,即将AVIF转换为常见的格式,比如JPG或PNG,需要的小... 目录环境配置1.将单个 AVIF 图片转换为 JPG 和 PNG2.批量转换目录下所有 AVIF 图

Pydantic中model_validator的实现

《Pydantic中model_validator的实现》本文主要介绍了Pydantic中model_validator的实现,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价... 目录引言基础知识创建 Pydantic 模型使用 model_validator 装饰器高级用法mo

Vue3使用router,params传参为空问题

《Vue3使用router,params传参为空问题》:本文主要介绍Vue3使用router,params传参为空问题,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐... 目录vue3使用China编程router,params传参为空1.使用query方式传参2.使用 Histo

AJAX请求上传下载进度监控实现方式

《AJAX请求上传下载进度监控实现方式》在日常Web开发中,AJAX(AsynchronousJavaScriptandXML)被广泛用于异步请求数据,而无需刷新整个页面,:本文主要介绍AJAX请... 目录1. 前言2. 基于XMLHttpRequest的进度监控2.1 基础版文件上传监控2.2 增强版多

Redis分片集群的实现

《Redis分片集群的实现》Redis分片集群是一种将Redis数据库分散到多个节点上的方式,以提供更高的性能和可伸缩性,本文主要介绍了Redis分片集群的实现,具有一定的参考价值,感兴趣的可以了解一... 目录1. Redis Cluster的核心概念哈希槽(Hash Slots)主从复制与故障转移2.

springboot+dubbo实现时间轮算法

《springboot+dubbo实现时间轮算法》时间轮是一种高效利用线程资源进行批量化调度的算法,本文主要介绍了springboot+dubbo实现时间轮算法,文中通过示例代码介绍的非常详细,对大家... 目录前言一、参数说明二、具体实现1、HashedwheelTimer2、createWheel3、n

使用Python实现一键隐藏屏幕并锁定输入

《使用Python实现一键隐藏屏幕并锁定输入》本文主要介绍了使用Python编写一个一键隐藏屏幕并锁定输入的黑科技程序,能够在指定热键触发后立即遮挡屏幕,并禁止一切键盘鼠标输入,这样就再也不用担心自己... 目录1. 概述2. 功能亮点3.代码实现4.使用方法5. 展示效果6. 代码优化与拓展7. 总结1.

Mybatis 传参与排序模糊查询功能实现

《Mybatis传参与排序模糊查询功能实现》:本文主要介绍Mybatis传参与排序模糊查询功能实现,本文通过实例代码给大家介绍的非常详细,感兴趣的朋友跟随小编一起看看吧... 目录一、#{ }和${ }传参的区别二、排序三、like查询四、数据库连接池五、mysql 开发企业规范一、#{ }和${ }传参的