作者归档:admin

uniapp扫码

以uuid为例,普通二维可能是直接的UUID值,也可能是小程序后台配置的打开普通链接打开小程序,如 https://yourdomain.com/qr/uuid值

其中uuid值为字符、数字组合。以下为事例代码

onLoad(opt) {
	_this = this
	console.log(opt)
	//传参数 uuid
	let uuid = opt.uuid 
	if(uuid && uuid.indexOf('/') !== -1){
		this.get_parse_qr(uuid)
	}else{
		this.uuid = opt.uuid || ''
	} 
	//扫普通二维码
	if(opt.q){
		this.get_parse_qr(opt.q)
	}   
	//opt.scene 是小程序码
},

methods: {
	get_parse_qr(q){ 
		let domain = this.config.domain;
		let text = decodeURIComponent(q);
		//小程序后台配置了 扫普通链接二维码打开小程序,值如 https://yourdomain.com/qr/
		//4是/qr/的长度
		let result = text.substr(domain.length+4);
		if(result){
			this.uuid = result
		}
	},
}

小程序内扫一扫

removeSpecialCharacters(input) {
	// 使用正则表达式匹配并去除 0x1D 字符
	return input.replace(/\u001d/g, ''); // 或者用 replaceAll 方法
},
open_qr() {
	uni.scanCode({
		scanType:['barCode','qrCode','datamatrix','pdf417'],
		success: function(res) {
			let d = _this.removeSpecialCharacters(res.result)
			console.log("res.charSet==",res.charSet) 
			console.log('条码类型:' + res.scanType);
			console.log('条码内容:' + d);  
		}
	});
},

在线生成普通二维码

文档转pdf

内部GIT代码位置:business/site

支持doc、docx、xls、xlsx、ppt、pptx格式转换成PDF格式。

实际效果很好。

mindoc安装

安装GO

1.访问 https://golang.google.cn/dl/

wget https://golang.google.cn/dl/go1.22.5.linux-amd64.tar.gz

2. 访问 https://golang.google.cn/doc/install

rm -rf /usr/local/go && tar -C /usr/local -xzf go1.22.5.linux-amd64.tar.gz
export PATH=$PATH:/usr/local/go/bin
go version

修改成国内源

go env -w GO111MODULE=on 
go env -w GOPROXY=https://mirrors.aliyun.com/goproxy/,direct 
go env | grep GOPROXY # 查看源信息

mindoc安装源码安装

mkdir /data/
cd /data/
git clone https://github.com/mindoc-org/mindoc.git
cd mindoc
go mod tidy -v
go build -ldflags "-w" -o mindoc main.go
./mindoc install # 执行前,需要修改conf/app.conf文件,配置数据库信息

数据库用mysql,如下

db_adapter="${MINDOC_DB_ADAPTER||mysql}"
db_host="${MINDOC_DB_HOST||127.0.0.1}"
db_port="${MINDOC_DB_PORT||3306}"
db_database="${MINDOC_DB_DATABASE||mindoc}"
db_username="${MINDOC_DB_USERNAME||mindoc}"
db_password="${MINDOC_DB_PASSWORD||111111}"

以上数据请改成真实有值

设置为服务并自启动

vim /etc/systemd/system/mindoc.service

写入

[Unit]
Description=Mindoc
After=network.target

[Service]
Type=simple
User=root
WorkingDirectory=/data/mindoc
ExecStart=/data/mindoc/mindoc
Restart=on-failure

[Install]
WantedBy=multi-user.target

保存并退出

sudo systemctl daemon-reload
sudo systemctl start mindoc
sudo systemctl status mindoc # 显示正常
sudo systemctl enable mindoc # 设为自启动

Nginx配置

location / {
    try_files /_not_exists_ @backend;
} 
location @backend {
    proxy_set_header X-Forwarded-For $remote_addr;
    proxy_set_header Host            $http_host;
    proxy_set_header   X-Forwarded-Proto $scheme; 
    proxy_pass http://127.0.0.1:8181;
}

最后一步

注册软链static目录

ln -s /data/mindoc/static  /www/wwwroot/yourdomain/static 
ln -s /data/mindoc/uploads  /www/wwwroot/yourdomain/uploads 

注意 /www/wwwroot/yourdomain/ 为网站目录

composer加载本地包

"repositories": {
    "thefunpower/flarum-ext-api-login": {
        "type": "path",
        "version": "dev-master", 
        "url": "./packages/api-login"
    }
} 

在require中加入

"thefunpower/flarum-ext-api-login": "dev-master",

drupal 重写

ngnix重写规则

location ~ ^/sites/[^/]+/files/.*\.php$ {
    deny all;
} 
location ~* ^/.well-known/ {
    allow all;
} 
location ~ (^|/)\. {
    return 403;
}

location / { 
    try_files $uri /index.php?$query_string; 
}

location ~ /vendor/.*\.php$ {
    deny all;
    return 404;
}
location ~ ^/sites/.*/files/styles/ {
    try_files $uri /index.php?$query_string;
}

location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg)$ {
    try_files $uri @rewrite;
    expires max;
    log_not_found off;
}

xhprof性能分析

https://pecl.php.net/package/xhprof

需要 xhprof_htmlxhprof_lib 两个文件夹,开启xhprof扩展

开始

if(function_exists('xhprof_enable')){
    xhprof_enable(XHPROF_FLAGS_NO_BUILTINS + XHPROF_FLAGS_CPU + XHPROF_FLAGS_MEMORY); 
}

结束

$xhprof_data = xhprof_disable();   
$xhprof_path =  __DIR__;
include_once $xhprof_path . "/xhprof_lib/utils/xhprof_lib.php";
include_once $xhprof_path . "/xhprof_lib/utils/xhprof_runs.php";
$xhprof_runs = new XHProfRuns_Default();
$n_name = '';
global $g_user_id; 
$n_name = $_SERVER['SERVER_NAME'];
$n_name .= $_SERVER['REQUEST_URI'];
$n_name = str_replace('/','@',$n_name);
$run_id = $xhprof_runs->save_run($xhprof_data, $n_name); 

自助打印-技术文档

计划任务

php think printer:printer_money  
php think printer:printer_pay 

智能证件照接口

http://dev.id-photo-verify.com/doc.html

配置参数

# 制作并检测证件照	
printer_ai_key = 
# 制作并裁剪换正装
printer_ai_change_dress =  

文档转PDF

https://market.aliyun.com/products/56928005/cmapi00044564.html

身份证去除背景

可在后台配置

https://www.textin.com

pip3 install --upgrade pip
yum install -y rh-python38 which
pip3 install backgroundremover 

配置命令行

backgroundremover = /opt/rh/rh-python38/root/usr/local/bin/backgroundremover

默认为 /opt/rh/rh-python38/root/usr/local/bin/backgroundremover

试卷翻新

https://www.textin.com/experience/text_auto_removal

解压zip、7z、gz、tar、bz2包

yum -y install p7zip unar unzip

PDF 依赖

yum install ImageMagick ImageMagick-devel ghostscript pdftk  poppler-utils  perl-Image-ExifTool.noarch 

安装 libreoffice

doc xls ppt转pdf

yum install libreoffice  

GX

yum install python3
如果提示requests模块不存在
pip install --upgrade pip
pip install requests
如果提示secrets模块不存在
pip install python-secrets -i https://pypi.tuna.tsinghua.edu.cn/simple
如果上面的secrets不能安装可尝试
pip install virtualenv
virtualenv myenv
source myenv/bin/activate 
后再执行 
如果报urllib3错误,说明 urllib3与chardet版本不一致,使用以下方式解决
pip uninstall urllib3 chardet 
pip install --upgrade requests