|
@@ -6,37 +6,39 @@
|
|
|
:class="innerClass"
|
|
:class="innerClass"
|
|
|
@click="handleClick"
|
|
@click="handleClick"
|
|
|
>
|
|
>
|
|
|
- <view v-if="showBackgroundEffect" :style="(backgroundEffectStyle as any)">
|
|
|
|
|
- </view>
|
|
|
|
|
- <view v-if="showBackgroundEffect" :style="(backgroundEffectStyle2 as any)">
|
|
|
|
|
- </view>
|
|
|
|
|
- <image
|
|
|
|
|
- :style="{
|
|
|
|
|
- width: precentOrFull(style.width),
|
|
|
|
|
- height: precentOrFull(style.height),
|
|
|
|
|
- borderRadius: themeContext.resolveThemeSize(props.radius),
|
|
|
|
|
- }"
|
|
|
|
|
- :mode="(mode as any)"
|
|
|
|
|
- :lazyLoad="$attrs.lazyLoad"
|
|
|
|
|
- :fadeShow="$attrs.fadeShow"
|
|
|
|
|
- :webp="$attrs.webp"
|
|
|
|
|
- :show-menu-by-longpress="$attrs.showMenuByLongpress"
|
|
|
|
|
- :draggable="$attrs.draggable"
|
|
|
|
|
- :src="isErrorState ? failedImage : (src || defaultImage)"
|
|
|
|
|
- @loadstart="isLoadState = true"
|
|
|
|
|
- @load="isLoadState = false"
|
|
|
|
|
- @error="isErrorState = true; isLoadState = false"
|
|
|
|
|
- />
|
|
|
|
|
- <view v-if="showFailed && isErrorState && !failedImage" class="inner-view error">
|
|
|
|
|
- <Icon icon="warning" color="text.second" :size="32" noError />
|
|
|
|
|
- <Text v-if="realWidth > 50" color="text.second" :text="src ? '加载失败' : '暂无图片'" :fontSize="22" />
|
|
|
|
|
- </view>
|
|
|
|
|
- <view v-if="showLoading && isLoadState" class="inner-view loading">
|
|
|
|
|
- <ActivityIndicator
|
|
|
|
|
- :color="themeContext.resolveThemeColor(loadingColor)"
|
|
|
|
|
- :size="themeContext.resolveThemeSize(loadingSize)"
|
|
|
|
|
|
|
+ <template v-if="mode !== 'borderImage'">
|
|
|
|
|
+ <view v-if="showBackgroundEffect" :style="(backgroundEffectStyle as any)">
|
|
|
|
|
+ </view>
|
|
|
|
|
+ <view v-if="showBackgroundEffect" :style="(backgroundEffectStyle2 as any)">
|
|
|
|
|
+ </view>
|
|
|
|
|
+ <image
|
|
|
|
|
+ :style="{
|
|
|
|
|
+ width: precentOrFull(style.width),
|
|
|
|
|
+ height: precentOrFull(style.height),
|
|
|
|
|
+ borderRadius: themeContext.resolveThemeSize(props.radius),
|
|
|
|
|
+ }"
|
|
|
|
|
+ :mode="(mode as any)"
|
|
|
|
|
+ :lazyLoad="$attrs.lazyLoad"
|
|
|
|
|
+ :fadeShow="$attrs.fadeShow"
|
|
|
|
|
+ :webp="$attrs.webp"
|
|
|
|
|
+ :show-menu-by-longpress="$attrs.showMenuByLongpress"
|
|
|
|
|
+ :draggable="$attrs.draggable"
|
|
|
|
|
+ :src="isErrorState ? failedImage : (src || defaultImage)"
|
|
|
|
|
+ @loadstart="isLoadState = true"
|
|
|
|
|
+ @load="isLoadState = false"
|
|
|
|
|
+ @error="isErrorState = true; isLoadState = false"
|
|
|
/>
|
|
/>
|
|
|
- </view>
|
|
|
|
|
|
|
+ <view v-if="showFailed && isErrorState && !failedImage" class="inner-view error">
|
|
|
|
|
+ <Icon icon="warning" color="text.second" :size="32" noError />
|
|
|
|
|
+ <Text v-if="realWidth > 50" color="text.second" :text="src ? '加载失败' : '暂无图片'" :fontSize="22" />
|
|
|
|
|
+ </view>
|
|
|
|
|
+ <view v-if="showLoading && isLoadState" class="inner-view loading">
|
|
|
|
|
+ <ActivityIndicator
|
|
|
|
|
+ :color="themeContext.resolveThemeColor(loadingColor)"
|
|
|
|
|
+ :size="themeContext.resolveThemeSize(loadingSize)"
|
|
|
|
|
+ />
|
|
|
|
|
+ </view>
|
|
|
|
|
+ </template>
|
|
|
<slot v-if="!src && !defaultImage" name="empty"></slot>
|
|
<slot v-if="!src && !defaultImage" name="empty"></slot>
|
|
|
<slot />
|
|
<slot />
|
|
|
</view>
|
|
</view>
|
|
@@ -111,11 +113,16 @@ export interface ImageProps {
|
|
|
* @default 0
|
|
* @default 0
|
|
|
*/
|
|
*/
|
|
|
radius?: string|number,
|
|
radius?: string|number,
|
|
|
|
|
+
|
|
|
|
|
+ borderImageSlice?: number,
|
|
|
|
|
+ borderImageRepeat?: 'stretch' | 'repeat' | 'round',
|
|
|
|
|
+ borderImageWidth?: number,
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 内部样式
|
|
* 内部样式
|
|
|
*/
|
|
*/
|
|
|
innerStyle?: object;
|
|
innerStyle?: object;
|
|
|
- mode?: 'aspectFill' | 'aspectFit' | 'widthFix' | 'heightFix' | 'top' | 'bottom' | 'left' | 'right' | 'center',
|
|
|
|
|
|
|
+ mode?: 'aspectFill' | 'aspectFit' | 'widthFix' | 'heightFix' | 'top' | 'bottom' | 'left' | 'right' | 'center' | 'borderImage',
|
|
|
innerClass?: string,
|
|
innerClass?: string,
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -159,6 +166,12 @@ const style = computed(() => {
|
|
|
height: themeContext.resolveThemeSize(props.height),
|
|
height: themeContext.resolveThemeSize(props.height),
|
|
|
...props.innerStyle,
|
|
...props.innerStyle,
|
|
|
}
|
|
}
|
|
|
|
|
+ if (props.mode === 'borderImage') {
|
|
|
|
|
+ o.borderImageSource = `url('${props.src || props.defaultImage}')`;
|
|
|
|
|
+ o.borderImageSlice = props.borderImageSlice;
|
|
|
|
|
+ o.borderImageRepeat = props.borderImageRepeat;
|
|
|
|
|
+ o.borderImageWidth = props.borderImageWidth;
|
|
|
|
|
+ }
|
|
|
return o;
|
|
return o;
|
|
|
});
|
|
});
|
|
|
const backgroundEffectStyle = computed(() => ({
|
|
const backgroundEffectStyle = computed(() => ({
|