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