Browse Source

upd: toast

suzigang 4 years ago
parent
commit
0a915f8a90

+ 1 - 0
package.json

@@ -61,6 +61,7 @@
   "devDependencies": {
     "@commitlint/cli": "^10.0.0",
     "@commitlint/config-conventional": "^10.0.0",
+    "@jd/upload-oss-tools": "^1.1.10",
     "@types/node": "^14.14.31",
     "@vitejs/plugin-vue": "^1.2.0",
     "@vue/compiler-sfc": "^3.0.5",

+ 2 - 2
src/packages/toast/demo.vue

@@ -42,10 +42,10 @@ export default createDemo({
     const { ctx } = getCurrentInstance();
 
     const textToast = msg => {
-      ctx.$toast.text(msg, { duration: 100000 });
+      ctx.$toast.text(msg, { duration: 1000 });
     };
     const successToast = msg => {
-      ctx.$toast.success(msg, { duration: 100000 });
+      ctx.$toast.success(msg, { duration: 2000 });
     };
     const errorToast = msg => {
       ctx.$toast.fail(msg);

+ 9 - 9
src/packages/toast/doc.md

@@ -81,16 +81,16 @@ toast.hide();
 | duration            | 展示时长(毫秒)<br>值为 0 时,toast 不会自动消失(loading类型默认为0)       | Number        | 2000                          |
 | center              | 是否展示在页面中部(为false时展示在底部)                                     | Boolean       | true                          |
 | bottom              | 距页面底部的距离(像素),option.center为false时生效                          | Number       | 30                          |
-| textAlignCenter     | 多行文案是否居中                                                              | Boolean       | true                          |
-| bgColor             | 背景颜色(透明度)                                                            | String        | "rgba(46, 46, 46, 0.7)"       |
-| customClass         | 自定义类名                                                                    | String        | ""                            |
+| text-align-center     | 多行文案是否居中                                                              | Boolean       | true                          |
+| bg-color             | 背景颜色(透明度)                                                            | String        | "rgba(0, 0, 0, 0.8)"       |
+| custom-class         | 自定义类名                                                                    | String        | ""                            |
 | icon                | 自定义图标,**支持图片链接或base64格式**                                        | String        | ""                            |
 | size                | 文案尺寸,**small**/**base**/**large**三选一                                                  | String        | "base"                        |
 | cover               | 是否显示遮罩层,loading类型默认显示                                           | Boolean       | loading类型true/其他类型false |
-| coverColor          | 遮罩层颜色,默认透明                                                          | String        | "rgba(0,0,0,0)"               |
-| loadingRotate       | loading图标是否旋转,仅对loading类型生效                                      | Boolean       | true                          |
-| onClose             | 关闭时触发的事件                                                              | function      | null                          |
-| closeOnClickOverlay | 是否在点击遮罩层后关闭提示                                                    | Boolean       | false                         |
-| toastStyle          | 提示框style                                                        | object       | {}                         |
-| toastClass          | 提示框class                                                        | String       | ""                         |
+| cover-color          | 遮罩层颜色,默认透明                                                          | String        | "rgba(0,0,0,0)"               |
+| loading-rotate       | loading图标是否旋转,仅对loading类型生效                                      | Boolean       | true                          |
+| on-close             | 关闭时触发的事件                                                              | function      | null                          |
+| close-on-click-overlay | 是否在点击遮罩层后关闭提示                                                    | Boolean       | false                         |
+| toast-style          | 提示框style                                                        | object       | {}                         |
+| toast-class          | 提示框class                                                        | String       | ""                         |
 

+ 15 - 23
src/packages/toast/index.scss

@@ -16,60 +16,56 @@
   pointer-events: none;
   z-index: 9999;
   font-family: $font-family;
-  &.nut-toast-small {
+  &-small {
     .nut-toast-inner {
       font-size: $font-size-small;
     }
   }
-  &.nut-toast-large {
+  &-large {
     .nut-toast-inner {
       font-size: $font-size-large;
     }
   }
-  &.nut-toast-cover {
+  &-cover {
     display: flex;
     align-items: center;
     justify-content: center;
     pointer-events: auto;
     height: 100%;
   }
-  .nut-toast-inner {
-    // position: relative;
+  &-inner {
     display: inline-block;
     font-size: $font-size-base;
     min-width: 40%;
     max-width: 65%;
     text-align: center;
-    line-height: 1.5;
-    padding: 10px 30px;
+    padding: 24px 30px;
     word-break: break-all;
     background: rgba(0, 0, 0, 0);
-    border-radius: 7px;
-    color: #fff;
+    border-radius: 12px;
+    color: $white;
   }
-  .nut-toast-text {
+  &-text {
     font-size: 14px;
-  }
-  &.nut-toast-has-icon {
-    .nut-toast-inner {
-      padding: 22px 15px 15px;
+    &:empty {
+      margin-bottom: -8px;
     }
+  }
+  &-has-icon {
     .nut-toast-icon-wrapper {
       width: 100%;
-      height: 50px;
       display: flex;
       align-items: center;
       justify-content: center;
-      margin-bottom: 18px;
+      margin-bottom: 8px;
     }
   }
-  &.nut-toast-center {
+  &-center {
     top: 50%;
     transform: translateY(-50%);
   }
-  &.nut-loading {
+  &-loading {
     .nut-toast-inner {
-      padding: 25px;
       display: inline-flex;
       flex-direction: column;
       justify-content: center;
@@ -78,10 +74,6 @@
     .nut-toast-icon-wrapper {
       animation: rotation 2s linear infinite;
     }
-    .nut-toast-text:not(:empty) {
-      margin-top: 10px;
-      margin-bottom: -10px;
-    }
   }
 }
 

File diff suppressed because it is too large
+ 2 - 4
src/packages/toast/index.ts


+ 3 - 3
src/packages/toast/index.vue

@@ -17,7 +17,7 @@
         }"
       >
         <view v-if="hasIcon" class="nut-toast-icon-wrapper">
-          <nut-icon size="44px" color="#ffffff" :name="icon"></nut-icon>
+          <nut-icon size="20" color="#ffffff" :name="icon"></nut-icon>
         </view>
         <view class="nut-toast-text" v-html="msg"></view>
       </view>
@@ -65,7 +65,7 @@ export default create({
     },
     bgColor: {
       type: String,
-      default: 'rgba(0, 0, 0, 1)'
+      default: 'rgba(0, 0, 0, .8)'
     },
 
     onClose: Function,
@@ -140,7 +140,7 @@ export default create({
         { 'nut-toast-center': props.center },
         { 'nut-toast-has-icon': hasIcon.value },
         { 'nut-toast-cover': props.cover },
-        { 'nut-loading': props.type == 'loading' },
+        { 'nut-toast-loading': props.type === 'loading' },
         props.customClass,
         'nut-toast-' + props.size
       ];

+ 16 - 3
src/sites/mobile/App.vue

@@ -1,10 +1,13 @@
 <template>
-  <div v-if="title != '/'" id="nav">{{ title }}</div>
+  <div v-if="title != '/'" id="nav">
+    <span class="back" @click="goBack"><nut-icon name="left"></nut-icon></span>
+    {{ title }}
+  </div>
   <router-view />
 </template>
 <script lang="ts">
 import { defineComponent, ref, watch } from 'vue';
-import { useRoute } from 'vue-router';
+import { useRoute, useRouter } from 'vue-router';
 import { isMobile } from '@/sites/assets/util';
 export default defineComponent({
   name: 'app',
@@ -12,6 +15,12 @@ export default defineComponent({
     const title = ref('NutUI');
     // 获取当前路由
     const route = useRoute();
+    const router = useRouter();
+
+    //返回demo页
+    const goBack = () => {
+      router.push('/');
+    };
     // 当当前路由发生变化时,调用回调函数
     watch(
       () => route,
@@ -31,7 +40,7 @@ export default defineComponent({
       }
     );
 
-    return { title };
+    return { title, goBack };
   }
 });
 </script>
@@ -57,6 +66,10 @@ export default defineComponent({
     font-size: 20px;
     color: rgba(51, 51, 51, 1);
     box-shadow: 0px 4px 10px 0px rgba(0, 0, 0, 0.07);
+    .back {
+      position: absolute;
+      left: 25px;
+    }
   }
 
   .demo {