接口请求地址以及接口返回提示修改
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
# the base url of the application, the default is "/"
|
||||
# if use a sub directory, it must be end with "/", like "/admin/" but not "/admin"
|
||||
VITE_BASE_URL=/
|
||||
VITE_BASE_URL=http://192.168.0.230:8086
|
||||
|
||||
VITE_APP_TITLE=MOC变更管理系统
|
||||
|
||||
@@ -23,7 +23,7 @@ VITE_ROUTE_HOME=home
|
||||
VITE_MENU_ICON=mdi:menu
|
||||
|
||||
# whether to enable http proxy when is dev mode
|
||||
VITE_HTTP_PROXY=Y
|
||||
VITE_HTTP_PROXY=N
|
||||
|
||||
# vue-router mode: hash | history | memory
|
||||
VITE_ROUTER_HISTORY_MODE=history
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
# backend service base url, prod environment
|
||||
VITE_SERVICE_BASE_URL=https://mock.apifox.cn/m1/3109515-0-default
|
||||
VITE_BASE_URL=http://192.168.0.230:8086
|
||||
VITE_SERVICE_BASE_URL=http://192.168.0.230:8086
|
||||
|
||||
# other backend service base url, prod environment
|
||||
VITE_OTHER_SERVICE_BASE_URL= `{
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
# backend service base url, test environment
|
||||
VITE_SERVICE_BASE_URL=https://mock.apifox.cn/m1/3109515-0-default
|
||||
VITE_BASE_URL=http://192.168.0.230:8086
|
||||
VITE_SERVICE_BASE_URL=http://192.168.0.230:8086
|
||||
|
||||
# other backend service base url, test environment
|
||||
VITE_OTHER_SERVICE_BASE_URL= `{
|
||||
|
||||
+4
-14
@@ -1,17 +1,17 @@
|
||||
import { request } from '../request';
|
||||
|
||||
/**
|
||||
* Login
|
||||
* 登录
|
||||
*
|
||||
* @param userName User name
|
||||
* @param password Password
|
||||
*/
|
||||
export function fetchLogin(userName: string, password: string) {
|
||||
export function fetchLogin(username: string, password: string) {
|
||||
return request<Api.Auth.LoginToken>({
|
||||
url: '/auth/login',
|
||||
url: '/api/auth/login',
|
||||
method: 'post',
|
||||
data: {
|
||||
userName,
|
||||
username,
|
||||
password
|
||||
}
|
||||
});
|
||||
@@ -36,13 +36,3 @@ export function fetchRefreshToken(refreshToken: string) {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* return custom backend error
|
||||
*
|
||||
* @param code error code
|
||||
* @param msg error message
|
||||
*/
|
||||
export function fetchCustomBackendError(code: string, msg: string) {
|
||||
return request({ url: '/auth/error', params: { code, msg } });
|
||||
}
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
import type { AxiosResponse } from 'axios';
|
||||
import { BACKEND_ERROR_CODE, createFlatRequest, createRequest } from '@sa/axios';
|
||||
import { BACKEND_ERROR_CODE, createFlatRequest } from '@sa/axios';
|
||||
import { useAuthStore } from '@/store/modules/auth';
|
||||
import { localStg } from '@/utils/storage';
|
||||
import { getServiceBaseURL } from '@/utils/service';
|
||||
import { $t } from '@/locales';
|
||||
import { getAuthorization, handleExpiredRequest, showErrorMsg } from './shared';
|
||||
import type { RequestInstanceState } from './type';
|
||||
|
||||
const isHttpProxy = import.meta.env.DEV && import.meta.env.VITE_HTTP_PROXY === 'Y';
|
||||
const { baseURL, otherBaseURL } = getServiceBaseURL(import.meta.env, isHttpProxy);
|
||||
const { baseURL } = getServiceBaseURL(import.meta.env, isHttpProxy);
|
||||
|
||||
export const request = createFlatRequest(
|
||||
{
|
||||
@@ -100,13 +99,12 @@ export const request = createFlatRequest(
|
||||
},
|
||||
onError(error) {
|
||||
// when the request is fail, you can show error message
|
||||
|
||||
let message = error.message;
|
||||
let backendErrorCode = '';
|
||||
|
||||
// get backend error message and code
|
||||
if (error.code === BACKEND_ERROR_CODE) {
|
||||
message = error.response?.data?.msg || message;
|
||||
message = error.response?.data?.message || message;
|
||||
backendErrorCode = String(error.response?.data?.code || '');
|
||||
}
|
||||
|
||||
@@ -126,45 +124,3 @@ export const request = createFlatRequest(
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
export const demoRequest = createRequest(
|
||||
{
|
||||
baseURL: otherBaseURL.demo
|
||||
},
|
||||
{
|
||||
transform(response: AxiosResponse<App.Service.DemoResponse>) {
|
||||
return response.data.result;
|
||||
},
|
||||
async onRequest(config) {
|
||||
const { headers } = config;
|
||||
|
||||
// set token
|
||||
const token = localStg.get('token');
|
||||
const Authorization = token ? `Bearer ${token}` : null;
|
||||
Object.assign(headers, { Authorization });
|
||||
|
||||
return config;
|
||||
},
|
||||
isBackendSuccess(response) {
|
||||
// when the backend response code is "200", it means the request is success
|
||||
// you can change this logic by yourself
|
||||
return response.data.status === '200';
|
||||
},
|
||||
async onBackendFail(_response) {
|
||||
// when the backend response code is not "200", it means the request is fail
|
||||
// for example: the token is expired, refresh token and retry request
|
||||
},
|
||||
onError(error) {
|
||||
// when the request is fail, you can show error message
|
||||
|
||||
let message = error.message;
|
||||
|
||||
// show backend error message
|
||||
if (error.code === BACKEND_ERROR_CODE) {
|
||||
message = error.response?.data?.message || message;
|
||||
}
|
||||
|
||||
window.$message?.error(message);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
Vendored
+1
-1
@@ -566,7 +566,7 @@ declare namespace App {
|
||||
/** The backend service response code */
|
||||
code: string;
|
||||
/** The backend service response message */
|
||||
msg: string;
|
||||
message: string;
|
||||
/** The backend service response data */
|
||||
data: T;
|
||||
};
|
||||
|
||||
@@ -15,9 +15,14 @@ export function createServiceConfig(env: Env.ImportMeta) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.error('VITE_OTHER_SERVICE_BASE_URL is not a valid json5 string');
|
||||
}
|
||||
|
||||
let url = 'http://192.168.0.230:8086';
|
||||
if(env.DEV){
|
||||
url = 'http://192.168.0.230:8086';
|
||||
}else{
|
||||
url = window.location.origin;
|
||||
}
|
||||
const httpConfig: App.Service.SimpleServiceConfig = {
|
||||
baseURL: VITE_SERVICE_BASE_URL,
|
||||
baseURL: url,
|
||||
other
|
||||
};
|
||||
|
||||
|
||||
@@ -1,16 +1,11 @@
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue';
|
||||
import type { Component } from 'vue';
|
||||
import { getPaletteColorByNumber, mixColor } from '@sa/color';
|
||||
import { useAppStore } from '@/store/modules/app';
|
||||
import { useThemeStore } from '@/store/modules/theme';
|
||||
import PwdLogin from './modules/pwd-login.vue';
|
||||
|
||||
const appStore = useAppStore();
|
||||
const themeStore = useThemeStore();
|
||||
|
||||
const activeModule = computed(() => ({ label: '密码登录', component: PwdLogin }));
|
||||
|
||||
const bgThemeColor = computed(() =>
|
||||
themeStore.darkMode ? getPaletteColorByNumber(themeStore.themeColor, 600) : themeStore.themeColor
|
||||
);
|
||||
@@ -27,30 +22,13 @@ const bgColor = computed(() => {
|
||||
<WaveBg :theme-color="bgThemeColor" />
|
||||
<NCard :bordered="false" class="relative z-4 w-auto rd-12px">
|
||||
<div class="w-400px lt-sm:w-300px">
|
||||
<header class="flex-y-center justify-between">
|
||||
<header class="flex-y-center justify-center gap-4">
|
||||
<SystemLogo class="size-64px lt-sm:size-48px" />
|
||||
<h3 class="text-28px text-primary font-500 lt-sm:text-22px">MOC变更管理系统</h3>
|
||||
<div class="i-flex-col">
|
||||
<!-- 主题切换 -->
|
||||
<ThemeSchemaSwitch
|
||||
:theme-schema="themeStore.themeScheme"
|
||||
:show-tooltip="false"
|
||||
class="text-20px lt-sm:text-18px"
|
||||
@switch="themeStore.toggleThemeScheme"
|
||||
/>
|
||||
<!-- 语言切换 -->
|
||||
<LangSwitch
|
||||
v-if="themeStore.header.multilingual.visible"
|
||||
:lang="appStore.locale"
|
||||
:lang-options="appStore.localeOptions"
|
||||
:show-tooltip="false"
|
||||
@change-lang="appStore.changeLocale"
|
||||
/>
|
||||
</div>
|
||||
</header>
|
||||
<main class="pt-24px">
|
||||
<Transition :name="themeStore.page.animateMode" mode="out-in" appear>
|
||||
<component :is="activeModule.component" />
|
||||
<component :is="PwdLogin" />
|
||||
</Transition>
|
||||
</main>
|
||||
</div>
|
||||
|
||||
@@ -8,7 +8,7 @@ defineOptions({
|
||||
});
|
||||
|
||||
const authStore = useAuthStore();
|
||||
const { formRef, validate } = useNaiveForm();
|
||||
const { validate } = useNaiveForm();
|
||||
|
||||
interface FormModel {
|
||||
userName: string;
|
||||
@@ -21,9 +21,7 @@ const model: FormModel = reactive({
|
||||
});
|
||||
|
||||
const rules = computed<Record<keyof FormModel, App.Global.FormRule[]>>(() => {
|
||||
// inside computed to make locale reactive, if not apply i18n, you can define it without computed
|
||||
const { formRules } = useFormRules();
|
||||
|
||||
return {
|
||||
userName: formRules.userName,
|
||||
password: formRules.pwd
|
||||
@@ -51,9 +49,6 @@ async function handleSubmit() {
|
||||
/>
|
||||
</NFormItem>
|
||||
<NSpace vertical :size="24">
|
||||
<div class="flex-y-center justify-between">
|
||||
<NCheckbox>记住我</NCheckbox>
|
||||
</div>
|
||||
<NButton type="primary" size="large" round block :loading="authStore.loginLoading" @click="handleSubmit">
|
||||
登录
|
||||
</NButton>
|
||||
|
||||
@@ -266,7 +266,6 @@ const treeProps = ({ option }: { option: any }) => {
|
||||
onContextmenu(e: MouseEvent) {
|
||||
e.preventDefault()
|
||||
currentNode.value = option
|
||||
console.log(currentNode.value)
|
||||
menuX.value = e.clientX
|
||||
menuY.value = e.clientY
|
||||
menuVisible.value = true
|
||||
|
||||
Reference in New Issue
Block a user