增加根据设备类型的不同返回不同的页面

master
QinZhen 6 years ago
parent cb1f64bec0
commit 9c1ff4b39b

@ -21,7 +21,25 @@ let kit={
})
}
}
app.use('/', express.static(__dirname + '/static'));
app.use('/static', express.static(__dirname + '/static'));
app.get("/",(req,res)=>{
let userAgent=req.headers['user-agent'].toLowerCase();
let bIsIpad = userAgent.match(/ipad/i) == "ipad";
let bIsIphoneOs = userAgent.match(/iphone os/i) == "iphone os";
let bIsMidp = userAgent.match(/midp/i) == "midp";
let bIsUc7 = userAgent.match(/rv:1.2.3.4/i) == "rv:1.2.3.4";
let bIsUc = userAgent.match(/ucweb/i) == "ucweb";
let bIsAndroid = userAgent.match(/android/i) == "android";
let bIsCE = userAgent.match(/windows ce/i) == "windows ce";
let bIsWM = userAgent.match(/windows mobile/i) == "windows mobile";
if (bIsIpad || bIsIphoneOs || bIsMidp || bIsUc7 || bIsUc || bIsAndroid || bIsCE || bIsWM) {
let path=__dirname + '/static/iChat.html';
res.sendFile(path);
} else {
let path=__dirname + '/static/index.html';
res.sendFile(path);
}
})
io.sockets.on('connection', function(socket) {
//创建用户链接
socket.on('login', function(user) {
@ -31,6 +49,7 @@ io.sockets.on('connection', function(socket) {
} else {
socket.user = user;
user.id=socket.id;
user.address=socket.handshake.address;
console.log("登录成功!",user)
socket.emit('loginSuccess',user,users);
users.push(user)
@ -68,6 +87,6 @@ io.sockets.on('connection', function(socket) {
socket.broadcast.to(id).emit('message',socket.user,msg);
});
});
server.listen(3000,function () {
console.log("服务器已启动在3000端口","http://localhost:3000`")
server.listen(3000,function (){
console.log("服务器已启动在3000端口","http://localhost:3000")
});

@ -8,9 +8,9 @@
<meta name="keywords" content="iChatsocketVuenodejs">
<meta name="author" content="cleverqin">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
<link rel="icon" sizes="any" mask href="./images/logo.png">
<link rel="stylesheet" href="./css/font-awesome.min.css">
<link rel="stylesheet" href="./css/iChat.css">
<link rel="icon" sizes="any" mask href="/static/images/logo.png">
<link rel="stylesheet" href="/static/css/font-awesome.min.css">
<link rel="stylesheet" href="/static/css/iChat.css">
</head>
<body>
<div id="bid"></div>
@ -83,7 +83,7 @@
</div>
</div>
<div class="ui-iChat-box" style="display: none" v-show="tab=='chat'">
<audio src="./images/8400.mp3" ref="audio"></audio>
<audio src="/static/images/8400.mp3" ref="audio"></audio>
<div class="ui-iChat-header">
<div class="ui-back fa fa-angle-left " @click="tab='menu'"></div>
{{channel.name}}
@ -139,9 +139,9 @@
<div class="ui-error" v-show="text!=''">{{text}}</div>
</div>
</template>
<script src="./js/vue.min.2.2.0.js"></script>
<script src="./js/vue-resource.js"></script>
<script src="./socket.io/socket.io.js"></script>
<script src="./js/iChat.js"></script>
<script src="/static/js/vue.min.2.2.0.js"></script>
<script src="/static/js/vue-resource.js"></script>
<script src="/socket.io/socket.io.js"></script>
<script src="/static/js/iChat.js"></script>
</body>
</html>

@ -7,16 +7,16 @@
<meta name="description" content="">
<meta name="keywords" content="">
<meta name="author" content="cleverqin">
<link rel="icon" sizes="any" mask href="./images/logo.png">
<link rel="stylesheet" href="./css/font-awesome.min.css">
<link rel="stylesheet" href="./css/webChat.css">
<link rel="icon" sizes="any" mask href="/static/images/logo.png">
<link rel="stylesheet" href="/static/css/font-awesome.min.css">
<link rel="stylesheet" href="/static/css/webChat.css">
</head>
<body>
<div id="webChatBox"></div>
<script id="webChat" type="text/html">
<div id="app" v-cloak>
<div class="ui-webChat-box" v-if="isLogin">
<audio src="./images/8400.mp3" ref="audio"></audio>
<audio src="/static/images/8400.mp3" ref="audio"></audio>
<div class="ui-webChat-menuBox">
<div class="ui-userCard">
<img :src="loginUser.avatarUrl" alt="" :title="loginUser.name">
@ -145,9 +145,9 @@
<div class="im-login-errorBox" v-show="errorMsg!=''">{{errorMsg}}</div>
</div>
</script>
<script src="./js/vue.min.2.2.0.js"></script>
<script src="./js/vue-resource.js"></script>
<script src="./socket.io/socket.io.js"></script>
<script src="./js/index.js"></script>
<script src="/static/js/vue.min.2.2.0.js"></script>
<script src="/static/js/vue-resource.js"></script>
<script src="/socket.io/socket.io.js"></script>
<script src="/static/js/index.js"></script>
</body>
</html>

@ -264,7 +264,7 @@ new Vue({
users:[
{
id:"group",
avatarUrl:"./images/group-icon.png",
avatarUrl:"/static/images/group-icon.png",
name:"聊天室群",
type:"room"
}

@ -271,7 +271,7 @@ new Vue({
users:[
{
id:"group",
avatarUrl:"./images/group-icon.png",
avatarUrl:"/static/images/group-icon.png",
name:"聊天室群",
type:"room"
}

Loading…
Cancel
Save