diff --git a/src/api/interceptor.ts b/src/api/interceptor.ts index 1d8214f..6e436c9 100644 --- a/src/api/interceptor.ts +++ b/src/api/interceptor.ts @@ -40,7 +40,7 @@ axios.interceptors.response.use( (response: AxiosResponse) => { const res = response.data; // if the custom code is not 20000, it is judged as an error. - if (res.code !== 20000) { + if (res.code !== 200) { Message.error({ content: res.msg || 'Error', duration: 5 * 1000, diff --git a/src/layout/default-layout.vue b/src/layout/default-layout.vue index a5488a1..f747d0b 100644 --- a/src/layout/default-layout.vue +++ b/src/layout/default-layout.vue @@ -3,14 +3,14 @@ @@ -34,14 +34,14 @@ @@ -126,6 +126,8 @@ import usePermission from '@/hooks/permission'; import useResponsive from '@/hooks/responsive'; import PageLayout from './page-layout.vue'; + import axios from 'axios'; + import { Message } from '@arco-design/web-vue'; const formData = reactive({ account: '', @@ -133,16 +135,45 @@ password2: '' }); - const onLogin = () => { - console.log(formData) - userStore.setInfo({ - showLogin: false, - name: '开发中' + const onLogin = async () => { + const resp : any = await axios.post("https://k5.vicicode.com/wsapi/login", { + 'username': formData.account, + 'password': formData.password }) + if(resp.code == 200){ + userStore.setInfo({ + showLogin: false, + name: formData.account, + accountId: resp.token + }) + } } - const onRegister = () => { - console.log(formData) + const onRegister = async () => { + if(formData.password == '' || formData.account == ''){ + Message.error({ + content: '用户名及密码不能为空', + duration: 5 * 1000, + }); + return; + } + if(formData.password != formData.password2){ + Message.error({ + content: '两次输入密码不一致', + duration: 5 * 1000, + }); + return; + } + const resp : any = await axios.post("https://k5.vicicode.com/wsapi/register", { + 'username': formData.account, + 'password': formData.password + }) + if(resp.code == 200){ + userStore.setInfo({ + showRegister: false, + showLogin: true + }) + } } const isInit = ref(false); diff --git a/src/locale/en-US.ts b/src/locale/en-US.ts index 3b2eed3..871ac3e 100644 --- a/src/locale/en-US.ts +++ b/src/locale/en-US.ts @@ -141,6 +141,12 @@ export default { 'global.use': 'Use', 'tool.ssbpatch': 'LOSEHU S Firmware SI4732 SSB Patch', 'tool.writessbpatch': 'SSB Patch Write', + 'global.login': 'Login', + 'global.register': 'Register', + 'global.logout': 'Logout', + 'global.username': 'Username', + 'global.password': 'Password', + 'global.password2': 'Retype password ', ...localeSettings, ...localeMessageBox, ...localeLogin, diff --git a/src/locale/zh-CN.ts b/src/locale/zh-CN.ts index a92dd94..39d7f68 100644 --- a/src/locale/zh-CN.ts +++ b/src/locale/zh-CN.ts @@ -141,6 +141,12 @@ export default { 'global.use': '使用', 'tool.ssbpatch': 'LOSEHU S 版固件 SI4732 单边带补丁', 'tool.writessbpatch': '写入单边带补丁', + 'global.login': '登录', + 'global.register': '注册', + 'global.logout': '退出', + 'global.username': '请输入用户名', + 'global.password': '请输入密码', + 'global.password2': '请再次输入密码', ...localeSettings, ...localeMessageBox, ...localeLogin, diff --git a/src/views/idea/firmware/index.vue b/src/views/idea/firmware/index.vue index a253c55..5631871 100644 --- a/src/views/idea/firmware/index.vue +++ b/src/views/idea/firmware/index.vue @@ -8,67 +8,28 @@
- + - - - - - - - - - - - - - - - - - - - - - + @@ -80,16 +41,16 @@ - +
- 审核中 - 固件名称 + {{ item.audit ? '已审核' : '审核中' }} + {{ item.title }}
- 固件描述固件描述固件描述固件描述固件描述固件描述固件描述固件描述固件描述固件描述固件描述固件描述固件描述固件描述固件描述固件描述固件描述固件描述固件描述 + {{ item.desc }}
- 删除 + 删除
@@ -111,7 +72,7 @@