zhilizhili-ui 2016始动 开始做个样例站吧 (一)

对 我又挖坑了 不过其实也不算挖坑 因为ui构建中就会有填坑的文章 之前一直在写《编写大型web页面 结合现有前端形势思考未来前端》这是一篇巨难写的文章 估计要到年中才能写好了 写作的过程中 发生了国内前端大撕逼 2015的尾声大战 是否可以宣告前端是否开始新的时代 2016年 国内前端可能还会依旧艰难 国外前端也不是很好 微软正式不再支持ie11以下的浏览器 估计今年内 国外框架就要完全提高至ie10兼容水平了

zhilizhili-ui

自己从有这个想法到现在zhilizhili-ui发展到1.24版本已经快一年了 这一年里自己收集和编写了sassstd scss-zhilizhili-mei 这些一直在用sass库 sass可能不再是很新鲜的样式预编译语言了 的确受到一些压力 不过自己也在积极改进样式构建的流程 自己加入了postcss支持 2016年 打算开始和css4无缝对接

写个样例站吧

我选用前端框架angular2 后端laravel

本文不会特地放出demo

要想找到源码 请到我的github项目上

tde.blade.php

<!doctype html>
<!--[if IE 8 ]><html class="ie8" lang="zh-cn"><![endif]-->
<!--[if IE 9 ]><html class="ie9" lang="zh-cn"><![endif]-->
<!--[if (gt IE 9)|!(IE)]><!--><html class="" lang="zh-cn"><!--<![endif]-->
<head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=EDGE" /><meta name="viewport"content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"><title>Mobile Component</title><!-- 1. Load libraries --><script src="/assets/static/node_modules/angular2/bundles/angular2-polyfills.js"></script><script src="/assets/static/node_modules/systemjs/dist/system.src.js"></script><script src="/assets/static/node_modules/rxjs/bundles/Rx.js"></script><script src="/assets/static/node_modules/angular2/bundles/angular2.dev.js"></script><!-- 2. Configure SystemJS --><script>System.defaultJSExtensions = true;System.config({map: {angular2: '/assets/static/node_modules/angular2',rxjs: '/assets/static/node_modules/rxjs'}});System.import('/assets/mobile/controller/ui/tde').then(null, console.error.bind(console));</script><link rel="stylesheet" href="/assets/static/css/normalize.css"><link rel="stylesheet" href="/assets/mobile/css/ui/tde.css?v=<% rand(0, 1000) %>"><script src="/assets/static/js/dom4.min.js"></script><!--[if lte IE 10]><script src="/assets/static/js/placeholders.min.js"></script><![endif]-->
</head>
<body class="ui-tde dark-style"><my-app>Loading...</my-app>
</body>
</html>

说到angular2 大家可能对她还不是很感兴趣 但是在浏览器依旧要面对ie的时代 这个时代可能还要5年 angular2的确是给了一个大型应用的解决方案 的确 还是脏检查 不过使用的是worker zone.js提供了支持

2014年的ngconf大会 angular团队介绍了zone.js zone 就像java thread ok 好吧用进程模拟线程 也是可以的 dart有zones

zone is a execution context

通常我们写异步js

a();
setTimeout(b, 0);
setTimeout(c, 0);    
d();

她的执行顺序

a
d
b
c

如果我们改改

start();
a();
setTimeout(b, 0);
setTimeout(c, 0);    
d();
stop();

b c是不会被影响的

zone希望去使代码可预测

zone.run(function() {a();setTimeout(b, 0);setTimeout(c, 0);    d();    
));function onZoneEnter() {
}function onZoneLeave() {
}

tde.ts

import {AppComponent}     from './tde/app.component';
import {bootstrap}        from 'angular2/platform/browser';
import {provide}          from 'angular2/core';
import {APP_BASE_HREF,ROUTER_PROVIDERS
} from 'angular2/router';
bootstrap(AppComponent, [ROUTER_PROVIDERS,provide(APP_BASE_HREF, {useValue: '/wex/mtc'})
]);

zone可以捕捉甚至异步操作 用过angular2的都知道她的debug非常好 就是使用的是zone.js
angular之前的$scope.apply没有了 没了 不要担心了

rxjs

响应式编程 rxjava很牛对吧 这个也不错

RxJS 是使用可观察序列和 LINQ 风格查询操作符来编写异步和基于事件程序的类库。 使用 RxJS, 开发者用 Observables 来 表示 异步数据流,通过 LINQ 操作符来 查询 异步数据量,并使用 Schedules 来参数化异步数据流中的并发。 简单地讲, Rx = Observables + LINQ + Schedulers。

在 RxJS 中,你可以表述多个异步数据流,并且使用 Observer 对象订阅事件流。 Observable 对象会在事件发生时通知已订阅的 Observer。

因为 Observable 序列是数据流,你可以使用由 Observable 扩展方法实现的标准查询操作符 来查询它们。这样你可以通过这些查询操作符很容易地在多个事件上进行过滤、投射、聚合、 组合和执行基于时间的操作。除此之外还有很多其他反应式流特定的操作符使得可以书写强大的查询。 取消、异常和同步都可以通过由 Rx 提供的扩展方法优雅地处理。

由 Rx 实现的 Push 模型表现为 Observable/Observer 的观察者模式。 Observable 会自动在任何状态改变时通知所有的 Observers。 要通过订阅注册一个关注,你要使用 Observable 上的 subscribe 方法, 它接收一个 Observer 并返回一个 Disposable 对象。 它让你能够跟踪你的订阅并能够取消该订阅。 本质上你可以将可观察序列看做一个常规的集合。

开始最初的页面设计

图片描述

大概就是desktop端需要一个框架样的东西 pad端 mobile端 就隐藏两边边栏

未来组团开发的时候 很多情况样式并非一个人开发 可能架构组会将页面元素定下来 register-hook 然后业务实现组 要通过 use-hook 来开发 这样上层设计改变 代码也可以有效维护

tde.scss
首先我们需要一些生成media query的sass方法 这样不错

@import "../../../../../node_modules/sass-mediaqueries/media-queries";@function mq($args...) {$media-type: 'only screen';$media-type-key: 'media-type';$args: keywords($args);$expr: '';@if map-has-key($args, $media-type-key) {$media-type: map-get($args, $media-type-key);$args: map-remove($args, $media-type-key);}@each $key, $value in $args {@if $value {$expr: "#{$expr} and (#{$key}: #{$value})";}}@return #{$media-type} #{$expr};
}@function screen($min, $max, $orientation: false) {@return mq($min-width: $min, $max-width: $max, $orientation: $orientation);
}

我们需要一些全局变量保存

$custom-deivces: ("mobile": 320,"pad": 768,"desktop": 1280,
) !global;$custom-deivces-media: () !global;
$custom-deivces-hook: () !global;

这样的话 我们需要一个初始化sass实现的方法

@mixin initlize-media-hooks($custom-deivces) {$custom-deivces-indicators: map-keys($custom-deivces);$custom-deivces-indicatorslength: length($custom-deivces-indicators);@for $i from 1 through $custom-deivces-indicatorslength {$currentDeviceIndicator: nth($custom-deivces-indicators, $i);$currentDevice: map-deep-get($custom-deivces, $currentDeviceIndicator);$currentMedia: $currentDevice + 0px;$nextDeviceIndicator: if($i < $custom-deivces-indicatorslength, nth($custom-deivces-indicators, ($i + 1)), null);$nextDevice: if($nextDeviceIndicator !=null, map-deep-get($custom-deivces, $nextDeviceIndicator), 2881);$nextMedia: $nextDevice + 0px - 1;@include screen($currentMedia, $nextMedia) {$custom-deivces-media: map-deep-set($custom-deivces-media, $currentDeviceIndicator, screen($currentMedia, $nextMedia)) !global;$custom-deivces-hook: map-deep-set($custom-deivces-hook, $currentDeviceIndicator, "device #{$currentDeviceIndicator}") !global;}}
}@mixin use-media-hook($device) {@media #{map-deep-get($custom-deivces-media, $device)} {@at-root {@content;}}
}

每个页面可能有不同兼容情况 然后只需要自定义设备 在初始化一下

$custom-deivces: map-extend($customo-device, (...));
@include initlize-media-hooks($custom-deivces);

然后我们就可以使用自己定义好的设备查询

@include use-media-hook("pad") {@include use-hook(".main-inner .layout__item.layout__item--prefix") {position: absolute;left: 0;top: 0;}@include use-hook(".main-inner .layout__item.layout__item--suffix") {position: absolute;right: 0;top: 0;}
}@include use-media-hook("mobile") {@include use-hook(".main-inner .layout__item.layout__item--prefix") {position: absolute;left: 0;top: 0;opacity: 0;z-index: -1;}@include use-hook(".main-inner .layout__item.layout__item--suffix") {position: absolute;right: 0;top: 0;opacity: 0;z-index: -1;}
}

然后一个操作视频

bilibili链接

happy fte

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/543788.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

python 网格_Python | 网格到情节

python 网格Most of the time, we need good accuracy in data visualization and a normal plot can be ambiguous. So, it is better to use a grid that allows us to locate the approximate value near the points in the plot. It helps in reducing the ambiguity and t…

2016年1月计划

开始试着每月做计划和总结&#xff0c;有节奏的规划自己的时间&#xff0c;一月计划&#xff1a; 1、hive那本书拖了很久了&#xff0c;一月一定会看完。 2、因为跟着阚爷的风准备试着做一下讲师&#xff0c;分配给我的是推荐这块&#xff0c;所以网上多找找做推荐的资源&#…

slr1文法_SLR的完整形式是什么?

slr1文法单反&#xff1a;单镜头反光 (SLR: Single Lens Reflex) SLR is an abbreviation of Single Lens Reflex. It is used in high standard cameras. SLR makes use of an automatic moving mirror arrangement that makes it possible for photographers to perceive pre…

vim快捷键2

一、移动光标 1、左移h、右移l、下移j、上移k 2、向下翻页ctrl f&#xff0c;向上翻页ctrl b 3、向下翻半页ctrl d&#xff0c;向上翻半页ctrl u 4、移动到行尾$&#xff0c;移动到行首0&#xff08;数字&#xff09;&#xff0c;移动到行首第一个字符处^ 5、移动光标到下一…

FYR的完整形式是什么?

财政年度&#xff1a;供您参考 (FYR: For Your Reference) FYR is an abbreviation of "For Your Reference". FYR是“供您参考”的缩写。 It is an expression, which is commonly used in the Gmail platform. It is written as a follow-up message for the info…

UIScrollView的简单使用

- UIScrollView 介绍 问&1.UIScrollView 是干什么的? • UIScrollView 也是一种控件&#xff0c;继承自UIView。• 用来实现”滚动”和”缩放”的控件 什么是UIScrollView? UIScrollView是一个能够滚动的视图控件&#xff0c;可以用来展示大量的内容&#xf…

什么是苹果耳塞?

苹果耳塞 (Apple Earbuds) Apple Earbuds are another sound device made by Apple on 23rd October 2001. It is an in-ear sound device and it has been included in all the mobile and music devices of Apple. Apple Earbuds are quite comfortable and easy to handle w…

趣说游戏AI开发:对状态机的褒扬和批判

0x00 前言 因为临近年关工作繁忙&#xff0c;已经有一段时间没有更新博客了。到了元旦终于有时间来写点东西&#xff0c;既是积累也是分享。如题目所示&#xff0c;本文要来聊一聊在游戏开发中经常会涉及到的话题——游戏AI。设计游戏AI的目标之一是要找到一种便于使用并容易拓…

类中函数模板 typeof_Julia中的typeof()函数

类中函数模板 typeofJulia| typeof()函数 (Julia | typeof() function) typeof() function is a library function in Julia programming language, it is used to get the concrete type of the given value or variable. typeof()函数是Julia编程语言中的库函数&#xff0c;…

sencha touch调试时Please close other application using ADB: Monitor, DDMS, Eclipse

1、运行——cmd—— netstat -aon|findstr "5037" 2、打开任务管理器&#xff0c;查看所有进程 显示进程pid&#xff08;文件-查看&#xff09;--查找pid7740的结束。转载于:https://www.cnblogs.com/taoshengyujiu/p/5099588.html

定时器mia是什么意思_MIA的完整形式是什么?

定时器mia是什么意思MIA&#xff1a;行动失踪 (MIA: Missing In Action) MIA is an abbreviation of "Missing In Action". MIA是“缺少行动”的缩写。 It is an expression, which is commonly used in the Gmail platform. It is written to show that the origin…

window下自己主动备份数据库成dmp格式的bat写法

复制以下的命令到一个txt文本文档&#xff0c;然后改动相应的參数为自己须要的參数&#xff0c;一切完毕之后&#xff0c;将文件保存为bat格式。这样每次须要备份的时候仅仅须要双击一下这个bat文件。其它的都不用你了&#xff0c;你仅仅须要静静的等待……</pre><pre…

l和l_L&T的完整形式是什么?

l和&lL&#xff06;T&#xff1a;Larsen和Toubro (L&T: Larsen and Toubro) L&T is an abbreviation of Larsen and Toubro. It is an Indian multinational conglomerate corporation with international networks and operations. It is dynamically engaged in …

例题 3-5 生成元 digit generator

1 #include<stdio.h>2 #include<string.h>3 #define maxn 1000054 int ans[maxn]; //类似于 比较大的数组还是开导外面比较好一点,防止报错.5 int main()6 {7 int x,y,m,T,n;8 memset(ans,0,sizeof(ans)); //数组归零.9 for(m1;m<maxn;m…

CRT的完整形式是什么?

CRT&#xff1a;阴极射线管 (CRT: Cathode Ray Tube) CRT is an abbreviation of Cathode Ray Tube. Cathode Ray Tube is a vacuum tube that accommodates one or more than one electron filled guns and a phosphorescent screen, which is used in television and convent…

Python打包程序

到py2exe的官网下载程序&#xff0c;注意对应的python版本&#xff0c;比如所用的python版本为2.7&#xff0c;那么就下载适配2.7版本的py2exe软件下载完成后安装&#xff08;与普通软件安装方式相同&#xff09; 2将要转换的python脚本放到Python文件夹内 在python的目录下面&…

ruby中!!_Ruby反向! 功能

ruby中!!逆转&#xff01; Ruby中的功能 (reverse! function in Ruby) As the name suggests, reverse! function is used to reverse the elements of an array. Most of the times, we need to reverse an array but if we do it with the help of loops, the program will b…

mcal rtm_RTM的完整形式是什么?

mcal rtmRTM&#xff1a;阅读手册 (RTM: Read The Manual) RTM is an abbreviation of "Read The Manual". RTM是“阅读本手册”的缩写 。 It is an expression, which is commonly used in messaging or chatting on social media networking sites like Facebook,…

mysql悲观锁总结和实践

使用场景举例&#xff1a;以MySQL InnoDB为例商品t_goods表中有一个字段status&#xff0c;status为1代表商品未被下单&#xff0c;status为2代表商品已经被下单&#xff0c;那么我们对某个商品下单时必须确保该商品status为1。假设商品的id为1。 一、如果不采用锁&#xff0c;…

2G的完整形式是什么?

2G&#xff1a;第二代 (2G: Second Generation) 2G is an abbreviation of the "Second-Generation Cellular Network". 2G是“第二代蜂窝网络”的缩写 。 In 1991, 2G cellular networks were commercially introduced on the GSM standard in Finland by Radiolin…