This commit is contained in:
2025-05-07 10:49:08 +08:00
parent f085b3c79b
commit 055c9a49b7
10 changed files with 1984 additions and 87 deletions

View File

@@ -35,7 +35,8 @@
"build:mp-xhs": "uni build -p mp-xhs",
"build:quickapp-webview": "uni build -p quickapp-webview",
"build:quickapp-webview-huawei": "uni build -p quickapp-webview-huawei",
"build:quickapp-webview-union": "uni build -p quickapp-webview-union"
"build:quickapp-webview-union": "uni build -p quickapp-webview-union",
"postinstall": "weapp-tw patch"
},
"dependencies": {
"@dcloudio/uni-app": "3.0.0-alpha-4050420250306001",
@@ -78,8 +79,10 @@
"@dcloudio/uni-cli-shared": "3.0.0-alpha-4050420250306001",
"@dcloudio/uni-stacktracey": "3.0.0-alpha-4050420250306001",
"@dcloudio/vite-plugin-uni": "3.0.0-alpha-4050420250306001",
"@tailwindcss/postcss": "^4.1.5",
"@types/crypto-js": "^4.2.2",
"@vue/runtime-core": "^3.4.21",
"vite": "6.2.2"
"vite": "6.3.5",
"weapp-tailwindcss": "^4.1.7"
}
}

1913
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

View File

@@ -19,5 +19,9 @@ export default {
</script>
<style>
/*每个页面公共css */
/* #ifdef MP-WEIXIN */
@import "weapp-tailwindcss/css";
@source not "dist";
/* #endif */
</style>

View File

@@ -1,7 +1,7 @@
<script setup>
import {ref} from 'vue';
const {src, list} = defineProps({
const {src, list, imageClass} = defineProps({
src: {
type: String,
default: "",
@@ -13,6 +13,10 @@ const {src, list} = defineProps({
cur: {
type: Number,
default: 0,
},
imageClass: {
type: String,
default: ''
}
});
@@ -28,7 +32,7 @@ const preview = () => {
<image @click="preview" v-bind="$attrs" :src="src" mode="aspectFill"></image>
<!-- #endif -->
<!-- #ifdef MP-WEIXIN -->
<image @click="preview" :src="src" mode="aspectFill"></image>
<image @click="preview" :class="imageClass" :src="src" mode="aspectFill"></image>
<!-- #endif -->
<view

View File

@@ -54,7 +54,8 @@
"setting": {
"urlCheck": false
},
"usingComponents": true
"usingComponents": true,
"lazyCodeLoading": "requiredComponents"
},
"h5": {
"router": {

View File

@@ -1,6 +1,14 @@
{
"pages": [
//pages数组中第一项表示应用启动页参考https://uniapp.dcloud.io/collocation/pages
// #ifdef MP-WEIXIN
{
"path": "pages/downloadMaterials/index",
"style": {
"navigationBarTitleText": "领取素材"
}
},
// #endif
// #ifndef MP-WEIXIN
{
"path": "pages/home/index",
"style": {
@@ -72,13 +80,6 @@
"navigationStyle": "custom"
}
},
{
"path": "pages/downloadMaterials/index",
"style": {
"navigationBarTitleText": "领取素材",
"navigationStyle": "custom"
}
},
{
"path": "pages/comingSoon/index",
"style": {
@@ -156,6 +157,7 @@
"navigationStyle": "custom"
}
}
// #endif
],
"globalStyle": {
"navigationBarTextStyle": "black",
@@ -170,6 +172,7 @@
"tui-(.*)": "thorui-uni/lib/thorui/tui-$1/tui-$1.vue"
}
},
// #ifndef MP-WEIXIN
"tabBar": {
"color": "#C9CDD4",
"selectedColor": "#2D5CF6",
@@ -202,4 +205,5 @@
}
]
}
// #endif
}

View File

@@ -35,7 +35,9 @@ const tabs = ref([
<template>
<!--下载素材-->
<!-- #ifndef MP-WEIXIN -->
<x-nav></x-nav>
<!-- #endif -->
<tui-tabs :tabs="tabs" :currentTab="current" @change="({index})=>current=index"></tui-tabs>
@@ -72,14 +74,14 @@ const tabs = ref([
<view class="title">素材请按顺序下载&发布</view>
<view class="info">
<view class="!grid grid-cols-5 flex-wrap gap-[32rpx]">
<x-image :src="testIcon" class="!w-[100%] !h-auto !aspect-square"></x-image>
<x-image :src="testIcon" class="!w-[100%] !h-auto !aspect-square"></x-image>
<x-image :src="testIcon" class="!w-[100%] !h-auto !aspect-square"></x-image>
<x-image :src="testIcon" class="!w-[100%] !h-auto !aspect-square"></x-image>
<x-image :src="testIcon" class="!w-[100%] !h-auto !aspect-square"></x-image>
<x-image :src="testIcon" class="!w-[100%] !h-auto !aspect-square"></x-image>
<x-image :src="testIcon" class="!w-[100%] !h-auto !aspect-square"></x-image>
<x-image :src="testIcon" class="!w-[100%] !h-auto !aspect-square"></x-image>
<x-image :src="testIcon" imageClass="!w-[100%] !h-auto !aspect-square"></x-image>
<x-image :src="testIcon" imageClass="!w-[100%] !h-auto !aspect-square"></x-image>
<x-image :src="testIcon" imageClass="!w-[100%] !h-auto !aspect-square"></x-image>
<x-image :src="testIcon" imageClass="!w-[100%] !h-auto !aspect-square"></x-image>
<x-image :src="testIcon" imageClass="!w-[100%] !h-auto !aspect-square"></x-image>
<x-image :src="testIcon" imageClass="!w-[100%] !h-auto !aspect-square"></x-image>
<x-image :src="testIcon" imageClass="!w-[100%] !h-auto !aspect-square"></x-image>
<x-image :src="testIcon" imageClass="!w-[100%] !h-auto !aspect-square"></x-image>
</view>
<view class="copy-button" @click="download(mock)">批量保存</view>
@@ -92,30 +94,34 @@ const tabs = ref([
正文正文正文正文正文正文正文正文正文正文正文正文正文正文正文正文正文正文正文正文正文正文正文文正文正文文正文正文文正文正文
<view class="!grid grid-cols-5 flex-wrap gap-[32rpx]">
<x-image :src="testIcon" class="!w-[100%] !h-auto !aspect-square"></x-image>
<x-image :src="testIcon" class="!w-[100%] !h-auto !aspect-square"></x-image>
<x-image :src="testIcon" class="!w-[100%] !h-auto !aspect-square"></x-image>
<x-image :src="testIcon" imageClass="!w-[100%] !h-auto !aspect-square"></x-image>
<x-image :src="testIcon" imageClass="!w-[100%] !h-auto !aspect-square"></x-image>
<x-image :src="testIcon" imageClass="!w-[100%] !h-auto !aspect-square"></x-image>
</view>
<view class="!flex gap-[24rpx] justify-center">
<view class="copy-button !mx-0" @click="copy('我是标题我是标题我是标题我是标题我是标题')">复制文字</view>
<view class="copy-button !mx-0" @click="copy('我是标题我是标题我是标题我是标题我是标题')">复制文字
</view>
<view class="copy-button !mx-0" @click="download(mock)">保存图片</view>
</view>
</view>
</view>
<view class="block">
<view class="title">评论2<x-link class="!ml-auto" show-description>查看引导</x-link></view>
<view class="title">评论2
<x-link class="!ml-auto" show-description>查看引导</x-link>
</view>
<view class="info">
正文正文正文正文正文正文正文正文正文正文正文正文正文正文正文正文正文正文正文正文正文正文正文文正文正文文正文正文文正文正文
<view class="!grid grid-cols-5 flex-wrap gap-[32rpx]">
<x-image :src="testIcon" class="!w-[100%] !h-auto !aspect-square"></x-image>
<x-image :src="testIcon" class="!w-[100%] !h-auto !aspect-square"></x-image>
<x-image :src="testIcon" imageClass="!w-[100%] !h-auto !aspect-square"></x-image>
<x-image :src="testIcon" imageClass="!w-[100%] !h-auto !aspect-square"></x-image>
</view>
<view class="!flex gap-[24rpx] justify-center">
<view class="copy-button !mx-0" @click="copy('我是标题我是标题我是标题我是标题我是标题')">复制文字</view>
<view class="copy-button !mx-0" @click="copy('我是标题我是标题我是标题我是标题我是标题')">复制文字
</view>
<view class="copy-button !mx-0" @click="download(mock)">保存图片</view>
</view>
</view>

View File

@@ -1 +1,3 @@
/* #ifndef MP-WEIXIN */
@import "tailwindcss";
/* #endif */

View File

@@ -1,8 +1,7 @@
export const showToast = (options) => {
if (typeof options === 'string') {
uni.showToast({
title: options,
icon: 'none',
title: options, icon: 'none',
}).then();
} else {
uni.showToast(options).then();
@@ -31,6 +30,7 @@ export const backPage = () => {
}
export const copy = (context) => {
// #ifndef APP-PLUS || MP-WEIXIN
try {
navigator.clipboard.writeText(context)
.then(() => {
@@ -42,10 +42,20 @@ export const copy = (context) => {
} catch (e) {
showToast('复制失败');
}
// #endif
// #ifdef APP-PLUS || MP-WEIXIN
uni.setClipboardData({
data: context, success: () => {
showToast('已复制');
}, fail: () => {
showToast('复制失败');
}
})
// #endif
}
export const download = (urls) => {
// #ifndef APP-PLUS
// #ifndef APP-PLUS || MP-WEIXIN
const promises1 = urls.map(url => new Promise((resolve, reject) => {
const iframe = document.createElement('iframe');
iframe.src = url;
@@ -62,16 +72,14 @@ export const download = (urls) => {
// #ifdef APP-PLUS
const promises2 = urls.map(v => new Promise((resolve, reject) => {
urls.forEach(v => {
uni.downloadFile({
url: v,
success: () => {
resolve(true);
},
fail: () => {
reject(false);
}
})
uni.downloadFile({
url: v,
success: () => {
resolve(true);
},
fail: () => {
reject(false);
}
})
}));
Promise.all(promises2).then(() => {
@@ -80,4 +88,32 @@ export const download = (urls) => {
showToast('保存失败');
});
// #endif
// #ifdef MP-WEIXIN
const promises3 = urls.map(v => new Promise((resolve, reject) => {
uni.downloadFile({
url: v,
success: ({tempFilePath}) => {
uni.saveImageToPhotosAlbum({
filePath: tempFilePath,
success: () => {
resolve(true);
},
fail: (err) => {
console.log(err);
reject(false);
}
})
},
fail: () => {
reject(false);
}
})
}));
Promise.all(promises3).then(() => {
showToast('保存成功');
}).catch(() => {
showToast('保存失败');
});
// #endif
}

View File

@@ -1,13 +1,21 @@
import {defineConfig} from 'vite';
import uni from '@dcloudio/vite-plugin-uni';
import tailwindcss from "@tailwindcss/vite";
import {UnifiedViteWeappTailwindcssPlugin} from 'weapp-tailwindcss/vite';
import tailwindcss from '@tailwindcss/postcss'
export default defineConfig({
plugins: [
uni.default(),
tailwindcss(),
UnifiedViteWeappTailwindcssPlugin({
rem2rpx: true,
})
],
css: {
postcss: {
plugins: [
tailwindcss()
]
},
preprocessorOptions: {
scss: {
silenceDeprecations: ['legacy-js-api'],