Skip to content

Commit

Permalink
Chore: release 1.2.10
Browse files Browse the repository at this point in the history
  • Loading branch information
Maorey committed Apr 20, 2020
1 parent 30f4d93 commit 7792610
Show file tree
Hide file tree
Showing 40 changed files with 2,162 additions and 1,093 deletions.
2 changes: 0 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
"git.autofetch": true,
"git.enableSmartCommit": true,

"svn.enableProposedApi": "product",

"files.trimTrailingWhitespace": true,

"typescript.tsdk": "./node_modules/typescript/lib",
Expand Down
42 changes: 9 additions & 33 deletions .vscode/vue.code-snippets
Original file line number Diff line number Diff line change
Expand Up @@ -225,41 +225,28 @@
"} from 'vuex-module-decorators'",
"import store from '${3:../}'",
"",
"/** ${1:动态模块}",
" */",
"/** ${1:动态模块} */",
"interface ${4:IDynamic} {",
" /** 是否动态",
" */",
" /** 是否动态 */",
" dynamic: boolean",
"",
" // ...",
"}",
"",
"/** ${1:动态模块}",
" */",
"/** ${1:动态模块} */",
"@Module({ dynamic: true, namespaced: true, name: '${5:dynamic}', store })",
"class ${6:Dynamic} extends VuexModule implements ${4:IDynamic} {",
" /// State & Getter(public) ///",
" dynamic = true",
"",
" /// Mutation 无法调用/commit 必须通过Action ///",
" /// Mutation ///",
" @Mutation",
" private DYNAMIC(dynamic: boolean) {",
" DYNAMIC(dynamic: boolean) {",
" this.dynamic = dynamic",
" }",
"",
" /// Action ///",
" /** 设置动态【同步】",
" * @param {Boolean} dynamic 是否动态",
" */",
" @Action",
" setDynamic(dynamic: boolean) {",
" // this.context.commit('DYNAMIC', dynamic) // 非动态模块",
" this.DYNAMIC(dynamic) // 动态模块",
" }",
"",
" /** 初始化是否动态属性【异步】",
" */",
" /** 初始化是否动态属性 */",
" @Action",
" async initDynamic() {",
" const dynamic = await Promise.resolve(true)",
Expand Down Expand Up @@ -291,31 +278,20 @@
"} from 'vuex-module-decorators'",
"import store from '${3:../}'",
"",
"/** ${1:动态模块}",
" */",
"/** ${1:动态模块} */",
"@Module({ dynamic: true, namespaced: true, name: '${4:dynamic}', store })",
"class ${5:Dynamic} extends VuexModule {",
" /// State & Getter(public) ///",
" dynamic = true",
"",
" /// Mutation 无法调用/commit 必须通过Action ///",
" /// Mutation ///",
" @Mutation",
" DYNAMIC(dynamic) {",
" this.dynamic = dynamic",
" }",
"",
" /// Action ///",
" /** 设置动态【同步】",
" * @param {Boolean} dynamic 是否动态",
" */",
" @Action",
" setDynamic(dynamic) {",
" // this.context.commit('DYNAMIC', dynamic) // 非动态模块",
" this.DYNAMIC(dynamic) // 动态模块",
" }",
"",
" /** 初始化是否动态属性【异步】",
" */",
" /** 初始化是否动态属性 */",
" @Action",
" async initDynamic() {",
" const dynamic = await Promise.resolve(true)",
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# 更新日志

## v 1.2.10

- banner插件
- 工具函数优化
- 文件/图片下载内存管理

## v 1.2.9

- 修复异步css chunk包含不定数量(皮肤/默认)文件问题等
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@ yarn vue-cli-service help # [命令] : 比如 yarn vue-cli-service help test:e2e
- Vue实例**私有属性**命名规则(避免 [属性名](https://cn.vuejs.org/v2/style-guide/#私有属性名-必要) 冲突):
- `$_` 实例命名空间(在保证易维护的前提下可以使用单字母, 但应尽量避免)
- `_$` **全局/跨组件/hack**命名空间, 命名前应**先全局搜索**是否有重复
- `/^[$_]+_$/` 注入**vue data 选项**命名空间应满足该正则, 即以`_`结尾(因为以`$_`其中一个字符开头的Vue不会劫持), 命名前应**先全局搜索**是否有重复
- 除了以下样式可以使用全局:
Expand Down Expand Up @@ -604,8 +605,8 @@ yarn vue-cli-service help # [命令] : 比如 yarn vue-cli-service help test:e2e
// ...
```
- 路由视图不需要被缓存的, 可以在自己的`deactivated`钩子销毁实例`this.$destroy()`
- 所有响应路由变化的可缓存组件(不缓存如上), 应确保失活/休眠后不再响应路由变化, 推荐使用 `@com/ChooserAsyncFunctional` 包裹
- 所有视图组件可接收props:`route`代替`this.$route`, 区别是: **只在首次进入当前视图或当前视图url发生变化时改变**
- 路由视图不需要被缓存的, 可以在`deactivated`钩子销毁实例(`this.$destroy()`)或者`activated`钩子进行更新
- 为避免渲染错误, 请务必为<b style="color: red;">循环创建的组件</b>**加上 `key`**, 特别是 `tsx/ts/jsx/js`
### 配置和优化
Expand Down
16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"crypto-js": "3.3.0",
"d3": "^5.15.1",
"echarts": "^4.7.0",
"element-ui": "^2.13.0",
"element-ui": "^2.13.1",
"jsencrypt": "^3.0.0-rc.1",
"luma.gl": "^7.3.2",
"normalize.css": "^8.0.1",
Expand All @@ -28,10 +28,10 @@
"three": "^0.115.0",
"vue": "^2.6.11",
"vue-class-component": "^7.2.3",
"vue-i18n": "^8.16.0",
"vue-i18n": "^8.17.3",
"vue-property-decorator": "^8.4.1",
"vue-router": "^3.1.6",
"vuex": "^3.1.3",
"vuex": "^3.2.0",
"vuex-class": "^0.3.2",
"vuex-module-decorators": "^0.16.1",
"zdog": "^1.1.2",
Expand All @@ -44,10 +44,10 @@
"@babel/plugin-proposal-private-methods": "^7.8.3",
"@types/crypto-js": "3.1.44",
"@types/d3": "^5.7.2",
"@types/echarts": "^4.4.5",
"@types/echarts": "^4.4.6",
"@types/jest": "^25.2.1",
"@typescript-eslint/eslint-plugin": "^2.27.0",
"@typescript-eslint/parser": "^2.27.0",
"@typescript-eslint/eslint-plugin": "^2.28.0",
"@typescript-eslint/parser": "^2.28.0",
"@vue/cli-plugin-babel": "~4.3.1",
"@vue/cli-plugin-e2e-cypress": "~4.3.1",
"@vue/cli-plugin-eslint": "~4.3.1",
Expand All @@ -70,14 +70,14 @@
"eslint-plugin-vue": "^6.2.2",
"fibers": "^4.0.2",
"hard-source-webpack-plugin": "^0.13.1",
"lint-staged": "^10.1.3",
"lint-staged": "^10.1.6",
"postcss-preset-env": "^6.7.0",
"regenerate": "^1.4.0",
"regjsgen": "^0.5.1",
"regjsparser": "^0.6.4",
"sass": "^1.26.3",
"sass-loader": "^8.0.2",
"stylelint": "^13.3.1",
"stylelint": "^13.3.2",
"stylelint-config-scss-maorey": "^1.1.1",
"stylelint-webpack-plugin": "^1.2.3",
"typescript": "~3.8.3",
Expand Down
47 changes: 34 additions & 13 deletions src/components/ChooserAsync.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,24 +24,36 @@ export const enum status {
loading = 2,
error = 3,
empty = 4,
success = 5,
}
type component = status | string | Comp
type filter = (data: any) => { data: any; comp: component } | void

/// 选项 name,directives,filters,extends,mixins ///
const DIC_SLOT = {
[status.none]: 'none',
[status.loading]: 'loading',
[status.error]: 'error',
[status.empty]: 'empty',
}
/** 异步选择器组件, 最终渲染组件将得到一个prop: data, 即异步结果
*
* props: 见: @Prop 【注意】: get/error 变化时会重新请求
* props: 见: Prop 【注意】: get/error 变化时会重新请求
*
* events: 见: const enum status 键值
* slots: 支持默认插槽/默认作用域插槽 二选一 (二者都有时无法确定顺序, 所以只能二选一)
*
* slots: 见: const enum status 键值, 支持对应作用域插槽/插槽【二选一】作用域插槽优先(二者都有时无法确定顺序, 故)
*
* 示例:
* <template>
* <ChooserAsync :get="get" @error="handleError">
* <template #none>啥也没有</template>
* <!-- 同#success -->
* <template #default="{ data }">
* <textarea :value="JSON.stringify(data)" />
* </template>
* </ChooserAsync>
* </template>
*
* ( import 咋没得文档呢, 因为tsx么... ┐(: ´ ゞ`)┌ )
*/
@Component
Expand Down Expand Up @@ -130,34 +142,43 @@ export default class extends Vue {
// see: https://github.com/vuejs/jsx#installation
// eslint-disable-next-line @typescript-eslint/no-unused-vars
private render(h: CreateElement) {
const Comp: any = this.is // for 依赖收集
// for 依赖收集 失活返回缓存
if (this.isSleep) {
return this.$_vnode
}

let temp: any
let Comp: any = this.is // for 依赖收集
let slot
if ((slot = DIC_SLOT[Comp as keyof typeof DIC_SLOT])) {
this.$emit(slot)
slot = this.$scopedSlots[slot]
? (this.$scopedSlots[slot] as any)(this.$_data)
: this.$slots[slot]
if (slot && slot.length) {
Comp = this.tag
return (this.$_vnode = <Comp on={{ $: this.i }}>{slot}</Comp>)
}
}

switch (Comp) {
case status.none:
this.$emit('none')
return (this.$_vnode = undefined)
case status.loading:
this.$emit('loading')
return (this.$_vnode = <Loading />)
case status.empty:
this.$emit('empty')
return (this.$_vnode = (
<Info icon="el-icon-info" type="info" msg="empty" retry="" />
))
case status.error:
this.$emit('error')
return (this.$_vnode = <Info on={{ $: this.i }} />)
default:
this.$emit('success')
slot = this.$scopedSlots
slot = slot.success || slot.default
return (this.$_vnode = (
<Comp {...this.$_data}>
{this.$slots.default ||
((temp = this.$scopedSlots.default) && temp(this.$_data.props))}
<Comp {...{ ...this.$data, ...this.$_data }}>
{slot
? slot(this.$_data)
: (slot = this.$slots).success || slot.default}
</Comp>
))
}
Expand Down
Loading

0 comments on commit 7792610

Please sign in to comment.