build(deps): 添加smooth-scroll插件、axios封装
This commit is contained in:
parent
afd4d04110
commit
82411cc5eb
6
.env.development
Normal file
6
.env.development
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
#请求的环境 测试环境
|
||||||
|
VITE_HTTP_ENV=TEST
|
||||||
|
#请求地址
|
||||||
|
VITE_HTTP_URL=http://192.168.100.57/
|
||||||
|
#emoss-admin服务请求地址
|
||||||
|
VITE_HTTP_URL_EMOSS_ADMIN = http://192.168.100.57:8201/emoss-admin
|
6
.env.production
Normal file
6
.env.production
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
#请求的环境 正式环境
|
||||||
|
VITE_HTTP_ENV=OFFICAL
|
||||||
|
#请求地址
|
||||||
|
VITE_HTTP_URL=http://119.23.220.176:17321
|
||||||
|
#emoss-admin服务请求地址
|
||||||
|
VITE_HTTP_URL_EMOSS_ADMIN = http://119.23.220.176:17321/emoss-admin
|
@ -14,6 +14,7 @@ module.exports = {
|
|||||||
'no-unused-vars': 0,
|
'no-unused-vars': 0,
|
||||||
'import/extensions': ['error', 'never'],
|
'import/extensions': ['error', 'never'],
|
||||||
'import/no-extraneous-dependencies': [2, { devDependencies: true }],
|
'import/no-extraneous-dependencies': [2, { devDependencies: true }],
|
||||||
'import/no-unresolved': 0
|
'import/no-unresolved': 0,
|
||||||
|
'no-shadow': 0
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -12,8 +12,12 @@
|
|||||||
"*.{vue,js,jsx,ts,tsx}": "eslint --fix"
|
"*.{vue,js,jsx,ts,tsx}": "eslint --fix"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"axios": "^0.21.1",
|
||||||
|
"dayjs": "^1.10.5",
|
||||||
"element-plus": "^1.0.2-beta.44",
|
"element-plus": "^1.0.2-beta.44",
|
||||||
"nprogress": "^0.2.0",
|
"nprogress": "^0.2.0",
|
||||||
|
"qs": "^6.10.1",
|
||||||
|
"smoothscroll-polyfill": "^0.4.4",
|
||||||
"vue": "^3.0.5"
|
"vue": "^3.0.5"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
@ -21,6 +25,8 @@
|
|||||||
"@commitlint/config-conventional": "^12.1.4",
|
"@commitlint/config-conventional": "^12.1.4",
|
||||||
"@iconify/json": "^1.1.349",
|
"@iconify/json": "^1.1.349",
|
||||||
"@types/nprogress": "^0.2.0",
|
"@types/nprogress": "^0.2.0",
|
||||||
|
"@types/qs": "^6.9.6",
|
||||||
|
"@types/smoothscroll-polyfill": "^0.3.1",
|
||||||
"@typescript-eslint/eslint-plugin": "^4.25.0",
|
"@typescript-eslint/eslint-plugin": "^4.25.0",
|
||||||
"@typescript-eslint/parser": "^4.25.0",
|
"@typescript-eslint/parser": "^4.25.0",
|
||||||
"@vitejs/plugin-vue": "^1.2.2",
|
"@vitejs/plugin-vue": "^1.2.2",
|
||||||
|
19
src/App.vue
19
src/App.vue
@ -1,19 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<img alt="Vue logo" src="./assets/logo.png" />
|
<div></div>
|
||||||
<HelloWorld msg="Hello Vue 3 + TypeScript + Vite" />
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup></script>
|
||||||
import HelloWorld from './components/HelloWorld.vue';
|
<style></style>
|
||||||
</script>
|
|
||||||
|
|
||||||
<style>
|
|
||||||
#app {
|
|
||||||
font-family: Avenir, Helvetica, Arial, sans-serif;
|
|
||||||
-webkit-font-smoothing: antialiased;
|
|
||||||
-moz-osx-font-smoothing: grayscale;
|
|
||||||
text-align: center;
|
|
||||||
color: #2c3e50;
|
|
||||||
margin-top: 60px;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
|
@ -1,7 +1,10 @@
|
|||||||
import { createApp } from 'vue';
|
import { createApp } from 'vue';
|
||||||
import App from './App.vue';
|
import App from './App.vue';
|
||||||
import { setupElementPlus } from './plugins';
|
import { setupSmoothScroll, setupElementPlus } from './plugins';
|
||||||
import 'virtual:windi.css';
|
import 'virtual:windi.css';
|
||||||
|
import './styles/css/global.css';
|
||||||
|
|
||||||
|
setupSmoothScroll();
|
||||||
|
|
||||||
const app = createApp(App);
|
const app = createApp(App);
|
||||||
setupElementPlus(app);
|
setupElementPlus(app);
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
import type { App } from 'vue';
|
import type { App } from 'vue';
|
||||||
import 'element-plus/lib/theme-chalk/base.css';
|
import 'element-plus/lib/theme-chalk/base.css';
|
||||||
|
import lang from 'element-plus/lib/locale/lang/zh-cn';
|
||||||
|
import 'dayjs/locale/zh-cn';
|
||||||
import {
|
import {
|
||||||
// ElAlert,
|
// ElAlert,
|
||||||
// ElAside,
|
// ElAside,
|
||||||
@ -26,7 +28,7 @@ import {
|
|||||||
ElCollapseTransition,
|
ElCollapseTransition,
|
||||||
// ElColorPicker,
|
// ElColorPicker,
|
||||||
// ElContainer,
|
// ElContainer,
|
||||||
// ElDatePicker,
|
ElDatePicker,
|
||||||
// ElDialog,
|
// ElDialog,
|
||||||
// ElDivider,
|
// ElDivider,
|
||||||
// ElDrawer,
|
// ElDrawer,
|
||||||
@ -81,10 +83,11 @@ import {
|
|||||||
// ElTree,
|
// ElTree,
|
||||||
// ElUpload,
|
// ElUpload,
|
||||||
// ElInfiniteScroll,
|
// ElInfiniteScroll,
|
||||||
ElLoading
|
ElLoading,
|
||||||
// ElMessage
|
// ElMessage
|
||||||
// ElMessageBox,
|
// ElMessageBox,
|
||||||
// ElNotification
|
// ElNotification
|
||||||
|
locale
|
||||||
} from 'element-plus';
|
} from 'element-plus';
|
||||||
|
|
||||||
const components = [
|
const components = [
|
||||||
@ -113,7 +116,7 @@ const components = [
|
|||||||
ElCollapseTransition,
|
ElCollapseTransition,
|
||||||
// ElColorPicker,
|
// ElColorPicker,
|
||||||
// ElContainer,
|
// ElContainer,
|
||||||
// ElDatePicker,
|
ElDatePicker,
|
||||||
// ElDialog,
|
// ElDialog,
|
||||||
// ElDivider,
|
// ElDivider,
|
||||||
// ElDrawer,
|
// ElDrawer,
|
||||||
@ -179,6 +182,8 @@ const plugins = [
|
|||||||
|
|
||||||
/** 引入element-plus UI组件 */
|
/** 引入element-plus UI组件 */
|
||||||
export default function setupElementPlus(app: App<Element>) {
|
export default function setupElementPlus(app: App<Element>) {
|
||||||
|
/** 国际化 */
|
||||||
|
locale(lang);
|
||||||
components.forEach(component => {
|
components.forEach(component => {
|
||||||
app.component(component.name, component);
|
app.component(component.name, component);
|
||||||
});
|
});
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
|
import setupSmoothScroll from './smooth-scroll';
|
||||||
import setupElementPlus from './element-plus';
|
import setupElementPlus from './element-plus';
|
||||||
import NProgress from './nprogress';
|
import NProgress from './nprogress';
|
||||||
|
|
||||||
export { setupElementPlus, NProgress };
|
export { setupSmoothScroll, setupElementPlus, NProgress };
|
||||||
|
6
src/plugins/smooth-scroll.ts
Normal file
6
src/plugins/smooth-scroll.ts
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
import smoothscroll from 'smoothscroll-polyfill';
|
||||||
|
|
||||||
|
/** 平滑滚动插件(兼容主流浏览器) */
|
||||||
|
export default function setupSmoothScroll() {
|
||||||
|
smoothscroll.polyfill();
|
||||||
|
}
|
0
src/service/api/auth.ts
Normal file
0
src/service/api/auth.ts
Normal file
0
src/service/index.ts
Normal file
0
src/service/index.ts
Normal file
0
src/service/middleware/auth.ts
Normal file
0
src/service/middleware/auth.ts
Normal file
8
src/service/request/config.ts
Normal file
8
src/service/request/config.ts
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
/** 请求超时时间 */
|
||||||
|
export const REQUEST_TIMEOUT = 15 * 1000;
|
||||||
|
|
||||||
|
/** 请求头的content-type类型 */
|
||||||
|
export enum ContentType {
|
||||||
|
json = 'application/json',
|
||||||
|
formUrlEncoded = 'application/x-www-form-urlencoded'
|
||||||
|
}
|
77
src/service/request/errorHandler.ts
Normal file
77
src/service/request/errorHandler.ts
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
import { ElMessage } from 'element-plus';
|
||||||
|
|
||||||
|
const ERROR_STATUS = {
|
||||||
|
400: '400: 请求出现语法错误',
|
||||||
|
401: '401: 用户未授权~',
|
||||||
|
403: '403: 服务器拒绝访问~',
|
||||||
|
404: '404: 请求的资源不存在~',
|
||||||
|
405: '405: 请求方法未允许~',
|
||||||
|
408: '408: 网络请求超时~',
|
||||||
|
500: '500: 服务器内部错误~',
|
||||||
|
501: '501: 服务器未实现请求功能~',
|
||||||
|
502: '502: 错误网关~',
|
||||||
|
503: '503: 服务不可用~',
|
||||||
|
504: '504: 网关超时~',
|
||||||
|
505: '505: http版本不支持该请求~'
|
||||||
|
};
|
||||||
|
type ErrorStatus = 400 | 401 | 403 | 404 | 405 | 408 | 500 | 501 | 502 | 503 | 504 | 505;
|
||||||
|
|
||||||
|
/** 错误信息显示时间 */
|
||||||
|
export const errorDuration = 3000 / 1000;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 网络请求错误状态处理
|
||||||
|
* @param error - 错误
|
||||||
|
*/
|
||||||
|
export function errorHandler(error: any) {
|
||||||
|
if (error.response) {
|
||||||
|
const status = error.response.status as ErrorStatus;
|
||||||
|
ElMessage.error(ERROR_STATUS[status]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (error.code === 'ECONNABORTED' && error.message.includes('timeout')) {
|
||||||
|
ElMessage.error('网络连接超时~');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!window.navigator.onLine || error.message === 'Network Error') {
|
||||||
|
ElMessage.error('网络不可用~');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ElMessage.error('未知错误~');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 连续的请求错误依此显示
|
||||||
|
* @param duration - 上一次弹出错误消息到下一次的时间(ms)
|
||||||
|
*/
|
||||||
|
export function continuousErrorHandler(duration: number) {
|
||||||
|
let errorStacks: string[] = [];
|
||||||
|
function pushError(id: string) {
|
||||||
|
errorStacks.push(id);
|
||||||
|
}
|
||||||
|
function removeError(id: string) {
|
||||||
|
errorStacks = errorStacks.filter(item => item !== id);
|
||||||
|
}
|
||||||
|
function handleError(id: string, callback: Function) {
|
||||||
|
callback();
|
||||||
|
setTimeout(() => {
|
||||||
|
removeError(id);
|
||||||
|
}, duration);
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleContinuousError(callback: Function) {
|
||||||
|
const id = Date.now().toString(36);
|
||||||
|
const { length } = errorStacks;
|
||||||
|
if (length > 0) {
|
||||||
|
pushError(id);
|
||||||
|
setTimeout(() => {
|
||||||
|
handleError(id, callback);
|
||||||
|
}, duration * length);
|
||||||
|
} else {
|
||||||
|
pushError(id);
|
||||||
|
handleError(id, callback);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return handleContinuousError;
|
||||||
|
}
|
11
src/service/request/index.ts
Normal file
11
src/service/request/index.ts
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
import { createRequest } from './request';
|
||||||
|
import { REQUEST_TIMEOUT, ContentType } from './config';
|
||||||
|
|
||||||
|
export { handleResponse } from './request';
|
||||||
|
export { ContentType };
|
||||||
|
|
||||||
|
// emoss-admin
|
||||||
|
export const adminRequest = createRequest({
|
||||||
|
baseURL: import.meta.env.VITE_HTTP_URL_EMOSS_ADMIN as string,
|
||||||
|
timeout: REQUEST_TIMEOUT
|
||||||
|
});
|
77
src/service/request/instance.ts
Normal file
77
src/service/request/instance.ts
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
import axios from 'axios';
|
||||||
|
import qs from 'qs';
|
||||||
|
import { getStorageToken } from '@/utils';
|
||||||
|
import { ElMessage } from 'element-plus';
|
||||||
|
import type { AxiosRequestConfig, AxiosInstance } from 'axios';
|
||||||
|
import { errorHandler } from './errorHandler';
|
||||||
|
|
||||||
|
export interface StatusConfig {
|
||||||
|
/** 表明请求状态的属性key */
|
||||||
|
statusKey: string;
|
||||||
|
/** 请求信息的属性key */
|
||||||
|
msgKey: string;
|
||||||
|
/** 成功状态的状态码 */
|
||||||
|
successCode: string | number;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 封装axios请求类
|
||||||
|
* @author Soybean(曹理斌) 2021-03-13
|
||||||
|
* @class CustomAxiosInstance
|
||||||
|
*/
|
||||||
|
export default class CustomAxiosInstance {
|
||||||
|
instance: AxiosInstance;
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
axiosConfig: AxiosRequestConfig,
|
||||||
|
statusConfig: StatusConfig = {
|
||||||
|
statusKey: 'code',
|
||||||
|
msgKey: 'message',
|
||||||
|
successCode: 200
|
||||||
|
}
|
||||||
|
) {
|
||||||
|
this.instance = axios.create(axiosConfig);
|
||||||
|
this.setInterceptor(statusConfig);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 设置请求拦截器 */
|
||||||
|
setInterceptor(statusConfig: StatusConfig) {
|
||||||
|
this.instance.interceptors.request.use(
|
||||||
|
config => {
|
||||||
|
const handleConfig = { ...config };
|
||||||
|
// content-type为application/x-www-form-urlencoded类型的data参数需要序列化
|
||||||
|
if (handleConfig.headers['Content-Type'] === 'application/x-www-form-urlencoded') {
|
||||||
|
handleConfig.data = qs.stringify(handleConfig.data);
|
||||||
|
}
|
||||||
|
// 设置token
|
||||||
|
handleConfig.headers.Authorization = getStorageToken();
|
||||||
|
|
||||||
|
return handleConfig;
|
||||||
|
},
|
||||||
|
error => {
|
||||||
|
errorHandler(error);
|
||||||
|
return Promise.reject(error);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
this.instance.interceptors.response.use(
|
||||||
|
response => {
|
||||||
|
const { status, data } = response;
|
||||||
|
const { statusKey, msgKey, successCode } = statusConfig;
|
||||||
|
if (status === 200 || status < 300 || status === 304) {
|
||||||
|
if (data[statusKey] === successCode) {
|
||||||
|
return Promise.resolve(data.data);
|
||||||
|
}
|
||||||
|
ElMessage.error(data[msgKey]);
|
||||||
|
return Promise.reject(data[msgKey]);
|
||||||
|
}
|
||||||
|
const error = { response };
|
||||||
|
errorHandler(error);
|
||||||
|
return Promise.reject(error);
|
||||||
|
},
|
||||||
|
error => {
|
||||||
|
errorHandler(error);
|
||||||
|
return Promise.reject(error);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
66
src/service/request/request.ts
Normal file
66
src/service/request/request.ts
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
import type { AxiosRequestConfig, AxiosInstance, AxiosResponse } from 'axios';
|
||||||
|
import CustomAxiosInstance from './instance';
|
||||||
|
import type { StatusConfig } from './instance';
|
||||||
|
|
||||||
|
type ResponseSuccess = [null, any];
|
||||||
|
type ResponseFail = [any, null];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 封装各个请求方法及结果处理的类
|
||||||
|
* @author Soybean(曹理斌) 2021-03-15
|
||||||
|
* @class Request
|
||||||
|
*/
|
||||||
|
class Request {
|
||||||
|
instance: AxiosInstance;
|
||||||
|
|
||||||
|
constructor(instance: AxiosInstance) {
|
||||||
|
this.instance = instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
static successHandler(response: AxiosResponse) {
|
||||||
|
const result: ResponseSuccess = [null, response];
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
static failHandler(error: any) {
|
||||||
|
const result: ResponseFail = [error, null];
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
get(url: string, config?: AxiosRequestConfig) {
|
||||||
|
return this.instance.get(url, config).then(Request.successHandler).catch(Request.failHandler);
|
||||||
|
}
|
||||||
|
|
||||||
|
post(url: string, data?: any, config?: AxiosRequestConfig) {
|
||||||
|
return this.instance.post(url, data, config).then(Request.successHandler).catch(Request.failHandler);
|
||||||
|
}
|
||||||
|
|
||||||
|
put(url: string, data?: any, config?: AxiosRequestConfig) {
|
||||||
|
return this.instance.put(url, data, config).then(Request.successHandler).catch(Request.failHandler);
|
||||||
|
}
|
||||||
|
|
||||||
|
delete(url: string, config?: AxiosRequestConfig) {
|
||||||
|
return this.instance.delete(url, config).then(Request.successHandler).catch(Request.failHandler);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function createRequest(axiosConfig: AxiosRequestConfig, statusConfig?: StatusConfig) {
|
||||||
|
const customInstance = new CustomAxiosInstance(axiosConfig, statusConfig);
|
||||||
|
const request = new Request(customInstance.instance);
|
||||||
|
return request;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 对请求的结果数据进行格式化的处理
|
||||||
|
* @param handleFunc - 处理函数
|
||||||
|
* @param errors - 接收多个请求的错误
|
||||||
|
* @param datas - 接收多个请求的数据
|
||||||
|
*/
|
||||||
|
export function handleResponse<T>(handleFunc: Function, errors: any[], datas: any[]) {
|
||||||
|
let handleData = null;
|
||||||
|
if (errors.every(error => !error)) {
|
||||||
|
handleData = handleFunc(...datas);
|
||||||
|
}
|
||||||
|
const resError = errors.find(error => Boolean(error));
|
||||||
|
return [resError, handleData] as [any, T];
|
||||||
|
}
|
0
src/store/helpers/index.ts
Normal file
0
src/store/helpers/index.ts
Normal file
10
src/store/index.ts
Normal file
10
src/store/index.ts
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
import type { App } from 'vue';
|
||||||
|
import { createAuthStore, useAuthStore } from './modules/auth';
|
||||||
|
import { createAsideStore, useAsideStore } from './modules/aside';
|
||||||
|
|
||||||
|
export function createStore(app: App) {
|
||||||
|
createAuthStore(app);
|
||||||
|
createAsideStore(app);
|
||||||
|
}
|
||||||
|
|
||||||
|
export { useAuthStore, useAsideStore };
|
33
src/store/modules/aside/index.ts
Normal file
33
src/store/modules/aside/index.ts
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
import { inject, reactive } from 'vue';
|
||||||
|
import type { App, InjectionKey } from 'vue';
|
||||||
|
|
||||||
|
interface AsideState {
|
||||||
|
collapse: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface AsideStore {
|
||||||
|
/** aside状态 */
|
||||||
|
asideState: AsideState;
|
||||||
|
/** 切换collapse */
|
||||||
|
toggle: () => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
const injectKey: InjectionKey<AsideStore> = Symbol('aside-store');
|
||||||
|
|
||||||
|
export function createAsideStore(app: App) {
|
||||||
|
const state = reactive<AsideState>({
|
||||||
|
collapse: false
|
||||||
|
});
|
||||||
|
function toggle() {
|
||||||
|
state.collapse = !state.collapse;
|
||||||
|
}
|
||||||
|
const provideData: AsideStore = {
|
||||||
|
asideState: state,
|
||||||
|
toggle
|
||||||
|
};
|
||||||
|
app.provide(injectKey, provideData);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useAsideStore() {
|
||||||
|
return inject(injectKey)!;
|
||||||
|
}
|
44
src/store/modules/auth/index.ts
Normal file
44
src/store/modules/auth/index.ts
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
import { computed, inject, reactive } from 'vue';
|
||||||
|
import type { ComputedRef, App, InjectionKey } from 'vue';
|
||||||
|
|
||||||
|
interface UserInfo {
|
||||||
|
userId: string;
|
||||||
|
userName: string;
|
||||||
|
userPhone: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface AuthState {
|
||||||
|
token: string;
|
||||||
|
userInfo: UserInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface AuthStore {
|
||||||
|
/** auth状态 */
|
||||||
|
authState: AuthState;
|
||||||
|
/** 是否登录 */
|
||||||
|
isLogin: ComputedRef<boolean>;
|
||||||
|
}
|
||||||
|
|
||||||
|
const injectKey: InjectionKey<AuthStore> = Symbol('auth-store');
|
||||||
|
|
||||||
|
export function createAuthStore(app: App) {
|
||||||
|
const state = reactive<AuthState>({
|
||||||
|
token: '',
|
||||||
|
userInfo: {
|
||||||
|
userId: '',
|
||||||
|
userName: '',
|
||||||
|
userPhone: ''
|
||||||
|
}
|
||||||
|
});
|
||||||
|
const isLogin = computed(() => Boolean(state.token));
|
||||||
|
|
||||||
|
const provideData: AuthStore = {
|
||||||
|
authState: state,
|
||||||
|
isLogin
|
||||||
|
};
|
||||||
|
app.provide(injectKey, provideData);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useAuthStore() {
|
||||||
|
return inject(injectKey)!;
|
||||||
|
}
|
23
src/styles/css/global.css
Normal file
23
src/styles/css/global.css
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
@import './scrollbar.css';
|
||||||
|
|
||||||
|
html,
|
||||||
|
body,
|
||||||
|
#app {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
html {
|
||||||
|
min-width: 1320px;
|
||||||
|
min-height: 650px;
|
||||||
|
font-size: 16px;
|
||||||
|
}
|
||||||
|
#app {
|
||||||
|
font-family: Avenir, Helvetica, Arial, sans-serif;
|
||||||
|
-webkit-font-smoothing: antialiased;
|
||||||
|
-moz-osx-font-smoothing: grayscale;
|
||||||
|
font-size: 14px;
|
||||||
|
color: rgba(0, 0, 0, 0.65);
|
||||||
|
}
|
||||||
|
svg {
|
||||||
|
display: inline-block;
|
||||||
|
}
|
20
src/styles/css/scrollbar.css
Normal file
20
src/styles/css/scrollbar.css
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
/*---滚动条默认显示样式--*/
|
||||||
|
::-webkit-scrollbar-thumb {
|
||||||
|
background-color: #d9d9d9;
|
||||||
|
border-radius: 8px;
|
||||||
|
}
|
||||||
|
/*---鼠标点击滚动条显示样式--*/
|
||||||
|
::-webkit-scrollbar-thumb:hover {
|
||||||
|
background-color: #d9d9d9;
|
||||||
|
border-radius: 4px;
|
||||||
|
}
|
||||||
|
/*---滚动条大小--*/
|
||||||
|
::-webkit-scrollbar {
|
||||||
|
width: 8px;
|
||||||
|
height: 10px;
|
||||||
|
}
|
||||||
|
/*---滚动框背景样式--*/
|
||||||
|
::-webkit-scrollbar-track-piece {
|
||||||
|
background-color: rgba(0, 0, 0, 0);
|
||||||
|
border-radius: 0;
|
||||||
|
}
|
18
src/styles/scss/global.scss
Normal file
18
src/styles/scss/global.scss
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
@mixin scrollbar($size:8px, $color:#d9d9d9) {
|
||||||
|
&::-webkit-scrollbar-thumb {
|
||||||
|
background-color: $color;
|
||||||
|
border-radius: $size;
|
||||||
|
}
|
||||||
|
&::-webkit-scrollbar-thumb:hover {
|
||||||
|
background-color: $color;
|
||||||
|
border-radius: $size;
|
||||||
|
}
|
||||||
|
&::-webkit-scrollbar {
|
||||||
|
width: $size;
|
||||||
|
height: $size;
|
||||||
|
}
|
||||||
|
&::-webkit-scrollbar-track-piece {
|
||||||
|
background-color: rgba(0, 0, 0, 0);
|
||||||
|
border-radius: 0;
|
||||||
|
}
|
||||||
|
}
|
5
src/utils/auth/index.ts
Normal file
5
src/utils/auth/index.ts
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
export function getStorageToken() {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getStorageUserInfo() {}
|
1
src/utils/index.ts
Normal file
1
src/utils/index.ts
Normal file
@ -0,0 +1 @@
|
|||||||
|
export { getStorageToken, getStorageUserInfo } from './auth';
|
@ -1,5 +1,21 @@
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
darkMode: 'class', // or 'media'
|
darkMode: 'class', // or 'media'
|
||||||
|
shortcuts: {
|
||||||
|
'center-layout': 'w-1280px mx-auto',
|
||||||
|
'flex-center': 'flex justify-center items-center',
|
||||||
|
'flex-x-center': 'flex justify-center',
|
||||||
|
'flex-y-center': 'flex items-center',
|
||||||
|
'inline-flex-center': 'inline-flex justify-center items-center',
|
||||||
|
'inline-flex-x-center': 'inline-flex justify-center',
|
||||||
|
'inline-flex-y-center': 'inline-flex items-center',
|
||||||
|
'absolute-center': 'absolute left-0 top-0 flex justify-center items-center w-full h-full',
|
||||||
|
'absolute-lt': 'absolute left-0 top-0',
|
||||||
|
'absolute-lb': 'absolute left-0 bottom-0',
|
||||||
|
'absolute-rt': 'absolute right-0 top-0',
|
||||||
|
'absolute-rb': 'absolute right-0 bottom-0',
|
||||||
|
'fixed-center': 'fixed left-0 top-0 flex justify-center items-center w-full h-full',
|
||||||
|
'ellipsis-text': 'whitespace-nowrap overflow-hidden overflow-ellipsis'
|
||||||
|
},
|
||||||
theme: {},
|
theme: {},
|
||||||
variants: {},
|
variants: {},
|
||||||
plugins: []
|
plugins: []
|
||||||
|
@ -5,5 +5,12 @@ import { alias, viteEnv, plugins } from './build';
|
|||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
base: viteEnv.VITE_BASE_URL,
|
base: viteEnv.VITE_BASE_URL,
|
||||||
resolve: { alias },
|
resolve: { alias },
|
||||||
|
css: {
|
||||||
|
preprocessorOptions: {
|
||||||
|
scss: {
|
||||||
|
additionalData: `@import "./src/styles/scss/global.scss";`
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
plugins: [vue(), ...plugins]
|
plugins: [vue(), ...plugins]
|
||||||
});
|
});
|
||||||
|
47
yarn.lock
47
yarn.lock
@ -434,6 +434,16 @@
|
|||||||
resolved "https://registry.nlark.com/@types/parse-json/download/@types/parse-json-4.0.0.tgz?cache=0&sync_timestamp=1621242198435&other_urls=https%3A%2F%2Fregistry.nlark.com%2F%40types%2Fparse-json%2Fdownload%2F%40types%2Fparse-json-4.0.0.tgz#2f8bb441434d163b35fb8ffdccd7138927ffb8c0"
|
resolved "https://registry.nlark.com/@types/parse-json/download/@types/parse-json-4.0.0.tgz?cache=0&sync_timestamp=1621242198435&other_urls=https%3A%2F%2Fregistry.nlark.com%2F%40types%2Fparse-json%2Fdownload%2F%40types%2Fparse-json-4.0.0.tgz#2f8bb441434d163b35fb8ffdccd7138927ffb8c0"
|
||||||
integrity sha1-L4u0QUNNFjs1+4/9zNcTiSf/uMA=
|
integrity sha1-L4u0QUNNFjs1+4/9zNcTiSf/uMA=
|
||||||
|
|
||||||
|
"@types/qs@^6.9.6":
|
||||||
|
version "6.9.6"
|
||||||
|
resolved "https://registry.nlark.com/@types/qs/download/@types/qs-6.9.6.tgz?cache=0&sync_timestamp=1621242292262&other_urls=https%3A%2F%2Fregistry.nlark.com%2F%40types%2Fqs%2Fdownload%2F%40types%2Fqs-6.9.6.tgz#df9c3c8b31a247ec315e6996566be3171df4b3b1"
|
||||||
|
integrity sha1-35w8izGiR+wxXmmWVmvjFx30s7E=
|
||||||
|
|
||||||
|
"@types/smoothscroll-polyfill@^0.3.1":
|
||||||
|
version "0.3.1"
|
||||||
|
resolved "https://registry.nlark.com/@types/smoothscroll-polyfill/download/@types/smoothscroll-polyfill-0.3.1.tgz#77fb3a6e116bdab4a5959122e3b8e201224dcd49"
|
||||||
|
integrity sha1-d/s6bhFr2rSllZEi47jiASJNzUk=
|
||||||
|
|
||||||
"@types/unist@*", "@types/unist@^2.0.0", "@types/unist@^2.0.2":
|
"@types/unist@*", "@types/unist@^2.0.0", "@types/unist@^2.0.2":
|
||||||
version "2.0.3"
|
version "2.0.3"
|
||||||
resolved "https://registry.nlark.com/@types/unist/download/@types/unist-2.0.3.tgz#9c088679876f374eb5983f150d4787aa6fb32d7e"
|
resolved "https://registry.nlark.com/@types/unist/download/@types/unist-2.0.3.tgz#9c088679876f374eb5983f150d4787aa6fb32d7e"
|
||||||
@ -850,6 +860,13 @@ at-least-node@^1.0.0:
|
|||||||
resolved "https://registry.npm.taobao.org/at-least-node/download/at-least-node-1.0.0.tgz#602cd4b46e844ad4effc92a8011a3c46e0238dc2"
|
resolved "https://registry.npm.taobao.org/at-least-node/download/at-least-node-1.0.0.tgz#602cd4b46e844ad4effc92a8011a3c46e0238dc2"
|
||||||
integrity sha1-YCzUtG6EStTv/JKoARo8RuAjjcI=
|
integrity sha1-YCzUtG6EStTv/JKoARo8RuAjjcI=
|
||||||
|
|
||||||
|
axios@^0.21.1:
|
||||||
|
version "0.21.1"
|
||||||
|
resolved "https://registry.nlark.com/axios/download/axios-0.21.1.tgz#22563481962f4d6bde9a76d516ef0e5d3c09b2b8"
|
||||||
|
integrity sha1-IlY0gZYvTWvemnbVFu8OXTwJsrg=
|
||||||
|
dependencies:
|
||||||
|
follow-redirects "^1.10.0"
|
||||||
|
|
||||||
babel-walk@3.0.0-canary-5:
|
babel-walk@3.0.0-canary-5:
|
||||||
version "3.0.0-canary-5"
|
version "3.0.0-canary-5"
|
||||||
resolved "https://registry.npm.taobao.org/babel-walk/download/babel-walk-3.0.0-canary-5.tgz#f66ecd7298357aee44955f235a6ef54219104b11"
|
resolved "https://registry.npm.taobao.org/babel-walk/download/babel-walk-3.0.0-canary-5.tgz#f66ecd7298357aee44955f235a6ef54219104b11"
|
||||||
@ -1408,7 +1425,7 @@ dargs@^7.0.0:
|
|||||||
resolved "https://registry.nlark.com/dargs/download/dargs-7.0.0.tgz?cache=0&sync_timestamp=1620054548989&other_urls=https%3A%2F%2Fregistry.nlark.com%2Fdargs%2Fdownload%2Fdargs-7.0.0.tgz#04015c41de0bcb69ec84050f3d9be0caf8d6d5cc"
|
resolved "https://registry.nlark.com/dargs/download/dargs-7.0.0.tgz?cache=0&sync_timestamp=1620054548989&other_urls=https%3A%2F%2Fregistry.nlark.com%2Fdargs%2Fdownload%2Fdargs-7.0.0.tgz#04015c41de0bcb69ec84050f3d9be0caf8d6d5cc"
|
||||||
integrity sha1-BAFcQd4Ly2nshAUPPZvgyvjW1cw=
|
integrity sha1-BAFcQd4Ly2nshAUPPZvgyvjW1cw=
|
||||||
|
|
||||||
dayjs@1.x:
|
dayjs@1.x, dayjs@^1.10.5:
|
||||||
version "1.10.5"
|
version "1.10.5"
|
||||||
resolved "https://registry.nlark.com/dayjs/download/dayjs-1.10.5.tgz?cache=0&sync_timestamp=1622012259636&other_urls=https%3A%2F%2Fregistry.nlark.com%2Fdayjs%2Fdownload%2Fdayjs-1.10.5.tgz#5600df4548fc2453b3f163ebb2abbe965ccfb986"
|
resolved "https://registry.nlark.com/dayjs/download/dayjs-1.10.5.tgz?cache=0&sync_timestamp=1622012259636&other_urls=https%3A%2F%2Fregistry.nlark.com%2Fdayjs%2Fdownload%2Fdayjs-1.10.5.tgz#5600df4548fc2453b3f163ebb2abbe965ccfb986"
|
||||||
integrity sha1-VgDfRUj8JFOz8WPrsqu+llzPuYY=
|
integrity sha1-VgDfRUj8JFOz8WPrsqu+llzPuYY=
|
||||||
@ -2113,6 +2130,11 @@ fn-name@^2.0.1:
|
|||||||
resolved "https://registry.npm.taobao.org/fn-name/download/fn-name-2.0.1.tgz#5214d7537a4d06a4a301c0cc262feb84188002e7"
|
resolved "https://registry.npm.taobao.org/fn-name/download/fn-name-2.0.1.tgz#5214d7537a4d06a4a301c0cc262feb84188002e7"
|
||||||
integrity sha1-UhTXU3pNBqSjAcDMJi/rhBiAAuc=
|
integrity sha1-UhTXU3pNBqSjAcDMJi/rhBiAAuc=
|
||||||
|
|
||||||
|
follow-redirects@^1.10.0:
|
||||||
|
version "1.14.1"
|
||||||
|
resolved "https://registry.nlark.com/follow-redirects/download/follow-redirects-1.14.1.tgz?cache=0&sync_timestamp=1620555300559&other_urls=https%3A%2F%2Fregistry.nlark.com%2Ffollow-redirects%2Fdownload%2Ffollow-redirects-1.14.1.tgz#d9114ded0a1cfdd334e164e6662ad02bfd91ff43"
|
||||||
|
integrity sha1-2RFN7Qoc/dM04WTmZirQK/2R/0M=
|
||||||
|
|
||||||
format@^0.2.0:
|
format@^0.2.0:
|
||||||
version "0.2.2"
|
version "0.2.2"
|
||||||
resolved "https://registry.npm.taobao.org/format/download/format-0.2.2.tgz#d6170107e9efdc4ed30c9dc39016df942b5cb58b"
|
resolved "https://registry.npm.taobao.org/format/download/format-0.2.2.tgz#d6170107e9efdc4ed30c9dc39016df942b5cb58b"
|
||||||
@ -3420,7 +3442,7 @@ object-assign@^4.1.1:
|
|||||||
resolved "https://registry.nlark.com/object-assign/download/object-assign-4.1.1.tgz?cache=0&sync_timestamp=1618847043548&other_urls=https%3A%2F%2Fregistry.nlark.com%2Fobject-assign%2Fdownload%2Fobject-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863"
|
resolved "https://registry.nlark.com/object-assign/download/object-assign-4.1.1.tgz?cache=0&sync_timestamp=1618847043548&other_urls=https%3A%2F%2Fregistry.nlark.com%2Fobject-assign%2Fdownload%2Fobject-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863"
|
||||||
integrity sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=
|
integrity sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=
|
||||||
|
|
||||||
object-inspect@^1.10.3:
|
object-inspect@^1.10.3, object-inspect@^1.9.0:
|
||||||
version "1.10.3"
|
version "1.10.3"
|
||||||
resolved "https://registry.nlark.com/object-inspect/download/object-inspect-1.10.3.tgz#c2aa7d2d09f50c99375704f7a0adf24c5782d369"
|
resolved "https://registry.nlark.com/object-inspect/download/object-inspect-1.10.3.tgz#c2aa7d2d09f50c99375704f7a0adf24c5782d369"
|
||||||
integrity sha1-wqp9LQn1DJk3VwT3oK3yTFeC02k=
|
integrity sha1-wqp9LQn1DJk3VwT3oK3yTFeC02k=
|
||||||
@ -3958,6 +3980,13 @@ q@^1.5.1:
|
|||||||
resolved "https://registry.npm.taobao.org/q/download/q-1.5.1.tgz?cache=0&sync_timestamp=1599054212574&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fq%2Fdownload%2Fq-1.5.1.tgz#7e32f75b41381291d04611f1bf14109ac00651d7"
|
resolved "https://registry.npm.taobao.org/q/download/q-1.5.1.tgz?cache=0&sync_timestamp=1599054212574&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fq%2Fdownload%2Fq-1.5.1.tgz#7e32f75b41381291d04611f1bf14109ac00651d7"
|
||||||
integrity sha1-fjL3W0E4EpHQRhHxvxQQmsAGUdc=
|
integrity sha1-fjL3W0E4EpHQRhHxvxQQmsAGUdc=
|
||||||
|
|
||||||
|
qs@^6.10.1:
|
||||||
|
version "6.10.1"
|
||||||
|
resolved "https://registry.nlark.com/qs/download/qs-6.10.1.tgz#4931482fa8d647a5aab799c5271d2133b981fb6a"
|
||||||
|
integrity sha1-STFIL6jWR6Wqt5nFJx0hM7mB+2o=
|
||||||
|
dependencies:
|
||||||
|
side-channel "^1.0.4"
|
||||||
|
|
||||||
queue-microtask@^1.2.2:
|
queue-microtask@^1.2.2:
|
||||||
version "1.2.3"
|
version "1.2.3"
|
||||||
resolved "https://registry.nlark.com/queue-microtask/download/queue-microtask-1.2.3.tgz#4929228bbc724dfac43e0efb058caf7b6cfb6243"
|
resolved "https://registry.nlark.com/queue-microtask/download/queue-microtask-1.2.3.tgz#4929228bbc724dfac43e0efb058caf7b6cfb6243"
|
||||||
@ -4312,6 +4341,15 @@ shellsubstitute@^1.1.0:
|
|||||||
resolved "https://registry.npm.taobao.org/shellsubstitute/download/shellsubstitute-1.2.0.tgz#e4f702a50c518b0f6fe98451890d705af29b6b70"
|
resolved "https://registry.npm.taobao.org/shellsubstitute/download/shellsubstitute-1.2.0.tgz#e4f702a50c518b0f6fe98451890d705af29b6b70"
|
||||||
integrity sha1-5PcCpQxRiw9v6YRRiQ1wWvKba3A=
|
integrity sha1-5PcCpQxRiw9v6YRRiQ1wWvKba3A=
|
||||||
|
|
||||||
|
side-channel@^1.0.4:
|
||||||
|
version "1.0.4"
|
||||||
|
resolved "https://registry.nlark.com/side-channel/download/side-channel-1.0.4.tgz#efce5c8fdc104ee751b25c58d4290011fa5ea2cf"
|
||||||
|
integrity sha1-785cj9wQTudRslxY1CkAEfpeos8=
|
||||||
|
dependencies:
|
||||||
|
call-bind "^1.0.0"
|
||||||
|
get-intrinsic "^1.0.2"
|
||||||
|
object-inspect "^1.9.0"
|
||||||
|
|
||||||
signal-exit@^3.0.0, signal-exit@^3.0.2, signal-exit@^3.0.3:
|
signal-exit@^3.0.0, signal-exit@^3.0.2, signal-exit@^3.0.3:
|
||||||
version "3.0.3"
|
version "3.0.3"
|
||||||
resolved "https://registry.npm.taobao.org/signal-exit/download/signal-exit-3.0.3.tgz#a1410c2edd8f077b08b4e253c8eacfcaf057461c"
|
resolved "https://registry.npm.taobao.org/signal-exit/download/signal-exit-3.0.3.tgz#a1410c2edd8f077b08b4e253c8eacfcaf057461c"
|
||||||
@ -4340,6 +4378,11 @@ slice-ansi@^4.0.0:
|
|||||||
astral-regex "^2.0.0"
|
astral-regex "^2.0.0"
|
||||||
is-fullwidth-code-point "^3.0.0"
|
is-fullwidth-code-point "^3.0.0"
|
||||||
|
|
||||||
|
smoothscroll-polyfill@^0.4.4:
|
||||||
|
version "0.4.4"
|
||||||
|
resolved "https://registry.npm.taobao.org/smoothscroll-polyfill/download/smoothscroll-polyfill-0.4.4.tgz#3a259131dc6930e6ca80003e1cb03b603b69abf8"
|
||||||
|
integrity sha1-OiWRMdxpMObKgAA+HLA7YDtpq/g=
|
||||||
|
|
||||||
snake-case@^3.0.4:
|
snake-case@^3.0.4:
|
||||||
version "3.0.4"
|
version "3.0.4"
|
||||||
resolved "https://registry.nlark.com/snake-case/download/snake-case-3.0.4.tgz#4f2bbd568e9935abdfd593f34c691dadb49c452c"
|
resolved "https://registry.nlark.com/snake-case/download/snake-case-3.0.4.tgz#4f2bbd568e9935abdfd593f34c691dadb49c452c"
|
||||||
|
Loading…
Reference in New Issue
Block a user