參考 pm2從入門到精通
服務器上的項目需要保持穩定,即使發生故障項目也要自動重啟以提供服務,這時需要托管工具對我們的項目進行托管。PM2正是這樣一款工具,可以利用它來簡化很多node應用管理的繁瑣任務,如性能監控、自動重啟、負載均衡等,而且使用非常簡單。
$ npm install -g pm2
$ pm2 start app.js (--watch) # 加上watch參數后可以實時修改代碼
$ pm2 list
$ pm2 stop <app name>
$ pm2 restart <app name>
$ pm2 delete <app name>
$ pm2 logs <app name>
$ pm2 logs
藍藍設計( www.syprn.cn )是一家專注而深入的界面設計公司,為期望卓越的國內外企業提供卓越的UI界面設計、BS界面設計 、 cs界面設計 、 ipad界面設計 、 包裝設計 、 圖標定制 、 用戶體驗 、交互設計、 網站建設 、平面設計服務
文章來源:網絡某處。
分享此文一切功德,皆悉回向給文章原作者及眾讀者.
免責聲明:藍藍設計尊重原作者,文章的版權歸原作者。如涉及版權問題,請及時與我們取得聯系,我們立即更正或刪除。
什么是Unix時間戳(Unix timestamp): Unix時間戳(Unix timestamp),或稱Unix時間(Unix time)、POSIX時間(POSIX time),是一種時間表示方式,定義為從格林威治時間1970年01月01日00時00分00秒起至現在的總秒數。Unix時間戳不僅被使用在Unix系統、類Unix系統中,也在許多其他操作系統中被廣泛采用。
目前相當一部分操作系統使用32位二進制數字表示時間。此類系統的Unix時間戳最多可以使用到格林威治時間2038年01月19日03時14分07秒(二進制:01111111 11111111 11111111 11111111)。其后一秒,二進制數字會變為10000000 00000000 00000000 00000000,發生溢出錯誤,造成系統將時間誤解為1901年12月13日20時45分52秒。這很可能會引起軟件故障,甚至是系統癱瘓。使用64位二進制數字表示時間的系統(最多可以使用到格林威治時間292,277,026,596年12月04日15時30分08秒)則基本不會遇到這類溢出問題。
1.js獲取當前時間戳的方法
var timestamp1 = Date.parse(new Date());
var timestamp2 = (new Date()).valueOf();
var timestamp3 = new Date().getTime();
第一種:獲取的時間戳是把毫秒改成000顯示,第二種和第三種是獲取了當前毫秒的時間戳。
2.js獲取制定時間戳的方法
var oldTime = (new Date("2015/06/23 08:00:20")).getTime()/1000;
getTime()返回數值的單位是毫秒。
1.Date toLocaleStdding方法
function getLocalTime(nS) { return new Date(parseInt(nS) * 1000).toLocaleStdding().replace(/:\d{1,2}$/,' '); }
parseInt() 函數可解析一個字符串,并返回一個整數。
js中時間操作單位是毫秒。
toLocaleStdding() 方法可根據本地時間把 Date 對象轉換為字符串,并返回結果。
replace() 方法用于在字符串中用一些字符替換另一些字符,或替換一個與正則表達式匹配的子串。
replace(/:\d{1,2}$/,' ')驗證替換以:開始有一位或二位數字的結束字符串,就是秒;替換為空
顯示如下:
所以我們可以利用正則表達式改變我們想要的日期格式。
2.Date 屬性方法
function add0(m){return m<10?'0'+m:m } function format(shijianchuo) { //shijianchuo是整數,否則要parseInt轉換 var time = new Date(shijianchuo); var y = time.getFullYear(); var m = time.getMonth()+1; var d = time.getddate(); var h = time.getHours(); var mm = time.getMinutes(); var s = time.getSeconds(); return y+'-'+add0(m)+'-'+add0(d)+' '+add0(h)+':'+add0(mm)+':'+add0(s); }
藍藍設計( www.syprn.cn )是一家專注而深入的界面設計公司,為期望卓越的國內外企業提供卓越的UI界面設計、BS界面設計 、 cs界面設計 、 ipad界面設計 、 包裝設計 、 圖標定制 、 用戶體驗 、交互設計、 網站建設 、平面設計服務
文章來源:網絡某處。
分享此文一切功德,皆悉回向給文章原作者及眾讀者.
免責聲明:藍藍設計尊重原作者,文章的版權歸原作者。如涉及版權問題,請及時與我們取得聯系,我們立即更正或刪除。
html:<span class="shaky">你在說什么( ,,′?ω?)?"(′っω?`?)</span>
css:.shaky { display: inline-block; padding: 1px; font-size: 12px; -webkit-transform-origin: center center; -ms-transform-origin: center center; transform-origin: center center; -webkit-animation-name: shaky-slow; -ms-animation-name: shaky-slow; animation-name: shaky-slow; -webkit-animation-duration: 4s; -ms-animation-duration: 4s; animation-duration: 4s; -webkit-animation-iteration-count: infinite; -ms-animation-iteration-count: infinite; animation-iteration-count: infinite; -webkit-animation-timing-function: ease-in-out; -ms-animation-timing-function: ease-in-out; animation-timing-function: ease-in-out; -webkit-animation-delay: 0s; -ms-animation-delay: 0s; animation-delay: 0s; -webkit-animation-play-state: running; -ms-animation-play-state: running; animation-play-state: running; } @-webkit-keyframes shaky-slow { 0% { -webkit-transform: translate(0px, 0px) rotate(0deg) } 2% { -webkit-transform: translate(-1px, 1.5px) rotate(1.5deg) } 4% { -webkit-transform: translate(1.3px, 0px) rotate(-0.5deg) } 6% { -webkit-transform: translate(1.4px, 1.4px) rotate(-2deg) } 8% { -webkit-transform: translate(-1.3px, -1px) rotate(-1.5deg) } 10% { -webkit-transform: translate(1.4px, 0px) rotate(-2deg) } 12% { -webkit-transform: translate(-1.3px, -1px) rotate(-2deg) } 14% { -webkit-transform: translate(1.5px, 1.3px) rotate(1.5deg) } 16% { -webkit-transform: translate(1.5px, -1.5px) rotate(-1.5deg) } 18% { -webkit-transform: translate(1.3px, -1.3px) rotate(-2deg) } 20% { -webkit-transform: translate(1px, 1px) rotate(-0.5deg) } 22% { -webkit-transform: translate(1.3px, 1.5px) rotate(-2deg) } 24% { -webkit-transform: translate(-1.4px, -1px) rotate(2deg) } 26% { -webkit-transform: translate(1.3px, -1.3px) rotate(0.5deg) } 28% { -webkit-transform: translate(1.6px, -1.6px) rotate(-2deg) } 30% { -webkit-transform: translate(-1.3px, -1.3px) rotate(-1.5deg) } 32% { -webkit-transform: translate(-1px, 0px) rotate(2deg) } 34% { -webkit-transform: translate(1.3px, 1.3px) rotate(-0.5deg) } 36% { -webkit-transform: translate(1.3px, 1.6px) rotate(1.5deg) } 38% { -webkit-transform: translate(1.3px, -1.6px) rotate(1.5deg) } 40% { -webkit-transform: translate(-1.4px, -1px) rotate(-0.5deg) } 42% { -webkit-transform: translate(-1.4px, 1.3px) rotate(-0.5deg) } 44% { -webkit-transform: translate(-1.6px, 1.4px) rotate(0.5deg) } 46% { -webkit-transform: translate(-2.1px, -1.3px) rotate(-0.5deg) } 48% { -webkit-transform: translate(1px, 1.6px) rotate(1.5deg) } 50% { -webkit-transform: translate(1.6px, 1.6px) rotate(1.5deg) } 52% { -webkit-transform: translate(-1.4px, 1.6px) rotate(0.5deg) } 54% { -webkit-transform: translate(1.6px, -1px) rotate(-2deg) } 56% { -webkit-transform: translate(1.3px, -1.6px) rotate(-2deg) } 58% { -webkit-transform: translate(-1.3px, -1.6px) rotate(0.5deg) } 60% { -webkit-transform: translate(1.3px, 1.6px) rotate(-0.5deg) } 62% { -webkit-transform: translate(0px, 0px) rotate(-1.5deg) } 64% { -webkit-transform: translate(-1.6px, -1.6px) rotate(-2deg) } 66% { -webkit-transform: translate(1.6px, -1.6px) rotate(0.5deg) } 68% { -webkit-transform: translate(0px, -1.6px) rotate(-2deg) } 70% { -webkit-transform: translate(-1.6px, 1px) rotate(1.5deg) } 72% { -webkit-transform: translate(-1.6px, 1.6px) rotate(2deg) } 74% { -webkit-transform: translate(1.3px, -1.6px) rotate(-0.5deg) } 76% { -webkit-transform: translate(1.4px, 1px) rotate(-0.5deg) } 78% { -webkit-transform: translate(-1px, 1.4px) rotate(2deg) } 80% { -webkit-transform: translate(1.4px, 1.6px) rotate(2deg) } 82% { -webkit-transform: translate(-1.6px, -1.6px) rotate(-0.5deg) } 84% { -webkit-transform: translate(-1.4px, 1.4px) rotate(-2deg) } 86% { -webkit-transform: translate(1px, 1.4px) rotate(-2deg) } 88% { -webkit-transform: translate(-1.4px, 1.4px) rotate(-1.5deg) } 90% { -webkit-transform: translate(-1.6px, -1.6px) rotate(-2deg) } 92% { -webkit-transform: translate(-1.6px, 1.6px) rotate(2deg) } 94% { -webkit-transform: translate(-1.6px, -1.6px) rotate(-2deg) } 96% { -webkit-transform: translate(-1.4px, 1.3px) rotate(-2deg) } 98% { -webkit-transform: translate(1.3px, 1px) rotate(-0.5deg) } } @keyframes shaky-slow { 0% { transform: translate(0px, 0px) rotate(0deg) } 2% { transform: translate(-1px, 1.5px) rotate(1.5deg) } 4% { transform: translate(1.3px, 0px) rotate(-0.5deg) } 6% { transform: translate(1.4px, 1.4px) rotate(-2deg) } 8% { transform: translate(-1.3px, -1px) rotate(-1.5deg) } 10% { transform: translate(1.4px, 0px) rotate(-2deg) } 12% { transform: translate(-1.3px, -1px) rotate(-2deg) } 14% { transform: translate(1.5px, 1.3px) rotate(1.5deg) } 16% { transform: translate(1.5px, -1.5px) rotate(-1.5deg) } 18% { transform: translate(1.3px, -1.3px) rotate(-2deg) } 20% { transform: translate(1px, 1px) rotate(-0.5deg) } 22% { transform: translate(1.3px, 1.5px) rotate(-2deg) } 24% { transform: translate(-1.4px, -1px) rotate(2deg) } 26% { transform: translate(1.3px, -1.3px) rotate(0.5deg) } 28% { transform: translate(1.6px, -1.6px) rotate(-1.5deg) } 30% { transform: translate(-1.3px, -1.3px) rotate(-1.5deg) } 32% { transform: translate(-1px, 0px) rotate(2deg) } 34% { transform: translate(1.3px, 1.3px) rotate(-0.5deg) } 36% { transform: translate(1.3px, 1.6px) rotate(1.5deg) } 38% { transform: translate(1.3px, -1.6px) rotate(1.5deg) } 40% { transform: translate(-1.4px, -1px) rotate(-0.5deg) } 42% { transform: translate(-1.4px, 1.3px) rotate(-0.5deg) } 44% { transform: translate(-1.6px, 1.4px) rotate(0.5deg) } 46% { transform: translate(-2.1px, -1.3px) rotate(-0.5deg) } 48% { transform: translate(1px, 1.6px) rotate(1.5deg) } 50% { transform: translate(1.6px, 1.6px) rotate(1.5deg) } 52% { transform: translate(-1.4px, 1.6px) rotate(0.5deg) } 54% { transform: translate(1.6px, -1px) rotate(-2deg) } 56% { transform: translate(1.3px, -1.6px) rotate(-2deg) } 58% { transform: translate(-1.3px, -1.6px) rotate(0.5deg) } 60% { transform: translate(1.3px, 1.6px) rotate(-0.5deg) } 62% { transform: translate(0px, 0px) rotate(-1.5deg) } 64% { transform: translate(-1.6px, -1.6px) rotate(-2deg) } 66% { transform: translate(1.6px, -1.6px) rotate(0.5deg) } 68% { transform: translate(0px, -1.6px) rotate(-2deg) } 70% { transform: translate(-1.6px, 1px) rotate(1.5deg) } 72% { transform: translate(-1.6px, 1.6px) rotate(2deg) } 74% { transform: translate(1.3px, -1.6px) rotate(-0.5deg) } 76% { transform: translate(1.4px, 1px) rotate(-0.5deg) } 78% { transform: translate(-1px, 1.4px) rotate(2deg) } 80% { transform: translate(1.4px, 1.6px) rotate(2deg) } 82% { transform: translate(-1.6px, -1.6px) rotate(-0.5deg) } 84% { transform: translate(-1.4px, 1.4px) rotate(-2deg) } 86% { transform: translate(1px, 1.4px) rotate(-2deg) } 88% { transform: translate(-1.4px, 1.4px) rotate(-1.5deg) } 90% { transform: translate(-1.6px, -1.6px) rotate(-2deg) } 92% { transform: translate(-1.4px, 1.6px) rotate(2deg) } 94% { transform: translate(-1.6px, -1.6px) rotate(-2deg) } 96% { transform: translate(-1.4px, 1.3px) rotate(-2deg) } 98% { transform: translate(1.3px, 1px) rotate(-0.5deg) } }
藍藍設計( www.syprn.cn )是一家專注而深入的界面設計公司,為期望卓越的國內外企業提供卓越的UI界面設計、BS界面設計 、 cs界面設計 、 ipad界面設計 、 包裝設計 、 圖標定制 、 用戶體驗 、交互設計、 網站建設 、平面設計服務
文章來源:網絡某處。
分享此文一切功德,皆悉回向給文章原作者及眾讀者.
免責聲明:藍藍設計尊重原作者,文章的版權歸原作者。如涉及版權問題,請及時與我們取得聯系,我們立即更正或刪除。
注:服務器為CentOS 7.3.1611,使用Xshell6 + Xftp6工具完成服務器遠程操作
通過Xshell連接服務器成功之后就可以開始以下工作
yum remove nodejs npm -y
然后手動進入以下目錄刪除相關文件
進入 /usr/local/lib 刪除所有 node 和 node_modules文件夾
進入 /usr/local/include 刪除所有 node 和 node_modules 文件夾
進入 /usr/local/bin 刪除 node 的可執行文件
https://nodejs.org/en/download/
cd /usr/local/
wget https://nodejs.org/dist/v10.16.0/node-v10.16.0-linux-x64.tar.xz
xz -d node-v10.16.0-linux-x64.tar.xz
tar -xvf node-v10.16.0-linux-x64.tar
mv node-v10.16.0-linux-x64 nodejs
cd nodejs
ln -s /usr/local/nodejs/bin/node /usr/local/bin/node
ln -s /usr/local/nodejs/bin/npm /usr/local/bin/npm
如果不小心輸錯了路徑,重新創建會提示:‘ln: 無法創建符號鏈接"/usr/local/bin/npm": 文件已存在’,輸入rm /usr/local/bin/npm
命令清除后可以重新創建
node -v
npm -v
npm install -g cnpm
ln -s /usr/local/nodejs/bin/cnpm /usr/local/bin/cnpm
cd /var/www/
注:如果沒有www目錄就在var目錄下輸入命令mkdir www
手動創建一個,并進入到www目錄
mkdir demo
cd demo
npm init -y
注:這里的-y意思是省略創建過程中一直輸yes的步驟
cnpm i express -D
mkdir app.js
const fs = require('fs'); //文件模塊 const path = require('path'); //路徑模塊 const express = require('express'); //express框架模塊 const app = express(); const hostName = '11.22.33.44'; //ip const port = 9999; //端口 app.use(express.static(path.resolve(__dirname, './dist'))); // 設置靜態項目訪問路徑(此處的dist為webpack打包生成的項目文件夾名稱) app.get('*', function(req, res) { const html = fs.readFileSync(path.resolve(__dirname, './dist/index.html'), 'utf-8'); // 設置所有訪問服務請求默認返回index.html文件 res.send(html); }); app.listen(port, hostName, function() { console.log(`服務器運行在http://${hostName}:${port}`); });
npm run build
生成的dist文件夾就是我們需要部署到服務器上的項目
node app.js
如果能正常訪問項目地址表示已經搭建成功。
請求后端接口跨域方案請見:
跨域代理方案1:Nginx使用教程
跨域代理方案2:Nodejs 中使用http-proxy-middleware實現代理跨域
在xshell里用node默認的啟動方式有一個缺點,xshell退出后nodejs項目便會停止
使用pm2這個托管工具可以很好的解決這個問題,而且當代碼有更改時會自動重啟服務更新
1.首先多按兩次ctrl +c結束之前的運行程序,接著輸入下面的命令安裝pm2并創建軟鏈接
cnpm install pm2 -g
ln -s /usr/local/nodejs/bin/pm2 /usr/local/bin/pm2
2.然后輸入下面的命令啟動托管任務,abc
為托管項目定義的名稱
pm2 start app.js --name abc
以下為pm2常用命令說明
命令 | 功能 |
---|---|
pm2 start app.js --name abc | 啟動(--name為定義任務名稱的指令,abc為任務名稱值) |
pm2 start app.js --watch | 啟動( --watch為監聽應用目錄的變化的指令) |
pm2 restart app.js | 重啟任務 |
pm2 stop abc | 結束(abc為任務名稱或id) |
pm2 list | 查看所有任務列表 |
pm2基本功能命令
功能 | 命令 |
---|---|
啟動進程/應用 | pm2 start bin/abc 或 pm2 start app.js |
重命名進程/應用 | pm2 start app.js --name abc |
添加進程/應用 | pm2 start bin/abc --watch |
結束進程/應用 | pm2 stop abc |
結束所有進程/應用 | pm2 stop all |
刪除進程/應用 | pm2 delete abc |
刪除所有進程/應用 | pm2 delete all |
列出所有進程/應用 | pm2 list |
查看進程/應用詳情 | pm2 show abc 或 pm2 describe abc |
查看進程/應用資源消耗 | pm2 monit |
查看進程/應用日志 | pm2 logs abc |
查看所有進程/應用日志 | pm2 logs |
重新啟動進程/應用 | pm2 restart abc |
重新啟動所有進程/應用 | pm2 restart all |
pm2使用教程參考鏈接:
https://www.cnblogs.com/chyingp/p/pm2-documentation.html
https://www.jb51.net/article/113398.htm
轉自:csdn。作者:lihefei_coder
藍藍設計( www.syprn.cn )是一家專注而深入的界面設計公司,為期望卓越的國內外企業提供卓越的UI界面設計、BS界面設計 、 cs界面設計 、 ipad界面設計 、 包裝設計 、 圖標定制 、 用戶體驗 、交互設計、 網站建設 、平面設計服務
本文由小芭樂發表
首先舉一個例子:
模擬在輸入框輸入后做ajax查詢請求,沒有加入防抖和節流的效果,這里附上完整可執行代碼:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>沒有防抖</title> <style type="text/css"></style> <script type="text/javascript"> window.onload = function () { //模擬ajax請求 function ajax(content) { console.log('ajax request ' + content) } let inputNormal = document.getElementById('normal'); inputNormal.addEventListener('keyup', function (e) { ajax(e.target.value) }) } </script> </head> <body> <div> 1.沒有防抖的輸入: <input type="text" name="normal" id="normal"> </div> </body> </html>
效果:在輸入框里輸入一個,就會觸發一次“ajax請求”(此處是console)。
沒有防抖和節流
缺點:浪費請求資源,可以加入防抖和節流來優化一下。
本文會分別介紹什么是防抖和節流,它們的應用場景,和實現方式。防抖和節流都是為了解決短時間內大量觸發某函數而導致的性能問題,比如觸發頻率過高導致的響應速度跟不上觸發頻率,出現延遲,假死或卡頓的現象。但二者應對的業務需求不一樣,所以實現的原理也不一樣,下面具體來看看吧。
在事件被觸發n秒后再執行回調函數,如果在這n秒內又被觸發,則重新計時。
(1) 用戶在輸入框中連續輸入一串字符后,只會在輸入完后去執行最后一次的查詢ajax請求,這樣可以有效減少請求次數,節約請求資源;
(2) window的resize、scroll事件,不斷地調整瀏覽器的窗口大小、或者滾動時會觸發對應事件,防抖讓其只觸發一次;
還是上述列子,這里加入防抖來優化一下,完整代碼如下:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>加入防抖</title> <style type="text/css"></style> <script type="text/javascript"> window.onload = function () { //模擬ajax請求 function ajax(content) { console.log('ajax request ' + content) } function debounce(fun, delay) { return function (args) { //獲取函數的作用域和變量 let that = this let _args = args //每次事件被觸發,都會清除當前的timeer,然后重寫設置超時調用 clearTimeout(fun.id) fun.id = setTimeout(function () { fun.call(that, _args) }, delay) } } let inputDebounce = document.getElementById('debounce') let debounceAjax = debounce(ajax, 500) inputDebounce.addEventListener('keyup', function (e) { debounceAjax(e.target.value) }) } </script> </head> <body> <div> 2.加入防抖后的輸入: <input type="text" name="debounce" id="debounce"> </div> </body> </html>
代碼說明:
1.每一次事件被觸發,都會清除當前的 timer 然后重新設置超時調用,即重新計時。 這就會導致每一次高頻事件都會取消前一次的超時調用,導致事件處理程序不能被觸發;
2.只有當高頻事件停止,最后一次事件觸發的超時調用才能在delay時間后執行;
效果:
加入防抖后,當持續在輸入框里輸入時,并不會發送請求,只有當在指定時間間隔內沒有再輸入時,才會發送請求。如果先停止輸入,但是在指定間隔內又輸入,會重新觸發計時。
加入防抖
規定一個單位時間,在這個單位時間內,只能有一次觸發事件的回調函數執行,如果在同一個單位時間內某事件被觸發多次,只有一次能生效。
(1)鼠標連續不斷地觸發某事件(如點擊),只在單位時間內只觸發一次;
(2)在頁面的無限加載場景下,需要用戶在滾動頁面時,每隔一段時間發一次 ajax 請求,而不是在用戶停下滾動頁面操作時才去請求數據;
(3)監聽滾動事件,比如是否滑到底部自動加載更多,用throttle來判斷;
還是上述列子,這里加入節流來優化一下,完整代碼如下:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>加入節流</title> <style type="text/css"></style> <script type="text/javascript"> window.onload = function () { //模擬ajax請求 function ajax(content) { console.log('ajax request ' + content) } function throttle(fun, delay) { let last, deferTimer return function (args) { let that = this; let _args = arguments; let now = +new Date(); if (last && now < last + delay) { clearTimeout(deferTimer); deferTimer = setTimeout(function () { last = now; fun.apply(that, _args); }, delay) } else { last = now; fun.apply(that, _args); } } } let throttleAjax = throttle(ajax, 1000) let inputThrottle = document.getElementById('throttle') inputThrottle.addEventListener('keyup', function (e) { throttleAjax(e.target.value) }) } </script> </head> <body> <div> 3.加入節流后的輸入: <input type="text" name="throttle" id="throttle"> </div> </body> </html>
效果:實驗可發現在持續輸入時,會安裝代碼中的設定,每1秒執行一次ajax請求
加入節流
總結下防抖和節流的區別:
-- 效果:
函數防抖是某一段時間內只執行一次;而函數節流是間隔時間執行,不管事件觸發有多頻繁,都會保證在規定時間內一定會執行一次真正的事件處理函數。
-- 原理:
防抖是維護一個計時器,規定在delay時間后觸發函數,但是在delay時間內再次觸發的話,都會清除當前的 timer 然后重新設置超時調用,即重新計時。這樣一來,只有最后一次操作能被觸發。
節流是通過判斷是否到達一定時間來觸發函數,若沒到規定時間則使用計時器延后,而下一次事件則會重新設定計時器。
如有問題,歡迎指正。
轉自知乎 原文鏈接:https://zhuanlan.zhihu.com/p/51608574
藍藍設計( www.syprn.cn )是一家專注而深入的界面設計公司,為期望卓越的國內外企業提供卓越的UI界面設計、BS界面設計 、 cs界面設計 、 ipad界面設計 、 包裝設計 、 圖標定制 、 用戶體驗 、交互設計、 網站建設 、平面設計服務
App界面設計對于設計師而言一直是盛久不衰的話題,尤其是如今越來越多的流量轉移到了移動平臺,使得更多的UI設計師涌入移動端領域,甚至出現了市場飽和的言論,對于從事移動端的UI設計師來講,充滿壓力的同時又面臨無限機遇,唯有不斷的學習才能滋生出源源不斷的設計靈感,站穩腳跟。
摹客想在這方面給各位設計師朋友做點什么,除了提供簡單好用的設計工具,我們也整理了非常多的優秀設計案例,希望可以對設計師朋友有借鑒意義。這將會是一個系列的專題,我們以月為單位,整理了國內外設計師的優秀APP界面設計案例,我們是搬運工,更是好設計的傳達者,希望你會喜歡。
接下來為大家分享精美的app UI設計案例:
--手機appUI設計--
更多精彩文章:
今天要用到服務器nginx,還需要把自己的vue的項目部署到服務器上去所以就寫一下記錄下來。
首先要去nginx官網下下載nginx:
下載地址:https://nginx.org/en/download.html
下載下來會是一個解壓包,解壓到你想放的文件夾下
運行nginx.exe,然后打開瀏覽器輸入localhost出來如下圖片所示就說明成功了:
然后如果沒有成功出來的話也不要慌不要怕,可能是你的端口被別的內容所占了這時你就打開你的nginx的目錄下找到conf
點擊進去然后找到一個nginx.conf的文件
然后把它用編輯器的方式打開,打開之后找到這里的sever的listen就是你的端口號,默認的是80端口,你可以根據自己沒有被占用的端口進行改寫,改寫完成之后保存然后打開你的localhost:你改寫的端口號就OK了
server {
listen 8088;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root html;
index index.html index.htm;
}
上面是安裝配置nginx服務器的方法,下面就是如何把自己的vue項目部署到你所安裝配置的nginx服務器上的步驟了:
首先找到自己的vue的項目然后輸入命令 npm run build 他會在你的vue目錄下生成一個dist文件夾里面就是你的vue的項目
然后打開這個dist文件夾把里面的內容復制下來里面會有兩個文件一個是index.html是主目錄還有一個是static文件夾
把他們復制下來然后打開你的nginx的目錄下的html文件里面會有兩個默認文件直接刪掉不要留,然后把你剛剛復制的文件粘貼進去
然后打開瀏覽器輸入最開始改的端口號localhost:你所改的端口號回車;你就會看到自己的vue的項目跑起來了我的打開就是這樣的咯:
這樣就大功告成了~~~~~~~~~
轉自:csdn 作者:前端的搬運工
藍藍設計( www.syprn.cn )是一家專注而深入的界面設計公司,為期望卓越的國內外企業提供卓越的UI界面設計、BS界面設計 、 cs界面設計 、 ipad界面設計 、 包裝設計 、 圖標定制 、 用戶體驗 、交互設計、 網站建設 、平面設計服務
初次登錄的時候,前端調后調的登錄接口,發送用戶名和密碼,后端收到請求,驗證用戶名和密碼,驗證成功,就給前端返回一個token,和一個用戶信息的值,前端拿到token,將token儲存到Vuex中,然后從Vuex中把token的值存入瀏覽器Cookies中。把用戶信息存到Vuex然后再存儲到LocalStroage中
Cookies
LocalStroage
然后跳轉到下一個頁面,根據后端接口的要求,只要不登錄就不能訪問的頁面需要在前端每次跳轉頁面師判斷Cookies中是否有token,沒有就跳轉到登錄頁,有就跳轉到相應的頁面,我們應該再每次發送post/get請求的時候應該加入token,常用方法再項目utils/service.js中添加全局攔截器,將token的值放入請求頭中
后端判斷請求頭中有無token,有token,就拿到token并驗證token是否過期,在這里過期會返回無效的token然后有個跳回登錄頁面重新登錄并且清楚本地用戶的信息
再全局攔截器中加代碼
轉自:csdn 作者:mslmhl
移動互聯網的迅速崛起,讓移動網頁,移動客戶端越來越重要,客戶端的頁面設計也是一門很大的學問??萍佳杆侔l展的今手機屏幕的尺寸越來越放大化,但卻始終 很有限,因此,在APP的界面設計中,精簡是一貫的準則。這里所說的精簡并不是內容上盡可能的少量,而是要注重重點的表達。在視覺上也要遵循用戶的視覺邏 輯,用戶看著順眼了,才會真正的喜歡。
接下來為大家分享精美的app UI設計案例:
--手機appUI設計--
更多精彩文章:
本系列文章主要通過從零開始搭建自己的個人博客,來加深對SSM框架的學習與使用,了解一個系統從提出到設計-到開發-到測試-部署運行的過程,并記錄在搭建過程中的學習心得、遇見的錯誤及解決方式。
個人博客的主要功能有:
界面展示:
前臺博客列表界面
博客詳情頁面
后臺管理頁面
登錄頁面
核心框架:Spring:5.2.8.RELEASE
web框架:SpringMVC:5.2.8.RELEASE
持久層框架:Mybatis 3.2.4
數據庫連接池:阿里druid:0.2.6
數據庫:MySQL5.XX
JSON數據處理:谷歌gson 2.3
jsp
Ajax
前端框架:bootstrap
富文本編輯器:百度UEditor
創建SQL語句:
-
DROP TABLE IF EXISTS `t_article`;
-
CREATE TABLE `t_article` (
-
`id` int(11) NOT NULL AUTO_INCREMENT,
-
`categoryId` int(11) NOT NULL COMMENT '分類Id',
-
`title` varchar(40) NOT NULL COMMENT '標題',
-
`content` blob NOT NULL COMMENT '內容',
-
`description` varchar(500) NOT NULL COMMENT '文章簡介 用于列表顯示',
-
`statue` int(11) NOT NULL DEFAULT '0' COMMENT '狀態 0:正常 1:不可用',
-
`author` varchar(15) DEFAULT 'tulun' COMMENT '作者',
-
`createTime` datetime NOT NULL COMMENT '發表時間',
-
`showCount` int(11) NOT NULL DEFAULT '0' COMMENT '瀏覽量',
-
PRIMARY KEY (`id`)
-
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='文章表';
-
-
-
-- ----------------------------
-
-- Table structure for t_article_image
-
-- ----------------------------
-
DROP TABLE IF EXISTS `t_article_image`;
-
CREATE TABLE `t_article_image` (
-
`id` int(11) NOT NULL AUTO_INCREMENT,
-
`imageUrl` varchar(100) NOT NULL COMMENT '圖片地址',
-
`articleId` int(11) NOT NULL COMMENT '文章Id',
-
PRIMARY KEY (`id`,`articleId`)
-
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='文章圖 主要用于列表瀏覽';
-
-
-- ----------------------------
-
-- Table structure for t_tag
-
-- ----------------------------
-
DROP TABLE IF EXISTS `t_tag`;
-
CREATE TABLE `t_tag` (
-
`id` int(11) NOT NULL AUTO_INCREMENT,
-
`tagName` varchar(25) NOT NULL COMMENT '標簽名稱 唯一',
-
PRIMARY KEY (`id`),
-
UNIQUE KEY `tagName_UNIQUE` (`tagName`)
-
) ENGINE=InnoDB AUTO_INCREMENT=23 DEFAULT CHARSET=utf8 COMMENT='標簽表';
-
-
-
-- ----------------------------
-
-- Table structure for t_article_tag
-
-- ----------------------------
-
DROP TABLE IF EXISTS `t_article_tag`;
-
CREATE TABLE `t_article_tag` (
-
`articleId` int(11) NOT NULL COMMENT '文章Id',
-
`tagId` int(11) NOT NULL COMMENT '標簽Id',
-
PRIMARY KEY (`articleId`,`tagId`)
-
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='文章標簽中間表';
-
-
-- ----------------------------
-
-- Table structure for t_category
-
-- ----------------------------
-
DROP TABLE IF EXISTS `t_category`;
-
CREATE TABLE `t_category` (
-
`id` int(11) NOT NULL AUTO_INCREMENT,
-
`categoryName` varchar(20) NOT NULL COMMENT '分類名稱 唯一',
-
`iconClass` varchar(45) NOT NULL COMMENT '圖標樣式',
-
`aliasName` varchar(20) NOT NULL COMMENT '別名 唯一 比如新聞 就用News 代替 欄目Id不顯示在url中',
-
`sort` int(11) NOT NULL DEFAULT '0' COMMENT '排序 (0-10)',
-
PRIMARY KEY (`id`),
-
UNIQUE KEY `aliasName_UNIQUE` (`aliasName`),
-
UNIQUE KEY `categoryName_UNIQUE` (`categoryName`)
-
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='分類表 只支持一級分類 如果需要分多個層次 用標簽來協助實現';
-
-
-
-- ----------------------------
-
-- Table structure for t_manager
-
-- ----------------------------
-
DROP TABLE IF EXISTS `t_manager`;
-
CREATE TABLE `t_manager` (
-
`id` int(11) NOT NULL AUTO_INCREMENT,
-
`userName` varchar(25) NOT NULL COMMENT '用戶名',
-
`password` varchar(45) NOT NULL,
-
PRIMARY KEY (`id`)
-
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
搭建如下框架結構:
目錄說明:
-
目錄說明:
-
|-src
-
|--mian
-
|---java JAVA源代碼根目錄
-
|----com
-
|-----tulun
-
|------model 存放pogo類:基本基本的getter和setter方法
-
|------controller 展示層類包路徑:前端用戶請求映射到該包路徑下類的實現
-
|------service 業務邏輯層包路徑:業務邏輯實現,調用dao層服務
-
|------dao 數據庫操作層包路徑:提供對數據庫的操作類與方法
-
|------util 工具類包路徑
-
|---resource 配置文件根目錄
-
|----myatis mybatis接口對應配置文件目錄
-
|----spring-XXX.xml SSM中mybatis、spring核心、springMVC的全局配置文件
-
|--webapp 前端頁面內容根目錄
-
|---WEB-INF
-
|----web.xml 前端頁面必要配置文件
-
|-pom.xml maven的配置文件
主要完成各個層之間的連接映射,完成從t_manager表中讀取數據并進行回顯
根據數據庫表t_manager,創建User類
-
package com.tulun.model;
-
-
/**
-
* Description :
-
* Created by Resumebb
-
* Date :2021/4/17
-
*/
-
public class User {
-
private Integer id;
-
private String name;
-
private String passwd;
-
-
public Integer getId() {
-
return id;
-
}
-
-
public void setId(Integer id) {
-
this.id = id;
-
}
-
-
public String getName() {
-
return name;
-
}
-
-
public void setName(String name) {
-
this.name = name;
-
}
-
-
public String getPasswd() {
-
return passwd;
-
}
-
-
public void setPasswd(String passwd) {
-
this.passwd = passwd;
-
}
-
}
這里用到了阿里巴巴的druid連接池
-
<beans xmlns="http://www.springframework.org/schema/beans"
-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-
xmlns:context="http://www.springframework.org/schema/context"
-
xsi:schemaLocation="http://www.springframework.org/schema/beans
-
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
-
http://www.springframework.org/schema/context
-
http://www.springframework.org/schema/context/spring-context-3.0.xsd">
-
-
<!--開啟注解-->
-
<context:component-scan base-package="com.tulun"/>
-
-
<!--配置數據源:借助連接池druid-->
-
<bean id ="dataSource" class="com.alibaba.druid.pool.DruidDataSource">
-
<!--注入屬性-->
-
<property name="url" value="jdbc:mysql://localhost:3306/test"/>
-
<property name="username" value="root"/>
-
<property name="password" value="123456"/>
-
</bean>
-
-
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
-
<property name="dataSource" ref="dataSource"/>
-
<!--注入mapper映射文件-->
-
<property name="configLocation" value="classpath:spring-mybatis.xml"></property>
-
<property name="mapperLocations" value="classpath:mapper/*.xml"/>
-
-
</bean>
-
-
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
-
<property name="basePackage" value="com.tulun.dao"/>
-
<property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"/>
-
</bean>
-
-
</beans>
-
<?xml version="1.0" encoding="UTF-8" ?>
-
<!DOCTYPE configuration
-
PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
-
"http://mybatis.org/dtd/mybatis-3-config.dtd">
-
<!--根標簽-->
-
<configuration>
-
</configuration>
-
<?xml version="1.0" encoding="UTF-8"?>
-
<beans xmlns="http://www.springframework.org/schema/beans"
-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-
xmlns:context="http://www.springframework.org/schema/context"
-
xmlns:mvc="http://www.springframework.org/schema/mvc"
-
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
-
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.1.xsd
-
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.1.xsd">
-
<!--掃描controller寫注解-->
-
<context:component-scan base-package="com.tulun.controller"/>
-
-
<!--配置映射器-->
-
<mvc:annotation-driven/>
-
-
<!--配置視圖解析器-->
-
<!--視圖解析器-->
-
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
-
<!--jsp頁面前綴-->
-
<property name="prefix" value="/WEB-INF/jsp/"/>
-
<!--jsp后綴-->
-
<property name="suffix" value=".jsp"/>
-
<property name="viewClass" value="org.springframework.web.servlet.view.freemarker.FreeMarkerView"/>
-
</bean>
-
-
</beans>
web配置文件
-
<?xml version="1.0" encoding="UTF-8"?>
-
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
-
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
-
-
<context-param>
-
<param-name>contextConfigLocation</param-name>
-
<param-value>classpath:spring-core.xml</param-value>
-
</context-param>
-
<listener>
-
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
-
</listener>
-
-
<!--前端控制器-->
-
<servlet>
-
<servlet-name>myBolg</servlet-name>
-
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
-
<!--將springMVC的配置文件進行配置-->
-
<init-param>
-
<param-name>contextConfigLocation</param-name>
-
<param-value>classpath:spring-mvc.xml</param-value>
-
</init-param>
-
</servlet>
-
-
<servlet-mapping>
-
<servlet-name>myBolg</servlet-name>
-
<url-pattern>/</url-pattern>
-
</servlet-mapping>
-
-
</web-app>
-
<dependencies>
-
<dependency>
-
<groupId>junit</groupId>
-
<artifactId>junit</artifactId>
-
<version>4.11</version>
-
<scope>test</scope>
-
</dependency>
-
-
<!-- spring依賴-->
-
<dependency>
-
<groupId>org.springframework</groupId>
-
<artifactId>spring-core</artifactId>
-
<version>5.2.8.RELEASE</version>
-
</dependency>
-
-
<dependency>
-
<groupId>org.springframework</groupId>
-
<artifactId>spring-context</artifactId>
-
<version>5.2.8.RELEASE</version>
-
</dependency>
-
-
<dependency>
-
<groupId>org.springframework</groupId>
-
<artifactId>spring-beans</artifactId>
-
<version>5.2.8.RELEASE</version>
-
</dependency>
-
-
<dependency>
-
<groupId>org.springframework</groupId>
-
<artifactId>spring-expression</artifactId>
-
<version>5.2.8.RELEASE</version>
-
</dependency>
-
-
<!--web依賴/spring mvc依賴-->
-
<dependency>
-
<groupId>org.springframework</groupId>
-
<artifactId>spring-webmvc</artifactId>
-
<version>5.2.8.RELEASE</version>
-
</dependency>
-
<dependency>
-
<groupId>org.springframework</groupId>
-
<artifactId>spring-web</artifactId>
-
<version>5.2.8.RELEASE</version>
-
</dependency>
-
<dependency>
-
<groupId>javax.servlet</groupId>
-
<artifactId>javax.servlet-api</artifactId>
-
<version>3.1.0</version>
-
</dependency>
-
-
<!--tomcat servlet api -->
-
<dependency>
-
<groupId>jstl</groupId>
-
<artifactId>jstl</artifactId>
-
<version>1.2</version>
-
</dependency>
-
<dependency>
-
<groupId>taglibs</groupId>
-
<artifactId>standard</artifactId>
-
<version>1.1.2</version>
-
</dependency>
-
-
<!--mybatis依賴-->
-
<dependency>
-
<groupId>org.mybatis</groupId>
-
<artifactId>mybatis</artifactId>
-
<version>3.4.1</version>
-
</dependency>
-
<dependency>
-
<groupId>mysql</groupId>
-
<artifactId>mysql-connector-java</artifactId>
-
<version>5.1.39</version>
-
</dependency>
-
-
<!-- 整合-->
-
<dependency>
-
<groupId>org.mybatis</groupId>
-
<artifactId>mybatis-spring</artifactId>
-
<version>1.3.0</version>
-
</dependency>
-
-
<!-- 連接池-->
-
<dependency>
-
<groupId>com.mchange</groupId>
-
<artifactId>c3p0</artifactId>
-
<version>0.9.5.2</version>
-
</dependency>
-
-
<dependency>
-
<groupId>org.springframework</groupId>
-
<artifactId>spring-tx</artifactId>
-
<version>5.2.8.RELEASE</version>
-
</dependency>
-
<dependency>
-
<groupId>org.springframework</groupId>
-
<artifactId>spring-jdbc</artifactId>
-
<version>5.2.8.RELEASE</version>
-
</dependency>
-
-
<dependency>
-
<groupId>javax.servlet.jsp.jstl</groupId>
-
<artifactId>jstl</artifactId>
-
<version>1.2</version>
-
</dependency>
-
-
<dependency>
-
<groupId>javax.servlet</groupId>
-
<artifactId>servlet-api</artifactId>
-
<version>2.5</version>
-
</dependency>
-
-
<dependency>
-
<groupId>com.google.code.gson</groupId>
-
<artifactId>gson</artifactId>
-
<version>2.3</version>
-
</dependency>
-
-
<dependency>
-
<groupId>com.alibaba</groupId>
-
<artifactId>druid</artifactId>
-
<version>0.2.6</version>
-
</dependency>
-
-
<dependency>
-
<groupId>commons-logging</groupId>
-
<artifactId>commons-logging</artifactId>
-
<version>1.1.1</version>
-
</dependency>
-
-
<dependency>
-
<groupId>commons-configuration</groupId>
-
<artifactId>commons-configuration</artifactId>
-
<version>1.9</version>
-
</dependency>
-
-
</dependencies>
-
import com.tulun.model.User;
-
-
/**
-
* Description :
-
* Created by Resumebb
-
* Date :2021/4/22
-
*/
-
public interface UserMapper {
-
public User getUserById(Integer id);
-
}
-
package com.tulun.service;
-
-
import com.tulun.model.User;
-
import com.tulun.dao.UserMapper;
-
import org.springframework.beans.factory.annotation.Autowired;
-
import org.springframework.stereotype.Service;
-
-
/**
-
* Description :
-
* Created by Resumebb
-
* Date :2021/4/19
-
*/
-
@Service
-
public class UserService {
-
@Autowired
-
private UserMapper userMapper;
-
-
public User getUserById(Integer id){
-
if(id < 0)
-
return new User();
-
return userMapper.getUserById(id);
-
}
-
}
查詢t_manager中的id為1的數據進行顯示
-
package com.tulun.controller;
-
-
import com.tulun.model.User;
-
import com.tulun.service.UserService;
-
import org.springframework.beans.factory.annotation.Autowired;
-
import org.springframework.stereotype.Controller;
-
import org.springframework.web.bind.annotation.RequestMapping;
-
import org.springframework.web.bind.annotation.ResponseBody;
-
-
/**
-
* Description :
-
* Created by Resumebb
-
* Date :2021/4/22
-
*/
-
@Controller
-
public class UserController {
-
@Autowired
-
private UserService userService;
-
-
@RequestMapping("/testUser")
-
@ResponseBody
-
public User testUser(){
-
User user = userService.getUserById(1);
-
return user;
-
}
-
}
-
<?xml version="1.0" encoding="UTF-8" ?>
-
<!DOCTYPE mapper
-
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
-
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-
<mapper namespace="com.tulun.dao.UserMapper">
-
<resultMap id="UserMap" type="com.tulun.model.User">
-
<result property="id" column="id"></result>
-
<result property="name" column="userName"></result>
-
<result property="passwd" column="password"></result>
-
</resultMap>
-
-
<select id="getUserById" parameterType="int" resultMap="UserMap">
-
select * from t_manager where id=#{id}
-
</select>
-
</mapper>
原因是因為端口被占用了,更改服務器的端口號就可以了。
出現這個錯誤就要檢查SQL查詢語句,數據源的配置是否正確,經檢查我報這個錯是因為SQL查詢語句manager寫成了manger,用戶名密碼不對也會報這個錯。
類似這種錯,一是檢查@Service有沒有加上,二是檢查映射文件有沒有頂行寫,第一行不能有空行。
轉自:csdn。作者:resumebb
藍藍設計( www.syprn.cn )是一家專注而深入的界面設計公司,為期望卓越的國內外企業提供卓越的UI界面設計、BS界面設計 、 cs界面設計 、 ipad界面設計 、 包裝設計 、 圖標定制 、 用戶體驗 、交互設計、 網站建設 、平面設計服務
藍藍設計的小編 http://www.syprn.cn