feat: 完善前端
This commit is contained in:
19
Yi.App.Vue3/components.d.ts
vendored
19
Yi.App.Vue3/components.d.ts
vendored
@@ -14,14 +14,33 @@ declare module '@vue/runtime-core' {
|
||||
HelloWorld: typeof import('./src/components/HelloWorld.vue')['default']
|
||||
RouterLink: typeof import('vue-router')['RouterLink']
|
||||
RouterView: typeof import('vue-router')['RouterView']
|
||||
VanActionBar: typeof import('vant/es')['ActionBar']
|
||||
VanActionBarButton: typeof import('vant/es')['ActionBarButton']
|
||||
VanActionBarIcon: typeof import('vant/es')['ActionBarIcon']
|
||||
VanActionSheet: typeof import('vant/es')['ActionSheet']
|
||||
VanButton: typeof import('vant/es')['Button']
|
||||
VanCell: typeof import('vant/es')['Cell']
|
||||
VanCellGroup: typeof import('vant/es')['CellGroup']
|
||||
VanCol: typeof import('vant/es')['Col']
|
||||
VanDivider: typeof import('vant/es')['Divider']
|
||||
VanField: typeof import('vant/es')['Field']
|
||||
VanGrid: typeof import('vant/es')['Grid']
|
||||
VanGridItem: typeof import('vant/es')['GridItem']
|
||||
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']
|
||||
VanRow: typeof import('vant/es')['Row']
|
||||
VanSticky: typeof import('vant/es')['Sticky']
|
||||
VanSwipe: typeof import('vant/es')['Swipe']
|
||||
VanSwipeItem: typeof import('vant/es')['SwipeItem']
|
||||
VanTab: typeof import('vant/es')['Tab']
|
||||
VanTabbar: typeof import('vant/es')['Tabbar']
|
||||
VanTabbarItem: typeof import('vant/es')['TabbarItem']
|
||||
VanTabs: typeof import('vant/es')['Tabs']
|
||||
VanUploader: typeof import('vant/es')['Uploader']
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,17 +1,16 @@
|
||||
import myaxios from '@/utils/myaxios'
|
||||
import { ArticleEntity } from '@/type/interface/ArticleEntity'
|
||||
|
||||
export default {
|
||||
add(data:any) {
|
||||
return myaxios({
|
||||
url: `/article/add`,
|
||||
url: `/Trends`,
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
},
|
||||
pageList(data:any) {
|
||||
return myaxios({
|
||||
url: '/article/pageList',
|
||||
url: '/Trends',
|
||||
method: 'get',
|
||||
params: data
|
||||
})
|
||||
|
||||
@@ -33,7 +33,7 @@ export function register(data:any) {
|
||||
// 获取用户详细信息
|
||||
export function getInfo() {
|
||||
return myaxios({
|
||||
url: '/account/getUserAllInfo',
|
||||
url: '/account',
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import router from './router'
|
||||
// import 'nprogress/nprogress.css'
|
||||
import { getToken } from '@/utils/auth'
|
||||
// import { isHttp } from '@/utils/validate'
|
||||
import useUserStore from '@/store/modules/user'
|
||||
import useUserStore from '@/store/modules/user.js'
|
||||
import { isRelogin } from '@/utils/myaxios'
|
||||
// import useSettingsStore from '@/store/modules/settings'
|
||||
// import usePermissionStore from '@/store/modules/permission'
|
||||
|
||||
@@ -21,21 +21,23 @@ const useUserStore = defineStore(
|
||||
return new Promise((resolve, reject) => {
|
||||
|
||||
login(username, password, code, uuid).then(res => {
|
||||
if(!res.status)
|
||||
if(!(res as any).succeeded)
|
||||
{
|
||||
reject(res)
|
||||
}
|
||||
setToken(res.data.token);
|
||||
this.token = res.data.token;
|
||||
resolve(res);
|
||||
|
||||
return resolve(res);
|
||||
}).catch(error => {
|
||||
reject(error)
|
||||
return reject(error)
|
||||
})
|
||||
})
|
||||
},
|
||||
// 获取用户信息
|
||||
getInfo() {
|
||||
return new Promise((resolve, reject) => {
|
||||
|
||||
getInfo().then(response => {
|
||||
const res=response.data;
|
||||
const user = res.user
|
||||
@@ -55,9 +57,9 @@ const useUserStore = defineStore(
|
||||
this.user.username = user.userName;
|
||||
this.user.nick=user.nick
|
||||
this.user.icon = user.icon;
|
||||
resolve(res)
|
||||
resolve(res)
|
||||
}).catch(error => {
|
||||
reject(error)
|
||||
reject(error)
|
||||
})
|
||||
|
||||
|
||||
|
||||
@@ -5,37 +5,43 @@ import axios from 'axios'
|
||||
import JsonBig from 'json-bigint'
|
||||
import { getToken } from '@/utils/auth'
|
||||
import { useRouter } from "vue-router";
|
||||
import useUserStore from '@/store/modules/user'
|
||||
import useUserStore from '@/store/modules/user.js'
|
||||
import { Notify } from 'vant';
|
||||
// import VuetifyDialogPlugin from 'vuetify-dialog/nuxt/index';
|
||||
export let isRelogin = { show: false };
|
||||
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:any) {
|
||||
const isToken = (config.headers || {}).isToken === false
|
||||
// 是否需要防止数据重复提交
|
||||
const isRepeatSubmit = (config.headers || {}).repeatSubmit === false
|
||||
if (getToken() && !isToken) {
|
||||
config.headers['Authorization'] = 'Bearer ' + getToken()
|
||||
}
|
||||
// store.dispatch("openLoad");
|
||||
return config;
|
||||
}, function(error) {
|
||||
return Promise.reject(error);
|
||||
// baseURL:'/'//
|
||||
baseURL: import.meta.env.VITE_APP_BASE_API, // /dev-apis
|
||||
timeout: 50000,
|
||||
headers: {
|
||||
'Authorization': 'Bearer ' + ""
|
||||
},
|
||||
//雪花id精度问题
|
||||
transformResponse: [data => {
|
||||
const json = JsonBig({
|
||||
storeAsString: true
|
||||
});
|
||||
try {
|
||||
return json.parse(data);
|
||||
}
|
||||
catch
|
||||
{
|
||||
return data;
|
||||
}
|
||||
}],
|
||||
})
|
||||
// 请求拦截器
|
||||
myaxios.interceptors.request.use(function (config:any) {
|
||||
const isToken = (config.headers || {}).isToken === false
|
||||
// 是否需要防止数据重复提交
|
||||
const isRepeatSubmit = (config.headers || {}).repeatSubmit === false
|
||||
if (getToken() && !isToken) {
|
||||
config.headers['Authorization'] = 'Bearer ' + getToken()
|
||||
}
|
||||
// store.dispatch("openLoad");
|
||||
return config;
|
||||
}, function (error) {
|
||||
return Promise.reject(error);
|
||||
});
|
||||
|
||||
// 响应拦截器
|
||||
@@ -53,18 +59,25 @@ myaxios.interceptors.response.use(async function(response) {
|
||||
}
|
||||
// store.dispatch("closeLoad");
|
||||
return resp;
|
||||
}, async function(error) {
|
||||
},
|
||||
async function(error) {
|
||||
const code=error.response.status;
|
||||
const message=error.message;
|
||||
//未授权、失败
|
||||
if(error.response==undefined)
|
||||
{
|
||||
Notify({ type: 'danger', message: `服务器异常:${error.message}` });
|
||||
|
||||
// useUserStore().logOut().then(() => {
|
||||
// location.href = '/';
|
||||
// })
|
||||
|
||||
return Promise.reject(error);;
|
||||
}
|
||||
|
||||
const resp = error.response.data
|
||||
if (resp.code == undefined && resp.message == undefined) {
|
||||
if (code == undefined &&message == undefined) {
|
||||
Notify({ type: 'danger', message: '未知错误' });
|
||||
} else if (resp.code == 401) {
|
||||
} else if (code == 401) {
|
||||
// if (!isRelogin.show) {
|
||||
Notify({ type: 'warning', message: '登录过期' });
|
||||
//登出
|
||||
@@ -73,9 +86,10 @@ if (resp.code == undefined && resp.message == undefined) {
|
||||
})
|
||||
isRelogin.show = false;
|
||||
// }
|
||||
} else if (resp.code !== 200) {
|
||||
Notify({ type: 'danger', message: `错误代码:${resp.code},原因:${resp.message}` });
|
||||
} else if (code !== 200) {
|
||||
Notify({ type: 'danger', message: `错误代码:${code},原因:${message}` });
|
||||
}
|
||||
return Promise.reject(error);
|
||||
});
|
||||
|
||||
export default myaxios
|
||||
@@ -36,8 +36,9 @@
|
||||
<script setup lang="ts">
|
||||
import { ref } from "vue";
|
||||
import { useRouter } from "vue-router";
|
||||
import useUserStore from "@/store/modules/user";
|
||||
import useUserStore from "@/store/modules/user.js";
|
||||
import { Toast } from "vant";
|
||||
import { debug } from "console";
|
||||
|
||||
const router = useRouter();
|
||||
const redirect = ref(undefined);
|
||||
@@ -55,15 +56,16 @@ const login = () => {
|
||||
.login(loginForm.value)
|
||||
.then((response: any) => {
|
||||
Toast({
|
||||
message: response.message,
|
||||
message: "登录成功",
|
||||
position: "bottom",
|
||||
});
|
||||
|
||||
router.push({ path: redirect.value || "/" });
|
||||
})
|
||||
.catch((response:any) => {
|
||||
loginForm.value.password="";
|
||||
Toast({
|
||||
message: response.message,
|
||||
message: response.errors,
|
||||
position: "bottom",
|
||||
});
|
||||
// loading.value = false;
|
||||
|
||||
@@ -58,10 +58,15 @@
|
||||
text="评论"
|
||||
@click="openComment(item.id)"
|
||||
/>
|
||||
<van-grid-item
|
||||
<!-- <van-grid-item
|
||||
icon="good-job-o"
|
||||
:text="`点赞:${item.agreeNum}`"
|
||||
@click="aggreeHand(item.id)"
|
||||
/> -->
|
||||
<van-grid-item
|
||||
icon="good-job-o"
|
||||
:text="`点赞:10`"
|
||||
@click="aggreeHand(item.id)"
|
||||
/>
|
||||
</van-grid>
|
||||
</van-col>
|
||||
@@ -113,7 +118,6 @@ import AppUserIcon from "@/components/AppUserIcon.vue";
|
||||
import articleApi from "@/api/articleApi";
|
||||
import agreeApi from "@/api/agreeApi";
|
||||
import commentApi from "@/api/commentApi";
|
||||
import { ArticleEntity } from "@/type/interface/ArticleEntity";
|
||||
const VanImagePreview = ImagePreview.Component;
|
||||
const url = `${import.meta.env.VITE_APP_BASE_API}/file/`;
|
||||
const data = reactive({
|
||||
@@ -174,19 +178,17 @@ const onLoad = async () => {
|
||||
// 异步更新数据
|
||||
// setTimeout 仅做示例,真实场景中一般为 ajax 请求
|
||||
articleApi.pageList(queryParams.value).then((response: any) => {
|
||||
if (response.data.data.length == 0) {
|
||||
if (response.data.items.length == 0) {
|
||||
console.log("结束");
|
||||
finished.value = true;
|
||||
} else {
|
||||
console.log("执行");
|
||||
articleList.value.push(...response.data.data);
|
||||
articleList.value.push(...response.data.items);
|
||||
totol.value = response.data.totol;
|
||||
queryParams.value.pageNum += 1;
|
||||
}
|
||||
|
||||
loading.value = false;
|
||||
|
||||
console.log(loading.value);
|
||||
});
|
||||
};
|
||||
const onRefresh = () => {
|
||||
|
||||
@@ -93,7 +93,7 @@ import AppGrid from "@/components/AppGrid.vue";
|
||||
import { AppGridData } from "@/type/class/AppGridData";
|
||||
import { ref } from "vue";
|
||||
import { Dialog } from "vant";
|
||||
import useUserStore from "@/store/modules/user";
|
||||
import useUserStore from "@/store/modules/user.js";
|
||||
import { storeToRefs } from 'pinia';
|
||||
import AppUserIcon from "@/components/AppUserIcon.vue";
|
||||
const show = ref<boolean>(false);
|
||||
|
||||
@@ -19,6 +19,6 @@
|
||||
"@/*": ["./src/*"]
|
||||
}
|
||||
},
|
||||
"include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue"],
|
||||
"include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue", "src/store/modules/user.ts", "src/utils/myaxios.ts"],
|
||||
"references": [{ "path": "./tsconfig.node.json" }]
|
||||
}
|
||||
|
||||
@@ -43,18 +43,19 @@ myaxios.interceptors.response.use(function (response) {
|
||||
}
|
||||
return response.data;
|
||||
}, function (error) {
|
||||
const response=error.response.data;
|
||||
const code = error.response.status;
|
||||
const msg = error.message;
|
||||
//业务异常+应用异常,统一处理
|
||||
switch(response.code)
|
||||
switch(code)
|
||||
{
|
||||
case 401:
|
||||
ElMessage.error('登录已过期')
|
||||
break;
|
||||
case 403:
|
||||
ElMessage.error(response.message)
|
||||
ElMessage.error(msg)
|
||||
break;
|
||||
case 500:
|
||||
ElMessage.error(response.message)
|
||||
ElMessage.error(msg)
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using Furion;
|
||||
using Furion.Schedule;
|
||||
using Furion.TimeCrontab;
|
||||
@@ -73,6 +72,7 @@ public class Startup : AppStartup
|
||||
app.UseAuthorization();
|
||||
|
||||
app.UseInject(string.Empty);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -55,6 +55,9 @@
|
||||
<Content Update="appsettings.Production.json">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Update="wwwroot\Image\1633441011139219456.jpg">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
<ProjectExtensions>
|
||||
<VisualStudio>
|
||||
|
||||
@@ -24,7 +24,13 @@ const service = axios.create({
|
||||
const json = JsonBig({
|
||||
storeAsString: true
|
||||
})
|
||||
return json.parse(data)
|
||||
try {
|
||||
return json.parse(data)
|
||||
}
|
||||
catch
|
||||
{
|
||||
return data;
|
||||
}
|
||||
}],
|
||||
})
|
||||
|
||||
@@ -94,7 +100,7 @@ service.interceptors.response.use(res => {
|
||||
},
|
||||
error => {
|
||||
const code = error.response.status;
|
||||
const msg = error.response.data.message;
|
||||
const msg = error.message;
|
||||
handler(code, msg);
|
||||
}
|
||||
)
|
||||
@@ -136,18 +142,18 @@ const handler = (code, msg) => {
|
||||
break;
|
||||
//业务异常
|
||||
case 403:
|
||||
ElNotification.error({
|
||||
title: msg
|
||||
})
|
||||
ElNotification.error({
|
||||
title: msg
|
||||
})
|
||||
break;
|
||||
|
||||
//未授权
|
||||
//未授权
|
||||
case 401:
|
||||
ElMessageBox.confirm('登录状态已过期,您可以继续留在该页面,或者重新登录', '系统提示', {
|
||||
confirmButtonText: '重新登录',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
})
|
||||
ElMessageBox.confirm('登录状态已过期,您可以继续留在该页面,或者重新登录', '系统提示', {
|
||||
confirmButtonText: '重新登录',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
})
|
||||
.then(() => {
|
||||
isRelogin.show = false;
|
||||
useUserStore().logOut().then(() => {
|
||||
@@ -163,7 +169,7 @@ const handler = (code, msg) => {
|
||||
type: 'error'
|
||||
});
|
||||
break;
|
||||
//正常
|
||||
//正常
|
||||
case 200:
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user