Skip to content

Commit

Permalink
plugin: add new plugin: ban wechat browser access
Browse files Browse the repository at this point in the history
  • Loading branch information
ntzyz committed Mar 8, 2019
1 parent 16a9349 commit b73712a
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
12 changes: 12 additions & 0 deletions plugins/ban-wechat/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "ban-wechat",
"version": "1.0.0",
"author": {
"name": "ntzyz",
"email": "ntzyz@live.cn"
},
"entry": {
"server": "server/index.js",
"browser": null
}
}
32 changes: 32 additions & 0 deletions plugins/ban-wechat/server/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
const pug = require('pug');
const path = require('path');
const fs = require('fs');
const express = require('express');

const template = `<html>
<head>
<title>抱歉,出错了</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=0">
<link rel="stylesheet" type="text/css" href="https://res.wx.qq.com/open/libs/weui/0.4.1/weui.css">
</head>
<body>
<div class="weui_msg">
<div class="weui_icon_area"><i class="weui_icon_info weui_icon_msg"></i></div>
<div class="weui_text_area">
<h4 class="weui_msg_title">请不要在微信客户端打开链接</h4>
</div>
</div>
</body>
</html>`;

function installer ({ site, utils, config }) {
site.use((req, res, next) => {
if (/MicroMessenger/ig.test(req.headers['user-agent'])) {
return res.send(template);
}
next();
});
}

module.exports = installer;

0 comments on commit b73712a

Please sign in to comment.