This repository has been archived on 2023-08-30. You can view files and clone it, but cannot push or open issues/pull-requests.
bytedo
/
wcui
Archived
1
0
Fork 0

优化依赖引用路径以兼容next版;修复next版打包配置;优化表单元素的样式

old
宇天 2018-08-06 02:27:40 +08:00
parent ce92b7ca4c
commit c982f33858
9 changed files with 32 additions and 520 deletions

View File

@ -30,9 +30,12 @@ const compileJs = (entry, output) => {
let { code } = uglify.minify(buf) let { code } = uglify.minify(buf)
code = code code = code
.replace(/\.scss/g, '.css') .replace(/\.scss/g, '.css')
.replace(/import"([a-z0-9/.]*)(?<!\.css)"/g, 'import "$1.js"') .replace(/import"([a-z0-9\/\.\-_]*)(?<!\.css)"/g, 'import "$1.js"')
.replace(/import ([\w]*) from"([a-z0-9/.]*)"/g, 'import $1 from "$2.js"') .replace(
.replace(/import"(([a-z0-9/.]*\.css))"/g, 'importCss("/$1")') /import ([\w]*) from"([a-z0-9\/\.\-_]*)"/g,
'import $1 from "$2.js"'
)
.replace(/import"([a-z0-9\/\.\-_]*\.css)"/g, 'importCss("/$1")')
log( log(
'编译JS: %s, 耗时 %s ms', '编译JS: %s, 耗时 %s ms',
chalk.green(entry), chalk.green(entry),

View File

@ -12,8 +12,8 @@
/*--------各种按钮---------*/ /*--------各种按钮---------*/
.do-ui-button {display:inline-block;height:16px;padding:2px 5px;line-height:12px;border-radius:3px;text-align:center;font-size:12px;background:nth($cp, 2);color:nth($cgr, 1);cursor:pointer;@include ts; .do-ui-button {display:inline-block;height:16px;padding:2px 5px;line-height:12px;border-radius:3px;text-align:center;font-size:12px;background:nth($cp, 2);color:nth($cgr, 1);cursor:pointer;@include ts;
&.medium {min-width:100px;height:35px;padding:0 8px;line-height:35px;border-radius:5px;font-size:15px} &.medium {min-width:80px;height:30px;padding:0 8px;line-height:30px;border-radius:5px;font-size:14px}
&.large {min-width:150px;height:50px;padding:0 13px;line-height:50px;border-radius:5px;font-size:18px;} &.large {min-width:130px;height:45px;padding:0 13px;line-height:45px;border-radius:5px;font-size:18px;}
&:hover {background:nth($cp, 1);} &:hover {background:nth($cp, 1);}
&:active {background:nth($cp, 3);} &:active {background:nth($cp, 3);}
@ -53,7 +53,7 @@
/*--------各种input---------*/ /*--------各种input---------*/
.do-ui-input {width:auto;height:35px;padding:0 5px;background:nth($cp, 1);border:2px solid transparent;border-radius:5px;font-size:14px;@include ts();color: nth($cd, 2); .do-ui-input {width:auto;height:30px;padding:0 5px;background:nth($cp, 1);border:2px solid transparent;border-radius:5px;font-size:13px;@include ts();color: nth($cd, 2);
&:focus {background:#fff;border-color:nth($cd, 2);} &:focus {background:#fff;border-color:nth($cd, 2);}
@ -71,28 +71,28 @@
/* select框 */ /* select框 */
.do-ui-select {position:relative;width:auto;height:35px;color:nth($cgr, 1); .do-ui-select {position:relative;width:auto;height:30px;color:nth($cgr, 1);
select {width:100%;height:100%;padding:5px 13px;line-height:1;background:nth($cp, 1);border-radius:5px;appearance:none;border:2px solid transparent;outline:none;color: nth($cd, 2);font-size:14px; select {width:100%;height:100%;padding:5px 13px;line-height:1;background:nth($cp, 1);border-radius:5px;appearance:none;border:2px solid transparent;outline:none;color: nth($cd, 2);font-size:13px;
&:focus {background:#fff;border-color:nth($cd, 2);} &:focus {background:#fff;border-color:nth($cd, 2);}
&::-ms-expand {display:none;} &::-ms-expand {display:none;}
&:disabled {border-color:transparent;background:#fff8ed;color:nth($cp, 3)} &:disabled {border-color:transparent;background:#fff8ed;color:nth($cp, 3)}
} }
.trigon {position:absolute;right:10px;top:0;width:15px;height:35px;padding:8px 0; .trigon {position:absolute;right:7px;top:0;width:15px;height:30px;padding:7px 0;font-size:12px;text-align:center;
i {position:absolute;width:15px;;height:12px;line-height:12px;} i {float:left;width:15px;height:12px;line-height:12px;}
i:nth-child(2) {top:15px;} i:nth-child(2) {margin-top:-6px;}
} }
} }
/* 单选和复选框 */ /* 单选和复选框 */
.do-ui-radio, .do-ui-radio,
.do-ui-checkbox {display:inline-block;position:relative;width:auto;height:auto;padding:0 5px 0 35px;line-height:35px;color:nth($cd, 1);font-size:14px; .do-ui-checkbox {display:inline-block;position:relative;width:auto;height:auto;padding:0 5px 0 35px;line-height:30px;color:nth($cd, 1);font-size:13px;
>input {position:absolute;left:7px;top:7px;width:21px;height:21px;border-radius:50%;border:1px solid nth($cp, 3);background:#fff;appearance:none; >input {position:absolute;left:7px;top:5px;width:20px;height:20px;border-radius:50%;border:1px solid nth($cp, 3);background:#fff;appearance:none;
&:checked {box-shadow:0 0 5px nth($cb, 1);} &:checked {box-shadow:0 0 5px nth($cb, 1);}
&:checked::after {display:block;width:13px;height:13px;margin:3px;border-radius:50%;background:nth($cgr, 1);content:""} &:checked::after {display:block;width:12px;height:12px;margin:3px;border-radius:50%;background:nth($cgr, 1);content:""}
&:disabled {background:#fff8ed;box-shadow:none;cursor:not-allowed;} &:disabled {background:#fff8ed;box-shadow:none;cursor:not-allowed;}
&:disabled:checked::after {background:nth($cgr, 1);} &:disabled:checked::after {background:nth($cgr, 1);}
@ -105,7 +105,7 @@
>input {border-radius:3px; >input {border-radius:3px;
&:checked::after {width:100%;height:100%;margin:0;line-height:19px;font-size:18px;text-align:center;color:nth($cgr, 1);background:none;content:""} &:checked::after {width:100%;height:100%;margin:0;line-height:18px;font-size:18px;text-align:center;color:nth($cgr, 1);background:none;content:""}
&:disabled:checked::after {color:nth($cgr, 1);background:none;} &:disabled:checked::after {color:nth($cgr, 1);background:none;}
} }

View File

@ -115,11 +115,11 @@
.do-switch {position:relative;display:inline-block;width:50px;height:30px;padding-right:10px;cursor:default; .do-switch {position:relative;display:inline-block;width:45px;height:30px;padding-right:10px;cursor:default;
&__label {position:relative;display:inline-block;width:100%;height:16px;margin:7px 0;background:nth($cp, 3);border-radius:12px;} &__label {position:relative;display:inline-block;width:100%;height:14px;margin:7px 0;background:nth($cp, 3);border-radius:7px;}
&__dot {position:absolute;left:0;top:-2px;width:20px;height:20px;border-radius:50%;background:#fff;box-shadow:0 1px 3px rgba(0,0,0,.3);} &__dot {position:absolute;left:0;top:-3px;width:20px;height:20px;border-radius:50%;background:#fff;box-shadow:0 1px 3px rgba(0,0,0,.3);}
&:hover &__dot {transform:scale(1.1);} &:hover &__dot {transform:scale(1.1);}
&.disabled {cursor:not-allowed;} &.disabled {cursor:not-allowed;}

File diff suppressed because one or more lines are too long

View File

@ -7,7 +7,7 @@
'use strict' 'use strict'
import 'drag/index' import '../drag/index'
import 'css/layer-normal.scss' import 'css/layer-normal.scss'
Anot.ui.layer = '1.0.0-normal' Anot.ui.layer = '1.0.0-normal'

View File

@ -7,7 +7,7 @@
'use strict' 'use strict'
import 'layer/index' import '../../layer/index'
import 'css/meditor__attach.scss' import 'css/meditor__attach.scss'
const $doc = Anot(document) const $doc = Anot(document)

View File

@ -6,7 +6,7 @@
*/ */
'use strict' 'use strict'
import 'layer/index' import '../../layer/index'
function objArr(num) { function objArr(num) {
let arr = [] let arr = []

View File

@ -7,8 +7,8 @@
'use strict' 'use strict'
import 'prism/base' import '../prism/base'
import 'marked/index' import '../marked/index'
import addon from './addon/base' import addon from './addon/base'
import 'css/meditor.scss' import 'css/meditor.scss'
@ -403,7 +403,7 @@ Anot.component('meditor', {
onUpdate: Anot.PropsTypes.isFunction(), onUpdate: Anot.PropsTypes.isFunction(),
onFullscreen: Anot.PropsTypes.isFunction() onFullscreen: Anot.PropsTypes.isFunction()
}, },
skip: ['addon', 'insert', 'selection', '__tmp__'], skip: ['addon', 'insert', 'selection'],
methods: { methods: {
// 往文本框中插入内容 // 往文本框中插入内容
insert(val, isSelect) { insert(val, isSelect) {

View File

@ -1,494 +0,0 @@
/**
* Request组件, modern版, 支持IE9+,chrome,FF
* @authors yutent (yutent@doui.cc)
* @date 2016-11-27 13:08:40
*
*/
'use strict'
import 'promise/index'
import Format from './lib/format'
var _request = function(url, protocol) {
this.transport = true
protocol = (protocol + '').trim().toUpperCase()
this.xhr = Xhr()
this.defer = Promise.defer()
this.opt = {
url: (url + '').trim(),
type: protocol || 'GET',
form: '',
data: {},
headers: {},
timeoutID: 0,
uuid: Math.random()
.toString(16)
.substr(2)
}
},
_requestp = _request.prototype,
toS = Object.prototype.toString,
win = window,
doc = win.document,
encode = encodeURIComponent,
decode = decodeURIComponent,
noop = function(e, res) {
this.defer.resolve(res)
}
// -----------------------------
// 本地协议判断正则
var rlocalProtocol = /^(?:about|app|app-storage|.+-extension|file|res|widget):$/
var isLocal = false
try {
isLocal = rlocalProtocol.test(location.ptyperotocol)
} catch (e) {}
var rheaders = /^(.*?):[ \t]*([^\r\n]*)\r?$/gm
// ----------------- 一些兼容性预处理 --------------------
win.Xhr = function() {
return new XMLHttpRequest()
}
var supportCors = 'withCredentials' in Xhr()
// ---------------------------------------------------------
// -------------------- request 模块开始 --------------------
// ---------------------------------------------------------
var requestConvert = {
text: function(val) {
return val
},
xml: function(val, xml) {
return xml !== undefined ? xml : Format.parseXML(val)
},
html: function(val) {
return Format.parseHTML(val)
},
json: function(val) {
return JSON.parse(val)
},
script: function(val) {
return Format.parseJS(val)
},
jsonp: function(name) {
var json = request.cache[name]
delete request.cache[name]
return json
}
}
var requestExtend = {
formData: function() {
if (this.opt.form) {
var data = Format.parseForm(this.opt.form)
Format.merge(this.opt.data, data)
}
var form = new FormData()
for (var i in this.opt.data) {
var el = this.opt.data[i]
if (Array.isArray(el)) {
el.forEach(function(it) {
form.append(i + '[]', it)
})
} else {
form.append(i, this.opt.data[i])
}
}
return form
},
jsonp: function(jsonpcallback) {
win[jsonpcallback] = function(val) {
delete win[jsonpcallback]
request.cache[jsonpcallback] = val
}
},
dispatch: function(self) {
if (!this.transport) return this.defer.reject('Request pending...')
var _this = this,
result = {
response: {
url: this.opt.url,
headers: { 'content-type': '' }
},
request: {
url: this.opt.url,
headers: _this.opt.headers
},
status: self === null ? 504 : 200,
statusText: self === null ? 'Connected timeout' : 'ok',
text: '',
body: '',
error: null
}
//状态为4,既已成功, 则清除超时
clearTimeout(_this.opt.timeoutID)
if (typeof this.transport === 'object' && this.opt.type === 'JSONP') {
//移除script
// this.transport.parentNode.removeChild(this.transport);
//超时返回
if (self !== null) {
var exec =
!this.transport.readyState ||
this.transport.readyState === 'loaded' ||
this.transport.readyState === 'complete'
if (exec) {
result.body = requestConvert.jsonp(this.opt.data.callback)
result.text = JSON.stringify(result.body)
}
}
this.callback(result.error, result)
} else {
//成功的回调
var isSucc = self
? (self.status >= 200 && self.status < 300) || self.status === 304
: false,
headers = (self && self.getAllResponseHeaders().split('\n')) || []
//处理返回的Header
headers.forEach(function(it, i) {
it = it.trim()
if (it) {
it = it.split(':')
result.response.headers[it.shift().toLowerCase()] = it
.join(':')
.trim()
}
})
if (isSucc) {
result.status = self.status
if (result.status === 204) {
result.statusText = 'no content'
} else if (result.status === 304) {
result.statusText = 'not modified'
}
} else {
result.status = self === null ? 504 : self.status || 500
result.statusText =
self === null
? 'Connected timeout'
: self.statusText || 'Internal Server Error'
result.error = Format.merge(new Error(result.statusText), {
status: result.status
})
}
try {
//处理返回的数据
var dataType = result.response.headers['content-type'].match(
/json|xml|script|html/i
) || ['text']
dataType = dataType[0].toLowerCase()
result.text = (self && (self.responseText || self.responseXML)) || ''
result.body = requestConvert[dataType](
result.text,
self && self.responseXML
)
} catch (err) {
result.error = err
result.statusText = 'parse error'
}
_this.callback(result.error, result)
}
delete _this.defer
delete _this.transport
delete _this.opt
delete _this.xhr
}
}
// 设置表单类型, 支持2种, form/json
_requestp.type = function(t) {
if (this.opt.formType === 'form-data') return this
this.opt.formType = t || 'form'
if (t === 'form' || this.opt.type === 'GET')
this.set('content-type', 'application/x-www-form-urlencoded; charset=UTF-8')
else this.set('content-type', 'application/json; charset=UTF-8')
return this
}
//设置头信息
_requestp.set = function(k, val) {
if (!this.transport) return
if (typeof k === 'object') {
for (var i in k) {
i = i.toLowerCase()
this.opt.headers[i] = k[i]
}
} else if (typeof k === 'string') {
if (arguments.length < 2) throw new Error('2 arguments required')
// 全转小写,避免重复写入
k = k.toLowerCase()
if (val === undefined) delete this.opt.headers[k]
else this.opt.headers[k] = val
} else {
throw new Error(
'arguments must be string/object, but [' + typeof k + '] given'
)
}
return this
}
//设置请求参数
_requestp.send = function(k, val) {
if (!this.transport) return
// 1. send方法可以多次调用, 但必须保证格式一致
// 2. 2次圴提交纯字符串也会抛出异常
if (typeof k === 'object') {
if (this.opt.data && typeof this.opt.data === 'string')
throw new Error('param can not be string and object at the same time')
if (!this.opt.data) this.opt.data = {}
Format.merge(this.opt.data, k)
} else {
if (typeof k === 'string') {
if (arguments.length === 1) {
if (this.opt.data) throw new Error('invalid param in function send')
this.opt.data = k
} else {
if (this.opt.data && typeof this.opt.data === 'string')
throw new Error('param can not be string and object at the same time')
if (!this.opt.data) this.opt.data = {}
this.opt.data[k] = val
}
} else {
throw new Error(
'argument of send must be string/object, but [' + typeof k + '] given'
)
}
}
return this
}
//该方法用于 form-data类型的post请求的参数设置
_requestp.field = function(k, val) {
if (!this.transport) return this
// 此类型优先级最高
this.opt.formType = 'form-data'
this.opt.type = 'POST'
if (!this.opt.data || (this.opt.data && typeof this.opt.data !== 'object'))
this.opt.data = {}
if (arguments.length === 1 && typeof k === 'object') {
Format.merge(this.opt.data, k)
} else if (arguments.length === 2) {
this.opt.data[k] = val
} else {
throw new TypeError(
'argument must be an object, but ' + typeof k + ' given'
)
}
return this
}
//设置缓存
_requestp.cache = function(t) {
if (!this.transport) return
if (this.opt.type === 'GET') this.opt.cache = !!t
return this
}
//取消网络请求
_requestp.abort = function() {
delete this.transport
if (!this.opt.form) this.xhr.abort()
return this
}
//超时设置, 单位毫秒
_requestp.timeout = function(time) {
if (typeof time !== 'number' || time < 1) return this
this.opt.timeout = time
return this
}
_requestp.form = function(form) {
if (typeof form === 'object' && form.nodeName === 'FORM') {
this.opt.type = 'POST'
this.opt.form = form
}
return this
}
var originAnchor = doc.createElement('a')
originAnchor.href = location.href
_requestp.end = function(callback) {
var _this = this
// 回调已执行, 或已取消, 则直接返回, 防止重复执行
if (!this.transport) return this
if (!this.opt.url) throw new Error('Invalid request url')
Format.merge(this, requestExtend)
this.callback = callback || noop.bind(this)
// 1. url规范化
this.opt.url = this.opt.url
.replace(/#.*$/, '')
.replace(/^\/\//, location.protocol + '//')
// 2. 处理跨域
if (typeof this.opt.crossDomain !== 'boolean') {
var anchor = doc.createElement('a')
try {
anchor.href = this.opt.url
// IE7及以下浏览器 '1'[0]的结果是 undefined
// IE7下需要获取绝对路径
var absUrl = !'1'[0] ? anchor.getAttribute('href', 4) : anchor.href
anchor.href = absUrl
anchor.async = true
this.opt.crossDomain =
originAnchor.protocol !== anchor.protocol ||
originAnchor.host !== anchor.host
} catch (e) {
this.opt.crossDomain = true
}
}
// 2.1 进一步处理跨域配置
if (this.opt.type === 'JSONP') {
//如果没有跨域自动转回xhr GET
if (!this.opt.crossDomain) {
this.opt.type = 'GET'
} else {
this.opt.data['callback'] =
this.opt.data['callback'] || 'jsonp' + request.cid++
this.jsonp(this.opt.data['callback']) //创建临时处理方法
}
}
// 2.2 如果不是跨域请求则自动加上一条header信息用以标识这是ajax请求
if (!this.opt.crossDomain) {
this.set('X-Requested-With', 'XMLHttpRequest')
} else {
supportCors && (this.xhr.withCredentials = true)
}
// 3. data转字符串
this.opt.param = Format.param(this.opt.data)
// 4. 设置Content-Type类型, 默认x-www-form-urlencoded
if (!this.opt.formType) this.type('form')
// 5.处理GET请求
this.opt.hasContent = this.opt.type === 'POST' //是否为post请求
if (!this.opt.hasContent) {
//GET请求直接把参数拼接到url上
if (this.opt.param) {
this.opt.url += (/\?/.test(this.opt.url) ? '&' : '?') + this.opt.param
}
//加随机值,避免缓存
if (this.opt.cache === false)
this.opt.url +=
(/\?/.test(this.opt.url) ? '&' : '?') + '_=' + Math.random()
} else {
if (this.opt.formType === 'form-data') {
delete this.opt.headers['content-type']
this.opt.param = this.formData()
} else if (this.opt.formType !== 'form') {
this.opt.param = JSON.stringify(this.opt.data)
}
}
//jsonp
if (this.opt.type === 'JSONP') {
this.transport = doc.createElement('script')
this.transport.onerror = this.transport.onload = function() {
_this.dispatch(_this.transport)
}
this.transport.src = this.opt.url
doc.head.insertBefore(this.transport, doc.head.firstChild)
//6. 超时处理
if (this.opt.timeout && this.opt.timeout > 0) {
this.opt.timeoutID = setTimeout(function() {
_this.transport.onerror = _this.transport.onload = null
_this.dispatch(null)
}, this.opt.timeout)
}
} else {
this.xhr.onreadystatechange = function(ev) {
if (_this.opt.timeout && _this.opt.timeout > 0) {
_this.opt['time' + this.readyState] = ev.timeStamp
if (this.readyState === 4) {
_this.opt.isTimeout =
_this.opt.time4 - _this.opt.time1 > _this.opt.timeout
}
}
if (this.readyState !== 4) {
return
}
_this.dispatch(_this.opt.isTimeout ? null : _this.xhr)
}
// 6. 初始化xhr提交
this.xhr.open(this.opt.type, this.opt.url, true)
// 7. 设置头信息
for (var i in this.opt.headers) {
if (this.opt.headers[i]) this.xhr.setRequestHeader(i, this.opt.headers[i])
}
// 8. 发起网络请求
_this.xhr.send(_this.opt.param)
//超时处理
if (this.opt.timeout && this.opt.timeout > 0) {
this.xhr.timeout = this.opt.timeout
}
}
return this.defer.promise
}
// ---------------------- end ------------------------
if (!win.request) {
win.request = {
get: function(url) {
if (!url) throw new Error('argument url is required')
return new _request(url, 'GET')
},
post: function(url) {
if (!url) throw new Error('argument url is required')
return new _request(url, 'POST')
},
cache: {},
cid: 0,
version: '1.1.0-light'
}
Anot.ui.request = request.version
}
export default request