前端联调接口

This commit is contained in:
陈淳
2022-10-11 16:48:25 +08:00
parent 58f85992b0
commit a0c869d0a1
54 changed files with 899 additions and 137 deletions

Binary file not shown.

View File

@@ -67,6 +67,21 @@
</summary>
<returns></returns>
</member>
<member name="M:Yi.Framework.ApiMicroservice.Controllers.ArticleController.PageList(Yi.Framework.Model.Models.ArticleEntity,Yi.Framework.Common.Models.PageParModel)">
<summary>
动态条件分页查询
</summary>
<param name="entity"></param>
<param name="page"></param>
<returns></returns>
</member>
<member name="M:Yi.Framework.ApiMicroservice.Controllers.ArticleController.Add(Yi.Framework.Model.Models.ArticleEntity)">
<summary>
添加
</summary>
<param name="entity"></param>
<returns></returns>
</member>
<member name="T:Yi.Framework.ApiMicroservice.Controllers.BaseCrudController`1">
<summary>
Json To Sql 类比模式,通用模型

View File

@@ -0,0 +1,51 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Yi.Framework.Common.Models;
using Yi.Framework.Interface;
using Yi.Framework.Model.Models;
using Yi.Framework.Repository;
using Yi.Framework.WebCore;
using Yi.Framework.WebCore.AttributeExtend;
using Yi.Framework.WebCore.AuthorizationPolicy;
namespace Yi.Framework.ApiMicroservice.Controllers
{
[ApiController]
[Route("api/[controller]/[action]")]
public class ArticleController : BaseSimpleCrudController<ArticleEntity>
{
private IArticleService _iArticleService;
public ArticleController(ILogger<ArticleEntity> logger, IArticleService iArticleService) : base(logger, iArticleService)
{
_iArticleService = iArticleService;
}
/// <summary>
/// 动态条件分页查询
/// </summary>
/// <param name="entity"></param>
/// <param name="page"></param>
/// <returns></returns>
[HttpGet]
public async Task<Result> PageList([FromQuery] ArticleEntity entity, [FromQuery] PageParModel page)
{
return Result.Success().SetData(await _iArticleService.SelctPageList(entity, page));
}
/// <summary>
/// 添加
/// </summary>
/// <param name="entity"></param>
/// <returns></returns>
public override Task<Result> Add(ArticleEntity entity)
{
entity.UserId=HttpContext.GetUserIdInfo();
return base.Add(entity);
}
}
}

View File

@@ -4,9 +4,11 @@ using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Hosting;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Yi.Framework.Common.Enum;
using Yi.Framework.Common.Models;
using Yi.Framework.Interface;
using Yi.Framework.WebCore;
@@ -39,10 +41,15 @@ namespace Yi.Framework.ApiMicroservice.Controllers
/// <param name="type"></param>
/// <param name="fileName"></param>
/// <returns></returns>
[Route("/api/{type}/{fileName}")]
[Route("/api/file/{type}/{fileName}")]
[HttpGet]
public IActionResult Get(string type, string fileName)
{
type = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(type.ToLower());
if (!Enum.IsDefined(typeof(PathEnum), type))
{
return new NotFoundResult();
}
try
{
var path = Path.Combine($"wwwroot/{type}", fileName);
@@ -64,8 +71,13 @@ namespace Yi.Framework.ApiMicroservice.Controllers
/// <returns></returns>
[Route("/api/Upload/{type}")]
[HttpPost]
public async Task<Result> Upload(string type, IFormFile file)
public async Task<Result> Upload(string type,IFormFile file)
{
type = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(type.ToLower());
if (!Enum.IsDefined(typeof(PathEnum), type))
{
return Result.Error("上传失败!文件类型不存在!");
}
try
{
string filename = Guid.NewGuid().ToString() + Path.GetExtension(file.FileName);

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 320 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 181 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 320 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 320 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 460 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 320 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 460 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 460 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 460 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 460 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 68 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 460 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 181 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 181 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

View File

@@ -0,0 +1,13 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using Yi.Framework.Common.Models;
using Yi.Framework.Model.Models;
using Yi.Framework.Repository;
namespace Yi.Framework.Interface
{
public partial interface IArticleService:IBaseService<ArticleEntity>
{
Task<PageModel<List<ArticleEntity>>> SelctPageList(ArticleEntity eneity, PageParModel page);
}
}

View File

@@ -0,0 +1,9 @@
using Yi.Framework.Model.Models;
using Yi.Framework.Repository;
namespace Yi.Framework.Interface
{
public partial interface IArticleService:IBaseService<ArticleEntity>
{
}
}

View File

@@ -0,0 +1,82 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.Json.Serialization;
using SqlSugar;
namespace Yi.Framework.Model.Models
{
/// <summary>
/// 文章表
///</summary>
[SugarTable("Article")]
public partial class ArticleEntity:IBaseModelEntity
{
public ArticleEntity()
{
this.CreateTime = DateTime.Now;
}
[JsonConverter(typeof(ValueToStringConverter))]
[SugarColumn(ColumnName="Id" ,IsPrimaryKey = true )]
public long Id { get; set; }
/// <summary>
/// 文章标题
///</summary>
[SugarColumn(ColumnName="Title" )]
public string Title { get; set; }
/// <summary>
/// 文章内容
///</summary>
[SugarColumn(ColumnName="Content" )]
public string Content { get; set; }
/// <summary>
/// 用户id
///</summary>
[SugarColumn(ColumnName="UserId" )]
public long? UserId { get; set; }
/// <summary>
/// 创建者
///</summary>
[SugarColumn(ColumnName="CreateUser" )]
public long? CreateUser { get; set; }
/// <summary>
/// 创建时间
///</summary>
[SugarColumn(ColumnName="CreateTime" )]
public DateTime? CreateTime { get; set; }
/// <summary>
/// 修改者
///</summary>
[SugarColumn(ColumnName="ModifyUser" )]
public long? ModifyUser { get; set; }
/// <summary>
/// 修改时间
///</summary>
[SugarColumn(ColumnName="ModifyTime" )]
public DateTime? ModifyTime { get; set; }
/// <summary>
/// 是否删除
///</summary>
[SugarColumn(ColumnName="IsDeleted" )]
public bool? IsDeleted { get; set; }
/// <summary>
/// 租户Id
///</summary>
[SugarColumn(ColumnName="TenantId" )]
public long? TenantId { get; set; }
/// <summary>
/// 排序字段
///</summary>
[SugarColumn(ColumnName="OrderNum" )]
public int? OrderNum { get; set; }
/// <summary>
/// 描述
///</summary>
[SugarColumn(ColumnName="Remark" )]
public string Remark { get; set; }
/// <summary>
/// 图片列表
///</summary>
[SugarColumn(ColumnName="Images",IsJson = true)]
public List<string> Images { get; set; }
}
}

View File

@@ -0,0 +1,28 @@
using SqlSugar;
using System.Collections.Generic;
using System.Threading.Tasks;
using Yi.Framework.Common.Models;
using Yi.Framework.Interface;
using Yi.Framework.Model.Models;
using Yi.Framework.Repository;
namespace Yi.Framework.Service
{
public partial class ArticleService : BaseService<ArticleEntity>, IArticleService
{
public async Task<PageModel<List<ArticleEntity>>> SelctPageList(ArticleEntity entity, PageParModel page)
{
RefAsync<int> total = 0;
var data = await _repository._DbQueryable
//.WhereIF(!string.IsNullOrEmpty(config.ConfigName), u => u.ConfigName.Contains(config.ConfigName))
//.WhereIF(!string.IsNullOrEmpty(config.ConfigKey), u => u.ConfigKey.Contains(config.ConfigKey))
.WhereIF(page.StartTime is not null && page.EndTime is not null, u => u.CreateTime >= page.StartTime && u.CreateTime <= page.EndTime)
.WhereIF(entity.IsDeleted is not null, u => u.IsDeleted == entity.IsDeleted)
.OrderBy(u => u.CreateTime, OrderByType.Desc)
.ToPageListAsync(page.PageNum, page.PageSize, total);
return new PageModel<List<ArticleEntity>>(data, total);
}
}
}

View File

@@ -0,0 +1,14 @@
using SqlSugar;
using Yi.Framework.Interface;
using Yi.Framework.Model.Models;
using Yi.Framework.Repository;
namespace Yi.Framework.Service
{
public partial class ArticleService : BaseService<ArticleEntity>, IArticleService
{
public ArticleService(IRepository<ArticleEntity> repository) : base(repository)
{
}
}
}

View File

@@ -37,7 +37,12 @@ namespace Yi.Framework.WebCore
public static long GetUserIdInfo(this HttpContext httpContext)
{
var p = httpContext;
return Convert.ToInt64(httpContext.User.Claims.FirstOrDefault(u => u.Type == JwtRegisteredClaimNames.Sid).Value);
var value = httpContext.User.Claims.FirstOrDefault(u => u.Type == JwtRegisteredClaimNames.Sid)?.Value;
if (value is not null)
{
return Convert.ToInt64(value);
}
return 0;
}
/// <summary>

View File

@@ -0,0 +1,17 @@
# 页面标题
VITE_APP_TITLE = 意框架管理系统
# 开发环境配置
VITE_APP_ENV = 'development'
# 若依管理系统/开发环境
VITE_APP_BASE_API = '/dev-api'
# ws/开发环境
VITE_APP_BASE_WS = '/dev-ws'
VITE_APP_BASE_URL='http://localhost:19001/api'

View File

@@ -0,0 +1,15 @@
# 页面标题
VITE_APP_TITLE = 意框架管理系统
# 生产环境配置
VITE_APP_ENV = 'production'
# 意框架管理系统/生产环境
VITE_APP_BASE_API = '/prod-api'
# ws/开发环境
VITE_APP_BASE_WS = '/prod-ws'
# 是否在打包时开启压缩,支持 gzip 和 brotli
VITE_BUILD_COMPRESS = gzip

View File

@@ -0,0 +1,15 @@
# 页面标题
VITE_APP_TITLE = 意框架管理系统
# 生产环境配置
VITE_APP_ENV = 'staging'
# 若依管理系统/生产环境
VITE_APP_BASE_API = '/stage-api'
# ws/开发环境
VITE_APP_BASE_WS = '/stage-ws'
# 是否在打包时开启压缩,支持 gzip 和 brotli
VITE_BUILD_COMPRESS = gzip

View File

@@ -7,6 +7,7 @@ export {}
declare module '@vue/runtime-core' {
export interface GlobalComponents {
AppCreateTime: typeof import('./src/components/AppCreateTime.vue')['default']
AppGrid: typeof import('./src/components/AppGrid.vue')['default']
HelloWorld: typeof import('./src/components/HelloWorld.vue')['default']
RouterLink: typeof import('vue-router')['RouterLink']

View File

@@ -8,11 +8,14 @@
"name": "yi",
"version": "0.0.0",
"dependencies": {
"axios": "^1.1.2",
"json-bigint": "^1.0.0",
"vant": "^3.6.3",
"vue": "^3.2.37",
"vue-router": "^4.1.5"
},
"devDependencies": {
"@types/json-bigint": "^1.0.1",
"@types/node": "^18.8.2",
"@vitejs/plugin-vue": "^3.1.0",
"typescript": "^4.6.4",
@@ -121,6 +124,12 @@
"node": ">= 8.0.0"
}
},
"node_modules/@types/json-bigint": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/@types/json-bigint/-/json-bigint-1.0.1.tgz",
"integrity": "sha512-zpchZLNsNuzJHi6v64UBoFWAvQlPhch7XAi36FkH6tL1bbbmimIF+cS7vwkzY4u5RaSWMoflQfu+TshMPPw8uw==",
"dev": true
},
"node_modules/@types/node": {
"version": "18.8.2",
"resolved": "https://registry.npmmirror.com/@types/node/-/node-18.8.2.tgz",
@@ -355,12 +364,35 @@
"node": ">= 8"
}
},
"node_modules/asynckit": {
"version": "0.4.0",
"resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz",
"integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q=="
},
"node_modules/axios": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/axios/-/axios-1.1.2.tgz",
"integrity": "sha512-bznQyETwElsXl2RK7HLLwb5GPpOLlycxHCtrpDR/4RqqBzjARaOTo3jz4IgtntWUYee7Ne4S8UHd92VCuzPaWA==",
"dependencies": {
"follow-redirects": "^1.15.0",
"form-data": "^4.0.0",
"proxy-from-env": "^1.1.0"
}
},
"node_modules/balanced-match": {
"version": "1.0.2",
"resolved": "https://registry.npmmirror.com/balanced-match/-/balanced-match-1.0.2.tgz",
"integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==",
"dev": true
},
"node_modules/bignumber.js": {
"version": "9.1.0",
"resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-9.1.0.tgz",
"integrity": "sha512-4LwHK4nfDOraBCtst+wOWIHbu1vhvAPJK8g8nROd4iuc3PSEjWif/qwbkh8jwCJz6yDBvtU4KPynETgrfh7y3A==",
"engines": {
"node": "*"
}
},
"node_modules/binary-extensions": {
"version": "2.2.0",
"resolved": "https://registry.npmmirror.com/binary-extensions/-/binary-extensions-2.2.0.tgz",
@@ -418,6 +450,17 @@
"fsevents": "~2.3.2"
}
},
"node_modules/combined-stream": {
"version": "1.0.8",
"resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz",
"integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==",
"dependencies": {
"delayed-stream": "~1.0.0"
},
"engines": {
"node": ">= 0.8"
}
},
"node_modules/csstype": {
"version": "2.6.21",
"resolved": "https://registry.npmmirror.com/csstype/-/csstype-2.6.21.tgz",
@@ -440,6 +483,14 @@
}
}
},
"node_modules/delayed-stream": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz",
"integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==",
"engines": {
"node": ">=0.4.0"
}
},
"node_modules/esbuild": {
"version": "0.15.10",
"resolved": "https://registry.npmmirror.com/esbuild/-/esbuild-0.15.10.tgz",
@@ -839,6 +890,38 @@
"node": ">=8"
}
},
"node_modules/follow-redirects": {
"version": "1.15.2",
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.2.tgz",
"integrity": "sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA==",
"funding": [
{
"type": "individual",
"url": "https://github.com/sponsors/RubenVerborgh"
}
],
"engines": {
"node": ">=4.0"
},
"peerDependenciesMeta": {
"debug": {
"optional": true
}
}
},
"node_modules/form-data": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz",
"integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==",
"dependencies": {
"asynckit": "^0.4.0",
"combined-stream": "^1.0.8",
"mime-types": "^2.1.12"
},
"engines": {
"node": ">= 6"
}
},
"node_modules/fsevents": {
"version": "2.3.2",
"resolved": "https://registry.npmmirror.com/fsevents/-/fsevents-2.3.2.tgz",
@@ -937,6 +1020,14 @@
"node": ">=0.12.0"
}
},
"node_modules/json-bigint": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/json-bigint/-/json-bigint-1.0.0.tgz",
"integrity": "sha512-SiPv/8VpZuWbvLSMtTDU8hEfrZWg/mH/nV/b4o0CYbSxu1UIQPLdwKOCIyLQX+VIPO5vrLX3i8qtqFyhdPSUSQ==",
"dependencies": {
"bignumber.js": "^9.0.0"
}
},
"node_modules/local-pkg": {
"version": "0.4.2",
"resolved": "https://registry.npmmirror.com/local-pkg/-/local-pkg-0.4.2.tgz",
@@ -991,6 +1082,25 @@
"node": ">=8.6"
}
},
"node_modules/mime-db": {
"version": "1.52.0",
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz",
"integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/mime-types": {
"version": "2.1.35",
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz",
"integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==",
"dependencies": {
"mime-db": "1.52.0"
},
"engines": {
"node": ">= 0.6"
}
},
"node_modules/minimatch": {
"version": "5.1.0",
"resolved": "https://registry.npmmirror.com/minimatch/-/minimatch-5.1.0.tgz",
@@ -1075,6 +1185,11 @@
"node": "^10 || ^12 || >=14"
}
},
"node_modules/proxy-from-env": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz",
"integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg=="
},
"node_modules/queue-microtask": {
"version": "1.2.3",
"resolved": "https://registry.npmmirror.com/queue-microtask/-/queue-microtask-1.2.3.tgz",
@@ -1482,6 +1597,12 @@
"picomatch": "^2.2.2"
}
},
"@types/json-bigint": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/@types/json-bigint/-/json-bigint-1.0.1.tgz",
"integrity": "sha512-zpchZLNsNuzJHi6v64UBoFWAvQlPhch7XAi36FkH6tL1bbbmimIF+cS7vwkzY4u5RaSWMoflQfu+TshMPPw8uw==",
"dev": true
},
"@types/node": {
"version": "18.8.2",
"resolved": "https://registry.npmmirror.com/@types/node/-/node-18.8.2.tgz",
@@ -1700,12 +1821,32 @@
"picomatch": "^2.0.4"
}
},
"asynckit": {
"version": "0.4.0",
"resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz",
"integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q=="
},
"axios": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/axios/-/axios-1.1.2.tgz",
"integrity": "sha512-bznQyETwElsXl2RK7HLLwb5GPpOLlycxHCtrpDR/4RqqBzjARaOTo3jz4IgtntWUYee7Ne4S8UHd92VCuzPaWA==",
"requires": {
"follow-redirects": "^1.15.0",
"form-data": "^4.0.0",
"proxy-from-env": "^1.1.0"
}
},
"balanced-match": {
"version": "1.0.2",
"resolved": "https://registry.npmmirror.com/balanced-match/-/balanced-match-1.0.2.tgz",
"integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==",
"dev": true
},
"bignumber.js": {
"version": "9.1.0",
"resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-9.1.0.tgz",
"integrity": "sha512-4LwHK4nfDOraBCtst+wOWIHbu1vhvAPJK8g8nROd4iuc3PSEjWif/qwbkh8jwCJz6yDBvtU4KPynETgrfh7y3A=="
},
"binary-extensions": {
"version": "2.2.0",
"resolved": "https://registry.npmmirror.com/binary-extensions/-/binary-extensions-2.2.0.tgz",
@@ -1746,6 +1887,14 @@
"readdirp": "~3.6.0"
}
},
"combined-stream": {
"version": "1.0.8",
"resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz",
"integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==",
"requires": {
"delayed-stream": "~1.0.0"
}
},
"csstype": {
"version": "2.6.21",
"resolved": "https://registry.npmmirror.com/csstype/-/csstype-2.6.21.tgz",
@@ -1760,6 +1909,11 @@
"ms": "2.1.2"
}
},
"delayed-stream": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz",
"integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ=="
},
"esbuild": {
"version": "0.15.10",
"resolved": "https://registry.npmmirror.com/esbuild/-/esbuild-0.15.10.tgz",
@@ -1966,6 +2120,21 @@
"to-regex-range": "^5.0.1"
}
},
"follow-redirects": {
"version": "1.15.2",
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.2.tgz",
"integrity": "sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA=="
},
"form-data": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz",
"integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==",
"requires": {
"asynckit": "^0.4.0",
"combined-stream": "^1.0.8",
"mime-types": "^2.1.12"
}
},
"fsevents": {
"version": "2.3.2",
"resolved": "https://registry.npmmirror.com/fsevents/-/fsevents-2.3.2.tgz",
@@ -2036,6 +2205,14 @@
"integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==",
"dev": true
},
"json-bigint": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/json-bigint/-/json-bigint-1.0.0.tgz",
"integrity": "sha512-SiPv/8VpZuWbvLSMtTDU8hEfrZWg/mH/nV/b4o0CYbSxu1UIQPLdwKOCIyLQX+VIPO5vrLX3i8qtqFyhdPSUSQ==",
"requires": {
"bignumber.js": "^9.0.0"
}
},
"local-pkg": {
"version": "0.4.2",
"resolved": "https://registry.npmmirror.com/local-pkg/-/local-pkg-0.4.2.tgz",
@@ -2075,6 +2252,19 @@
"picomatch": "^2.3.1"
}
},
"mime-db": {
"version": "1.52.0",
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz",
"integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg=="
},
"mime-types": {
"version": "2.1.35",
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz",
"integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==",
"requires": {
"mime-db": "1.52.0"
}
},
"minimatch": {
"version": "5.1.0",
"resolved": "https://registry.npmmirror.com/minimatch/-/minimatch-5.1.0.tgz",
@@ -2128,6 +2318,11 @@
"source-map-js": "^1.0.2"
}
},
"proxy-from-env": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz",
"integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg=="
},
"queue-microtask": {
"version": "1.2.3",
"resolved": "https://registry.npmmirror.com/queue-microtask/-/queue-microtask-1.2.3.tgz",

View File

@@ -9,11 +9,14 @@
"preview": "vite preview"
},
"dependencies": {
"axios": "^1.1.2",
"json-bigint": "^1.0.0",
"vant": "^3.6.3",
"vue": "^3.2.37",
"vue-router": "^4.1.5"
},
"devDependencies": {
"@types/json-bigint": "^1.0.1",
"@types/node": "^18.8.2",
"@vitejs/plugin-vue": "^3.1.0",
"typescript": "^4.6.4",

View File

@@ -0,0 +1,20 @@
import myaxios from '@/utils/myaxios.ts'
import { ArticleEntity } from '@/type/interface/ArticleEntity'
export default {
add(data: ArticleEntity) {
console.log(data)
return myaxios({
url: `/article/add`,
method: 'post',
data: data
})
},
pageList(data:ArticleEntity) {
return myaxios({
url: '/article/pageList',
method: 'get',
params: data
})
}
}

View File

@@ -0,0 +1,12 @@
import myaxios from '@/utils/myaxios.ts'
export default{
upload(type:string,data:any){
return myaxios({
url: `/upload/${type}`,
headers:{"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8"},
method: 'POST',
data:data
});
}
}

View File

@@ -0,0 +1,37 @@
<template>
<span class="subtitle">{{ showTime }}</span>
</template>
<style scoped>
</style>
<script setup lang="ts">
import { ref, computed } from "vue";
const props = defineProps<{ time: string }>();
const showTime = computed(() => {
var dataTime=new Date(Date.parse(props.time));
const hour:number= getHour(dataTime,new Date())
if(hour<=0)
{
return "刚刚"
}
if(hour<=6)
{
return hour+"小时前"
}
return props.time;
});
const getHour=(s1:Date, s2:Date)=> {
var ms = s2.getTime() - s1.getTime();
if (ms < 0) return 0;
return Math.floor(ms / 1000 / 60 / 60); //小时
}
</script>
<style scoped>
.subtitle{
color: #CBCBCB;
}
</style>

View File

@@ -15,7 +15,7 @@
<router-view />
<div style="min-height: 100rem;"></div>
<div style=""></div>
</template>
<script setup lang="ts">
import { ref } from "vue";

View File

@@ -0,0 +1,8 @@
export interface ArticleEntity{
title: string;
content: string;
images:string[];
isDeleted:boolean;
createTime:string;
}
// import { ArticleEntity } from '@/type/interface/ArticleEntity'

View File

@@ -0,0 +1,93 @@
import axios from 'axios'
// import store from '../store/index'
// import vm from '../main'
import JsonBig from 'json-bigint'
// import VuetifyDialogPlugin from 'vuetify-dialog/nuxt/index';
const myaxios = axios.create({
// baseURL:'/'//
baseURL: import.meta.env.VITE_APP_BASE_API, // /dev-apis
timeout: 50000,
headers: {
'Authorization': 'Bearer ' + ""
},
//雪花id精度问题
transformResponse: [ data => {
const json = JsonBig({
storeAsString: true
})
return json.parse(data)
}],
})
// 请求拦截器
myaxios.interceptors.request.use(function(config) {
// config.headers.Authorization = 'Bearer ' + store.state.user.token;
// store.dispatch("openLoad");
return config;
}, function(error) {
return Promise.reject(error);
});
// 响应拦截器
myaxios.interceptors.response.use(async function(response) {
const resp = response.data
if (resp.code == undefined && resp.message == undefined) {
// vm.$dialog.notify.error("错误代码:无,原因:与服务器失去连接", {
// position: "top-right",
// timeout: 5000,
// });
} else if (resp.code == 401) {
// const res = await vm.$dialog.error({
// text: `错误代码:${resp.code},原因:${resp.message}<br>是否重新进行登录?`,
// title: '错误',
// actions: {
// 'false': '取消',
// 'true': '跳转'
// }
// });
// if (res) {
// vm.$router.push({ path: "/login" });
// }
} else if (resp.code !== 200) {
// vm.$dialog.notify.error(`错误代码:${resp.code},原因:${resp.message}`, {
// position: "top-right",
// timeout: 5000,
// });
}
// store.dispatch("closeLoad");
return resp;
}, async function(error) {
// const resp = error.response.data
// if (resp.code == undefined && resp.message == undefined) {
// vm.$dialog.notify.error("错误代码:无,原因:与服务器失去连接", {
// position: "top-right",
// timeout: 5000,
// });
// } else if (resp.code == 401) {
// const res = await vm.$dialog.error({
// text: `错误代码:${resp.code},原因:${resp.message}<br>是否重新进行登录?`,
// title: '错误',
// actions: {
// 'false': '取消',
// 'true': '跳转'
// }
// });
// if (res) {
// vm.$store.dispatch("Logout").then((resp) => {
// vm.$router.push({ path: "/login" });
// });
// }
// } else if (resp.code !== 200) {
// vm.$dialog.notify.error(`错误代码:${resp.code},原因:${resp.message}`, {
// position: "top-right",
// timeout: 5000,
// });
// }
// store.dispatch("closeLoad");
return Promise.reject(error);
});
export default myaxios

View File

@@ -1,5 +1,5 @@
<template>
<van-pull-refresh v-model="refreshing" @refresh="onRefresh">
<van-list
class="list"
v-model:loading="loading"
@@ -7,7 +7,8 @@
finished-text="没有更多了"
@load="onLoad"
>
<van-row v-for="item in list" class="row">
<van-row v-for="(item,index) in articleList" :key="index" class="row">
<van-col span="4" class="leftCol">
<van-image
round
@@ -20,7 +21,7 @@
<van-col span="14" class="centerTitle">
<span class="justtitle"> 大白</span>
<br />
<span class="subtitle">一小时前</span>
<app-createTime :time="item.createTime"/>
</van-col>
<van-col span="6" class="down">
@@ -28,21 +29,19 @@
</van-col>
<van-col class="rowBody" span="24"
>这是第:{{
item
}},不要害怕重新开始因为这一次你不是从头开始而是从经验开始</van-col
>{{item.content}}</van-col
>
<van-col
span="8"
v-for="item of 9"
:key="item"
v-for="(image,imageIndex) in item.images"
:key="imageIndex"
class="imageCol"
@click="imageShow = true"
@click="openImage(item.images)"
><van-image
width="100%"
height="7rem"
src="https://fastly.jsdelivr.net/npm/@vant/assets/cat.jpeg"
:src="url+image"
radius="5"
/>
</van-col>
@@ -56,7 +55,7 @@
</van-col>
</van-row>
</van-list>
</van-pull-refresh>
<!-- 功能页面 -->
<van-action-sheet
@@ -69,27 +68,40 @@
<!-- 图片预览 -->
<van-image-preview
v-model:show="imageShow"
:images="images"
:images="imagesPreview"
@change="onChange"
:closeable=true
>
<template v-slot:index>{{ index }}</template>
<template v-slot:index>{{ index+1 }}</template>
</van-image-preview>
</template>
<script setup lang="ts">
import { ref } from "vue";
import { ref ,onMounted,reactive, toRefs} from "vue";
import { ImagePreview, Toast } from "vant";
import AppCreateTime from '@/components/AppCreateTime.vue'
import articleApi from "@/api/articleApi.ts";
import { ArticleEntity } from "@/type/interface/ArticleEntity.ts";
const VanImagePreview = ImagePreview.Component;
const url=`${import.meta.env.VITE_APP_BASE_API}/file/image/`
const data=reactive({
queryParams:{
pageNum: 1,
pageSize: 10,
// dictName: undefined,
// dictType: undefined,
isDeleted: false
}
});
const {queryParams} =toRefs(data);
const articleList=ref<ArticleEntity[]>([]);
const totol=ref<Number>(0);
const imageShow = ref(false);
const index = ref(0);
const images = [
"https://fastly.jsdelivr.net/npm/@vant/assets/apple-1.jpeg",
"https://fastly.jsdelivr.net/npm/@vant/assets/apple-2.jpeg",
];
let imagesPreview =ref<string[]>([]);
const onChange = (newIndex: any) => {
index.value = newIndex;
};
@@ -105,24 +117,40 @@ const actions = [
{ name: "将TA拉黑" },
{ name: "举报"}
];
const onLoad = () => {
setTimeout(() => {
if (refreshing.value) {
list.value = [];
refreshing.value = false;
}
// const onLoad = () => {
// if (refreshing.value) {
// articleList.value = [];
// refreshing.value = false;
// queryParams.value.pageNum=0;
// }
for (let i = 0; i < 10; i++) {
list.value.push(list.value.length + 1);
}
loading.value = false;
// queryParams.value.pageNum+=1;
// getList();
if (list.value.length >= 40) {
finished.value = true;
}
}, 100);
};
// loading.value = false;
// if (articleList.value.length >= 40) {
// finished.value = true;
// }
// };
const onLoad = async() => {
// 异步更新数据
// setTimeout 仅做示例,真实场景中一般为 ajax 请求
setTimeout(async() => {
console.log("执行")
// await getList();
// queryParams.value.pageNum+=1
// 加载状态结束
loading.value = false;
// 数据全部加载完成
if (list.value.length >= 4000) {
finished.value = true;
}
}, 1000);
};
const onRefresh = () => {
// 清空列表数据
finished.value = false;
@@ -130,8 +158,23 @@ const onRefresh = () => {
// 重新加载数据
// 将 loading 设置为 true表示处于加载状态
loading.value = true;
onLoad();
// onLoad();
};
const openImage=(imagesUrl :string[])=>{
imagesPreview.value=imagesUrl.map(i=>url+i);
imageShow.value=true;
}
onMounted(()=>{
articleList.value=[];
getList();
})
const getList=()=>{
articleApi.pageList(queryParams.value).then((response:any)=>{
articleList.value.push(...response.data.data as ArticleEntity[]);
totol.value=response.data.totol;
})
}
</script>
<style scoped>
.list {

View File

@@ -3,7 +3,14 @@
<van-row class="test ">
<van-col span="24">
这里是广场页面
<van-list
v-model:loading="loading"
:finished="finished"
finished-text="没有更多了"
@load="onLoad"
>
<van-cell v-for="item in list" :key="item" :title="item" />
</van-list>
</van-col>
</van-row>
@@ -11,4 +18,31 @@
<van-col span="24"></van-col>
</template>
<style scoped>
</style>
</style>
<script lang="ts" setup>
import {ref} from 'vue'
const list = ref([]);
const loading = ref(false);
const finished = ref(false);
const onLoad = () => {
console.log("执行")
// 异步更新数据
// setTimeout 仅做示例,真实场景中一般为 ajax 请求
setTimeout(() => {
for (let i = 0; i < 100; i++) {
list.value.push(list.value.length + 1);
}
// 加载状态结束
loading.value = false;
// 数据全部加载完成
if (list.value.length >= 1000) {
finished.value = true;
}
}, 1);
};
</script>

View File

@@ -1,95 +1,126 @@
<template>
<transition name="van-slide-right">
<div v-show="visible" >
<van-sticky>
<van-row class="head-row">
<van-col span="3">
<router-link to="/recommend">
<van-icon name="arrow-left" size="1.5rem" />
</router-link>
</van-col>
<van-col span="18"><span>发图文</span></van-col>
<van-col span="3">发布</van-col>
</van-row>
</van-sticky>
<van-cell-group>
<van-field rows="5" autosize type="textarea" v-model="value" label-width="0" :show-word-limit="true"
maxlength="500" placeholder="每一天,都是为了下一天" />
</van-cell-group>
<van-row class="body-row">
<van-col span="10">
<van-icon name="share-o" size="1.5rem" /><span>发布到去其他</span>
</van-col>
<van-col span="4"></van-col>
<van-col span="10"><span>选择更多人看到</span>
<van-icon name="arrow" size="1.2rem" />
</van-col>
<transition name="van-slide-right">
<div v-show="visible">
<van-sticky>
<van-row class="head-row">
<van-col span="3">
<router-link to="/recommend">
<van-icon name="arrow-left" size="1.5rem" />
</router-link>
</van-col>
<van-col span="18"><span>发图文</span></van-col>
<van-col span="3" @click="send">发布</van-col>
</van-row>
</van-sticky>
<van-cell-group>
<van-field
rows="5"
autosize
type="textarea"
v-model="content"
label-width="0"
:show-word-limit="true"
maxlength="500"
placeholder="每一天,都是为了下一天"
/>
</van-cell-group>
<van-row class="body-row">
<van-col span="10">
<van-icon name="share-o" size="1.5rem" /><span>发布到去其他</span>
</van-col>
<van-col span="4"></van-col>
<van-col span="10"
><span>选择更多人看到</span>
<van-icon name="arrow" size="1.2rem" />
</van-col>
</van-row>
<van-divider />
<van-row>
<van-col class="img-col" span="24">
<van-uploader v-model="fileList" multiple />
</van-col>
</van-row>
<van-divider />
<van-row>
<van-col class="img-col" span="24">
<van-uploader :after-read="afterRead" v-model="fileList" multiple />
</van-col>
</van-row>
</div>
</transition>
</transition>
</template>
<script setup lang="ts">
import { ref,onMounted } from 'vue'
const value = ref<string>("")
const fileList = ref([
]);
const visible=ref<boolean>(false)
import { ref, onMounted, reactive, toRefs } from "vue";
import { ArticleEntity } from "@/type/interface/ArticleEntity.ts";
import fileApi from "@/api/fileApi.ts";
import articleApi from "@/api/articleApi.ts";
import { useRouter } from 'vue-router'
const router = useRouter();
const form = reactive<ArticleEntity>({
title: "",
content: "",
images: [],
isDeleted: false,
});
const { images, content } = toRefs(form);
const fileList = ref([]);
const visible = ref<boolean>(false);
onMounted(() => {
visible.value=true;
})
visible.value = true;
});
const afterRead = (file: any) => {
file.status = "uploading";
file.message = "上传中...";
var formData = new FormData();
formData.append("file", file.file);
fileApi.upload("image", formData)
.then((response: any) => {
images.value.push(response.data);
file.status = "done";
file.message = "成功";
})
};
const send = () => {
articleApi.add(form).then((response:any)=>{
router.push({ path: '/recommend'});
})
};
</script>
<style scoped>
.head-row {
background-color: #F8F8F8;
background-color: #f8f8f8;
padding: 2rem 1rem 1.5rem 1rem;
padding: 2rem 1rem 1.5rem 1rem;
}
.head-row span {
font-size: large;
font-size: large;
}
.van-field-5-label {
display: none;
display: none;
}
.body-row {
margin-top: 1rem;
margin-top: 1rem;
}
.preview-cover {
position: absolute;
bottom: 0;
box-sizing: border-box;
width: 100%;
padding: 4px;
color: #fff;
font-size: 12px;
text-align: center;
background: rgba(0, 0, 0, 0.3);
position: absolute;
bottom: 0;
box-sizing: border-box;
width: 100%;
padding: 4px;
color: #fff;
font-size: 12px;
text-align: center;
background: rgba(0, 0, 0, 0.3);
}
.van-uploader {
margin: 0 1.2rem 0 1.2rem;
margin: 0 1.2rem 0 1.2rem;
}
.img-col {
text-align: left;
text-align: left;
}
</style>

View File

@@ -1,4 +1,4 @@
import { defineConfig } from 'vite'
import { defineConfig, loadEnv } from 'vite'
import path from 'path'
import vue from '@vitejs/plugin-vue'
import Components from 'unplugin-vue-components/vite';
@@ -6,38 +6,47 @@ import { VantResolver } from 'unplugin-vue-components/resolvers';
// https://vitejs.dev/config/
export default defineConfig({
plugins: [vue(), Components({
resolvers: [VantResolver()],
}),],
resolve: {
// https://cn.vitejs.dev/config/#resolve-alias
alias: {
// 设置路径
'~': path.resolve(__dirname, './'),
// 设置别名
'@': path.resolve(__dirname, './src')
}
},
server: {
port: 17000,
host: true,
open: true,
// proxy: {
// // https://cn.vitejs.dev/config/#server-proxy
// '/dev-api': {
// target: VITE_APP_BASE_URL,
// changeOrigin: true,
// rewrite: (p) => p.replace(/^\/dev-api/, ''),
// },
export default defineConfig(({ mode, command }) => {
const env = loadEnv(mode, process.cwd())
const { VITE_APP_ENV, VITE_APP_BASE_URL} = env
return {
plugins: [vue(), Components({
resolvers: [VantResolver()],
}),],
resolve: {
// https://cn.vitejs.dev/config/#resolve-alias
alias: {
// 设置路径
'~': path.resolve(__dirname, './'),
// 设置别名
'@': path.resolve(__dirname, './src')
}
},
server: {
port: 17000,
host: true,
open: true,
proxy: {
// https://cn.vitejs.dev/config/#server-proxy
'/dev-api': {
target: VITE_APP_BASE_URL,
changeOrigin: true,
rewrite: (p) => p.replace(/^\/dev-api/, ''),
},
'/dev-ws': {
target: VITE_APP_BASE_URL,
changeOrigin: true,
rewrite: (p) => p.replace(/^\/dev-ws/, ''),
ws: true
}
}
},
}
// '/dev-ws': {
// target: VITE_APP_BASE_URL,
// changeOrigin: true,
// rewrite: (p) => p.replace(/^\/dev-ws/, ''),
// ws: true
// }
}
// }
},
})
)