这次总算把js-ojus/flow的ui部署到腾讯云上,比较吐槽的就是,为啥这么复杂,vue.js前后端分离,比golang编写的部署方面复杂几万倍。真是浪费人生啊。
golang+sqlite写的东西,直接传到任意文件里,运行即可。——当然,适用于小型的东西。
vue.js,要安装node.js环境,要nginx环境,要配置nginx跨域;要安装mysql数据库,要配置用户。体验地址:
只有这个nginx的配置文件值得贴出来,其他都忒复杂了。
[root@VM_16_4_centos nginx]# vim nginx.conf
server {
listen 8080 default_server;
listen [::]:8080 default_server;
server_name _;
root /usr/share/nginx/html;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
location / {
}
location ^~/api {
proxy_pass https://bjys.itdos.com/v1/admin;——以分号结束
}
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
# Settings for a TLS enabled server.
#
# server {
# listen 443 ssl http2 default_server;
# listen [::]:443 ssl http2 default_server;
# server_name _;
# root /usr/share/nginx/html;
#
# ssl_certificate "/etc/pki/nginx/server.crt";
# ssl_certificate_key "/etc/pki/nginx/private/server.key";
# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 10m;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;
#
# # Load configuration files for the default server block.
# include /etc/nginx/default.d/*.conf;
#
# location / {
# }
#
# error_page 404 /404.html;
# location = /40x.html {
# }
#
# error_page 500 502 503 504 /50x.html;
# location = /50x.html {
# }
# }
}——结尾括号
对应的vue.js_config_index.js
module.exports = {
dev: {
// Paths
assetsSubDirectory: 'static',
assetsPublicPath: '/',
proxyTable: {
"/api": {
target: "https://bjys.itdos.com/v1/admin", //https://bjys.itdos.com/v1/admin---218.78.187.216/api/v1设置调用的接口域名和端口
changeOrigin: true,
pathRewrite: {
"^/api": "" //用'/api' 代替 'http://218.78.187.216/api/v1'
}
}
},
只有这样,vue.js才能axios请求api:https://bjys.itdos.com/v1/admin之类的,比如vue某个页面:
axios({
// headers: {
// 'X-Requested-With': 'XMLHttpRequest',
// 'Content-Type': 'application/json; charset=UTF-8',
// 'Access-Control-Allow-Origin': '*'
// },//设置跨域请求头
method: "POST",//请求方式
url: "/api/flowtype",//请求地址
params:{
name:this.ruleForm2.typename,
},
当然,后端的flow作为一种通用流程包,是golang目前唯一的吧,对于第一次做流程的开发人员来讲还是蛮拗口的。
默认页的文档我还没写完呢~
Document Type : docType1 //1.定义文档类型-流程类型
Document States : [
docState1, docState2, docState3, docState4 // 2.定义4个状态
]
Document Actions : [
docAction12, docAction23, docAction34 // 3.定义修改状态的动作,实际应用中,除了向前传递,还要定义向后回退的动作。for the above document states
docAction21, docAction31, docAction41 //每个都直接回退到1
]
Document Type State Transitions : [
docState1 --docAction12--> docState2, //前进流程
docState2 --docAction21--> docState1, //回退流程
docState2 --docAction23--> docState3,
docState3 --docAction31--> docState1,
docState3 --docAction34--> docState4,
docState4 --docAction41--> docState1,
]
Access Contexts : [
accCtx1, accCtx2 // 主要是为了用户-角色-权限用的
]
Workflow : {
Name : wFlow1, //一个doctype只能对应一个workflow
Initial State : docState1 //一个流程的初始状态
}
Nodes : [
node1: {
Document Type : docType1,
Workflow : wFlow1,
Node Type : NodeTypeBegin, // 开始节点 note this
From State : docState1,
Access Context : accCtx1,
},
node2: {
Document Type : docType1,
Workflow : wFlow1,
Node Type : NodeTypeLinear, // 中间节点可以是线性的,也可以是平行的 note this
From State : docState2,
Access Context : accCtx2, // a different context
},
node3: {
Document Type : docType1,
Workflow : wFlow1,
Node Type : NodeTypeEnd, // note this
From State : docState3,
Access Context : accCtx1,
},
]
以上都是系统管理员设置的部分,当一个用户使用这个系统的时候,他在某个板块(doctype分类)新建(上传)一个文档document,系统自动根据这个分类,设置了文档的初始state,在这个state下,一般只有一个动作可选,就是传递给下一个状态的操作,还要选接受的人或组(也可以系统固定),还可以写上注释、说明,最后点击按钮提交apply;系统要做的,记录下来谁在什么时间操作了,把信息message发送给对应的用户的信箱mailbox,当对应的用户登录系统的时候,可以查看message。 当用户点击信箱里某个信息,转到对应的文档详情detail上,能看到这个文档以往(历史)操作记录时间线,可以对这个文档进行操作:选择动作action,选择接受的组,提交apply。