Skip to content

Commit

Permalink
✨ feat(project): add Message fuc download fullscreen guide
Browse files Browse the repository at this point in the history
  • Loading branch information
ishareme committed Jan 6, 2023
1 parent c5cf823 commit 9e2dca9
Show file tree
Hide file tree
Showing 16 changed files with 364 additions and 133 deletions.
12 changes: 6 additions & 6 deletions .cz-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,32 @@ module.exports = {
{ value: ':zap: perf', name: '⚡ perf: 性能优化' },
{
value: ':rocket: chore',
name: '🚀 chore: 构建过程或辅助工具的变动'
name: '🚀 chore: 构建过程或辅助工具的变动',
},
{ value: ':tada: init', name: '🎉 init: 初始化' },
{ value: ':memo: docs', name: '📝 docs: 文档变更' },
{
value: ':lipstick: style',
name: '💄 style: 代码格式(不影响代码运行的变动)'
name: '💄 style: 代码格式(不影响代码运行的变动)',
},
{
value: ':recycle: refactor',
name: '♻️ refactor: 重构(既不是增加feature,也不是修复bug)'
name: '♻️ refactor: 重构(既不是增加feature,也不是修复bug)',
},
{ value: ':white_check_mark: test', name: '✅ test: 增加测试' },
{ value: ':rewind: revert', name: '⏪️ revert: 回退' },
{ value: ':package: build', name: '📦️ build: 打包' }
{ value: ':package: build', name: '📦️ build: 打包' },
],
messages: {
type: '请选择提交类型:',
customScope: '请输入修改范围(可选):',
subject: '请简要描述提交(必填):',
body: '请输入详细描述(可选):',
footer: '请输入要关闭的issue(可选):',
confirmCommit: '确认使用以上信息提交?(y/n/e/h)'
confirmCommit: '确认使用以上信息提交?(y/n/e/h)',
},
// 跳过问题
skipQuestions: ['body', 'footer'],
// subject文字长度默认是72
subjectLimit: 72
subjectLimit: 100,
};
42 changes: 42 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
"dependencies": {
"@vueuse/core": "^9.10.0",
"axios": "^1.2.2",
"driver.js": "^0.9.8",
"file-saver": "^2.0.5",
"vue": "^3.2.45",
"vue-router": "^4.1.6",
"vuex": "^4.1.0",
Expand All @@ -32,6 +34,7 @@
"lint-staged": "^13.1.0",
"postcss": "^8.4.20",
"sass": "^1.57.1",
"tailwind-scrollbar": "^2.1.0",
"tailwindcss": "^3.2.4",
"vite": "^4.0.0",
"vite-plugin-svg-icons": "^2.0.1"
Expand Down
6 changes: 3 additions & 3 deletions src/libs/Button/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
@click.stop="onClick"
>
<!-- loading -->
<SvgIcon
<mSvgIcon
v-if="loading"
name="loading"
class="w-2 h-2 animate-spin mr-1"
/>
<!-- icon 按钮 -->
<SvgIcon
<mSvgIcon
v-if="icon"
:name="icon"
class="m-auto"
Expand Down Expand Up @@ -64,7 +64,7 @@ const sizeEnum = {
</script>

<script setup>
import SvgIcon from '../SvgIcon/index.vue';
import mSvgIcon from '../SvgIcon/index.vue';
/**
* 1. 构建type 风格 和 size 大小可选项
* 2. 通过props 控制按钮
Expand Down
22 changes: 22 additions & 0 deletions src/libs/Message/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { h, render } from 'vue';
import messageComponent from './index.vue';

export const Message = (type, content, duration = 3000) => {
/**
* 动画结束时的回调
*/
const onDestroy = () => {
// 3. message 销毁
render(null, document.body);
};

// 1. 返回 vnode
const vnode = h(messageComponent, {
type,
content,
duration,
destroy: onDestroy,
});
// 2. render
render(vnode, document.body);
};
122 changes: 122 additions & 0 deletions src/libs/Message/index.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
<template>
<transition name="down" @after-leave="destroy">
<div
v-show="isVisable"
class="min-w-[420px] fixed top-[20px] left-[50%] translate-x-[-50%] z-50 flex items-center px-3 py-1.5 rounded-sm border cursor-pointer"
:class="styles[type].containerClass"
>
<m-svg-icon
:name="styles[type].icon"
:fillClass="styles[type].fillClass"
class="h-1.5 w-1.5 mr-1.5"
/>
<span class="text-sm" :class="styles[type].textClass">
{{ content }}
</span>
</div>
</transition>
</template>

<script>
import mSvgIcon from '../SvgIcon/index.vue';
/**
* 消息类型可选项
*/
const typeEnum = ['success', 'warn', 'error'];
</script>

<script setup>
import { ref, onMounted } from 'vue';
const props = defineProps({
/**
* message 的消息类型
*/
type: {
type: String,
required: true,
validator(val) {
const result = typeEnum.includes(val);
if (!result) {
throw new Error(`type 必须是 ${typeEnum.join('')} 中的一个`);
}
return result;
},
},
/**
* 描述文本
*/
content: {
type: String,
required: true,
},
/**
* 展示时长
*/
duration: {
type: Number,
},
/**
* 关闭时的回调
*/
destroy: {
type: Function,
},
});
// 样式表数据
const styles = {
// 警告
warn: {
icon: 'warn',
fillClass: 'fill-warn-300',
textClass: 'text-warn-300',
containerClass:
'bg-warn-100 border-warn-200 hover:shadow-lg hover:shadow-warn-100',
},
// 错误
error: {
icon: 'error',
fillClass: 'fill-error-300',
textClass: 'text-error-300',
containerClass:
'bg-error-100 border-error-200 hover:shadow-lg hover:shadow-error-100',
},
// 成功
success: {
icon: 'success',
fillClass: 'fill-success-300',
textClass: 'text-success-300',
containerClass:
'bg-success-100 border-success-200 hover:shadow-lg hover:shadow-success-100',
},
};
// 控制显示处理
const isVisable = ref(false);
/**
* 保证动画展示,需要在 mounted 之后进行展示
*/
onMounted(() => {
isVisable.value = true;
/**
* 延迟时间关闭
*/
setTimeout(() => {
isVisable.value = false;
}, props.duration);
});
</script>

<style lang="scss" scoped>
.down-enter-active,
.down-leave-active {
transition: all 0.5s;
}
.down-enter-from,
.down-leave-to {
opacity: 0;
transform: translate3d(-50%, -100px, 0);
}
</style>
2 changes: 1 addition & 1 deletion src/libs/Search/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
<div
v-if="$slots.dropdown"
v-show="isFocus"
class="max-h-[368px] w-full text-base overflow-auto bg-white dark:bg-zinc-800 absolute top-[60px] left-0 z-20 p-2 rounded border border-b-zinc-200 dark:border-zinc-600 duration-200 hover:shadow-2xl"
class="max-h-[368px] w-full text-base overflow-auto bg-white dark:bg-zinc-800 absolute top-[60px] left-0 z-20 p-2 rounded border border-b-zinc-200 dark:border-zinc-600 duration-200 hover:shadow-2xl scrollbar-thin scrollbar-thumb-transparent xl:scrollbar-thumb-zinc-200 xl:dark:scrollbar-thumb-zinc-900 scrollbar-track-transparent"
>
<slot name="dropdown"></slot>
</div>
Expand Down
1 change: 1 addition & 0 deletions src/libs/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { defineAsyncComponent } from 'vue';

export { Confirm } from '@/libs/Confirm/index.js';
export { Message } from '@/libs/Message/index.js';

export default {
install(app) {
Expand Down
Loading

0 comments on commit 9e2dca9

Please sign in to comment.