diff --git a/.angular-cli.json b/.angular-cli.json index b323585..8531a01 100644 --- a/.angular-cli.json +++ b/.angular-cli.json @@ -4,8 +4,8 @@ "name": "wstie" }, "apps": [{ - "root": "side_client", - "outDir": "dist_client", + "root": "app/public", + "outDir": "dist/browser", "assets": [ "assets" ], @@ -16,19 +16,47 @@ "prefix": "app", "styles": [ "styles.less", - "../node_modules/froala-editor/css/froala_editor.pkgd.min.css", - "../node_modules/froala-editor/css/froala_style.min.css" + "../../node_modules/froala-editor/css/froala_editor.pkgd.min.css", + "../../node_modules/froala-editor/css/froala_style.min.css" ], "scripts": [ - "../node_modules/froala-editor/js/froala_editor.pkgd.min.js", - "../node_modules/froala-editor/js/languages/zh_cn.js" + "../../node_modules/froala-editor/js/froala_editor.pkgd.min.js", + "../../node_modules/froala-editor/js/languages/zh_cn.js" ], "environmentSource": "environments/environment.ts", "environments": { "dev": "environments/environment.ts", "prod": "environments/environment.prod.ts" } - }], + }, + { + "platform": "server", + "root": "app/public", + "outDir": "dist/server", + "assets": [ + "assets", + "favicon.ico" + ], + "index": "index.html", + "main": "main.server.ts", + "polyfills": "polyfills.ts", + "tsconfig": "tsconfig.server.json", + "prefix": "app", + "styles": [ + "styles.less", + "../../node_modules/froala-editor/css/froala_editor.pkgd.min.css", + "../../node_modules/froala-editor/css/froala_style.min.css" + ], + "scripts": [ + "../../node_modules/froala-editor/js/froala_editor.pkgd.min.js", + "../../node_modules/froala-editor/js/languages/zh_cn.js" + ], + "environmentSource": "environments/environment.ts", + "environments": { + "dev": "environments/environment.ts", + "prod": "environments/environment.prod.ts" + } + }], "defaults": { "styleExt": "less" } diff --git a/.gitignore b/.gitignore index 9888baf..1d114d8 100644 --- a/.gitignore +++ b/.gitignore @@ -33,3 +33,5 @@ Thumbs.db # Ignore built ts files dist_*/**/* +dist/**/* +devServer/**/* diff --git a/README.md b/README.md index 92a56af..15817f1 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ # 全栈项目 -前端angular 4.3.4 -node 8.0.0 -此项目前后独立,未有同构,ts开发,去webpack化 +前端angular 5 +node 9.6 +同构优化中.... diff --git a/side_server/config/imageUpload.ts b/app/config/imageUpload.ts similarity index 93% rename from side_server/config/imageUpload.ts rename to app/config/imageUpload.ts index 0221357..e5ea00b 100644 --- a/side_server/config/imageUpload.ts +++ b/app/config/imageUpload.ts @@ -1,108 +1,108 @@ -import * as Busboy from 'busboy'; -import * as path from "path"; -import * as fs from "fs"; -import * as sha1 from "sha1"; - -// Gets a filename extension. - let getExtension =(filename)=> { - return filename.split(".").pop(); -} - -// Test if a image is valid based on its extension and mime type. -let isImageValid =(filename, mimetype)=> { - let allowedExts = ["gif", "jpeg", "jpg", "png", "svg", "blob"]; - let allowedMimeTypes = ["image/gif", "image/jpeg", "image/pjpeg", "image/x-png", "image/png", "image/svg+xml"]; - - // Get image extension. - let extension = getExtension(filename); - - return allowedExts.indexOf(extension.toLowerCase()) != -1 && - allowedMimeTypes.indexOf(mimetype) != -1; -} - -export let upload = (req, callback)=>{ - let busboy:any; - // The route on which the image is saved. - var fileRoute = "/uploads/"; - - // Server side file path on which the image is saved. - var saveToPath = null; - - // Flag to tell if a stream had an error. - var hadStreamError = null; - - // Used for sending response. - var link = null; - - // Stream error handler. - let handleStreamError =(error)=>{ - // Do not enter twice in here. - if (hadStreamError) { - return; - } - - hadStreamError = error; - - // Cleanup: delete the saved path. - if (saveToPath) { - return fs.unlink(saveToPath, function(err) { - return callback(error); - }); - } - - return callback(error); - } - - // Instantiate Busboy. - try { - busboy = new Busboy({ headers: req.headers }); - } catch (e) { - return callback(e); - } - - // Handle file arrival. - busboy.on("file", (fieldname, file, filename, encoding, mimetype)=>{ - // Check fieldname: - if ("file" != fieldname) { - // Stop receiving from this stream. - file.resume(); - return callback("Fieldname is not correct. It must be file ."); - } - - // Generate link. - var randomName = sha1(new Date().getTime()) + "." + getExtension(filename); - link = fileRoute + randomName; - - // Generate path where the file will be saved. - var appDir = path.dirname(require.main.filename); - saveToPath = path.join(appDir, link); - - // Pipe reader stream (file from client) into writer stream (file from disk). - file.on("error", handleStreamError); - - // Create stream writer to save to file to disk. - var diskWriterStream = fs.createWriteStream(saveToPath); - diskWriterStream.on("error", handleStreamError); - - // Validate image after it is successfully saved to disk. - diskWriterStream.on("finish", ()=>{ - // Check if image is valid - var status = isImageValid(saveToPath, mimetype); - if (!status) { - return handleStreamError("File does not meet the validation."); - } - - return callback(null, { link: link }); - }); - - // Save image to disk. - file.pipe(diskWriterStream); - }); - - // Handle file upload termination. - busboy.on("error", handleStreamError); - req.on("error", handleStreamError); - - // Pipe reader stream into writer stream. - return req.pipe(busboy); -} +import * as Busboy from 'busboy'; +import * as path from "path"; +import * as fs from "fs"; +import sha1 from "sha1"; + +// Gets a filename extension. + let getExtension =(filename)=> { + return filename.split(".").pop(); +} + +// Test if a image is valid based on its extension and mime type. +let isImageValid =(filename, mimetype)=> { + let allowedExts = ["gif", "jpeg", "jpg", "png", "svg", "blob"]; + let allowedMimeTypes = ["image/gif", "image/jpeg", "image/pjpeg", "image/x-png", "image/png", "image/svg+xml"]; + + // Get image extension. + let extension = getExtension(filename); + + return allowedExts.indexOf(extension.toLowerCase()) != -1 && + allowedMimeTypes.indexOf(mimetype) != -1; +} + +export let upload = (req, callback)=>{ + let busboy:any; + // The route on which the image is saved. + var fileRoute = "/uploads/"; + + // Server side file path on which the image is saved. + var saveToPath = null; + + // Flag to tell if a stream had an error. + var hadStreamError = null; + + // Used for sending response. + var link = null; + + // Stream error handler. + let handleStreamError =(error)=>{ + // Do not enter twice in here. + if (hadStreamError) { + return; + } + + hadStreamError = error; + + // Cleanup: delete the saved path. + if (saveToPath) { + return fs.unlink(saveToPath, function(err) { + return callback(error); + }); + } + + return callback(error); + } + + // Instantiate Busboy. + try { + busboy = new Busboy({ headers: req.headers }); + } catch (e) { + return callback(e); + } + + // Handle file arrival. + busboy.on("file", (fieldname, file, filename, encoding, mimetype)=>{ + // Check fieldname: + if ("file" != fieldname) { + // Stop receiving from this stream. + file.resume(); + return callback("Fieldname is not correct. It must be file ."); + } + + // Generate link. + var randomName = sha1(String(new Date().getTime())) + "." + getExtension(filename); + link = fileRoute + randomName; + + // Generate path where the file will be saved. + var appDir = path.dirname(require.main.filename); + saveToPath = path.join(appDir, link); + + // Pipe reader stream (file from client) into writer stream (file from disk). + file.on("error", handleStreamError); + + // Create stream writer to save to file to disk. + var diskWriterStream = fs.createWriteStream(saveToPath); + diskWriterStream.on("error", handleStreamError); + + // Validate image after it is successfully saved to disk. + diskWriterStream.on("finish", ()=>{ + // Check if image is valid + var status = isImageValid(saveToPath, mimetype); + if (!status) { + return handleStreamError("File does not meet the validation."); + } + + return callback(null, { link: link }); + }); + + // Save image to disk. + file.pipe(diskWriterStream); + }); + + // Handle file upload termination. + busboy.on("error", handleStreamError); + req.on("error", handleStreamError); + + // Pipe reader stream into writer stream. + return req.pipe(busboy); +} diff --git a/side_server/config/passport.ts b/app/config/passport.ts similarity index 97% rename from side_server/config/passport.ts rename to app/config/passport.ts index c647838..c5036dd 100644 --- a/side_server/config/passport.ts +++ b/app/config/passport.ts @@ -1,88 +1,88 @@ -import * as passport from 'passport'; -import {default as User, UserModel } from "./../models/User"; -import * as passportLocal from "passport-local"; -import {Strategy as GitHubStrategy} from 'passport-github2'; -import { WriteError } from "mongodb"; - - - -let LocalStrategy = passportLocal.Strategy; - -passport.serializeUser((user, done) => { - if(user){ - done(undefined, user._id); - } -}); - -passport.deserializeUser((_id, done) => { - User.findById(_id, (err, user) => { - done(err, user); - }); -}); - -passport.use('local.email',new LocalStrategy({ usernameField:'email',passwordField:'password'}, - (email, password, done)=>{ - User.findOne({ email: email.toLowerCase() }, function (err:WriteError, user:UserModel) { - if (err) { return done(err); } - if (!user) { - return done(null, false,{ message: "用户不存在" }); - } - user.comparePassword(password,(err: Error, isMatch: boolean)=> { - if (err) { return done(err); } - if (isMatch) { - return done(null, user); - } - return done(null, false,{ message: "密码不正确" }); - }); - - }); - } - )); - passport.use('local.phone',new LocalStrategy({usernameField:'phone',passwordField:'validateCode' },(phone, validateCode, done)=>{ - User.findOne({ name: phone}).exec((err, user:UserModel)=> { - if (err) { return done(err); } - if (!user) { - return done(null, false,{ message: "用户不存在" }); - } - if(user.verificationCodeToken !=validateCode){ - return done(null, false,{ message: "验证码不正确" }); - } else if(user.verificationCodeExpires.getTime() < new Date().getTime()){ - return done(null, false,{ message: "验证码超时" }); - } else { - return done(null, user); - } - }) - } -)); - - passport.use(new GitHubStrategy({ - clientID: process.env.GITHUB_ID, - clientSecret: process.env.GITHUB_SECRET, - callbackURL: '/auth/github/callback' - }, (accessToken, refreshToken, profile:any, done) => { - User.findOne({ github: profile.id },(err, existingUser)=>{ - if (err) { return done(err); } - if (existingUser) { - done(null,existingUser) - }else { - User.findOne({ email: profile._json.email},(error,existingEmailUser)=>{ - if (err) { return done(err); } - if (existingEmailUser) { - done(err); - } else { - let user:UserModel = new User({ - email:profile._json.email, - github:profile.id - }) as UserModel; - user.tokens.push({ kind: 'github', accessToken }); - user.name = profile.username; - user.avatar = profile._json.avatar_url; - user.save((err) => { - done(err, user); - }); - } - }) - } - }) - })); +import * as passport from 'passport'; +import {default as User, UserModel } from "./../models/User"; +import * as passportLocal from "passport-local"; +import {Strategy as GitHubStrategy} from 'passport-github2'; +import { WriteError } from "mongodb"; + + + +let LocalStrategy = passportLocal.Strategy; + +passport.serializeUser((user, done) => { + if(user){ + done(undefined, user._id); + } +}); + +passport.deserializeUser((_id, done) => { + User.findById(_id, (err, user) => { + done(err, user); + }); +}); + +passport.use('local.email',new LocalStrategy({ usernameField:'email',passwordField:'password'}, + (email, password, done)=>{ + User.findOne({ email: email.toLowerCase() }, function (err:WriteError, user:UserModel) { + if (err) { return done(err); } + if (!user) { + return done(null, false,{ message: "用户不存在" }); + } + user.comparePassword(password,(err: Error, isMatch: boolean)=> { + if (err) { return done(err); } + if (isMatch) { + return done(null, user); + } + return done(null, false,{ message: "密码不正确" }); + }); + + }); + } + )); + passport.use('local.phone',new LocalStrategy({usernameField:'phone',passwordField:'validateCode' },(phone, validateCode, done)=>{ + User.findOne({ name: phone}).exec((err, user:UserModel)=> { + if (err) { return done(err); } + if (!user) { + return done(null, false,{ message: "用户不存在" }); + } + if(user.verificationCodeToken !=validateCode){ + return done(null, false,{ message: "验证码不正确" }); + } else if(user.verificationCodeExpires.getTime() < new Date().getTime()){ + return done(null, false,{ message: "验证码超时" }); + } else { + return done(null, user); + } + }) + } +)); + + passport.use(new GitHubStrategy({ + clientID: process.env.GITHUB_ID, + clientSecret: process.env.GITHUB_SECRET, + callbackURL: '/auth/github/callback' + }, (accessToken, refreshToken, profile:any, done) => { + User.findOne({ github: profile.id },(err, existingUser)=>{ + if (err) { return done(err); } + if (existingUser) { + done(null,existingUser) + }else { + User.findOne({ email: profile._json.email},(error,existingEmailUser)=>{ + if (err) { return done(err); } + if (existingEmailUser) { + done(err); + } else { + let user:UserModel = new User({ + email:profile._json.email, + github:profile.id + }) as UserModel; + user.tokens.push({ kind: 'github', accessToken }); + user.name = profile.username; + user.avatar = profile._json.avatar_url; + user.save((err) => { + done(err, user); + }); + } + }) + } + }) + })); \ No newline at end of file diff --git a/side_server/controllers/api.ts b/app/controllers/api.ts similarity index 95% rename from side_server/controllers/api.ts rename to app/controllers/api.ts index aef4324..f176832 100644 --- a/side_server/controllers/api.ts +++ b/app/controllers/api.ts @@ -1,73 +1,73 @@ -import { Request,Response,NextFunction } from 'express'; -import * as SMSClient from '@alicloud/sms-sdk'; -import { WriteError } from "mongodb"; -import * as _ from 'lodash'; -import * as async from "async"; - -import { default as User, UserModel, AuthToken } from "../models/User"; -import { tranferJson } from './../util/util'; - -import {upload} from '../config/imageUpload'; - -export let postFileUpload = (req:Request,res: Response,next:NextFunction)=>{ - - upload(req, function(err, data) { - if (err) { - return res.status(404).end(JSON.stringify(err)); - } - //res.send({link:`http://${req.headers.host}${data.link}`}); - res.send(data); - }); -} - -export let sendNote = (req:Request,res: Response,next:NextFunction)=>{ - async.waterfall([ - function createRandomToken(done: Function) { - let str = ''; - for(var i=0;i<4;i++){ - str += _.random(0,9,false); - } - done(null, str); - }, - function setRandomToken(token:string,done: Function){ - User.findOne({ name: req.body.phone }, (err, user: any) => { - if (err) { return done(err); } - if (!user) { - res.send(tranferJson({status:0,message:'用户不存在'})); - return; - } - user.verificationCodeToken = token; - user.verificationCodeExpires = Date.now() + 300000; // 5分钟 - user.save((err: WriteError,userInfo:UserModel) => { - if(err) return done(err); - done(err, token, userInfo); - }); - }) - }, - function sendNote(token:string,user:UserModel,done:Function){ - // ACCESS_KEY_ID/ACCESS_KEY_SECRET 根据实际申请的账号信息进行替换 - const accessKeyId = process.env.ALI_ACCESSKEYID - const secretAccessKey = process.env.ALI_SECRETACCESSKEY - //初始化sms_client - let smsClient = new SMSClient({accessKeyId, secretAccessKey}) - //发送短信 - smsClient.sendSMS({ - PhoneNumbers: user.name, - SignName: '吴涛', - TemplateCode: 'SMS_97085004', - TemplateParam: `{"code":"${token}","product":"涛cling"}` - }).then(function (response) { - let {Code}=response; - if (Code === 'OK') { - res.send(tranferJson({status:1,message:'验证码发送成功!'})); - } else { - done(null); - } - }, function (err) { - done(err) - }) - } - ],(err) => { - if (err) { return next(err); } - }) +import { Request,Response,NextFunction } from 'express'; +import {SMSClient} from '@alicloud/sms-sdk'; +import { WriteError } from "mongodb"; +import * as _ from 'lodash'; +import * as async from "async"; + +import { default as User, UserModel, AuthToken } from "../models/User"; +import { tranferJson } from './../util/util'; + +import {upload} from '../config/imageUpload'; + +export let postFileUpload = (req:Request,res: Response,next:NextFunction)=>{ + + upload(req, function(err, data) { + if (err) { + return res.status(404).end(JSON.stringify(err)); + } + //res.send({link:`http://${req.headers.host}${data.link}`}); + res.send(data); + }); +} + +export let sendNote = (req:Request,res: Response,next:NextFunction)=>{ + async.waterfall([ + function createRandomToken(done: Function) { + let str = ''; + for(var i=0;i<4;i++){ + str += _.random(0,9,false); + } + done(null, str); + }, + function setRandomToken(token:string,done: Function){ + User.findOne({ name: req.body.phone }, (err, user: any) => { + if (err) { return done(err); } + if (!user) { + res.send(tranferJson({status:0,message:'用户不存在'})); + return; + } + user.verificationCodeToken = token; + user.verificationCodeExpires = Date.now() + 300000; // 5分钟 + user.save((err: WriteError,userInfo:UserModel) => { + if(err) return done(err); + done(err, token, userInfo); + }); + }) + }, + function sendNote(token:string,user:UserModel,done:Function){ + // ACCESS_KEY_ID/ACCESS_KEY_SECRET 根据实际申请的账号信息进行替换 + const accessKeyId = process.env.ALI_ACCESSKEYID + const secretAccessKey = process.env.ALI_SECRETACCESSKEY + //初始化sms_client + let smsClient = new SMSClient({accessKeyId, secretAccessKey}) + //发送短信 + smsClient.sendSMS({ + PhoneNumbers: user.name, + SignName: '吴涛', + TemplateCode: 'SMS_97085004', + TemplateParam: `{"code":"${token}","product":"涛cling"}` + }).then(function (response) { + let {Code}=response; + if (Code === 'OK') { + res.send(tranferJson({status:1,message:'验证码发送成功!'})); + } else { + done(null); + } + }, function (err) { + done(err) + }) + } + ],(err) => { + if (err) { return next(err); } + }) } \ No newline at end of file diff --git a/side_server/controllers/article.ts b/app/controllers/article.ts similarity index 82% rename from side_server/controllers/article.ts rename to app/controllers/article.ts index 4d6743e..36cf543 100644 --- a/side_server/controllers/article.ts +++ b/app/controllers/article.ts @@ -1,84 +1,101 @@ -import { tranferJson } from './../util/util'; -import { Request,Response,NextFunction } from 'express'; -import {default as Article, ArticleModel} from '../models/Article' -import { WriteError } from "mongodb"; -import '../models/User' -import * as htmlToText from 'html-to-text' - -export let getNote = (req:Request,res: Response) => { - let page = +req.body.page||+req.query.page || 0; - let courent = 10; - let num = page * courent; - - Article.find().sort({time:'desc'}).limit(courent).skip(num).populate('_creator').exec(function(err,articles:ArticleModel[]){ - if(err) return; - let resultJson:any[] = []; - articles.forEach(function(item,index){ - let json:any = { - id:item.id, - title:item.title, - time:item.time, - meta:item.meta - }; - var text = htmlToText.fromString(item.content, { - ignoreImage: true, - ignoreHref: true, - preserveNewlines:true - }); - var reg = /\\n|\s/g; - json.content = text.replace(reg,"").substring(0,140) + '...'; - json.user = { - id:item._creator.id, - name:item._creator.name, - avatar:item._creator.avatar - } - resultJson.push(json) - }); - res.send(tranferJson({status:1},resultJson)); - }); -} - -export let getDetail = (req:Request,res: Response) => { - let id = req.query.id || req.body.id; - Article.findOne({id:id}).populate('_creator').exec(function(err:WriteError,item:ArticleModel){ - if(err) return; - let resultJson; - if(!item){ - resultJson = {}; - } else { - item.meta.look++; - item.save() - resultJson = { - title:item.title, - time:item.time, - meta:item.meta, - content:item.content, - user:{ - id:item._creator.id, - name:item._creator.name, - avatar:item._creator.avatar - } - }; - } - res.send(tranferJson({status:1},resultJson)); - }) -} - -export let publish = (req:Request,res: Response,next:NextFunction)=>{ - let article = new Article({ - title: req.body.title, - content: req.body.editor, - time:Date.now(), - _creator:req.user._id, - meta:{ - look: 0, - favs: 0, - comments: 0 - } - }) - article.save((error:any,note)=>{ - if(error) return next(error); - res.send(tranferJson({status:1,message:'发布成功'})) - }) -} - +import { tranferJson } from './../util/util'; +import { Request,Response,NextFunction } from 'express'; +import {default as Article, ArticleModel} from '../models/Article' +import { WriteError } from "mongodb"; +import '../models/User' +import * as htmlToText from 'html-to-text' + +export let initGetNotes = (req:Request,res: Response,isInit:boolean=false) =>{ + + let page = +req.body.page||+req.query.page || 0; + let courent = 10; + let num = page * courent; + + Article.find().sort({time:'desc'}).limit(courent).skip(num).populate('_creator').exec(function(err,articles:ArticleModel[]){ + if(err) return; + let resultJson:any[] = []; + articles.forEach(function(item,index){ + let json:any = { + id:item.id, + title:item.title, + time:item.time, + meta:item.meta + }; + var text = htmlToText.fromString(item.content, { + ignoreImage: true, + ignoreHref: true, + preserveNewlines:true + }); + var reg = /\\n|\s/g; + json.content = text.replace(reg,"").substring(0,140) + '...'; + json.user = { + id:item._creator.id, + name:item._creator.name, + avatar:item._creator.avatar + } + resultJson.push(json) + }); + if(!isInit){ + res.send(tranferJson({status:1},resultJson)); + } else { + res.render('index', { + req,res, + providers: [{ + provide: 'noteList', + useValue: resultJson + }], + async: true, + preboot: false + }); + } + }); +} + +export let getNote = (req:Request,res: Response,next:NextFunction) => { + initGetNotes(req,res); +} + +export let getDetail = (req:Request,res: Response) => { + let id = req.query.id || req.body.id; + Article.findOne({id:id}).populate('_creator').exec(function(err:WriteError,item:ArticleModel){ + if(err) return; + let resultJson; + if(!item){ + resultJson = {}; + } else { + item.meta.look++; + item.save() + resultJson = { + title:item.title, + time:item.time, + meta:item.meta, + content:item.content, + user:{ + id:item._creator.id, + name:item._creator.name, + avatar:item._creator.avatar + } + }; + } + res.send(tranferJson({status:1},resultJson)); + }) +} + +export let publish = (req:Request,res: Response,next:NextFunction)=>{ + let article = new Article({ + title: req.body.title, + content: req.body.editor, + time:Date.now(), + _creator:req.user._id, + meta:{ + look: 0, + favs: 0, + comments: 0 + } + }) + article.save((error:any,note)=>{ + if(error) return next(error); + res.send(tranferJson({status:1,message:'发布成功'})) + }) +} + diff --git a/side_server/controllers/user.ts b/app/controllers/user.ts similarity index 97% rename from side_server/controllers/user.ts rename to app/controllers/user.ts index f602565..b8745f8 100644 --- a/side_server/controllers/user.ts +++ b/app/controllers/user.ts @@ -1,162 +1,162 @@ -import * as passport from "passport"; -import { LocalStrategyInfo } from "passport-local"; -import { WriteError } from "mongodb"; -import { default as User, UserModel, AuthToken } from "../models/User"; -import { Request, Response, NextFunction } from "express"; -import * as async from "async"; -import * as crypto from "crypto"; -import { tranferJson } from './../util/util'; -import * as nodemailer from 'nodemailer'; - -export let postLogin = (req:Request,res:Response,next:NextFunction)=>{ - passport.authenticate('local.email', function(err:Error, user:UserModel, info:LocalStrategyInfo) { - // if(info.message){ - // res.send(tranferJson({status:0,message:info.message})) - // } - if (err) { return next(err); } - if (!user) { - res.send(tranferJson({status:0,message:info.message})) } - req.logIn(user, function(err) { - if (err) { - return next(err); } - res.send(tranferJson({status:1,message:'登录成功'})) - }); - })(req, res, next); -} -export let postLoginByNote = (req:Request,res:Response,next:NextFunction)=>{ - passport.authenticate('local.phone', function(err:Error, user:UserModel, info:LocalStrategyInfo) { - if (err) { return next(err); } - if (!user) { - res.send(tranferJson({status:0,message:info.message})) - } - req.logIn(user, function(err) { - if (err) { - return next(err); } - res.send(tranferJson({status:1,message:'登录成功'})) - }); - })(req, res, next); -} - -export let postRegister = (req:Request,res:Response,next:NextFunction)=>{ - let user = new User({ - name: req.body.name, - email: req.body.email, - password: req.body.password - }); - User.findOne({ - "$or":[{ - email:req.body.email - },{ - name:req.body.name - }] - },(err:WriteError,resultUser:UserModel)=>{ - if(err) return next(err); - if(resultUser){ - res.send(tranferJson({status:0,message:'用户已存在'})) - } else { - user.save((error:any,personUser)=>{ - if(error) return next(error); - req.logIn(personUser, function(err) { - if (err) { - return next(err); } - res.send(tranferJson({status:1,message:'注册成功'})) - }); - }) - } - }) -} - -export let getUser = (req:Request,res:Response,next:NextFunction)=>{ - if(req.user){ - res.send(tranferJson({status:1},{name:req.user.name,email:req.user.email,avatar:req.user.avatar})); - } else { - res.send(tranferJson({status:0,message:'用户未登陆'})) - } -} - -export let logout = (req:Request,res:Response,next:NextFunction)=>{ - req.logout(); - res.send(tranferJson({status:1,message:'退出成功'})) -} - -export let postForgot = (req: Request, res: Response, next: NextFunction) => { - async.waterfall([ - function createRandomToken(done: Function) { - crypto.randomBytes(16, (err, buf) => { - const token = buf.toString("hex"); - done(err, token); - }); - }, - function setRandomToken(token: AuthToken, done: Function) { - User.findOne({ email: req.body.email }, (err, user: any) => { - if (err) { return done(err); } - if (!user) { - res.send(tranferJson({status:0,message:'用户不存在'})); - return; - } - user.passwordRestToken = token; - user.passwordRestExpires = Date.now() + 3600000; // 1 hour - user.save((err: WriteError,userInfo:UserModel) => { - if(err) return done(err); - done(err, token, user); - }); - }); - }, - function sendForgotPasswordEmail(token: AuthToken, user: UserModel, done: Function) { - const transporter = nodemailer.createTransport({ - service: "qq", - auth: { - user: process.env.SENDGRID_USER, - pass: process.env.SENDGRID_PASSWORD - } - }); - const mailOptions = { - to: user.email, - from: process.env.SENDGRID_USER, - subject: "重置你的cling密码", - text: `点击链接修改密码.\n\n - http://${req.headers.host}/reset/${token}\n\n - 1小时内有效.\n` - }; - transporter.sendMail(mailOptions, (err) => { - if(err) done(err); - res.send(tranferJson({status:1,message:'邮件发送成功!'})) - }); - } - ], (err) => { - if (err) { return next(err); } - res.send(tranferJson({status:0,message:'邮件发送错误'})) - }); - }; - - export let postReset = (req: Request, res: Response, next: NextFunction) => { - async.waterfall([ - function resetPassword(done: Function) { - User - .findOne({ passwordRestToken: req.params.token||req.body.token }) - .where("passwordRestExpires").gt(Date.now()) - .exec((err, user: any) => { - if (err) { return next(err); } - if (!user) { - res.send(tranferJson({status:0,message:'要修改密码的用户不存在'})); - return; - } - user.password = req.body.password; - user.passwordRestToken = undefined; - user.passwordRestExpires = undefined; - user.save((err: WriteError) => { - if (err) { return next(err); } - req.logIn(user, (err) => { - if(err) { - done(err); - }; - res.send(tranferJson({status:1,message:'密码修改成功'})); - }); - }); - }); - } - ], (err) => { - if (err) { return next(err); } - - }); +import * as passport from "passport"; +import { LocalStrategyInfo } from "passport-local"; +import { WriteError } from "mongodb"; +import { default as User, UserModel, AuthToken } from "../models/User"; +import { Request, Response, NextFunction } from "express"; +import * as async from "async"; +import * as crypto from "crypto"; +import { tranferJson } from './../util/util'; +import * as nodemailer from 'nodemailer'; + +export let postLogin = (req:Request,res:Response,next:NextFunction)=>{ + passport.authenticate('local.email', function(err:Error, user:UserModel, info:LocalStrategyInfo) { + // if(info.message){ + // res.send(tranferJson({status:0,message:info.message})) + // } + if (err) { return next(err); } + if (!user) { + res.send(tranferJson({status:0,message:info.message})) } + req.logIn(user, function(err) { + if (err) { + return next(err); } + res.send(tranferJson({status:1,message:'登录成功'})) + }); + })(req, res, next); +} +export let postLoginByNote = (req:Request,res:Response,next:NextFunction)=>{ + passport.authenticate('local.phone', function(err:Error, user:UserModel, info:LocalStrategyInfo) { + if (err) { return next(err); } + if (!user) { + res.send(tranferJson({status:0,message:info.message})) + } + req.logIn(user, function(err) { + if (err) { + return next(err); } + res.send(tranferJson({status:1,message:'登录成功'})) + }); + })(req, res, next); +} + +export let postRegister = (req:Request,res:Response,next:NextFunction)=>{ + let user = new User({ + name: req.body.name, + email: req.body.email, + password: req.body.password + }); + User.findOne({ + "$or":[{ + email:req.body.email + },{ + name:req.body.name + }] + },(err:WriteError,resultUser:UserModel)=>{ + if(err) return next(err); + if(resultUser){ + res.send(tranferJson({status:0,message:'用户已存在'})) + } else { + user.save((error:any,personUser)=>{ + if(error) return next(error); + req.logIn(personUser, function(err) { + if (err) { + return next(err); } + res.send(tranferJson({status:1,message:'注册成功'})) + }); + }) + } + }) +} + +export let getUser = (req:Request,res:Response,next:NextFunction)=>{ + if(req.user){ + res.send(tranferJson({status:1},{name:req.user.name,email:req.user.email,avatar:req.user.avatar})); + } else { + res.send(tranferJson({status:0,message:'用户未登陆'})) + } +} + +export let logout = (req:Request,res:Response,next:NextFunction)=>{ + req.logout(); + res.send(tranferJson({status:1,message:'退出成功'})) +} + +export let postForgot = (req: Request, res: Response, next: NextFunction) => { + async.waterfall([ + function createRandomToken(done: Function) { + crypto.randomBytes(16, (err, buf) => { + const token = buf.toString("hex"); + done(err, token); + }); + }, + function setRandomToken(token: AuthToken, done: Function) { + User.findOne({ email: req.body.email }, (err, user: any) => { + if (err) { return done(err); } + if (!user) { + res.send(tranferJson({status:0,message:'用户不存在'})); + return; + } + user.passwordRestToken = token; + user.passwordRestExpires = Date.now() + 3600000; // 1 hour + user.save((err: WriteError,userInfo:UserModel) => { + if(err) return done(err); + done(err, token, user); + }); + }); + }, + function sendForgotPasswordEmail(token: AuthToken, user: UserModel, done: Function) { + const transporter = nodemailer.createTransport({ + service: "qq", + auth: { + user: process.env.SENDGRID_USER, + pass: process.env.SENDGRID_PASSWORD + } + }); + const mailOptions = { + to: user.email, + from: process.env.SENDGRID_USER, + subject: "重置你的cling密码", + text: `点击链接修改密码.\n\n + http://${req.headers.host}/reset/${token}\n\n + 1小时内有效.\n` + }; + transporter.sendMail(mailOptions, (err) => { + if(err) done(err); + res.send(tranferJson({status:1,message:'邮件发送成功!'})) + }); + } + ], (err) => { + if (err) { return next(err); } + res.send(tranferJson({status:0,message:'邮件发送错误'})) + }); + }; + + export let postReset = (req: Request, res: Response, next: NextFunction) => { + async.waterfall([ + function resetPassword(done: Function) { + User + .findOne({ passwordRestToken: req.params.token||req.body.token }) + .where("passwordRestExpires").gt(Date.now()) + .exec((err, user: any) => { + if (err) { return next(err); } + if (!user) { + res.send(tranferJson({status:0,message:'要修改密码的用户不存在'})); + return; + } + user.password = req.body.password; + user.passwordRestToken = undefined; + user.passwordRestExpires = undefined; + user.save((err: WriteError) => { + if (err) { return next(err); } + req.logIn(user, (err) => { + if(err) { + done(err); + }; + res.send(tranferJson({status:1,message:'密码修改成功'})); + }); + }); + }); + } + ], (err) => { + if (err) { return next(err); } + + }); }; \ No newline at end of file diff --git a/side_server/models/Article.ts b/app/models/Article.ts similarity index 95% rename from side_server/models/Article.ts rename to app/models/Article.ts index 167e9cb..baa1208 100644 --- a/side_server/models/Article.ts +++ b/app/models/Article.ts @@ -1,39 +1,39 @@ -import * as mongoose from 'mongoose'; -var Schema = mongoose.Schema; - - -export type ArticleModel = mongoose.Document & { - id:string, - _creator:any, - title:string, - time: Date, - content:string, - meta: { - look: number, - favs: number, - comments: number, - } -} - - -var articleSchema = new Schema({ - id: { type: String, unique: true }, - _creator: { type: String, ref: 'User' }, - title: String, - time: Date, - content: String, - meta: { - look: Number, - favs: Number, - comments: Number, - } -}); -articleSchema.pre('save',function(next){ - let self = this; - if(!self.id){ - self.id = self._id.toString(); - } - next(); -}) -var Article = mongoose.model('Article', articleSchema); +import * as mongoose from 'mongoose'; +var Schema = mongoose.Schema; + + +export type ArticleModel = mongoose.Document & { + id:string, + _creator:any, + title:string, + time: Date, + content:string, + meta: { + look: number, + favs: number, + comments: number, + } +} + + +var articleSchema = new Schema({ + id: { type: String, unique: true }, + _creator: { type: String, ref: 'User' }, + title: String, + time: Date, + content: String, + meta: { + look: Number, + favs: Number, + comments: Number, + } +}); +articleSchema.pre('save',function(next){ + let self = this; + if(!self.id){ + self.id = self._id.toString(); + } + next(); +}) +var Article = mongoose.model('Article', articleSchema); export default Article; \ No newline at end of file diff --git a/side_server/models/User.ts b/app/models/User.ts similarity index 96% rename from side_server/models/User.ts rename to app/models/User.ts index dbabaaa..ba44933 100644 --- a/side_server/models/User.ts +++ b/app/models/User.ts @@ -1,83 +1,83 @@ -import * as mongoose from 'mongoose'; -// import passport = require("./../config/passport") -import * as crypto from "crypto"; -let Schema = mongoose.Schema; -import * as bcrypt from "bcrypt-nodejs"; - -export type UserModel = mongoose.Document & { - id:string, - email:string, - password:string, - passwordRestToken:string, - passwordRestExpires:Date, - verificationCodeToken:string, - verificationCodeExpires:Date, - github:string, - tokens:AuthToken[], - name: string, - avatar: string, - notes:any[], - compareValidateCode:any, - comparePassword: any, - gravatar:()=>{} -} -export type AuthToken = { - accessToken: string, - kind: string - }; -var userSchema = new Schema({ - id: { type: String, unique: true }, - email:{type:String}, - password:String, - passwordRestToken:String, - passwordRestExpires:Date, - verificationCodeToken:String, - verificationCodeExpires:Date, - github:String, - tokens:Array, - name: String, - avatar: String, - notes: [{ - type: Number, - ref: 'Article' - }] -}) - -userSchema.methods.comparePassword = function(candidatePassword:string, cb:(err:any,isMatch:any)=>{}) { - bcrypt.compare(candidatePassword, this.password, (err, isMa) => { - cb(err, isMa); - }); - }; - userSchema.pre('save',function(next){ - let self = this; - if(!self.id){ - self.id = self._id.toString(); - } - if(!self.isModified('password')){return next()}; - if(!self.avatar) { - self.avatar = self.gravatar(); - } - - bcrypt.genSalt(10,(error:Error,result)=>{ - if(error) return next(error); - bcrypt.hash(self.password,result,undefined,(err:Error,hash)=>{ - if(err) return next(err); - self.password = hash; - next() - }) - }); - }) - userSchema.methods.gravatar = function (size: number) { - if (!size) { - size = 200; - } - if (!this.email) { - return `https://gravatar.com/avatar/?s=${size}&d=retro`; - } - const md5 = crypto.createHash("md5").update(this.email).digest("hex"); - return `https://gravatar.com/avatar/${md5}?s=${size}&d=retro`; - }; - -var User = mongoose.model('User', userSchema); - +import * as mongoose from 'mongoose'; +// import passport = require("./../config/passport") +import * as crypto from "crypto"; +let Schema = mongoose.Schema; +import * as bcrypt from "bcrypt-nodejs"; + +export type UserModel = mongoose.Document & { + id:string, + email:string, + password:string, + passwordRestToken:string, + passwordRestExpires:Date, + verificationCodeToken:string, + verificationCodeExpires:Date, + github:string, + tokens:AuthToken[], + name: string, + avatar: string, + notes:any[], + compareValidateCode:any, + comparePassword: any, + gravatar:()=>{} +} +export type AuthToken = { + accessToken: string, + kind: string + }; +var userSchema = new Schema({ + id: { type: String, unique: true }, + email:{type:String}, + password:String, + passwordRestToken:String, + passwordRestExpires:Date, + verificationCodeToken:String, + verificationCodeExpires:Date, + github:String, + tokens:Array, + name: String, + avatar: String, + notes: [{ + type: Number, + ref: 'Article' + }] +}) + +userSchema.methods.comparePassword = function(candidatePassword:string, cb:(err:any,isMatch:any)=>{}) { + bcrypt.compare(candidatePassword, this.password, (err, isMa) => { + cb(err, isMa); + }); + }; + userSchema.pre('save',function(next){ + let self = this; + if(!self.id){ + self.id = self._id.toString(); + } + if(!self.isModified('password')){return next()}; + if(!self.avatar) { + self.avatar = self.gravatar(); + } + + bcrypt.genSalt(10,(error:Error,result)=>{ + if(error) return next(error); + bcrypt.hash(self.password,result,undefined,(err:Error,hash)=>{ + if(err) return next(err); + self.password = hash; + next() + }) + }); + }) + userSchema.methods.gravatar = function (size: number) { + if (!size) { + size = 200; + } + if (!this.email) { + return `https://gravatar.com/avatar/?s=${size}&d=retro`; + } + const md5 = crypto.createHash("md5").update(this.email).digest("hex"); + return `https://gravatar.com/avatar/${md5}?s=${size}&d=retro`; + }; + +var User = mongoose.model('User', userSchema); + export default User; \ No newline at end of file diff --git a/app/prerender.ts b/app/prerender.ts new file mode 100644 index 0000000..76c8145 --- /dev/null +++ b/app/prerender.ts @@ -0,0 +1,44 @@ + +// Load zone.js for the server. +import 'zone.js/dist/zone-node'; +import 'reflect-metadata'; +import {readFileSync, writeFileSync, existsSync, mkdirSync} from 'fs'; +import {join} from 'path'; + +import {enableProdMode} from '@angular/core'; +// Faster server renders w/ Prod mode (dev mode never needed) +enableProdMode(); + +// Import module map for lazy loading +import {provideModuleMap} from '@nguniversal/module-map-ngfactory-loader'; +import {renderModuleFactory} from '@angular/platform-server'; +import {ROUTES} from './static.paths'; + +// * NOTE :: leave this as require() since this file is built Dynamically from webpack +const {AppServerModuleNgFactory, LAZY_MODULE_MAP} = require('../dist/server/main.bundle'); + +const BROWSER_FOLDER = join(process.cwd(), 'browser'); + +// Load the index.html file containing referances to your application bundle. +const index = readFileSync(join('browser', 'index.html'), 'utf8'); + +let previousRender = Promise.resolve(); + +// Iterate each route path +ROUTES.forEach(route => { + var fullPath = join(BROWSER_FOLDER, route); + + // Make sure the directory structure is there + if(!existsSync(fullPath)){ + mkdirSync(fullPath); + } + + // Writes rendered HTML to index.html, replacing the file if it already exists. + previousRender = previousRender.then(_ => renderModuleFactory(AppServerModuleNgFactory, { + document: index, + url: route, + extraProviders: [ + provideModuleMap(LAZY_MODULE_MAP) + ] + })).then(html => writeFileSync(join(fullPath, 'index.html'), html)); +}); diff --git a/side_client/app/app.component.html b/app/public/app/app.component.html similarity index 100% rename from side_client/app/app.component.html rename to app/public/app/app.component.html diff --git a/side_client/app/app.component.less b/app/public/app/app.component.less similarity index 94% rename from side_client/app/app.component.less rename to app/public/app/app.component.less index 024cb20..314d83b 100644 --- a/side_client/app/app.component.less +++ b/app/public/app/app.component.less @@ -1,15 +1,15 @@ -main { - max-width: 900px; - margin: 0 auto; - &:before { - content: ''; - position: fixed; - top: 0; - right: 0; - z-index: -1; - bottom: 0; - left: 0; - background-image: linear-gradient(to bottom right,#002f4b,#dc4225); - opacity: .6; - } +main { + max-width: 900px; + margin: 0 auto; + &:before { + content: ''; + position: fixed; + top: 0; + right: 0; + z-index: -1; + bottom: 0; + left: 0; + background-image: linear-gradient(to bottom right,#002f4b,#dc4225); + opacity: .6; + } } \ No newline at end of file diff --git a/app/public/app/app.component.ts b/app/public/app/app.component.ts new file mode 100644 index 0000000..d2611f7 --- /dev/null +++ b/app/public/app/app.component.ts @@ -0,0 +1,24 @@ +import { Component,Inject,PLATFORM_ID } from '@angular/core'; +import { isPlatformBrowser, isPlatformServer } from '@angular/common'; +import { GlobalState } from './global.state'; + +@Component({ + selector: 'app-root', + templateUrl: './app.component.html', + styleUrls: ['./app.component.less'] +}) +export class AppComponent { + isMenuCollapsed: boolean = false; + title = 'app'; + constructor(@Inject(PLATFORM_ID) private platformId: Object,private _state:GlobalState){ + + } + ngAfterViewInit():void{ + if (isPlatformBrowser(this.platformId)) { + $('#preloader').hide(); + this._state.subscribe('menu.isCollapsed', (isCollapsed) => { + this.isMenuCollapsed = isCollapsed; + }); + } +} +} diff --git a/side_client/app/app.constant.ts b/app/public/app/app.constant.ts similarity index 96% rename from side_client/app/app.constant.ts rename to app/public/app/app.constant.ts index b1d0768..c507795 100644 --- a/side_client/app/app.constant.ts +++ b/app/public/app/app.constant.ts @@ -1,18 +1,18 @@ -interface CONFIG_NI { - [key:string]:string -} -declare var CONFIGNI:CONFIG_NI; -CONFIGNI = { - getArticles: '/v1/atricles', - getArticleDetail: '/v1/getArticleDetail', - postRegister: '/v1/register', - postLogin: '/v1/login', - postLoginByNote:'/v1/postLoginByNote',//手机号,验证码登录 - isLogin: '/v1/getUser', - logout: '/v1/logout', - forget: '/v1/forget', - reset: '/v1/reset', - publish: '/v1/publish', - upload: '/v1/upload', - sendNote:'/v1/sendNote'//发送短信 +interface CONFIG_NI { + [key:string]:string +} +declare var CONFIGNI:CONFIG_NI; +CONFIGNI = { + getArticles: '/v1/atricles', + getArticleDetail: '/v1/getArticleDetail', + postRegister: '/v1/register', + postLogin: '/v1/login', + postLoginByNote:'/v1/postLoginByNote',//手机号,验证码登录 + isLogin: '/v1/getUser', + logout: '/v1/logout', + forget: '/v1/forget', + reset: '/v1/reset', + publish: '/v1/publish', + upload: '/v1/upload', + sendNote:'/v1/sendNote'//发送短信 } \ No newline at end of file diff --git a/side_client/app/app.module.ts b/app/public/app/app.module.ts similarity index 76% rename from side_client/app/app.module.ts rename to app/public/app/app.module.ts index 2c85f8b..5cdc156 100644 --- a/side_client/app/app.module.ts +++ b/app/public/app/app.module.ts @@ -1,7 +1,8 @@ -import { BrowserModule } from '@angular/platform-browser'; +import { BrowserModule,BrowserTransferStateModule } from '@angular/platform-browser'; import { NgModule } from '@angular/core'; import { HttpClientModule,HTTP_INTERCEPTORS } from '@angular/common/http'; import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; +import {TransferHttpCacheModule} from '@nguniversal/common'; import { AppComponent } from './app.component'; import { PnfModule } from './theme/pnf.module'; @@ -21,12 +22,14 @@ const APP_PROVIDERS = [ AppComponent ], imports: [ - BrowserModule, + BrowserModule.withServerTransition({appId: 'my-app'}), + BrowserTransferStateModule, HttpClientModule, BrowserAnimationsModule, PnfModule.forRoot(), PagesModule, - routing + routing, + TransferHttpCacheModule ], providers: [...APP_PROVIDERS, { diff --git a/side_client/app/app.routing.ts b/app/public/app/app.routing.ts similarity index 97% rename from side_client/app/app.routing.ts rename to app/public/app/app.routing.ts index 4079759..abeeb3c 100644 --- a/side_client/app/app.routing.ts +++ b/app/public/app/app.routing.ts @@ -1,9 +1,9 @@ -import { Routes, RouterModule } from '@angular/router'; -import { ModuleWithProviders } from '@angular/core'; - -export const routes: Routes = [ - { path: '',redirectTo: 'pages',pathMatch: 'full' }, - { path: '**', redirectTo: 'pages/home' } -]; - +import { Routes, RouterModule } from '@angular/router'; +import { ModuleWithProviders } from '@angular/core'; + +export const routes: Routes = [ + { path: '',redirectTo: 'pages',pathMatch: 'full' }, + { path: '**', redirectTo: 'pages/home' } +]; + export const routing: ModuleWithProviders = RouterModule.forRoot(routes); \ No newline at end of file diff --git a/app/public/app/app.server.module.ts b/app/public/app/app.server.module.ts new file mode 100644 index 0000000..f622567 --- /dev/null +++ b/app/public/app/app.server.module.ts @@ -0,0 +1,18 @@ +import { NgModule } from '@angular/core'; +import {ServerModule, ServerTransferStateModule} from '@angular/platform-server'; +import {ModuleMapLoaderModule} from '@nguniversal/module-map-ngfactory-loader'; + +import {AppModule} from './app.module'; +import { AppComponent } from './app.component'; + + +@NgModule({ + imports: [ + AppModule, + ServerModule, + ModuleMapLoaderModule, + ServerTransferStateModule + ], + bootstrap: [AppComponent] +}) +export class AppServerModule { } diff --git a/side_client/app/auth.guard.service.ts b/app/public/app/auth.guard.service.ts similarity index 97% rename from side_client/app/auth.guard.service.ts rename to app/public/app/auth.guard.service.ts index c8e32c6..b8f2b00 100644 --- a/side_client/app/auth.guard.service.ts +++ b/app/public/app/auth.guard.service.ts @@ -1,41 +1,41 @@ -import { Observable } from 'rxjs/Observable'; -import 'rxjs/add/operator/map'; -import { HttpClient } from '@angular/common/http'; -import { Injectable } from '@angular/core'; -import { CanActivate, Routes,Router,CanLoad,ActivatedRoute } from '@angular/router'; -@Injectable() -export class AuthGuard { - constructor(private http:HttpClient,private router:Router,private activeRouter: ActivatedRoute){} - canActivate():Observable{ - return this.checkLogin(); - } - canLoad():Observable{ - return this.checkLogin(); - } - checkLogin():Observable{ - return this.http.post(CONFIGNI.isLogin,{}).map(response => { - if(response.resultCode ==1){ - return true; - } else if(response.resultCode ==0){ - alert('请先登录'); - this.router.navigate(['/login']); - return false; - } - }) - } - - getUser():Observable { - return this.http.post(CONFIGNI.isLogin,{}).map(res => { - if(res.resultCode==1){ - return res.resultObj; - } else { - return {}; - } - }); - } - logout():Observable { - return this.http.post(CONFIGNI.logout,{}).map(res => { - return res; - }); - } +import { Observable } from 'rxjs/Observable'; +import 'rxjs/add/operator/map'; +import { HttpClient } from '@angular/common/http'; +import { Injectable } from '@angular/core'; +import { CanActivate, Routes,Router,CanLoad,ActivatedRoute } from '@angular/router'; +@Injectable() +export class AuthGuard { + constructor(private http:HttpClient,private router:Router,private activeRouter: ActivatedRoute){} + canActivate():Observable{ + return this.checkLogin(); + } + canLoad():Observable{ + return this.checkLogin(); + } + checkLogin():Observable{ + return this.http.post(CONFIGNI.isLogin,{}).map(response => { + if(response.resultCode ==1){ + return true; + } else if(response.resultCode ==0){ + alert('请先登录'); + this.router.navigate(['/login']); + return false; + } + }) + } + + getUser():Observable { + return this.http.post(CONFIGNI.isLogin,{}).map(res => { + if(res.resultCode==1){ + return res.resultObj; + } else { + return {}; + } + }); + } + logout():Observable { + return this.http.post(CONFIGNI.logout,{}).map(res => { + return res; + }); + } } \ No newline at end of file diff --git a/side_client/app/global.state.ts b/app/public/app/global.state.ts similarity index 96% rename from side_client/app/global.state.ts rename to app/public/app/global.state.ts index 727a2ca..6d0d310 100644 --- a/side_client/app/global.state.ts +++ b/app/public/app/global.state.ts @@ -1,42 +1,42 @@ -import { Injectable } from '@angular/core'; -import { Subject } from 'rxjs/Subject'; - -@Injectable() -export class GlobalState { - - private _data = new Subject(); - private _dataStream$ = this._data.asObservable(); - - private _subscriptions: Map> = new Map>(); - - constructor() { - this._dataStream$.subscribe((data) => this._onEvent(data)); - } - - notifyDataChanged(event, value) { - let current = this._data[event]; - if (current !== value) { - this._data[event] = value; - - this._data.next({ - event: event, - data: this._data[event] - }); - } - } - - subscribe(event: string, callback: Function) { - let subscribers = this._subscriptions.get(event) || []; - subscribers.push(callback); - - this._subscriptions.set(event, subscribers); - } - - _onEvent(data: any) { - let subscribers = this._subscriptions.get(data['event']) || []; - - subscribers.forEach((callback) => { - callback.call(null, data['data']); - }); - } -} +import { Injectable } from '@angular/core'; +import { Subject } from 'rxjs/Subject'; + +@Injectable() +export class GlobalState { + + private _data = new Subject(); + private _dataStream$ = this._data.asObservable(); + + private _subscriptions: Map> = new Map>(); + + constructor() { + this._dataStream$.subscribe((data) => this._onEvent(data)); + } + + notifyDataChanged(event, value) { + let current = this._data[event]; + if (current !== value) { + this._data[event] = value; + + this._data.next({ + event: event, + data: this._data[event] + }); + } + } + + subscribe(event: string, callback: Function) { + let subscribers = this._subscriptions.get(event) || []; + subscribers.push(callback); + + this._subscriptions.set(event, subscribers); + } + + _onEvent(data: any) { + let subscribers = this._subscriptions.get(data['event']) || []; + + subscribers.forEach((callback) => { + callback.call(null, data['data']); + }); + } +} diff --git a/side_client/app/http.interceptor.ts b/app/public/app/http.interceptor.ts similarity index 97% rename from side_client/app/http.interceptor.ts rename to app/public/app/http.interceptor.ts index 4af599e..eac696d 100644 --- a/side_client/app/http.interceptor.ts +++ b/app/public/app/http.interceptor.ts @@ -1,58 +1,58 @@ -import {Injectable} from '@angular/core'; -import {HttpEvent, HttpInterceptor, HttpHandler, HttpRequest,HttpResponse,HttpHeaders,HttpParams,HttpErrorResponse } from '@angular/common/http'; -import { Observable } from 'rxjs/Observable'; - -import 'rxjs/add/operator/catch' -import 'rxjs/add/operator/do' -import {environment} from '../environments/environment'; - -@Injectable() -export class InterceptedHttp implements HttpInterceptor { - intercept(req: HttpRequest, next: HttpHandler): Observable> { - const headers = new HttpHeaders().set('Content-Type', 'application/x-www-form-urlencoded;charset=UTF-8'); - const duplicate = req.clone({ - url:environment.realHost+req.url, - headers:headers, - body:this.param(req.body) - }); - - return next.handle(duplicate).do((next:HttpResponse)=>{ - if(next.body && next.body.resultCode == 401){ - console.log('未登陆') - } - },(err:HttpErrorResponse)=>{ - if(err){ - alert('网络异常') - } - }) - } - param(obj) { - let query = '', - name, value, fullSubName, subName, subValue, innerObj, i; - - for (name in obj) { - value = obj[name]; - - if (value instanceof Array) { - for (i = 0; i < value.length; ++i) { - subValue = value[i]; - fullSubName = name + '[' + i + ']'; - innerObj = {}; - innerObj[fullSubName] = subValue; - query += this.param(innerObj) + '&'; - } - } else if (value instanceof Object) { - for (subName in value) { - subValue = value[subName]; - fullSubName = name + '[' + subName + ']'; - innerObj = {}; - innerObj[fullSubName] = subValue; - query += this.param(innerObj) + '&'; - } - } else if (value !== undefined && value !== null) - query += encodeURIComponent(name) + '=' + encodeURIComponent(value) + '&'; - } - - return query.length ? query.substr(0, query.length - 1) : query; - }; +import {Injectable} from '@angular/core'; +import {HttpEvent, HttpInterceptor, HttpHandler, HttpRequest,HttpResponse,HttpHeaders,HttpParams,HttpErrorResponse } from '@angular/common/http'; +import { Observable } from 'rxjs/Observable'; + +import 'rxjs/add/operator/catch' +import 'rxjs/add/operator/do' +import {environment} from '../environments/environment'; + +@Injectable() +export class InterceptedHttp implements HttpInterceptor { + intercept(req: HttpRequest, next: HttpHandler): Observable> { + const headers = new HttpHeaders().set('Content-Type', 'application/x-www-form-urlencoded;charset=UTF-8'); + const duplicate = req.clone({ + url:environment.realHost+req.url, + headers:headers, + body:this.param(req.body) + }); + + return next.handle(duplicate).do((next:HttpResponse)=>{ + if(next.body && next.body.resultCode == 401){ + console.log('未登陆') + } + },(err:HttpErrorResponse)=>{ + if(err){ + alert('网络异常') + } + }) + } + param(obj) { + let query = '', + name, value, fullSubName, subName, subValue, innerObj, i; + + for (name in obj) { + value = obj[name]; + + if (value instanceof Array) { + for (i = 0; i < value.length; ++i) { + subValue = value[i]; + fullSubName = name + '[' + i + ']'; + innerObj = {}; + innerObj[fullSubName] = subValue; + query += this.param(innerObj) + '&'; + } + } else if (value instanceof Object) { + for (subName in value) { + subValue = value[subName]; + fullSubName = name + '[' + subName + ']'; + innerObj = {}; + innerObj[fullSubName] = subValue; + query += this.param(innerObj) + '&'; + } + } else if (value !== undefined && value !== null) + query += encodeURIComponent(name) + '=' + encodeURIComponent(value) + '&'; + } + + return query.length ? query.substr(0, query.length - 1) : query; + }; } \ No newline at end of file diff --git a/side_client/app/pages/detail/detail.component.ts b/app/public/app/pages/detail/detail.component.ts similarity index 96% rename from side_client/app/pages/detail/detail.component.ts rename to app/public/app/pages/detail/detail.component.ts index bef7cc5..c79cb5b 100644 --- a/side_client/app/pages/detail/detail.component.ts +++ b/app/public/app/pages/detail/detail.component.ts @@ -1,33 +1,33 @@ -import { DetailService } from './detail.service'; -import { Router,ActivatedRoute,ParamMap } from '@angular/router'; -import {Component } from '@angular/core'; - -import 'rxjs/add/operator/switchMap'; -import { Observable } from 'rxjs/Observable'; - -@Component({ - selector: 'detail', - templateUrl: './detail.html', - styleUrls:['./detail.less'], - providers:[DetailService] -}) -export class DetailComponent{ - detail:any; - constructor(private router: Router,private route:ActivatedRoute,private detailService:DetailService){ - - } - - ngOnInit():void{ - this.route.paramMap - .switchMap((params: ParamMap) => { - // (+) before `params.get()` turns the string into a number - let selectedId = params.get('id'); - return this.detailService.getArticleDetail({id:selectedId}); - }).subscribe((response)=>{ - if(response.resultCode==1){ - this.detail = response.resultObj; - } - }); - - } -} +import { DetailService } from './detail.service'; +import { Router,ActivatedRoute,ParamMap } from '@angular/router'; +import {Component } from '@angular/core'; + +import 'rxjs/add/operator/switchMap'; +import { Observable } from 'rxjs/Observable'; + +@Component({ + selector: 'detail', + templateUrl: './detail.html', + styleUrls:['./detail.less'], + providers:[DetailService] +}) +export class DetailComponent{ + detail:any; + constructor(private router: Router,private route:ActivatedRoute,private detailService:DetailService){ + + } + + ngOnInit():void{ + this.route.paramMap + .switchMap((params: ParamMap) => { + // (+) before `params.get()` turns the string into a number + let selectedId = params.get('id'); + return this.detailService.getArticleDetail({id:selectedId}); + }).subscribe((response)=>{ + if(response.resultCode==1){ + this.detail = response.resultObj; + } + }); + + } +} diff --git a/side_client/app/pages/detail/detail.html b/app/public/app/pages/detail/detail.html similarity index 96% rename from side_client/app/pages/detail/detail.html rename to app/public/app/pages/detail/detail.html index 2e9c6a3..fc326cb 100644 --- a/side_client/app/pages/detail/detail.html +++ b/app/public/app/pages/detail/detail.html @@ -1,7 +1,7 @@ -
-
-
- -
-
+
+
+
+ +
+
\ No newline at end of file diff --git a/side_client/app/pages/detail/detail.less b/app/public/app/pages/detail/detail.less similarity index 94% rename from side_client/app/pages/detail/detail.less rename to app/public/app/pages/detail/detail.less index 210e1cc..6a66911 100644 --- a/side_client/app/pages/detail/detail.less +++ b/app/public/app/pages/detail/detail.less @@ -1,9 +1,9 @@ -.article-detail { - margin: 0 auto; - padding: 0 2%; - padding-top: 20px; - padding-bottom: 40px; - max-width: 620px; - width: 100%; - +.article-detail { + margin: 0 auto; + padding: 0 2%; + padding-top: 20px; + padding-bottom: 40px; + max-width: 620px; + width: 100%; + } \ No newline at end of file diff --git a/side_client/app/pages/detail/detail.module.ts b/app/public/app/pages/detail/detail.module.ts similarity index 95% rename from side_client/app/pages/detail/detail.module.ts rename to app/public/app/pages/detail/detail.module.ts index 1fb5189..bf8361e 100644 --- a/side_client/app/pages/detail/detail.module.ts +++ b/app/public/app/pages/detail/detail.module.ts @@ -1,17 +1,17 @@ -import { DetailComponent } from './detail.component'; -import { NgModule } from '@angular/core'; -import { CommonModule } from '@angular/common'; -import { PnfModule } from '../../theme/pnf.module'; -import {routing} from './detail.routing' - -@NgModule({ - imports: [ - CommonModule, - PnfModule, - routing - ], - declarations: [ - DetailComponent - ] -}) -export class DetailModule {} +import { DetailComponent } from './detail.component'; +import { NgModule } from '@angular/core'; +import { CommonModule } from '@angular/common'; +import { PnfModule } from '../../theme/pnf.module'; +import {routing} from './detail.routing' + +@NgModule({ + imports: [ + CommonModule, + PnfModule, + routing + ], + declarations: [ + DetailComponent + ] +}) +export class DetailModule {} diff --git a/side_client/app/pages/detail/detail.routing.ts b/app/public/app/pages/detail/detail.routing.ts similarity index 96% rename from side_client/app/pages/detail/detail.routing.ts rename to app/public/app/pages/detail/detail.routing.ts index 52ad89c..aa2c62f 100644 --- a/side_client/app/pages/detail/detail.routing.ts +++ b/app/public/app/pages/detail/detail.routing.ts @@ -1,12 +1,12 @@ -import { DetailComponent } from './detail.component'; -import { Routes, RouterModule } from '@angular/router'; -import { ModuleWithProviders } from '@angular/core'; - -export const routes: Routes = [ - { - path: '', - component: DetailComponent - } -]; - -export const routing: ModuleWithProviders = RouterModule.forChild(routes); +import { DetailComponent } from './detail.component'; +import { Routes, RouterModule } from '@angular/router'; +import { ModuleWithProviders } from '@angular/core'; + +export const routes: Routes = [ + { + path: '', + component: DetailComponent + } +]; + +export const routing: ModuleWithProviders = RouterModule.forChild(routes); diff --git a/side_client/app/pages/detail/detail.service.ts b/app/public/app/pages/detail/detail.service.ts similarity index 96% rename from side_client/app/pages/detail/detail.service.ts rename to app/public/app/pages/detail/detail.service.ts index 103152b..3c9c3cf 100644 --- a/side_client/app/pages/detail/detail.service.ts +++ b/app/public/app/pages/detail/detail.service.ts @@ -1,10 +1,10 @@ -import { HttpClient } from '@angular/common/http'; -import { Injectable,Inject } from '@angular/core'; - -@Injectable() -export class DetailService { - constructor(private http:HttpClient){} - getArticleDetail(obj){ - return this.http.post(CONFIGNI.getArticleDetail,obj) - } +import { HttpClient } from '@angular/common/http'; +import { Injectable,Inject } from '@angular/core'; + +@Injectable() +export class DetailService { + constructor(private http:HttpClient){} + getArticleDetail(obj){ + return this.http.post(CONFIGNI.getArticleDetail,obj) + } } \ No newline at end of file diff --git a/side_client/app/pages/detail/index.ts b/app/public/app/pages/detail/index.ts similarity index 100% rename from side_client/app/pages/detail/index.ts rename to app/public/app/pages/detail/index.ts diff --git a/side_client/app/pages/forget/forget.component.ts b/app/public/app/pages/forget/forget.component.ts similarity index 97% rename from side_client/app/pages/forget/forget.component.ts rename to app/public/app/pages/forget/forget.component.ts index 3d210d8..7490d55 100644 --- a/side_client/app/pages/forget/forget.component.ts +++ b/app/public/app/pages/forget/forget.component.ts @@ -1,37 +1,37 @@ -import { ForgetService } from './forget.service'; -import { Component, OnInit } from '@angular/core'; -import { FormGroup, AbstractControl, FormBuilder, Validators } from '@angular/forms'; -import { Router } from '@angular/router'; - -@Component({ - selector: 'forget', - templateUrl: './forget.html', - styleUrls: ['./forget.less'], - providers:[ForgetService] -}) -export class ForgetComponent{ - - public form:FormGroup; - public email:AbstractControl; - public password:AbstractControl; - public submitted:boolean = false; - constructor(fb:FormBuilder,private forgetService:ForgetService,private router:Router) { - this.form = fb.group({ - 'email': ['', Validators.compose([Validators.required, Validators.minLength(4)])] - }); - - this.email = this.form.controls['email']; - } - public onSubmit(values:any):void { - this.submitted = true; - if (this.form.valid) { - this.forgetService.postForget({ - email:values.email}).subscribe((response)=>{ - alert(response.resultMess); - if(response.resultCode ==1){ - this.router.navigate(['/pages/home']); - } - }) - } - } +import { ForgetService } from './forget.service'; +import { Component, OnInit } from '@angular/core'; +import { FormGroup, AbstractControl, FormBuilder, Validators } from '@angular/forms'; +import { Router } from '@angular/router'; + +@Component({ + selector: 'forget', + templateUrl: './forget.html', + styleUrls: ['./forget.less'], + providers:[ForgetService] +}) +export class ForgetComponent{ + + public form:FormGroup; + public email:AbstractControl; + public password:AbstractControl; + public submitted:boolean = false; + constructor(fb:FormBuilder,private forgetService:ForgetService,private router:Router) { + this.form = fb.group({ + 'email': ['', Validators.compose([Validators.required, Validators.minLength(4)])] + }); + + this.email = this.form.controls['email']; + } + public onSubmit(values:any):void { + this.submitted = true; + if (this.form.valid) { + this.forgetService.postForget({ + email:values.email}).subscribe((response)=>{ + alert(response.resultMess); + if(response.resultCode ==1){ + this.router.navigate(['/pages/home']); + } + }) + } + } } \ No newline at end of file diff --git a/side_client/app/pages/forget/forget.html b/app/public/app/pages/forget/forget.html similarity index 98% rename from side_client/app/pages/forget/forget.html rename to app/public/app/pages/forget/forget.html index fd3f730..1bc9ee6 100644 --- a/side_client/app/pages/forget/forget.html +++ b/app/public/app/pages/forget/forget.html @@ -1,19 +1,19 @@ -
-
-

忘记密码

-
-
- - -
- -
-
-
-
- -
-
-
-
+
+
+

忘记密码

+
+
+ + +
+ +
+
+
+
+ +
+
+
+
\ No newline at end of file diff --git a/side_client/app/pages/forget/forget.less b/app/public/app/pages/forget/forget.less similarity index 100% rename from side_client/app/pages/forget/forget.less rename to app/public/app/pages/forget/forget.less diff --git a/side_client/app/pages/forget/forget.module.ts b/app/public/app/pages/forget/forget.module.ts similarity index 97% rename from side_client/app/pages/forget/forget.module.ts rename to app/public/app/pages/forget/forget.module.ts index bbbb877..50b67b4 100644 --- a/side_client/app/pages/forget/forget.module.ts +++ b/app/public/app/pages/forget/forget.module.ts @@ -1,12 +1,12 @@ -import { ForgetComponent } from './forget.component'; -import { NgModule } from '@angular/core'; -import { CommonModule } from '@angular/common'; -import { FormsModule, ReactiveFormsModule } from '@angular/forms'; -import {routing} from './forget.routing' - -@NgModule({ - declarations: [ForgetComponent], - imports: [ CommonModule,ReactiveFormsModule, - FormsModule,routing ], -}) +import { ForgetComponent } from './forget.component'; +import { NgModule } from '@angular/core'; +import { CommonModule } from '@angular/common'; +import { FormsModule, ReactiveFormsModule } from '@angular/forms'; +import {routing} from './forget.routing' + +@NgModule({ + declarations: [ForgetComponent], + imports: [ CommonModule,ReactiveFormsModule, + FormsModule,routing ], +}) export class ForgetModule {} \ No newline at end of file diff --git a/side_client/app/pages/forget/forget.routing.ts b/app/public/app/pages/forget/forget.routing.ts similarity index 96% rename from side_client/app/pages/forget/forget.routing.ts rename to app/public/app/pages/forget/forget.routing.ts index 2e21efb..0125ab9 100644 --- a/side_client/app/pages/forget/forget.routing.ts +++ b/app/public/app/pages/forget/forget.routing.ts @@ -1,14 +1,14 @@ -import { Routes, RouterModule } from '@angular/router'; - -import { ModuleWithProviders } from '@angular/core'; -import {ForgetComponent} from './forget.component' - -// noinspection TypeScriptValidateTypes -export const routes: Routes = [ - { - path: '', - component: ForgetComponent - } -]; - -export const routing: ModuleWithProviders = RouterModule.forChild(routes); +import { Routes, RouterModule } from '@angular/router'; + +import { ModuleWithProviders } from '@angular/core'; +import {ForgetComponent} from './forget.component' + +// noinspection TypeScriptValidateTypes +export const routes: Routes = [ + { + path: '', + component: ForgetComponent + } +]; + +export const routing: ModuleWithProviders = RouterModule.forChild(routes); diff --git a/side_client/app/pages/forget/forget.service.ts b/app/public/app/pages/forget/forget.service.ts similarity index 96% rename from side_client/app/pages/forget/forget.service.ts rename to app/public/app/pages/forget/forget.service.ts index abbaa76..29181ee 100644 --- a/side_client/app/pages/forget/forget.service.ts +++ b/app/public/app/pages/forget/forget.service.ts @@ -1,10 +1,10 @@ -import { Injectable } from '@angular/core'; -import { HttpClient } from '@angular/common/http'; - -@Injectable() -export class ForgetService { - constructor(private http:HttpClient){} - postForget(obj){ - return this.http.post(CONFIGNI.forget,obj) - } +import { Injectable } from '@angular/core'; +import { HttpClient } from '@angular/common/http'; + +@Injectable() +export class ForgetService { + constructor(private http:HttpClient){} + postForget(obj){ + return this.http.post(CONFIGNI.forget,obj) + } } \ No newline at end of file diff --git a/side_client/app/pages/forget/index.ts b/app/public/app/pages/forget/index.ts similarity index 100% rename from side_client/app/pages/forget/index.ts rename to app/public/app/pages/forget/index.ts diff --git a/side_client/app/pages/home/home.component.html b/app/public/app/pages/home/home.component.html similarity index 98% rename from side_client/app/pages/home/home.component.html rename to app/public/app/pages/home/home.component.html index 27bf510..5cc5157 100644 --- a/side_client/app/pages/home/home.component.html +++ b/app/public/app/pages/home/home.component.html @@ -1,25 +1,26 @@ -
-
- -
+
+
+ +
\ No newline at end of file diff --git a/side_client/app/pages/home/home.component.less b/app/public/app/pages/home/home.component.less similarity index 95% rename from side_client/app/pages/home/home.component.less rename to app/public/app/pages/home/home.component.less index db6d9b1..8771a24 100644 --- a/side_client/app/pages/home/home.component.less +++ b/app/public/app/pages/home/home.component.less @@ -1,34 +1,34 @@ -.card { - color: #fff; - background-color: rgba(255,255,255,0.1); - border: 0; - border-radius: 7px; - position: relative; - margin-bottom: 24px; - box-shadow: 1px 1px 4px rgba(0,0,0,0.15); - .card-footer { - .meta { - &>a { - display: inline-block; - i { - vertical-align: middle; - width: 20px; - line-height: 16px; - height: 20px; - } - } - } - } -} -.note-list { - margin-top: 24px; -} - -.card-header { - height: 75px; - overflow: hidden; - img { - height: 100%; - } -} - +.card { + color: #fff; + background-color: rgba(255,255,255,0.1); + border: 0; + border-radius: 7px; + position: relative; + margin-bottom: 24px; + box-shadow: 1px 1px 4px rgba(0,0,0,0.15); + .card-footer { + .meta { + &>a { + display: inline-block; + i { + vertical-align: middle; + width: 20px; + line-height: 16px; + height: 20px; + } + } + } + } +} +.note-list { + margin-top: 24px; +} + +.card-header { + height: 75px; + overflow: hidden; + img { + height: 100%; + } +} + diff --git a/app/public/app/pages/home/home.component.ts b/app/public/app/pages/home/home.component.ts new file mode 100644 index 0000000..90189bf --- /dev/null +++ b/app/public/app/pages/home/home.component.ts @@ -0,0 +1,65 @@ + +import { Router } from '@angular/router'; +import { isPlatformBrowser, isPlatformServer } from '@angular/common'; +import { makeStateKey, TransferState } from '@angular/platform-browser'; + +import { HomeService } from './home.service'; +import {Component ,Inject,PLATFORM_ID,Optional,OnInit} from '@angular/core'; +import 'rxjs/add/operator/exhaustMap'; +import {Observable} from 'rxjs/Observable'; +import 'rxjs/add/observable/empty'; + +const NOTELIST_KEY = makeStateKey('noteList'); + +@Component({ + selector: 'home', + templateUrl: './home.component.html', + styleUrls:['./home.component.less'], + providers:[HomeService] +}) +export class HomeComponent implements OnInit{ + noteList:any[] = []; + page:number = 0; + constructor(private state: TransferState,@Optional() @Inject('noteList') private noteListUrl:any,@Inject(PLATFORM_ID) private platformId: Object,private router: Router,private homeService:HomeService){ + + } + onScroll():void { + console.log('scrolled!!') + ++this.page; + this.getList(this.page); + } + toDetail(id:string):void { + this.router.navigate(['/pages/detail', id]); + } + ngOnInit():void{ + + if (isPlatformBrowser(this.platformId)) { + let a = this.state.get(NOTELIST_KEY,null as any); + if(!a){ + this.getList() + } else { + this.noteList = a; + } + console.log('当前是客户端平台===>=>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>============>'); + } + if (isPlatformServer(this.platformId)) { + this.state.set(NOTELIST_KEY,this.noteListUrl as any); + this.page++; + console.log('当前是服务端平台===>=>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>============>'); + } + } + getList(page:number=0):void{ + this.homeService.getListArticle({page:page}).subscribe((response)=>{ + if(response.resultCode==1){ + if(page ==0){ + this.noteList = response.resultObj; + + }else { + this.noteList = this.noteList.concat(response.resultObj); + } + + } + }) + } + +} diff --git a/side_client/app/pages/home/home.module.ts b/app/public/app/pages/home/home.module.ts similarity index 96% rename from side_client/app/pages/home/home.module.ts rename to app/public/app/pages/home/home.module.ts index 9653a4c..e9f4bea 100644 --- a/side_client/app/pages/home/home.module.ts +++ b/app/public/app/pages/home/home.module.ts @@ -1,18 +1,18 @@ -import { HomeComponent } from './home.component'; -import { NgModule } from '@angular/core'; -import { CommonModule } from '@angular/common'; -import { PnfModule } from '../../theme/pnf.module'; -import {routing} from './home.routing' -import { InfiniteScrollModule } from 'ngx-infinite-scroll'; - -@NgModule({ - imports: [ - CommonModule, - InfiniteScrollModule, - PnfModule - ], - declarations: [ - HomeComponent - ] -}) -export class HomeModule {} +import { HomeComponent } from './home.component'; +import { NgModule } from '@angular/core'; +import { CommonModule } from '@angular/common'; +import { PnfModule } from '../../theme/pnf.module'; +import {routing} from './home.routing' +import { InfiniteScrollModule } from 'ngx-infinite-scroll'; + +@NgModule({ + imports: [ + CommonModule, + InfiniteScrollModule, + PnfModule + ], + declarations: [ + HomeComponent + ] +}) +export class HomeModule {} diff --git a/side_client/app/pages/home/home.routing.ts b/app/public/app/pages/home/home.routing.ts similarity index 96% rename from side_client/app/pages/home/home.routing.ts rename to app/public/app/pages/home/home.routing.ts index 3faf468..fb69bf4 100644 --- a/side_client/app/pages/home/home.routing.ts +++ b/app/public/app/pages/home/home.routing.ts @@ -1,13 +1,13 @@ -import { Routes, RouterModule } from '@angular/router'; - -import { HomeComponent } from './home.component'; -import { ModuleWithProviders } from '@angular/core'; - -export const routes: Routes = [ - { - path: '', - component: HomeComponent - } -]; - -export const routing: ModuleWithProviders = RouterModule.forChild(routes); +import { Routes, RouterModule } from '@angular/router'; + +import { HomeComponent } from './home.component'; +import { ModuleWithProviders } from '@angular/core'; + +export const routes: Routes = [ + { + path: '', + component: HomeComponent + } +]; + +export const routing: ModuleWithProviders = RouterModule.forChild(routes); diff --git a/side_client/app/pages/home/home.service.ts b/app/public/app/pages/home/home.service.ts similarity index 97% rename from side_client/app/pages/home/home.service.ts rename to app/public/app/pages/home/home.service.ts index f3de977..b7514d8 100644 --- a/side_client/app/pages/home/home.service.ts +++ b/app/public/app/pages/home/home.service.ts @@ -1,9 +1,9 @@ -import { HttpClient } from '@angular/common/http'; -import { Injectable,Inject } from '@angular/core'; -@Injectable() -export class HomeService { - constructor(private http:HttpClient){} - getListArticle(obj){ - return this.http.post(CONFIGNI.getArticles,obj) - } +import { HttpClient } from '@angular/common/http'; +import { Injectable,Inject } from '@angular/core'; +@Injectable() +export class HomeService { + constructor(private http:HttpClient){} + getListArticle(obj){ + return this.http.post(CONFIGNI.getArticles,obj) + } } \ No newline at end of file diff --git a/side_client/app/pages/home/index.ts b/app/public/app/pages/home/index.ts similarity index 100% rename from side_client/app/pages/home/index.ts rename to app/public/app/pages/home/index.ts diff --git a/side_client/app/pages/login/index.ts b/app/public/app/pages/login/index.ts similarity index 100% rename from side_client/app/pages/login/index.ts rename to app/public/app/pages/login/index.ts diff --git a/side_client/app/pages/login/login.component.ts b/app/public/app/pages/login/login.component.ts similarity index 97% rename from side_client/app/pages/login/login.component.ts rename to app/public/app/pages/login/login.component.ts index 8a7476d..5b30a3b 100644 --- a/side_client/app/pages/login/login.component.ts +++ b/app/public/app/pages/login/login.component.ts @@ -1,126 +1,126 @@ -import { LoginService } from './login.service'; -import {Component} from '@angular/core'; -import { Router } from '@angular/router'; -import {FormGroup, AbstractControl, FormBuilder, Validators} from '@angular/forms'; -import {Observable} from 'rxjs' - -import { - trigger, - state, - style, - animate, - transition -} from '@angular/animations'; - -@Component({ - selector: 'login', - templateUrl: './login.html', - styleUrls: ['./login.less'], - providers:[LoginService], - animations: [ - trigger('flyInOut', [ - state('in', style({opacity: 1, transform: 'translateX(0)'})), - state('out', style({opacity: 0, transform: 'translateX(-100%)'})), - transition('out <=> in', [ - style({transform: 'translateX(-100%)'}), - animate(100) - ]), - transition('void => in', [ - style({transform: 'translateX(-100%)'}), - animate(100) - ]) - ]), - trigger('flyInIn', [ - state('in', style({opacity: 0, transform: 'translateX(100%)'})), - state('out', style({opacity: 1, transform: 'translateX(0)'})), - transition('in <=> out', [ - animate(100), - style({transform: 'translateX(100%)'}), - ]) - ]) - ] -}) -export class Login { - public emailLogin:boolean =false; - public form:FormGroup; - public emailGroup:FormGroup; - public email:AbstractControl; - public password:AbstractControl; - public phoneGroup:FormGroup; - public phone:AbstractControl; - public validateCode:AbstractControl; - public submitted:boolean = false; - - public animationState:string ='in'; - public countDown = 20; - public cdType:boolean =false; - - constructor(fb:FormBuilder,private loginService:LoginService,private router:Router) { - this.form = fb.group({ - 'emailGroup':fb.group({ - 'email': ['', Validators.compose([Validators.required, Validators.minLength(4)])], - 'password': ['', Validators.compose([Validators.required, Validators.minLength(4)])] - }), - 'phoneGroup':fb.group({ - 'phone': ['', Validators.compose([Validators.required, Validators.minLength(4)])], - 'validateCode': ['', Validators.compose([Validators.required, Validators.minLength(4)])] - }) - }); - this.emailGroup = this.form.controls['emailGroup']; - this.email = this.emailGroup.controls['email']; - this.password = this.emailGroup.controls['password']; - this.phoneGroup = this.form.controls['phoneGroup']; - this.phone = this.phoneGroup.controls['phone']; - this.validateCode = this.phoneGroup.controls['validateCode']; - } - public changeLogin():void { - - if(this.animationState == 'in'){ - this.animationState = 'out' - }else { - this.animationState = 'in' - } - this.emailLogin = !this.emailLogin; - } - public sendNote():void{ - this.cdType = true; - let num = this.countDown; - let observable = Observable.interval(1000).take(this.countDown); - let subscription = observable.subscribe(x => { - this.countDown =num - x-1; - if(this.countDown==0){ - this.cdType = false; - this.countDown = num; - } - }); - this.loginService.sendNote({phone:this.phone.value}).subscribe((response)=>{ - alert(response.resultMess); - }) - } - public onSubmit(form:FormGroup):void { - this.submitted = true; - if (this.emailLogin&& form.controls.emailGroup.valid) { - let values = form.controls.emailGroup.value; - this.loginService.postLogin({ - email:values.email, - password:values.password}).subscribe((response)=>{ - if(response.resultCode ==1){ - this.router.navigate(['/pages/home']); - } else { - alert(response.resultMess) - } - }) - } else if (!this.emailLogin&& form.controls.phoneGroup.valid){ - let values = form.controls.phoneGroup.value; - this.loginService.postLoginByNote({ - phone:values.phone, - validateCode:values.validateCode}).subscribe((response)=>{ - if(response.resultCode ==1){ - this.router.navigate(['/pages/home']); - } else { - alert(response.resultMess) - } - }) - } - } -} +import { LoginService } from './login.service'; +import {Component} from '@angular/core'; +import { Router } from '@angular/router'; +import {FormGroup, AbstractControl, FormBuilder, Validators} from '@angular/forms'; +import {Observable} from 'rxjs' + +import { + trigger, + state, + style, + animate, + transition +} from '@angular/animations'; + +@Component({ + selector: 'login', + templateUrl: './login.html', + styleUrls: ['./login.less'], + providers:[LoginService], + animations: [ + trigger('flyInOut', [ + state('in', style({opacity: 1, transform: 'translateX(0)'})), + state('out', style({opacity: 0, transform: 'translateX(-100%)'})), + transition('out <=> in', [ + style({transform: 'translateX(-100%)'}), + animate(100) + ]), + transition('void => in', [ + style({transform: 'translateX(-100%)'}), + animate(100) + ]) + ]), + trigger('flyInIn', [ + state('in', style({opacity: 0, transform: 'translateX(100%)'})), + state('out', style({opacity: 1, transform: 'translateX(0)'})), + transition('in <=> out', [ + animate(100), + style({transform: 'translateX(100%)'}), + ]) + ]) + ] +}) +export class Login { + public emailLogin:boolean =false; + public form:FormGroup; + public emailGroup:FormGroup; + public email:AbstractControl; + public password:AbstractControl; + public phoneGroup:FormGroup; + public phone:AbstractControl; + public validateCode:AbstractControl; + public submitted:boolean = false; + + public animationState:string ='in'; + public countDown = 20; + public cdType:boolean =false; + + constructor(fb:FormBuilder,private loginService:LoginService,private router:Router) { + this.form = fb.group({ + 'emailGroup':fb.group({ + 'email': ['', Validators.compose([Validators.required, Validators.minLength(4)])], + 'password': ['', Validators.compose([Validators.required, Validators.minLength(4)])] + }), + 'phoneGroup':fb.group({ + 'phone': ['', Validators.compose([Validators.required, Validators.minLength(4)])], + 'validateCode': ['', Validators.compose([Validators.required, Validators.minLength(4)])] + }) + }); + this.emailGroup = this.form.controls['emailGroup']; + this.email = this.emailGroup.controls['email']; + this.password = this.emailGroup.controls['password']; + this.phoneGroup = this.form.controls['phoneGroup']; + this.phone = this.phoneGroup.controls['phone']; + this.validateCode = this.phoneGroup.controls['validateCode']; + } + public changeLogin():void { + + if(this.animationState == 'in'){ + this.animationState = 'out' + }else { + this.animationState = 'in' + } + this.emailLogin = !this.emailLogin; + } + public sendNote():void{ + this.cdType = true; + let num = this.countDown; + let observable = Observable.interval(1000).take(this.countDown); + let subscription = observable.subscribe(x => { + this.countDown =num - x-1; + if(this.countDown==0){ + this.cdType = false; + this.countDown = num; + } + }); + this.loginService.sendNote({phone:this.phone.value}).subscribe((response)=>{ + alert(response.resultMess); + }) + } + public onSubmit(form:FormGroup):void { + this.submitted = true; + if (this.emailLogin&& form.controls.emailGroup.valid) { + let values = form.controls.emailGroup.value; + this.loginService.postLogin({ + email:values.email, + password:values.password}).subscribe((response)=>{ + if(response.resultCode ==1){ + this.router.navigate(['/pages/home']); + } else { + alert(response.resultMess) + } + }) + } else if (!this.emailLogin&& form.controls.phoneGroup.valid){ + let values = form.controls.phoneGroup.value; + this.loginService.postLoginByNote({ + phone:values.phone, + validateCode:values.validateCode}).subscribe((response)=>{ + if(response.resultCode ==1){ + this.router.navigate(['/pages/home']); + } else { + alert(response.resultMess) + } + }) + } + } +} diff --git a/side_client/app/pages/login/login.html b/app/public/app/pages/login/login.html similarity index 98% rename from side_client/app/pages/login/login.html rename to app/public/app/pages/login/login.html index 71b4d23..8a4d1bb 100644 --- a/side_client/app/pages/login/login.html +++ b/app/public/app/pages/login/login.html @@ -1,62 +1,62 @@ -
-
-

登录

- 注册 -
- -
-
- - -
- -
-
-
- -
-
- -
- - -
-
-
-
-
- - - 忘记密码 -
- -
-
- -
其他登录方式 -
- - -
+
+
+

登录

+ 注册 +
+ +
+
+ + +
+ +
+
+
+ +
+
+ +
+ + +
+
+
+
+
+ + + 忘记密码 +
+ +
+
+ +
其他登录方式 +
+ + +
\ No newline at end of file diff --git a/side_client/app/pages/login/login.less b/app/public/app/pages/login/login.less similarity index 94% rename from side_client/app/pages/login/login.less rename to app/public/app/pages/login/login.less index 023b1c0..68f1757 100644 --- a/side_client/app/pages/login/login.less +++ b/app/public/app/pages/login/login.less @@ -1,146 +1,146 @@ -@text-color: #ffffff; -.auth-main { - display: flex; - align-items: center; - height: 100%; - width: 100%; - position: absolute; - left:0; - } - - .auth-block { - width: 90%; - margin: 0 auto; - border-radius: 5px; - color: #fff; - padding: 32px; - background: rgba(0,0,0,0.55); - h1 { - margin-bottom: 28px; - text-align: center; - } - p { - font-size: 16px; - } - a { - text-decoration: none; - outline: none; - transition: all 0.2s ease; - &:hover { - - } - } - - .control-label { - padding-top: 11px; - color: @text-color; - } - - .form-group { - margin-bottom: 12px; - &.input-label { - margin: 0; - } - } - } - - .auth-input { - width: 300px; - margin-bottom: 24px; - input { - display: block; - width: 100%; - border: none; - font-size: 16px; - padding: 4px 10px; - outline: none; - } - } - - a.forgot-pass { - display: block; - text-align: right; - margin-bottom: -20px; - float: right; - z-index: 2; - position: relative; - } - - .auth-link { - display: block; - font-size: 16px; - text-align: center; - margin-bottom: 33px; - } - - .auth-sep { - margin-top: 36px; - margin-bottom: 24px; - line-height: 20px; - font-size: 16px; - text-align: center; - display: block; - position: relative; - & > span { - display: table-cell; - width: 30%; - white-space: nowrap; - padding: 0 24px; - color: @text-color; - & > span { - margin-top: -12px; - display: block; - } - } - &:before, &:after { - border-top: solid 1px @text-color; - content: ""; - height: 1px; - width: 35%; - display: table-cell; - } - } - - .al-share-auth { - text-align: center; - .al-share { - float: none; - margin: 0; - padding: 0; - display: inline-block; - li { - margin-left: 24px; - &:first-child { - margin-left: 0; - } - i { - font-size: 24px; - } - } - } - } - - .btn-auth { - color: #ffffff!important; - } - .has-error .form-control { - border: 1px solid #fa758e; -} - -button.btn.btn-default { - border-width: 1px; - color: #fff; - background: transparent; - border-color: rgba(255,255,255,0.5); -} - -.al-share { - list-style: none; - li a { - color: inherit; - } -} -.login-change { - text-align: center; - padding-top: 12px; -} +@text-color: #ffffff; +.auth-main { + display: flex; + align-items: center; + height: 100%; + width: 100%; + position: absolute; + left:0; + } + + .auth-block { + width: 90%; + margin: 0 auto; + border-radius: 5px; + color: #fff; + padding: 32px; + background: rgba(0,0,0,0.55); + h1 { + margin-bottom: 28px; + text-align: center; + } + p { + font-size: 16px; + } + a { + text-decoration: none; + outline: none; + transition: all 0.2s ease; + &:hover { + + } + } + + .control-label { + padding-top: 11px; + color: @text-color; + } + + .form-group { + margin-bottom: 12px; + &.input-label { + margin: 0; + } + } + } + + .auth-input { + width: 300px; + margin-bottom: 24px; + input { + display: block; + width: 100%; + border: none; + font-size: 16px; + padding: 4px 10px; + outline: none; + } + } + + a.forgot-pass { + display: block; + text-align: right; + margin-bottom: -20px; + float: right; + z-index: 2; + position: relative; + } + + .auth-link { + display: block; + font-size: 16px; + text-align: center; + margin-bottom: 33px; + } + + .auth-sep { + margin-top: 36px; + margin-bottom: 24px; + line-height: 20px; + font-size: 16px; + text-align: center; + display: block; + position: relative; + & > span { + display: table-cell; + width: 30%; + white-space: nowrap; + padding: 0 24px; + color: @text-color; + & > span { + margin-top: -12px; + display: block; + } + } + &:before, &:after { + border-top: solid 1px @text-color; + content: ""; + height: 1px; + width: 35%; + display: table-cell; + } + } + + .al-share-auth { + text-align: center; + .al-share { + float: none; + margin: 0; + padding: 0; + display: inline-block; + li { + margin-left: 24px; + &:first-child { + margin-left: 0; + } + i { + font-size: 24px; + } + } + } + } + + .btn-auth { + color: #ffffff!important; + } + .has-error .form-control { + border: 1px solid #fa758e; +} + +button.btn.btn-default { + border-width: 1px; + color: #fff; + background: transparent; + border-color: rgba(255,255,255,0.5); +} + +.al-share { + list-style: none; + li a { + color: inherit; + } +} +.login-change { + text-align: center; + padding-top: 12px; +} diff --git a/side_client/app/pages/login/login.module.ts b/app/public/app/pages/login/login.module.ts similarity index 95% rename from side_client/app/pages/login/login.module.ts rename to app/public/app/pages/login/login.module.ts index c2aa97c..c9afa9a 100644 --- a/side_client/app/pages/login/login.module.ts +++ b/app/public/app/pages/login/login.module.ts @@ -1,20 +1,20 @@ -import { routing } from './login.routing'; -import { NgModule } from '@angular/core'; -import { CommonModule } from '@angular/common'; -import { FormsModule, ReactiveFormsModule } from '@angular/forms'; - -import { Login } from './login.component'; - - -@NgModule({ - imports: [ - CommonModule, - ReactiveFormsModule, - FormsModule, - routing - ], - declarations: [ - Login - ] -}) -export class LoginModule {} +import { routing } from './login.routing'; +import { NgModule } from '@angular/core'; +import { CommonModule } from '@angular/common'; +import { FormsModule, ReactiveFormsModule } from '@angular/forms'; + +import { Login } from './login.component'; + + +@NgModule({ + imports: [ + CommonModule, + ReactiveFormsModule, + FormsModule, + routing + ], + declarations: [ + Login + ] +}) +export class LoginModule {} diff --git a/side_client/app/pages/login/login.routing.ts b/app/public/app/pages/login/login.routing.ts similarity index 96% rename from side_client/app/pages/login/login.routing.ts rename to app/public/app/pages/login/login.routing.ts index f9bb9b4..3b4796b 100644 --- a/side_client/app/pages/login/login.routing.ts +++ b/app/public/app/pages/login/login.routing.ts @@ -1,14 +1,14 @@ -import { Routes, RouterModule } from '@angular/router'; - -import { Login } from './login.component'; -import { ModuleWithProviders } from '@angular/core'; - -// noinspection TypeScriptValidateTypes -export const routes: Routes = [ - { - path: '', - component: Login - } -]; - -export const routing: ModuleWithProviders = RouterModule.forChild(routes); +import { Routes, RouterModule } from '@angular/router'; + +import { Login } from './login.component'; +import { ModuleWithProviders } from '@angular/core'; + +// noinspection TypeScriptValidateTypes +export const routes: Routes = [ + { + path: '', + component: Login + } +]; + +export const routing: ModuleWithProviders = RouterModule.forChild(routes); diff --git a/side_client/app/pages/login/login.service.ts b/app/public/app/pages/login/login.service.ts similarity index 96% rename from side_client/app/pages/login/login.service.ts rename to app/public/app/pages/login/login.service.ts index fe7d0a3..a36dda0 100644 --- a/side_client/app/pages/login/login.service.ts +++ b/app/public/app/pages/login/login.service.ts @@ -1,16 +1,16 @@ -import { HttpClient } from '@angular/common/http'; -import { Injectable,Inject } from '@angular/core'; - -@Injectable() -export class LoginService { - constructor(private http:HttpClient){} - postLogin(obj){ - return this.http.post(CONFIGNI.postLogin,obj); - } - postLoginByNote(obj){ - return this.http.post(CONFIGNI.postLoginByNote,obj); - } - sendNote(obj){ - return this.http.post(CONFIGNI.sendNote,obj); - } +import { HttpClient } from '@angular/common/http'; +import { Injectable,Inject } from '@angular/core'; + +@Injectable() +export class LoginService { + constructor(private http:HttpClient){} + postLogin(obj){ + return this.http.post(CONFIGNI.postLogin,obj); + } + postLoginByNote(obj){ + return this.http.post(CONFIGNI.postLoginByNote,obj); + } + sendNote(obj){ + return this.http.post(CONFIGNI.sendNote,obj); + } } \ No newline at end of file diff --git a/side_client/app/pages/pages.component.ts b/app/public/app/pages/pages.component.ts similarity index 95% rename from side_client/app/pages/pages.component.ts rename to app/public/app/pages/pages.component.ts index 3f2cdb1..e708577 100644 --- a/side_client/app/pages/pages.component.ts +++ b/app/public/app/pages/pages.component.ts @@ -1,25 +1,25 @@ - -import { Component} from '@angular/core'; -import { Routes } from '@angular/router'; - -import { BaMenuService } from '../theme'; -import { PAGES_MENU } from './pages.menu'; - -@Component({ - selector: 'pages', - template: ` - -
- -
- `, - styles:['.wrap {padding-top:60px;}'] -}) -export class Pages { - constructor(private _menuService:BaMenuService){ - - } - ngOnInit(){ - this._menuService.updateMenuByRoutes(PAGES_MENU); - } + +import { Component} from '@angular/core'; +import { Routes } from '@angular/router'; + +import { BaMenuService } from '../theme'; +import { PAGES_MENU } from './pages.menu'; + +@Component({ + selector: 'pages', + template: ` + +
+ +
+ `, + styles:['.wrap {padding-top:60px;}'] +}) +export class Pages { + constructor(private _menuService:BaMenuService){ + + } + ngOnInit(){ + this._menuService.updateMenuByRoutes(PAGES_MENU); + } } \ No newline at end of file diff --git a/side_client/app/pages/pages.menu.ts b/app/public/app/pages/pages.menu.ts similarity index 95% rename from side_client/app/pages/pages.menu.ts rename to app/public/app/pages/pages.menu.ts index 6d63ff7..3056b3b 100644 --- a/side_client/app/pages/pages.menu.ts +++ b/app/public/app/pages/pages.menu.ts @@ -1,32 +1,32 @@ -export const PAGES_MENU = [ - { - path: 'pages', - children: [ - { - path: 'home', - data: { - menu: { - title: '首页', - icon: 'fa fa-home', - selected: false, - expanded: false, - order: 0 - } - } - }, - { - path: 'publish', - data: { - menu: { - title: '发布', - icon: 'fa fa-edit', - selected: false, - expanded: false, - order: 50, - } - } - } - ] - } - ]; +export const PAGES_MENU = [ + { + path: 'pages', + children: [ + { + path: 'home', + data: { + menu: { + title: '首页', + icon: 'fa fa-home', + selected: false, + expanded: false, + order: 0 + } + } + }, + { + path: 'publish', + data: { + menu: { + title: '发布', + icon: 'fa fa-edit', + selected: false, + expanded: false, + order: 50, + } + } + } + ] + } + ]; \ No newline at end of file diff --git a/side_client/app/pages/pages.module.ts b/app/public/app/pages/pages.module.ts similarity index 96% rename from side_client/app/pages/pages.module.ts rename to app/public/app/pages/pages.module.ts index ea82903..e443e01 100644 --- a/side_client/app/pages/pages.module.ts +++ b/app/public/app/pages/pages.module.ts @@ -1,19 +1,19 @@ - -import { FormsModule } from '@angular/forms'; -import { AuthGuard } from '../auth.guard.service'; -import { HomeModule } from './home/home.module'; -import { PnfModule } from '../theme/pnf.module'; -import { NgModule } from '@angular/core'; -import { CommonModule } from '@angular/common'; - -import { routing } from './pages.routing'; - -import { Pages } from './pages.component'; - -@NgModule({ - imports: [CommonModule,HomeModule,PnfModule,routing], - declarations: [Pages], - providers:[AuthGuard] -}) -export class PagesModule { -} + +import { FormsModule } from '@angular/forms'; +import { AuthGuard } from '../auth.guard.service'; +import { HomeModule } from './home/home.module'; +import { PnfModule } from '../theme/pnf.module'; +import { NgModule } from '@angular/core'; +import { CommonModule } from '@angular/common'; + +import { routing } from './pages.routing'; + +import { Pages } from './pages.component'; + +@NgModule({ + imports: [CommonModule,HomeModule,PnfModule,routing], + declarations: [Pages], + providers:[AuthGuard] +}) +export class PagesModule { +} diff --git a/side_client/app/pages/pages.routing.ts b/app/public/app/pages/pages.routing.ts similarity index 96% rename from side_client/app/pages/pages.routing.ts rename to app/public/app/pages/pages.routing.ts index 4095db8..03e209d 100644 --- a/side_client/app/pages/pages.routing.ts +++ b/app/public/app/pages/pages.routing.ts @@ -1,36 +1,36 @@ -import { AuthGuard } from '../auth.guard.service'; -import { HomeComponent } from './home/home.component'; -import { Routes, RouterModule } from '@angular/router'; -import { Pages } from './pages.component'; -import { ModuleWithProviders } from '@angular/core'; - -export const routes: Routes = [ - { - path: 'login', - loadChildren: './login/login.module#LoginModule' - }, - { - path: 'register', - loadChildren: './register/register.module#RegisterModule' - }, - { - path: 'forget', - loadChildren: './forget/forget.module#ForgetModule' - }, - { - path: 'reset/:token', - loadChildren: './reset/reset.module#ResetModule' - }, - { - path: 'pages', - component: Pages, - children: [ - { path: '', redirectTo: 'home', pathMatch: 'full' }, - { path: 'home', component: HomeComponent }, - { path: 'detail/:id', loadChildren:'./detail/detail.module#DetailModule' }, - { path: 'publish', loadChildren:'./publish/publish.module#PublishModule',canLoad:[AuthGuard] } - ] - } -]; - -export const routing: ModuleWithProviders = RouterModule.forChild(routes); +import { AuthGuard } from '../auth.guard.service'; +import { HomeComponent } from './home/home.component'; +import { Routes, RouterModule } from '@angular/router'; +import { Pages } from './pages.component'; +import { ModuleWithProviders } from '@angular/core'; + +export const routes: Routes = [ + { + path: 'login', + loadChildren: './login/login.module#LoginModule' + }, + { + path: 'register', + loadChildren: './register/register.module#RegisterModule' + }, + { + path: 'forget', + loadChildren: './forget/forget.module#ForgetModule' + }, + { + path: 'reset/:token', + loadChildren: './reset/reset.module#ResetModule' + }, + { + path: 'pages', + component: Pages, + children: [ + { path: '', redirectTo: 'home', pathMatch: 'full' }, + { path: 'home', component: HomeComponent }, + { path: 'detail/:id', loadChildren:'./detail/detail.module#DetailModule' }, + { path: 'publish', loadChildren:'./publish/publish.module#PublishModule',canLoad:[AuthGuard] } + ] + } +]; + +export const routing: ModuleWithProviders = RouterModule.forChild(routes); diff --git a/side_client/app/pages/publish/index.ts b/app/public/app/pages/publish/index.ts similarity index 100% rename from side_client/app/pages/publish/index.ts rename to app/public/app/pages/publish/index.ts diff --git a/side_client/app/pages/publish/publish.component.ts b/app/public/app/pages/publish/publish.component.ts similarity index 97% rename from side_client/app/pages/publish/publish.component.ts rename to app/public/app/pages/publish/publish.component.ts index 93c7f64..f884953 100644 --- a/side_client/app/pages/publish/publish.component.ts +++ b/app/public/app/pages/publish/publish.component.ts @@ -1,57 +1,57 @@ -import { PublishService } from './publish.service'; -import {environment} from '../../../environments/environment'; -import { Component, OnInit } from '@angular/core'; -import {FormGroup, AbstractControl, FormBuilder, Validators} from '@angular/forms'; -import { Router } from '@angular/router'; - -@Component({ - selector: 'publish', - templateUrl: './publish.html', - styleUrls: ['./publish.less'] -}) -export class PublishComponent{ - public form:FormGroup; - public title:AbstractControl; - public editor:AbstractControl; - public submitted:boolean = false; - constructor(private fb:FormBuilder,private publishService:PublishService,private router:Router ) { - this.form = fb.group({ - 'title': ['', Validators.compose([Validators.required])], - 'editor':['',Validators.compose([Validators.required])] - }); - this.title = this.form.controls['title']; - this.editor = this.form.controls['editor']; - } - public onSubmit(values:any):void { - this.submitted = true; - if (this.form.valid) { - this.publishService.postPublish(values).subscribe(response=>{ - if(response.resultCode ==1){ - alert('发布成功'); - this.router.navigate(['/page/home']); - } - }) - } - } - public setControlValue(html){ - this.form.patchValue({'editor':html}); - } - public options: any = { - placeholderText: '在这里编辑!', - language:'zh_cn', - imageUploadURL:environment.realHost + CONFIGNI.upload, - imageErrorCallback: (data)=> { - console.log(data) - }, - events : { - 'froalaEditor.focus' : (e, editor)=> { - var html = editor.html.get(); - this.setControlValue(html); - }, - 'froalaEditor.contentChanged': (e, editor)=> { - var html = editor.html.get(); - this.setControlValue(html); - }, - } - } +import { PublishService } from './publish.service'; +import {environment} from '../../../environments/environment'; +import { Component, OnInit } from '@angular/core'; +import {FormGroup, AbstractControl, FormBuilder, Validators} from '@angular/forms'; +import { Router } from '@angular/router'; + +@Component({ + selector: 'publish', + templateUrl: './publish.html', + styleUrls: ['./publish.less'] +}) +export class PublishComponent{ + public form:FormGroup; + public title:AbstractControl; + public editor:AbstractControl; + public submitted:boolean = false; + constructor(private fb:FormBuilder,private publishService:PublishService,private router:Router ) { + this.form = fb.group({ + 'title': ['', Validators.compose([Validators.required])], + 'editor':['',Validators.compose([Validators.required])] + }); + this.title = this.form.controls['title']; + this.editor = this.form.controls['editor']; + } + public onSubmit(values:any):void { + this.submitted = true; + if (this.form.valid) { + this.publishService.postPublish(values).subscribe(response=>{ + if(response.resultCode ==1){ + alert('发布成功'); + this.router.navigate(['/page/home']); + } + }) + } + } + public setControlValue(html){ + this.form.patchValue({'editor':html}); + } + public options: any = { + placeholderText: '在这里编辑!', + language:'zh_cn', + imageUploadURL:environment.realHost + CONFIGNI.upload, + imageErrorCallback: (data)=> { + console.log(data) + }, + events : { + 'froalaEditor.focus' : (e, editor)=> { + var html = editor.html.get(); + this.setControlValue(html); + }, + 'froalaEditor.contentChanged': (e, editor)=> { + var html = editor.html.get(); + this.setControlValue(html); + }, + } + } } \ No newline at end of file diff --git a/side_client/app/pages/publish/publish.html b/app/public/app/pages/publish/publish.html similarity index 98% rename from side_client/app/pages/publish/publish.html rename to app/public/app/pages/publish/publish.html index 7d5c969..000bc56 100644 --- a/side_client/app/pages/publish/publish.html +++ b/app/public/app/pages/publish/publish.html @@ -1,13 +1,13 @@ -
-
-
- -
-
-
-
-
- -
-
+
+
+
+ +
+
+
+
+
+ +
+
\ No newline at end of file diff --git a/side_client/app/pages/publish/publish.less b/app/public/app/pages/publish/publish.less similarity index 94% rename from side_client/app/pages/publish/publish.less rename to app/public/app/pages/publish/publish.less index 1869d86..c1b5942 100644 --- a/side_client/app/pages/publish/publish.less +++ b/app/public/app/pages/publish/publish.less @@ -1,41 +1,41 @@ -.publish-ui { - position: absolute; - top: 60px; - right: 0; - left: 0; - bottom: 0; - z-index: 2; - .title { - height: 40px; - input { - width: 100%; - height: 40px; - border: 0; - padding: 0 12px; - } - - } - .has-error .form-control { - border: 1px solid #fa758e; - } - .editor-layout { - position: absolute; - z-index: 9; - top: 40px; - bottom: 40px; - left: 0; - right: 0; - overflow-y: auto; - } - .publish-btn { - position: absolute; - left: 0; - height: 40px; - vertical-align: middle; - width: 100%; - bottom: 0; - text-align: center; - } -} - - +.publish-ui { + position: absolute; + top: 60px; + right: 0; + left: 0; + bottom: 0; + z-index: 2; + .title { + height: 40px; + input { + width: 100%; + height: 40px; + border: 0; + padding: 0 12px; + } + + } + .has-error .form-control { + border: 1px solid #fa758e; + } + .editor-layout { + position: absolute; + z-index: 9; + top: 40px; + bottom: 40px; + left: 0; + right: 0; + overflow-y: auto; + } + .publish-btn { + position: absolute; + left: 0; + height: 40px; + vertical-align: middle; + width: 100%; + bottom: 0; + text-align: center; + } +} + + diff --git a/side_client/app/pages/publish/publish.module.ts b/app/public/app/pages/publish/publish.module.ts similarity index 97% rename from side_client/app/pages/publish/publish.module.ts rename to app/public/app/pages/publish/publish.module.ts index 39e213d..59dc364 100644 --- a/side_client/app/pages/publish/publish.module.ts +++ b/app/public/app/pages/publish/publish.module.ts @@ -1,15 +1,15 @@ -import { PublishService } from './publish.service'; -import { routing } from './publish.routing'; -import { PublishComponent } from './publish.component'; -import { NgModule } from '@angular/core'; -import { CommonModule } from '@angular/common'; -import { FormsModule, ReactiveFormsModule } from '@angular/forms'; -import { FroalaEditorModule, FroalaViewModule } from 'angular-froala-wysiwyg'; - - -@NgModule({ - declarations: [PublishComponent], - imports: [ CommonModule,ReactiveFormsModule,routing,FroalaEditorModule.forRoot(), FroalaViewModule.forRoot() ], - providers:[PublishService] -}) +import { PublishService } from './publish.service'; +import { routing } from './publish.routing'; +import { PublishComponent } from './publish.component'; +import { NgModule } from '@angular/core'; +import { CommonModule } from '@angular/common'; +import { FormsModule, ReactiveFormsModule } from '@angular/forms'; +import { FroalaEditorModule, FroalaViewModule } from 'angular-froala-wysiwyg'; + + +@NgModule({ + declarations: [PublishComponent], + imports: [ CommonModule,ReactiveFormsModule,routing,FroalaEditorModule.forRoot(), FroalaViewModule.forRoot() ], + providers:[PublishService] +}) export class PublishModule {} \ No newline at end of file diff --git a/side_client/app/pages/publish/publish.routing.ts b/app/public/app/pages/publish/publish.routing.ts similarity index 96% rename from side_client/app/pages/publish/publish.routing.ts rename to app/public/app/pages/publish/publish.routing.ts index 0c1f5f9..0352d4e 100644 --- a/side_client/app/pages/publish/publish.routing.ts +++ b/app/public/app/pages/publish/publish.routing.ts @@ -1,13 +1,13 @@ -import { PublishComponent } from './publish.component'; -import { Routes, RouterModule } from '@angular/router'; - -import { ModuleWithProviders } from '@angular/core'; - -export const routes: Routes = [ - { - path: '', - component: PublishComponent - } -]; - -export const routing: ModuleWithProviders = RouterModule.forChild(routes); +import { PublishComponent } from './publish.component'; +import { Routes, RouterModule } from '@angular/router'; + +import { ModuleWithProviders } from '@angular/core'; + +export const routes: Routes = [ + { + path: '', + component: PublishComponent + } +]; + +export const routing: ModuleWithProviders = RouterModule.forChild(routes); diff --git a/side_client/app/pages/publish/publish.service.ts b/app/public/app/pages/publish/publish.service.ts similarity index 96% rename from side_client/app/pages/publish/publish.service.ts rename to app/public/app/pages/publish/publish.service.ts index fb00664..b57a08b 100644 --- a/side_client/app/pages/publish/publish.service.ts +++ b/app/public/app/pages/publish/publish.service.ts @@ -1,10 +1,10 @@ -import { Injectable } from '@angular/core'; -import { HttpClient } from '@angular/common/http'; - -@Injectable() -export class PublishService { - constructor(private http:HttpClient){} - public postPublish(obj){ - return this.http.post(CONFIGNI.publish,obj); - } +import { Injectable } from '@angular/core'; +import { HttpClient } from '@angular/common/http'; + +@Injectable() +export class PublishService { + constructor(private http:HttpClient){} + public postPublish(obj){ + return this.http.post(CONFIGNI.publish,obj); + } } \ No newline at end of file diff --git a/side_client/app/pages/register/index.ts b/app/public/app/pages/register/index.ts similarity index 100% rename from side_client/app/pages/register/index.ts rename to app/public/app/pages/register/index.ts diff --git a/side_client/app/pages/register/register.component.ts b/app/public/app/pages/register/register.component.ts similarity index 97% rename from side_client/app/pages/register/register.component.ts rename to app/public/app/pages/register/register.component.ts index 2aa87d6..1e26eae 100644 --- a/side_client/app/pages/register/register.component.ts +++ b/app/public/app/pages/register/register.component.ts @@ -1,58 +1,58 @@ -import { RegisterService } from './register.service'; -import {Component} from '@angular/core'; -import {FormGroup, AbstractControl, FormBuilder, Validators} from '@angular/forms'; -import {EmailValidator, EqualPasswordsValidator} from '../../theme/validators'; -import { Router } from '@angular/router'; - -@Component({ - selector: 'register', - templateUrl: './register.html', - styleUrls: ['./register.less'], - providers:[RegisterService] -}) -export class Register { - - public form:FormGroup; - public name:AbstractControl; - public email:AbstractControl; - public password:AbstractControl; - public repeatPassword:AbstractControl; - public passwords:FormGroup; - - public submitted:boolean = false; - - constructor(fb:FormBuilder,private registerService:RegisterService,private router:Router) { - - this.form = fb.group({ - 'name': ['', Validators.compose([Validators.required, Validators.minLength(4)])], - 'email': ['', Validators.compose([Validators.required, EmailValidator.validate])], - 'passwords': fb.group({ - 'password': ['', Validators.compose([Validators.required, Validators.minLength(4)])], - 'repeatPassword': ['', Validators.compose([Validators.required, Validators.minLength(4)])] - }, {validator: EqualPasswordsValidator.validate('password', 'repeatPassword')}) - }); - - this.name = this.form.controls['name']; - this.email = this.form.controls['email']; - this.passwords = this.form.get('passwords') as FormGroup; - this.password = this.form.get('passwords.password'); - this.repeatPassword =this.form.get('passwords.repeatPassword'); - } - - - public onSubmit(values:any):void { - this.submitted = true; - if (this.form.valid) { - this.registerService.postRegister({ - name:values.name, - email:values.email, - password:values.passwords.password - }).subscribe((response)=>{ - alert(response.resultMess); - if(response.resultCode ==1){ - this.router.navigate(['/pages/home']); - } - }) - } - } -} +import { RegisterService } from './register.service'; +import {Component} from '@angular/core'; +import {FormGroup, AbstractControl, FormBuilder, Validators} from '@angular/forms'; +import {EmailValidator, EqualPasswordsValidator} from '../../theme/validators'; +import { Router } from '@angular/router'; + +@Component({ + selector: 'register', + templateUrl: './register.html', + styleUrls: ['./register.less'], + providers:[RegisterService] +}) +export class Register { + + public form:FormGroup; + public name:AbstractControl; + public email:AbstractControl; + public password:AbstractControl; + public repeatPassword:AbstractControl; + public passwords:FormGroup; + + public submitted:boolean = false; + + constructor(fb:FormBuilder,private registerService:RegisterService,private router:Router) { + + this.form = fb.group({ + 'name': ['', Validators.compose([Validators.required, Validators.minLength(4)])], + 'email': ['', Validators.compose([Validators.required, EmailValidator.validate])], + 'passwords': fb.group({ + 'password': ['', Validators.compose([Validators.required, Validators.minLength(4)])], + 'repeatPassword': ['', Validators.compose([Validators.required, Validators.minLength(4)])] + }, {validator: EqualPasswordsValidator.validate('password', 'repeatPassword')}) + }); + + this.name = this.form.controls['name']; + this.email = this.form.controls['email']; + this.passwords = this.form.get('passwords') as FormGroup; + this.password = this.form.get('passwords.password'); + this.repeatPassword =this.form.get('passwords.repeatPassword'); + } + + + public onSubmit(values:any):void { + this.submitted = true; + if (this.form.valid) { + this.registerService.postRegister({ + name:values.name, + email:values.email, + password:values.passwords.password + }).subscribe((response)=>{ + alert(response.resultMess); + if(response.resultCode ==1){ + this.router.navigate(['/pages/home']); + } + }) + } + } +} diff --git a/side_client/app/pages/register/register.html b/app/public/app/pages/register/register.html similarity index 98% rename from side_client/app/pages/register/register.html rename to app/public/app/pages/register/register.html index 4cfc102..c807f9b 100644 --- a/side_client/app/pages/register/register.html +++ b/app/public/app/pages/register/register.html @@ -1,44 +1,44 @@ -
-
-

注册

- 登录 -
-
- - -
- -
-
-
- - -
- -
-
-
-
- - -
- -
-
-
- - -
- - 密码不相同 -
-
-
-
-
- -
-
-
-
+
+
+

注册

+ 登录 +
+
+ + +
+ +
+
+
+ + +
+ +
+
+
+
+ + +
+ +
+
+
+ + +
+ + 密码不相同 +
+
+
+
+
+ +
+
+
+
\ No newline at end of file diff --git a/side_client/app/pages/register/register.less b/app/public/app/pages/register/register.less similarity index 100% rename from side_client/app/pages/register/register.less rename to app/public/app/pages/register/register.less diff --git a/side_client/app/pages/register/register.module.ts b/app/public/app/pages/register/register.module.ts similarity index 95% rename from side_client/app/pages/register/register.module.ts rename to app/public/app/pages/register/register.module.ts index d81a0ed..fd5c034 100644 --- a/side_client/app/pages/register/register.module.ts +++ b/app/public/app/pages/register/register.module.ts @@ -1,22 +1,22 @@ -import { NgModule } from '@angular/core'; -import { CommonModule, } from '@angular/common'; -import { FormsModule, ReactiveFormsModule } from '@angular/forms'; -import { PnfModule } from '../../theme/pnf.module'; - -import { Register } from './register.component'; -import { routing } from './register.routing'; - - -@NgModule({ - imports: [ - CommonModule, - ReactiveFormsModule, - FormsModule, - PnfModule, - routing - ], - declarations: [ - Register - ] -}) -export class RegisterModule {} +import { NgModule } from '@angular/core'; +import { CommonModule, } from '@angular/common'; +import { FormsModule, ReactiveFormsModule } from '@angular/forms'; +import { PnfModule } from '../../theme/pnf.module'; + +import { Register } from './register.component'; +import { routing } from './register.routing'; + + +@NgModule({ + imports: [ + CommonModule, + ReactiveFormsModule, + FormsModule, + PnfModule, + routing + ], + declarations: [ + Register + ] +}) +export class RegisterModule {} diff --git a/side_client/app/pages/register/register.routing.ts b/app/public/app/pages/register/register.routing.ts similarity index 96% rename from side_client/app/pages/register/register.routing.ts rename to app/public/app/pages/register/register.routing.ts index 01c2950..13aaa9e 100644 --- a/side_client/app/pages/register/register.routing.ts +++ b/app/public/app/pages/register/register.routing.ts @@ -1,14 +1,14 @@ -import { Routes, RouterModule } from '@angular/router'; - -import { Register } from './register.component'; -import { ModuleWithProviders } from '@angular/core'; - -// noinspection TypeScriptValidateTypes -export const routes: Routes = [ - { - path: '', - component: Register - } -]; - -export const routing: ModuleWithProviders = RouterModule.forChild(routes); +import { Routes, RouterModule } from '@angular/router'; + +import { Register } from './register.component'; +import { ModuleWithProviders } from '@angular/core'; + +// noinspection TypeScriptValidateTypes +export const routes: Routes = [ + { + path: '', + component: Register + } +]; + +export const routing: ModuleWithProviders = RouterModule.forChild(routes); diff --git a/side_client/app/pages/register/register.service.ts b/app/public/app/pages/register/register.service.ts similarity index 96% rename from side_client/app/pages/register/register.service.ts rename to app/public/app/pages/register/register.service.ts index 3be9855..a5ccfa0 100644 --- a/side_client/app/pages/register/register.service.ts +++ b/app/public/app/pages/register/register.service.ts @@ -1,11 +1,11 @@ - -import { HttpClient } from '@angular/common/http'; -import { Injectable,Inject } from '@angular/core'; - -@Injectable() -export class RegisterService { - constructor(private http:HttpClient){} - postRegister(obj){ - return this.http.post(CONFIGNI.postRegister,obj); - } + +import { HttpClient } from '@angular/common/http'; +import { Injectable,Inject } from '@angular/core'; + +@Injectable() +export class RegisterService { + constructor(private http:HttpClient){} + postRegister(obj){ + return this.http.post(CONFIGNI.postRegister,obj); + } } \ No newline at end of file diff --git a/side_client/app/pages/reset/index.ts b/app/public/app/pages/reset/index.ts similarity index 100% rename from side_client/app/pages/reset/index.ts rename to app/public/app/pages/reset/index.ts diff --git a/side_client/app/pages/reset/reset.component.ts b/app/public/app/pages/reset/reset.component.ts similarity index 97% rename from side_client/app/pages/reset/reset.component.ts rename to app/public/app/pages/reset/reset.component.ts index 62185eb..2473f9f 100644 --- a/side_client/app/pages/reset/reset.component.ts +++ b/app/public/app/pages/reset/reset.component.ts @@ -1,51 +1,51 @@ -import { ResetService } from './reset.service'; -import { Component, OnInit } from '@angular/core'; -import { FormGroup, AbstractControl, FormBuilder, Validators } from '@angular/forms'; -import { Router,ActivatedRoute,ParamMap } from '@angular/router'; -import 'rxjs/add/operator/switchMap'; -import 'rxjs/add/operator/map'; -import { Observable } from 'rxjs/Observable'; - -@Component({ - selector: 'reset', - templateUrl: './reset.html', - styleUrls: ['./reset.less'], - providers:[ResetService] -}) -export class ResetComponent implements OnInit { - token:string; - public form:FormGroup; - public email:AbstractControl; - public password:AbstractControl; - public submitted:boolean = false; - constructor(fb:FormBuilder,private resetService:ResetService,private router:Router,private route:ActivatedRoute) { - this.form = fb.group({ - 'password': ['', Validators.compose([Validators.required, Validators.minLength(4)])] - }); - - this.password = this.form.controls['password']; - } - public onSubmit(values:any):void { - this.submitted = true; - if (this.form.valid) { - this.resetService.postRest({ - token:this.token, - password:values.password}).subscribe((response)=>{ - alert(response.resultMess); - if(response.resultCode ==1){ - this.router.navigate(['/pages/home']); - } - }) - } - } - ngOnInit(){ - this.route.paramMap - .switchMap((params: ParamMap) => { - let str = params.get('token'); - this.token = str; - return str; - }).subscribe(res=>{ - }) - } - +import { ResetService } from './reset.service'; +import { Component, OnInit } from '@angular/core'; +import { FormGroup, AbstractControl, FormBuilder, Validators } from '@angular/forms'; +import { Router,ActivatedRoute,ParamMap } from '@angular/router'; +import 'rxjs/add/operator/switchMap'; +import 'rxjs/add/operator/map'; +import { Observable } from 'rxjs/Observable'; + +@Component({ + selector: 'reset', + templateUrl: './reset.html', + styleUrls: ['./reset.less'], + providers:[ResetService] +}) +export class ResetComponent implements OnInit { + token:string; + public form:FormGroup; + public email:AbstractControl; + public password:AbstractControl; + public submitted:boolean = false; + constructor(fb:FormBuilder,private resetService:ResetService,private router:Router,private route:ActivatedRoute) { + this.form = fb.group({ + 'password': ['', Validators.compose([Validators.required, Validators.minLength(4)])] + }); + + this.password = this.form.controls['password']; + } + public onSubmit(values:any):void { + this.submitted = true; + if (this.form.valid) { + this.resetService.postRest({ + token:this.token, + password:values.password}).subscribe((response)=>{ + alert(response.resultMess); + if(response.resultCode ==1){ + this.router.navigate(['/pages/home']); + } + }) + } + } + ngOnInit(){ + this.route.paramMap + .switchMap((params: ParamMap) => { + let str = params.get('token'); + this.token = str; + return str; + }).subscribe(res=>{ + }) + } + } \ No newline at end of file diff --git a/side_client/app/pages/reset/reset.html b/app/public/app/pages/reset/reset.html similarity index 98% rename from side_client/app/pages/reset/reset.html rename to app/public/app/pages/reset/reset.html index 9114141..cb4ce19 100644 --- a/side_client/app/pages/reset/reset.html +++ b/app/public/app/pages/reset/reset.html @@ -1,19 +1,19 @@ -
-
-

重置密码

-
-
- - -
- -
-
-
-
- -
-
-
-
+
+
+

重置密码

+
+
+ + +
+ +
+
+
+
+ +
+
+
+
\ No newline at end of file diff --git a/side_client/app/pages/reset/reset.less b/app/public/app/pages/reset/reset.less similarity index 100% rename from side_client/app/pages/reset/reset.less rename to app/public/app/pages/reset/reset.less diff --git a/side_client/app/pages/reset/reset.module.ts b/app/public/app/pages/reset/reset.module.ts similarity index 97% rename from side_client/app/pages/reset/reset.module.ts rename to app/public/app/pages/reset/reset.module.ts index 4560ec2..89d3f94 100644 --- a/side_client/app/pages/reset/reset.module.ts +++ b/app/public/app/pages/reset/reset.module.ts @@ -1,13 +1,13 @@ -import { NgModule } from '@angular/core'; -import { ResetComponent } from "./reset.component"; -import { CommonModule } from '@angular/common'; -import { FormsModule, ReactiveFormsModule } from '@angular/forms'; -import {routing} from './reset.routing' - -@NgModule({ - declarations: [ResetComponent], - imports: [ CommonModule, - ReactiveFormsModule, - FormsModule,routing ] -}) +import { NgModule } from '@angular/core'; +import { ResetComponent } from "./reset.component"; +import { CommonModule } from '@angular/common'; +import { FormsModule, ReactiveFormsModule } from '@angular/forms'; +import {routing} from './reset.routing' + +@NgModule({ + declarations: [ResetComponent], + imports: [ CommonModule, + ReactiveFormsModule, + FormsModule,routing ] +}) export class ResetModule {} \ No newline at end of file diff --git a/side_client/app/pages/reset/reset.routing.ts b/app/public/app/pages/reset/reset.routing.ts similarity index 96% rename from side_client/app/pages/reset/reset.routing.ts rename to app/public/app/pages/reset/reset.routing.ts index afe37ea..f62d1da 100644 --- a/side_client/app/pages/reset/reset.routing.ts +++ b/app/public/app/pages/reset/reset.routing.ts @@ -1,14 +1,14 @@ -import { Routes, RouterModule } from '@angular/router'; - -import { ModuleWithProviders } from '@angular/core'; -import {ResetComponent} from './reset.component' - -// noinspection TypeScriptValidateTypes -export const routes: Routes = [ - { - path: '', - component: ResetComponent - } -]; - -export const routing: ModuleWithProviders = RouterModule.forChild(routes); +import { Routes, RouterModule } from '@angular/router'; + +import { ModuleWithProviders } from '@angular/core'; +import {ResetComponent} from './reset.component' + +// noinspection TypeScriptValidateTypes +export const routes: Routes = [ + { + path: '', + component: ResetComponent + } +]; + +export const routing: ModuleWithProviders = RouterModule.forChild(routes); diff --git a/side_client/app/pages/reset/reset.service.ts b/app/public/app/pages/reset/reset.service.ts similarity index 96% rename from side_client/app/pages/reset/reset.service.ts rename to app/public/app/pages/reset/reset.service.ts index fd0703b..bfeb0d5 100644 --- a/side_client/app/pages/reset/reset.service.ts +++ b/app/public/app/pages/reset/reset.service.ts @@ -1,10 +1,10 @@ -import { Injectable } from '@angular/core'; -import { HttpClient } from '@angular/common/http'; - -@Injectable() -export class ResetService { - constructor(private http:HttpClient){} - postRest(obj){ - return this.http.post(CONFIGNI.reset,obj); - } +import { Injectable } from '@angular/core'; +import { HttpClient } from '@angular/common/http'; + +@Injectable() +export class ResetService { + constructor(private http:HttpClient){} + postRest(obj){ + return this.http.post(CONFIGNI.reset,obj); + } } \ No newline at end of file diff --git a/side_client/app/theme/components/baBackTop/baBackTop.less b/app/public/app/theme/components/baBackTop/baBackTop.less similarity index 94% rename from side_client/app/theme/components/baBackTop/baBackTop.less rename to app/public/app/theme/components/baBackTop/baBackTop.less index 1da4e1d..6d74ea8 100644 --- a/side_client/app/theme/components/baBackTop/baBackTop.less +++ b/app/public/app/theme/components/baBackTop/baBackTop.less @@ -1,23 +1,23 @@ -@height: 52px; -@primary: #209e91; -.ba-back-top { - position: fixed; - width: @height; - height: @height; - cursor: pointer; - z-index: 9999; - display: none; - text-decoration: none; - right: 40px; - bottom: 40px !important; - font-size: 45px; - color: @primary; - text-align: center; - opacity: 0.4; - background-color: rgba(0, 0, 0, 0.75); - border-radius: 50%; - line-height: 46px; - &:hover { - opacity: 0.8; - } -} +@height: 52px; +@primary: #209e91; +.ba-back-top { + position: fixed; + width: @height; + height: @height; + cursor: pointer; + z-index: 9999; + display: none; + text-decoration: none; + right: 40px; + bottom: 40px !important; + font-size: 45px; + color: @primary; + text-align: center; + opacity: 0.4; + background-color: rgba(0, 0, 0, 0.75); + border-radius: 50%; + line-height: 46px; + &:hover { + opacity: 0.8; + } +} diff --git a/side_client/app/theme/components/baBackTop/baBacltop.component.ts b/app/public/app/theme/components/baBackTop/baBacltop.component.ts similarity index 70% rename from side_client/app/theme/components/baBackTop/baBacltop.component.ts rename to app/public/app/theme/components/baBackTop/baBacltop.component.ts index 6ac5b46..d9b217f 100644 --- a/side_client/app/theme/components/baBackTop/baBacltop.component.ts +++ b/app/public/app/theme/components/baBackTop/baBacltop.component.ts @@ -1,32 +1,38 @@ -import {Component, ViewChild, HostListener, Input, ElementRef} from '@angular/core'; - -@Component({ - selector: 'ba-back-top', - styleUrls: ['./baBackTop.less'], - template: ` - - ` -}) -export class BaBackTopComponent { - @Input() position:number = 400; - @Input() showSpeed:number = 500; - @Input() moveSpeed:number = 1000; - - @ViewChild('baBackTop') _selector:ElementRef; - - ngAfterViewInit () { - this._onWindowScroll(); - } - - @HostListener('click') - _onClick():boolean { - jQuery('html, body').animate({scrollTop:0}, {duration:this.moveSpeed}); - return false; - } - - @HostListener('window:scroll') - _onWindowScroll():void { - let el = this._selector.nativeElement; - window.scrollY > this.position ? jQuery(el).fadeIn(this.showSpeed) : jQuery(el).fadeOut(this.showSpeed); - } -} +import {Component, ViewChild, HostListener, Input, ElementRef,PLATFORM_ID,Inject} from '@angular/core'; +import { isPlatformBrowser, isPlatformServer } from '@angular/common'; + + +@Component({ + selector: 'ba-back-top', + styleUrls: ['./baBackTop.less'], + template: ` + + ` +}) +export class BaBackTopComponent { + @Input() position:number = 400; + @Input() showSpeed:number = 500; + @Input() moveSpeed:number = 1000; + + @ViewChild('baBackTop') _selector:ElementRef; + constructor(@Inject(PLATFORM_ID) private platformId: Object){ + + } + ngAfterViewInit () { + if (isPlatformBrowser(this.platformId)) { + this._onWindowScroll(); + } + } + + @HostListener('click') + _onClick():boolean { + jQuery('html, body').animate({scrollTop:0}, {duration:this.moveSpeed}); + return false; + } + + @HostListener('window:scroll') + _onWindowScroll():void { + let el = this._selector.nativeElement; + window.scrollY > this.position ? jQuery(el).fadeIn(this.showSpeed) : jQuery(el).fadeOut(this.showSpeed); + } +} diff --git a/side_client/app/theme/components/baBackTop/index.ts b/app/public/app/theme/components/baBackTop/index.ts similarity index 100% rename from side_client/app/theme/components/baBackTop/index.ts rename to app/public/app/theme/components/baBackTop/index.ts diff --git a/side_client/app/theme/components/baMenu/baMenu.component.ts b/app/public/app/theme/components/baMenu/baMenu.component.ts similarity index 89% rename from side_client/app/theme/components/baMenu/baMenu.component.ts rename to app/public/app/theme/components/baMenu/baMenu.component.ts index 764fbc3..244ff18 100644 --- a/side_client/app/theme/components/baMenu/baMenu.component.ts +++ b/app/public/app/theme/components/baMenu/baMenu.component.ts @@ -43,8 +43,9 @@ export class BaMenu { if (this.menuItems) { this.selectMenuAndNotify(); } else { + this.selectMenuAndNotify() // on page load we have to wait as event is fired before menu elements are prepared - setTimeout(() => this.selectMenuAndNotify()); + //setTimeout(() => this.selectMenuAndNotify()); } } }); @@ -53,7 +54,7 @@ export class BaMenu { } public ngOnDestroy(): void { - this._onRouteChange.unsubscribe(); - this._menuItemsSub.unsubscribe(); + // this._onRouteChange.unsubscribe(); + // this._menuItemsSub.unsubscribe(); } } diff --git a/side_client/app/theme/components/baMenu/baMenu.html b/app/public/app/theme/components/baMenu/baMenu.html similarity index 100% rename from side_client/app/theme/components/baMenu/baMenu.html rename to app/public/app/theme/components/baMenu/baMenu.html diff --git a/side_client/app/theme/components/baMenu/baMenu.less b/app/public/app/theme/components/baMenu/baMenu.less similarity index 100% rename from side_client/app/theme/components/baMenu/baMenu.less rename to app/public/app/theme/components/baMenu/baMenu.less diff --git a/side_client/app/theme/components/baMenu/components/baMenuItem/baMenuItem.component.ts b/app/public/app/theme/components/baMenu/components/baMenuItem/baMenuItem.component.ts similarity index 100% rename from side_client/app/theme/components/baMenu/components/baMenuItem/baMenuItem.component.ts rename to app/public/app/theme/components/baMenu/components/baMenuItem/baMenuItem.component.ts diff --git a/side_client/app/theme/components/baMenu/components/baMenuItem/baMenuItem.html b/app/public/app/theme/components/baMenu/components/baMenuItem/baMenuItem.html similarity index 100% rename from side_client/app/theme/components/baMenu/components/baMenuItem/baMenuItem.html rename to app/public/app/theme/components/baMenu/components/baMenuItem/baMenuItem.html diff --git a/side_client/app/theme/components/baMenu/components/baMenuItem/baMenuItem.less b/app/public/app/theme/components/baMenu/components/baMenuItem/baMenuItem.less similarity index 100% rename from side_client/app/theme/components/baMenu/components/baMenuItem/baMenuItem.less rename to app/public/app/theme/components/baMenu/components/baMenuItem/baMenuItem.less diff --git a/side_client/app/theme/components/baMenu/components/baMenuItem/index.ts b/app/public/app/theme/components/baMenu/components/baMenuItem/index.ts similarity index 100% rename from side_client/app/theme/components/baMenu/components/baMenuItem/index.ts rename to app/public/app/theme/components/baMenu/components/baMenuItem/index.ts diff --git a/side_client/app/theme/components/baMenu/index.ts b/app/public/app/theme/components/baMenu/index.ts similarity index 100% rename from side_client/app/theme/components/baMenu/index.ts rename to app/public/app/theme/components/baMenu/index.ts diff --git a/side_client/app/theme/components/baPageTop/baPageTop.component.ts b/app/public/app/theme/components/baPageTop/baPageTop.component.ts similarity index 96% rename from side_client/app/theme/components/baPageTop/baPageTop.component.ts rename to app/public/app/theme/components/baPageTop/baPageTop.component.ts index 07bba17..a42192f 100644 --- a/side_client/app/theme/components/baPageTop/baPageTop.component.ts +++ b/app/public/app/theme/components/baPageTop/baPageTop.component.ts @@ -1,51 +1,51 @@ -import { AuthGuard } from '../../../auth.guard.service'; -import {Component,Input } from '@angular/core'; -import { Router } from '@angular/router'; - -import {GlobalState} from '../../../global.state'; - -@Component({ - selector: 'ba-page-top', - templateUrl: './baPageTop.html', - styleUrls: ['./baPageTop.less'], - providers:[AuthGuard] -}) -export class BaPageTop { - @Input() user:any; - public isScrolled:boolean = false; - public isMenuCollapsed:boolean = true; - - constructor(private _state:GlobalState,private authGuard:AuthGuard,private router:Router) { - this._state.subscribe('menu.isCollapsed', (isCollapsed) => { - this.isMenuCollapsed = isCollapsed; - }); - } - - public toggleMenu() { - this.isMenuCollapsed = !this.isMenuCollapsed; - this._state.notifyDataChanged('menu.isCollapsed', this.isMenuCollapsed); - return false; - } - - public scrolledChanged(isScrolled) { - this.isScrolled = isScrolled; - } - ngOnInit() { - this.authGuard.getUser().subscribe((response)=>{ - this.user = response; - }); - this.router.events.subscribe((event:any) => { - if(event.url){ - this._state.notifyDataChanged('menu.isCollapsed', true); - } - }); - } - logout(){ - this.authGuard.logout().subscribe((response) =>{ - if(response.resultCode ==1){ - alert(response.resultMess); - location.reload(); - } - }) - } -} +import { AuthGuard } from '../../../auth.guard.service'; +import {Component,Input } from '@angular/core'; +import { Router } from '@angular/router'; + +import {GlobalState} from '../../../global.state'; + +@Component({ + selector: 'ba-page-top', + templateUrl: './baPageTop.html', + styleUrls: ['./baPageTop.less'], + providers:[AuthGuard] +}) +export class BaPageTop { + @Input() user:any; + public isScrolled:boolean = false; + public isMenuCollapsed:boolean = true; + + constructor(private _state:GlobalState,private authGuard:AuthGuard,private router:Router) { + this._state.subscribe('menu.isCollapsed', (isCollapsed) => { + this.isMenuCollapsed = isCollapsed; + }); + } + + public toggleMenu() { + this.isMenuCollapsed = !this.isMenuCollapsed; + this._state.notifyDataChanged('menu.isCollapsed', this.isMenuCollapsed); + return false; + } + + public scrolledChanged(isScrolled) { + this.isScrolled = isScrolled; + } + ngOnInit() { + this.authGuard.getUser().subscribe((response)=>{ + this.user = response; + }); + this.router.events.subscribe((event:any) => { + if(event.url){ + this._state.notifyDataChanged('menu.isCollapsed', true); + } + }); + } + logout(){ + this.authGuard.logout().subscribe((response) =>{ + if(response.resultCode ==1){ + alert(response.resultMess); + location.reload(); + } + }) + } +} diff --git a/side_client/app/theme/components/baPageTop/baPageTop.html b/app/public/app/theme/components/baPageTop/baPageTop.html similarity index 98% rename from side_client/app/theme/components/baPageTop/baPageTop.html rename to app/public/app/theme/components/baPageTop/baPageTop.html index 0e79579..e5e8ec9 100644 --- a/side_client/app/theme/components/baPageTop/baPageTop.html +++ b/app/public/app/theme/components/baPageTop/baPageTop.html @@ -1,20 +1,20 @@ -
- - +
+ +
\ No newline at end of file diff --git a/side_client/app/theme/components/baPageTop/baPageTop.less b/app/public/app/theme/components/baPageTop/baPageTop.less similarity index 94% rename from side_client/app/theme/components/baPageTop/baPageTop.less rename to app/public/app/theme/components/baPageTop/baPageTop.less index b782cbe..d4c16a2 100644 --- a/side_client/app/theme/components/baPageTop/baPageTop.less +++ b/app/public/app/theme/components/baPageTop/baPageTop.less @@ -1,254 +1,254 @@ - - -:host /deep/ { - .page-top { - background-color: rgba(251, 250, 250, 0.5); - position: fixed; - z-index: 904; - top: 0; - left: 0; - box-shadow: 2px 0 3px rgba(0, 0, 0, 0.5); - height: 60px; - width: 100%; - padding: 0 12px; - .dropdown-toggle::after { - display: none; - } - } - - .blur { - .page-top.scrolled { - background-color: rgba(0,0,0, 0.85) - } - } - - a.al-logo { - color: #ffffff; - display: block; - font-size: 24px; - white-space: nowrap; - float: left; - outline: none !important; - line-height: 60px; - - span { - color: #00abff; - } - } - - a.al-logo:hover { - color: #00abff; - } - - .user-profile { - float: right; - margin-top: 10px; - } - - .al-user-profile { - float: right; - margin-right: 12px; - transition: all .15s ease-in-out; - padding: 0; - border: 0; - opacity: 1; - position: relative; - ul.profile-dropdown:after { - bottom: 100%; - right: 0; - border: solid transparent; - content: " "; - height: 0; - width: 0; - position: absolute; - pointer-events: none; - border-color: rgba(255, 255, 255, 0); - border-bottom-color: #fff; - border-width: 10px; - margin-right: 28px; - } - a { - display: block; - } - img { - width: 45px; - height: 45px; - border-radius: 50%; - } - } - - a.refresh-data { - color: #ffffff; - font-size: 13px; - text-decoration: none; - float: right; - margin-top: 13px; - margin-right: 26px; - &:hover { - color: #e7ba08 !important; - } - } - - a.collapse-menu-link { - font-size: 31px; - cursor: pointer; - display: block; - text-decoration: none; - line-height: 42px; - color: #ffffff; - padding: 0; - float: left; - margin: 11px 0 0 25px; - &:hover { - text-decoration: none; - color: #e7ba08; - } - } - - .al-skin-dropdown { - float: right; - margin-top: 14px; - margin-right: 26px; - .tpl-skin-panel { - max-height: 300px; - overflow-y: scroll; - overflow-x: hidden; - } - } - .icon-palette { - display: inline-block; - width: 14px; - height: 13px; - background-size: cover; - } - .search { - text-shadow: none; - font-size: 13px; - line-height: 25px; - transition: all 0.5s ease; - white-space: nowrap; - overflow: hidden; - width: 162px; - float: left; - margin: 20px 0 0 30px; - label { - cursor: pointer; - } - i { - width: 16px; - display: inline-block; - cursor: pointer; - padding-left: 1px; - font-size: 16px; - margin-right: 13px; - } - input { - color: #ffffff; - background: none; - border: none; - outline: none; - width: 120px; - padding: 0; - margin: 0 0 0 -3px; - height: 27px; - } - } -} - -.dropdown-menu { - background-color:rgba(255, 255, 255, 0.32); - min-width: auto; -} - -.logined { - margin-top: 6px; -} - - -#nav-icon4 { - width: 40px; - height: 28px; - margin-top: 16px; - position: relative; - -webkit-transform: rotate(0deg); - -moz-transform: rotate(0deg); - -o-transform: rotate(0deg); - transform: rotate(0deg); - -webkit-transition: .5s ease-in-out; - -moz-transition: .5s ease-in-out; - -o-transition: .5s ease-in-out; - transition: .5s ease-in-out; - cursor: pointer; -} - -nav { - float: left; -} -#nav-icon4 span { - display: block; - position: absolute; - height: 6px; - width: 100%; - background: #e60b3e; - border-radius: 0px; - opacity: 1; - left: 0; - -webkit-transform: rotate(0deg); - -moz-transform: rotate(0deg); - -o-transform: rotate(0deg); - transform: rotate(0deg); - -webkit-transition: .25s ease-in-out; - -moz-transition: .25s ease-in-out; - -o-transition: .25s ease-in-out; - transition: .25s ease-in-out; -} - -#nav-icon4 { -} - -#nav-icon4 span:nth-child(1) { - top: 0px; - -webkit-transform-origin: left center; - -moz-transform-origin: left center; - -o-transform-origin: left center; - transform-origin: left center; -} - -#nav-icon4 span:nth-child(2) { - top: 10px; - -webkit-transform-origin: left center; - -moz-transform-origin: left center; - -o-transform-origin: left center; - transform-origin: left center; -} - -#nav-icon4 span:nth-child(3) { - top: 20px; - -webkit-transform-origin: left center; - -moz-transform-origin: left center; - -o-transform-origin: left center; - transform-origin: left center; -} - -#nav-icon4.open span:nth-child(1) { - -webkit-transform: rotate(45deg); - -moz-transform: rotate(45deg); - -o-transform: rotate(45deg); - transform: rotate(45deg); - top: -3px; - left: 8px; -} - -#nav-icon4.open span:nth-child(2) { - width: 0%; - opacity: 0; -} - -#nav-icon4.open span:nth-child(3) { - -webkit-transform: rotate(-45deg); - -moz-transform: rotate(-45deg); - -o-transform: rotate(-45deg); - transform: rotate(-45deg); - top: 26px; - left: 8px; + + +:host /deep/ { + .page-top { + background-color: rgba(251, 250, 250, 0.5); + position: fixed; + z-index: 904; + top: 0; + left: 0; + box-shadow: 2px 0 3px rgba(0, 0, 0, 0.5); + height: 60px; + width: 100%; + padding: 0 12px; + .dropdown-toggle::after { + display: none; + } + } + + .blur { + .page-top.scrolled { + background-color: rgba(0,0,0, 0.85) + } + } + + a.al-logo { + color: #ffffff; + display: block; + font-size: 24px; + white-space: nowrap; + float: left; + outline: none !important; + line-height: 60px; + + span { + color: #00abff; + } + } + + a.al-logo:hover { + color: #00abff; + } + + .user-profile { + float: right; + margin-top: 10px; + } + + .al-user-profile { + float: right; + margin-right: 12px; + transition: all .15s ease-in-out; + padding: 0; + border: 0; + opacity: 1; + position: relative; + ul.profile-dropdown:after { + bottom: 100%; + right: 0; + border: solid transparent; + content: " "; + height: 0; + width: 0; + position: absolute; + pointer-events: none; + border-color: rgba(255, 255, 255, 0); + border-bottom-color: #fff; + border-width: 10px; + margin-right: 28px; + } + a { + display: block; + } + img { + width: 45px; + height: 45px; + border-radius: 50%; + } + } + + a.refresh-data { + color: #ffffff; + font-size: 13px; + text-decoration: none; + float: right; + margin-top: 13px; + margin-right: 26px; + &:hover { + color: #e7ba08 !important; + } + } + + a.collapse-menu-link { + font-size: 31px; + cursor: pointer; + display: block; + text-decoration: none; + line-height: 42px; + color: #ffffff; + padding: 0; + float: left; + margin: 11px 0 0 25px; + &:hover { + text-decoration: none; + color: #e7ba08; + } + } + + .al-skin-dropdown { + float: right; + margin-top: 14px; + margin-right: 26px; + .tpl-skin-panel { + max-height: 300px; + overflow-y: scroll; + overflow-x: hidden; + } + } + .icon-palette { + display: inline-block; + width: 14px; + height: 13px; + background-size: cover; + } + .search { + text-shadow: none; + font-size: 13px; + line-height: 25px; + transition: all 0.5s ease; + white-space: nowrap; + overflow: hidden; + width: 162px; + float: left; + margin: 20px 0 0 30px; + label { + cursor: pointer; + } + i { + width: 16px; + display: inline-block; + cursor: pointer; + padding-left: 1px; + font-size: 16px; + margin-right: 13px; + } + input { + color: #ffffff; + background: none; + border: none; + outline: none; + width: 120px; + padding: 0; + margin: 0 0 0 -3px; + height: 27px; + } + } +} + +.dropdown-menu { + background-color:rgba(255, 255, 255, 0.32); + min-width: auto; +} + +.logined { + margin-top: 6px; +} + + +#nav-icon4 { + width: 40px; + height: 28px; + margin-top: 16px; + position: relative; + -webkit-transform: rotate(0deg); + -moz-transform: rotate(0deg); + -o-transform: rotate(0deg); + transform: rotate(0deg); + -webkit-transition: .5s ease-in-out; + -moz-transition: .5s ease-in-out; + -o-transition: .5s ease-in-out; + transition: .5s ease-in-out; + cursor: pointer; +} + +nav { + float: left; +} +#nav-icon4 span { + display: block; + position: absolute; + height: 6px; + width: 100%; + background: #e60b3e; + border-radius: 0px; + opacity: 1; + left: 0; + -webkit-transform: rotate(0deg); + -moz-transform: rotate(0deg); + -o-transform: rotate(0deg); + transform: rotate(0deg); + -webkit-transition: .25s ease-in-out; + -moz-transition: .25s ease-in-out; + -o-transition: .25s ease-in-out; + transition: .25s ease-in-out; +} + +#nav-icon4 { +} + +#nav-icon4 span:nth-child(1) { + top: 0px; + -webkit-transform-origin: left center; + -moz-transform-origin: left center; + -o-transform-origin: left center; + transform-origin: left center; +} + +#nav-icon4 span:nth-child(2) { + top: 10px; + -webkit-transform-origin: left center; + -moz-transform-origin: left center; + -o-transform-origin: left center; + transform-origin: left center; +} + +#nav-icon4 span:nth-child(3) { + top: 20px; + -webkit-transform-origin: left center; + -moz-transform-origin: left center; + -o-transform-origin: left center; + transform-origin: left center; +} + +#nav-icon4.open span:nth-child(1) { + -webkit-transform: rotate(45deg); + -moz-transform: rotate(45deg); + -o-transform: rotate(45deg); + transform: rotate(45deg); + top: -3px; + left: 8px; +} + +#nav-icon4.open span:nth-child(2) { + width: 0%; + opacity: 0; +} + +#nav-icon4.open span:nth-child(3) { + -webkit-transform: rotate(-45deg); + -moz-transform: rotate(-45deg); + -o-transform: rotate(-45deg); + transform: rotate(-45deg); + top: 26px; + left: 8px; } \ No newline at end of file diff --git a/side_client/app/theme/components/baPageTop/index.ts b/app/public/app/theme/components/baPageTop/index.ts similarity index 100% rename from side_client/app/theme/components/baPageTop/index.ts rename to app/public/app/theme/components/baPageTop/index.ts diff --git a/side_client/app/theme/components/baSidebar/baSidebar.component.ts b/app/public/app/theme/components/baSidebar/baSidebar.component.ts similarity index 96% rename from side_client/app/theme/components/baSidebar/baSidebar.component.ts rename to app/public/app/theme/components/baSidebar/baSidebar.component.ts index 4a955da..09ed621 100644 --- a/side_client/app/theme/components/baSidebar/baSidebar.component.ts +++ b/app/public/app/theme/components/baSidebar/baSidebar.component.ts @@ -1,34 +1,34 @@ -import {Component, ElementRef, HostListener} from '@angular/core'; -import {GlobalState} from '../../../global.state'; - -@Component({ - selector: 'ba-sidebar', - templateUrl: './baSidebar.html', - styleUrls: ['./baSidebar.less'] -}) -export class BaSidebar { - public isMenuCollapsed:boolean = false; - public isMenuShouldCollapsed:boolean = false; - - constructor(private _elementRef:ElementRef, private _state:GlobalState) { - - this._state.subscribe('menu.isCollapsed', (isCollapsed) => { - this.isMenuCollapsed = isCollapsed; - }); - } - public ngOnInit():void { - this.menuCollapse(); - } - public menuExpand():void { - this.menuCollapseStateChange(false); - } - - public menuCollapse():void { - this.menuCollapseStateChange(true); - } - - public menuCollapseStateChange(isCollapsed:boolean):void { - this.isMenuCollapsed = isCollapsed; - this._state.notifyDataChanged('menu.isCollapsed', this.isMenuCollapsed); - } -} +import {Component, ElementRef, HostListener} from '@angular/core'; +import {GlobalState} from '../../../global.state'; + +@Component({ + selector: 'ba-sidebar', + templateUrl: './baSidebar.html', + styleUrls: ['./baSidebar.less'] +}) +export class BaSidebar { + public isMenuCollapsed:boolean = false; + public isMenuShouldCollapsed:boolean = false; + + constructor(private _elementRef:ElementRef, private _state:GlobalState) { + + this._state.subscribe('menu.isCollapsed', (isCollapsed) => { + this.isMenuCollapsed = isCollapsed; + }); + } + public ngOnInit():void { + this.menuCollapse(); + } + public menuExpand():void { + this.menuCollapseStateChange(false); + } + + public menuCollapse():void { + this.menuCollapseStateChange(true); + } + + public menuCollapseStateChange(isCollapsed:boolean):void { + this.isMenuCollapsed = isCollapsed; + this._state.notifyDataChanged('menu.isCollapsed', this.isMenuCollapsed); + } +} diff --git a/side_client/app/theme/components/baSidebar/baSidebar.html b/app/public/app/theme/components/baSidebar/baSidebar.html similarity index 98% rename from side_client/app/theme/components/baSidebar/baSidebar.html rename to app/public/app/theme/components/baSidebar/baSidebar.html index 364ed78..b21594a 100644 --- a/side_client/app/theme/components/baSidebar/baSidebar.html +++ b/app/public/app/theme/components/baSidebar/baSidebar.html @@ -1,3 +1,3 @@ -