From 50d43a2fc531e5cd757bdbeafdce3bf6999d1fbb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A9=99=E5=AD=90?= <454313500@qq.com> Date: Sun, 16 Oct 2022 22:51:53 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=E6=8E=A8=E8=8D=90=E9=A1=B5?= =?UTF-8?q?=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/ArticleController.cs | 4 ++- .../Controllers/FileController.cs | 26 ++++++++---------- .../yi-sqlsugar-dev.db | Bin 364544 -> 364544 bytes .../Yi.Framework.Common/Helper/TreeHelper.cs | 6 ++-- Yi.Vue3.x.Vant/components.d.ts | 1 + Yi.Vue3.x.Vant/src/main.ts | 2 ++ Yi.Vue3.x.Vant/src/view/main/recommend.vue | 15 +++++++--- Yi.Vue3.x.Vant/src/view/send/imageText.vue | 5 ++-- 8 files changed, 33 insertions(+), 26 deletions(-) diff --git a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/ArticleController.cs b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/ArticleController.cs index fef4fcac..50f7ff67 100644 --- a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/ArticleController.cs +++ b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/ArticleController.cs @@ -50,7 +50,9 @@ namespace Yi.Framework.ApiMicroservice.Controllers public override Task Add(ArticleEntity entity) { //如果标题为空,默认为内容的前20个字符 - entity.Title = string.IsNullOrEmpty(entity.Title) ? entity.Content.Substring(0, 20): entity.Title; + entity.Title = string.IsNullOrEmpty(entity.Title) ? + (entity.Content.Length > 20 ? entity.Content.Substring(0, 20) : entity.Content) : + entity.Title; entity.UserId = HttpContext.GetUserIdInfo(); return base.Add(entity); } diff --git a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/FileController.cs b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/FileController.cs index 0d274f65..cc9c5dde 100644 --- a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/FileController.cs +++ b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/FileController.cs @@ -56,10 +56,10 @@ namespace Yi.Framework.ApiMicroservice.Controllers try { //路径为: 文件路径/文件id+文件扩展名 - var path = Path.Combine($"{PathConst.wwwroot}/{file.FilePath}", file.Id.ToString()+ Path.GetExtension(file.FileName)); + var path = Path.Combine($"{PathConst.wwwroot}/{file.FilePath}", file.Id.ToString() + Path.GetExtension(file.FileName)); var stream = System.IO.File.OpenRead(path); var MimeType = Common.Helper.MimeHelper.GetMimeMapping(file.FileName); - return File(stream, MimeType, file.FileName); + return File(stream, MimeType, file.FileName); } catch { @@ -76,22 +76,18 @@ namespace Yi.Framework.ApiMicroservice.Controllers /// [Route("/api/file/Upload/{type?}")] [HttpPost] - public async Task Upload([FromRoute] string? type, [FromForm] IFormFileCollection file,[FromQuery] string? remark) + public async Task Upload([FromRoute] string? type, [FromForm] IFormFileCollection file, [FromQuery] string? remark) { - if (type is null) + type = type ?? PathEnum.File.ToString(); + + type = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(type.ToLower()); + if (!Enum.IsDefined(typeof(PathEnum), type)) { - type = PathEnum.File.ToString(); - } - else - { - type = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(type!.ToLower()); - if (!Enum.IsDefined(typeof(PathEnum), type)) - { - //后续类型可从字典表中获取 - return Result.Error("上传失败!文件类型不支持!"); - } + //后续类型可从字典表中获取 + return Result.Error("上传失败!文件类型不支持!"); } + if (file.Count() == 0) { return Result.Error("未选择文件"); @@ -118,7 +114,7 @@ namespace Yi.Framework.ApiMicroservice.Controllers string filename = data.Id.ToString() + Path.GetExtension(f.FileName); string typePath = $"{PathConst.wwwroot}/{type}"; if (!Directory.Exists(typePath)) - { + { Directory.CreateDirectory(typePath); } using (var stream = new FileStream(Path.Combine(typePath, filename), FileMode.CreateNew, FileAccess.Write)) diff --git a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/yi-sqlsugar-dev.db b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/yi-sqlsugar-dev.db index da5b244af193c06bf06753a74af3271501e0fe3d..70b960570348b064a9c6f818d18882708be93c1f 100644 GIT binary patch delta 1367 zcmZuxTWB0r7(TmaE}QISwzivONlkXc;wBq+cIKQjXD+ei)?hA*f%qb|HL131YSrpn zwUBHOt@!V5wHnLStDdSfoCuv`;B3DEMF>l~l-E@t@t5Pb-RN5D4XuBEa5A)BS^Q`*bYn4m`7i0J%8-c7<8d)J7CI|#{~cb7sK?ZKbwXvE z*;aWfu`|CpH2HlkZ1nZXCDg$({Wx>DJvYDzY%ph<)x2%*Y;PlQYL+2IVFrj_ZB#P@Ot1bqEzdmGET8ahy=%rtg1A z$3t!Y>_7gublfe)AEBxBY;wGBT1qJC{mtytD7ACHIx`U@PsL&$A2`S}CT%AnCX|LI zK1GLtWbEl_c@N3Dl-}NE3TPy?Q@i`a`N#bWn)g4QGtGA1M&~TfDYuAC z2y-ZbW^{s*s$D_aKiUJWrfq3IYn$2?Ef+i@ZQy9NVBm9_8N*7bIX-F~1hFU$aKBy_ zIRH@T>h>ruCh=U%6Y4zvED~Fay&QW!=51y(Uq!{rwUAtTnA^P$wVVsMcdtWtW}Dy| ze3@y`)x0|ZrmOF~iof^;58zIrW~4(AsSn@4%eZqho4gh7Iy#q7`qlAnG}4%M2o~7I zZ$)Wj2^<$UVeM2e4=#f%!%^YoBCZS4SM6ae(Fql#<#c3X|NVV zC$3YT@wpb-xctalxIXznyr4@w*AfJAoVTWfgTZn_YavT|mc{rjRmVcGsmm`q=9jT{WDI}GB+5U8P*xz^fMe28p7=Im) z6`I6eR>%3<+B0hTPLBxUwkt%d%A4M%<@lZrCt>6PI zSP|Kapa(sQ2bJ8_ga3di-ldlo6$Gz-Y1&d`W|!S>zQ^zTeZQG`QJ;BHpWl_c^?3Ji z?$+%1o$=iJ@%+o5g;%9XFDs9t6WOWbxf|JsU-|jB`x-m_&g9?x(*rfn^HBdouR7KL zrT<}x_g1IgK%GtPrMr8x{D8Oc?D%|LN3Od zR2o8*l9Y1AWXQBK&5KZErn0xs8}__D_@3QbTe|bL45@!Sx!>FWrKBy%gSO%!H;Sz# zrAjKO!&pdJb7-{`)k=p_3aJQLXEll#s=0ue=Ed19e$`)(;7D!p-0uf~fHF>*fM*Q> zZBW@_tR>q#V8&2M^jMQf0K=Tc(oum0Nh0i^EauRoOo+BlrNQNE696DgVi9rfaLNS( zSCL|)lNehQB}S$ZGr|Pdu1<7m$$#-Hl|Ju8kC)pMwZ&6Q3nvG>Wiah7#ehb%I02Re z!*!^DV#j2n7)i0@Ns5KDDGn1&Ff%l@u^@3oL@;qF1uWJOqnWf=nFO$CM*)V@m=o#} z;Z$sdTXEHqQ&yx5y9lN$gd}YoYDICH3Zf&L0#RheH%UdLiHR|X7%aj_;E)*!QC!l9 z*+?eovMaQh`{P&kuZ{lpW@z#AJ0QL*sMubQExguqFIp^Y2^nZ{nlq|l`bp#{We$)r zC?pbXp|U7acdz=Vx={UI9qg@6 zouK(Dg|o`4v`b~==T=n)IlSYm!!5!O@6pitdJN$KG*Z5rl}6DcxR~EIW$ib)V(0n= u^!Ov%Q<%$2jlxkl7%AMF8!U9@28%bwP|bgxm1c^Ez<$&3yuMpJyWt-vYXKkt diff --git a/Yi.Framework.Net6/Yi.Framework.Common/Helper/TreeHelper.cs b/Yi.Framework.Net6/Yi.Framework.Common/Helper/TreeHelper.cs index da1242ab..b1252d6b 100644 --- a/Yi.Framework.Net6/Yi.Framework.Common/Helper/TreeHelper.cs +++ b/Yi.Framework.Net6/Yi.Framework.Common/Helper/TreeHelper.cs @@ -11,14 +11,14 @@ namespace Yi.Framework.Common.Helper { public static List SetTree(List list, Action action = null) { - if (list != null && list.Count > 0) + if (list is not null && list.Count > 0) { IList result = new List(); long pid = list.Min(m => (m as ITreeModel).ParentId); IList t = list.Where(m => (m as ITreeModel).ParentId == pid).ToList(); foreach (T model in t) { - if (action != null) + if (action is not null) { action(model); } @@ -40,7 +40,7 @@ namespace Yi.Framework.Common.Helper mm.Children = new List(); foreach (T item in children) { - if (action != null) + if (action is not null) { action(item); } diff --git a/Yi.Vue3.x.Vant/components.d.ts b/Yi.Vue3.x.Vant/components.d.ts index f9d48ee6..b04c459e 100644 --- a/Yi.Vue3.x.Vant/components.d.ts +++ b/Yi.Vue3.x.Vant/components.d.ts @@ -25,6 +25,7 @@ declare module '@vue/runtime-core' { VanIcon: typeof import('vant/es')['Icon'] VanImage: typeof import('vant/es')['Image'] VanList: typeof import('vant/es')['List'] + VanLoading: typeof import('vant/es')['Loading'] VanNavBar: typeof import('vant/es')['NavBar'] VanPopup: typeof import('vant/es')['Popup'] VanPullRefresh: typeof import('vant/es')['PullRefresh'] diff --git a/Yi.Vue3.x.Vant/src/main.ts b/Yi.Vue3.x.Vant/src/main.ts index 429931bc..50eb4bb1 100644 --- a/Yi.Vue3.x.Vant/src/main.ts +++ b/Yi.Vue3.x.Vant/src/main.ts @@ -7,9 +7,11 @@ import 'vant/es/notify/style'; import router from './router' import store from './store' import './permission' +import { Lazyload } from 'vant'; import App from './App.vue' const app=createApp(App) app.use(router) app.use(store) +app.use(Lazyload); app.mount('#app'); \ No newline at end of file diff --git a/Yi.Vue3.x.Vant/src/view/main/recommend.vue b/Yi.Vue3.x.Vant/src/view/main/recommend.vue index 4573e0c1..2a7eb6dc 100644 --- a/Yi.Vue3.x.Vant/src/view/main/recommend.vue +++ b/Yi.Vue3.x.Vant/src/view/main/recommend.vue @@ -30,13 +30,18 @@ v-for="(image, imageIndex) in item.images" :key="imageIndex" class="imageCol" - @click="openImage(item.images)" + @click="openImage(item.images,imageIndex)" > + @@ -61,6 +66,7 @@ @@ -102,7 +108,7 @@ const list = ref([]); const loading = ref(false); const finished = ref(false); const refreshing = ref(false); - +const startIndex=ref(0) const show = ref(false); const actions = [{ name: "取消关注" }, { name: "将TA拉黑" }, { name: "举报" }]; @@ -138,8 +144,9 @@ const onRefresh = () => { queryParams.value.pageNum = 1; onLoad(); }; -const openImage = (imagesUrl: string[]) => { +const openImage = (imagesUrl: string[],imageIndex:any) => { imagesPreview.value = imagesUrl.map((i) => url + i); + startIndex.value=imageIndex; imageShow.value = true; }; onMounted(() => { @@ -149,7 +156,7 @@ onMounted(() => { const getList = () => { articleApi.pageList(queryParams.value).then((response: any) => { - articleList.value.unshift(...(response.data.data)); + articleList.value.push(...(response.data.data)); totol.value = response.data.totol; }); }; diff --git a/Yi.Vue3.x.Vant/src/view/send/imageText.vue b/Yi.Vue3.x.Vant/src/view/send/imageText.vue index 183b2430..6fbf7933 100644 --- a/Yi.Vue3.x.Vant/src/view/send/imageText.vue +++ b/Yi.Vue3.x.Vant/src/view/send/imageText.vue @@ -53,12 +53,11 @@ import articleApi from "@/api/articleApi"; import { Toast } from "vant"; import { useRouter } from 'vue-router' const router = useRouter(); -const form = reactive({ +const form = reactive({ title: "", content: "", images: [], - isDeleted: false, - createTime:"" + isDeleted: false }); const isSend=ref(false)