[24章]Qt 全流程实战企业级项目 - 云对象存储浏览器

165 阅读4分钟

下载地址1:pan.baidu.com/s/180fnOsA0… 提取码:laa9 下载地址2:pan.baidu.com/s/1a_dwzeyb… 提取码:a5p2

Qt开发浏览器全流程实战讲解。 体设计如下: 模块功能: 提供用户界面,显示网页的内容。 允许用户在界面中浏览网页,包括滚动和缩放功能。 支持网页导航,包括前进和后退功能。

设计说明: 浏览网页模块可以使用一个 WebView 控件实现,用于显示网页内容。 用户可以使用滚动条进行页面的上下滚动,以查看完整的页面内容。 提供缩放功能,允许用户调整页面的大小比例。 通过前进和后退按钮,用户可以导航到浏览历史记录中的前一个或后一个页面。

步骤1: 创建Qt项目首先,我们需要创建一个新的Q项自。打开Qt Creatr,并选择“新建项目”,然后选择“Qt Widgets应用程序”。为项目命名并选择保存路径。点击“下一步”并按照向导的指示完成项目创建过程。

步骤2: 添加WebEngine模块在QtCreaor的项目资源管理器中,找到项日文件夹中的,oro文件。右键单未该文件并选择“编辑”。在打开的,0文件中,找到"“OT+=widaets”这并在其下方添加加以下代码: mybatis-plus: configuration: map-underscore-to-camel-case: true log-impl: org.apache.ibatis.logging.stdout.StdOutImpl global-config: db-config: id-type: assign_id update-strategy: not_empty mapper-locations: classpath*:/mapper/*.xml ./configure
--prefix=/usr/local/nginx
--pid-path=/var/run/nginx/nginx.pid
--lock-path=/var/lock/nginx.lock
--error-log-path=/var/log/nginx/error.log
--http-log-path=/var/log/nginx/access.log
--with-http_gzip_static_module
--http-client-body-temp-path=/var/temp/nginx/client
--http-proxy-temp-path=/var/temp/nginx/proxy
--http-fastcgi-temp-path=/var/temp/nginx/fastcgi
--http-uwsgi-temp-path=/var/temp/nginx/uwsgi
--http-scgi-temp-path=/var/temp/nginx/scgi 编写一个http请求工具类,可以放入到lualib路径中,如此可以更加的通用化 local function get(path, params) local response = ngx.location.capture(path, { method = ngx.HTTP_GET,
args = params }); -- 目标路径不存在,无法响应客户端 if not response then ngx.exit(404); end -- 只要有响应,不管是200还是5xx状态,直接return return response.body; end

local function post(path, params, body) local response = ngx.location.capture(path, { method = ngx.HTTP_POST,
args = params, body = body }); -- 目标路径不存在,无法响应客户端 if not response then ngx.exit(404); end -- 只要有响应,不管是200还是5xx状态,直接return return response.body; end

-- 导出函数 local http = { post = post, get = get } return http; docker run -p 3306:3306 --name mysql
-v /home/mysql8/log:/var/log/mysql
-v /home/mysql8/data:/var/lib/mysql
-v /home/mysql8/conf:/etc/mysql/conf.d
-v /home/mysql8/mysql-files:/var/lib/mysql-files
-e MYSQL_ROOT_PASSWORD=imooc123
-d mysql:8.0.33
--character-set-server=utf8mb4
--collation-server=utf8mb4_unicode_ci //导入JQuery库,因为Ajax用起来非常方便,支持同步和异步的Ajax请求 import $ from 'jquery';

//导入ElementUI的消息通知组件,下面封装全局Ajax的时候处理异常的时候需要弹出通知 import { ElMessage } from 'element-plus';

//后端项目的URL根路径 let baseUrl = 'http://localhost:7700/his-api'; app.config.globalProperties.baseUrl=baseUrl;//设置全局变量baseUrl = baseUrl; //设置全局变量baseUrl

//Minio服务器地址 let minioUrl = 'http://localhost:9000/his'; app.config.globalProperties.$minioUrl = minioUrl;

//封装全局Ajax公共函数 app.config.globalProperties.http = function (url : string, method : string, data : JSON, async : boolean, fun : Function) { .ajax({ url: baseUrl + url, type: method, dataType: 'json', contentType: 'application/json', //上传的数据被序列化(允许Ajax上传数组) traditional: true, xhrFields: { //允许Ajax请求跨域 withCredentials: true }, headers: { token: localStorage.getItem('token') }, async: async, data: JSON.stringify(data), success: function (resp : any) { if (resp.code == 200) { fun(resp); } else { ElMessage.error({ message: resp.msg, duration: 1200 }); } }, error: function (e : any) { //ajax有语法错误的时候 if (e.status == undefined) { ElMessage.error({ message: '前端页面错误', duration: 1200 }); } else { let status = e.status; //没有登陆体检系统 if (status == 401) { if (url.startsWith('/front/')) { router.push({ name: 'FrontIndex' }); } else { router.push({ name: 'MisLogin' }); } } else { //后端没有运行,提交的数据有误,或者没有连接上后端项目 if (!e.hasOwnProperty('responseText')) { ElMessage.error({ message: '后端项目没有启动,或者HTTP请求类型以及参数错误', duration: 1200 }); } else { ElMessage.error({ message: e.responseText, duration: 1200 }); } } } } }); }; MIS端框架页面的视图层代码我们要加以修改,比如说

标签的:class属性要根据isTab切换不同的样式。还有就是给设置上v-if判断,如果isTab为true就用Tab控件引用Vue压面;反之就用控件引用Vue页面。

还是在刚才的yml文件中,填写Redis配置信息。这里我用的是Redis里面0号逻辑库。如果你有其他项目也在使用0号逻辑库,建议你这里改成其他的逻辑库,避免缓存数据发生覆盖。 spring: …… redis: database: 0 host: localhost port: 6379 password: abc123456 jedis: pool: #连接超时的最大时间 max-active: 1000 #等待空闲连接的最大等待时间(负数代表一直等待) max-wait: -1ms max-idle: 16 min-idle: 8 在com.example.his.api.config包中,创建RedisTemplateConfig类。 import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.data.redis.connection.RedisConnectionFactory; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer; import org.springframework.data.redis.serializer.StringRedisSerializer;

@Configuration public class RedisTemplateConfig { @Bean public RedisTemplate<Object, Object> redisTemplate(RedisConnectionFactory factory) { RedisTemplate<Object, Object> template = new RedisTemplate<>(); template.setKeySerializer(new StringRedisSerializer()); template.setValueSerializer(new StringRedisSerializer()); template.setHashKeySerializer(new StringRedisSerializer()); template.setHashValueSerializer(new GenericJackson2JsonRedisSerializer()); template.setConnectionFactory(factory); return template; } } 在com.example.his.api.config包中,创建ThreadPoolConfig.java类,这个类的用途是配置线程池。 @Configuration public class ThreadPoolConfig {

@Bean("AsyncTaskExecutor")
public AsyncTaskExecutor taskExecutor() {
    ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
    // 设置核心线程数
    executor.setCorePoolSize(8);
    // 设置最大线程数
    executor.setMaxPoolSize(16);
    // 设置队列容量
    executor.setQueueCapacity(1000);
    // 设置线程活跃时间(秒)
    executor.setKeepAliveSeconds(60);
    // 线程名称的前缀
    executor.setThreadNamePrefix("task-");
    // 设置拒绝策略
    executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
    //初始化线程池
    executor.initialize();
    return executor;
}

}