diff --git a/README.md b/README.md
index 5237dfbb6..5f061e99a 100644
--- a/README.md
+++ b/README.md
@@ -18,16 +18,6 @@ npm run serve
npm run build
```
-## Run your unit tests
-```
-npm run test:unit
-```
-
-## Run your end-to-end tests
-```
-npm run test:e2e
-```
-
## Lints and fixes files
```
npm run lint
diff --git a/package-lock.json b/package-lock.json
index 126b9a585..3fe93afae 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -2689,9 +2689,9 @@
"dev": true
},
"element-plus": {
- "version": "1.0.1-beta.2",
- "resolved": "http://192.168.250.101:4873/element-plus/-/element-plus-1.0.1-beta.2.tgz",
- "integrity": "sha1-CmoQ3BU+5KTsVHdbrSKmhT6uYzc=",
+ "version": "1.0.1-beta.3",
+ "resolved": "http://192.168.250.101:4873/element-plus/-/element-plus-1.0.1-beta.3.tgz",
+ "integrity": "sha1-lF1Xh4I+ikR1G5AbGxqUrS1If18=",
"requires": {
"@popperjs/core": "^2.4.4",
"async-validator": "^3.4.0",
diff --git a/package.json b/package.json
index 576c42c4a..bb5dcde84 100644
--- a/package.json
+++ b/package.json
@@ -10,7 +10,7 @@
"dependencies": {
"await-to-js": "^2.1.1",
"axios": "^0.21.0",
- "element-plus": "^1.0.1-beta.2",
+ "element-plus": "^1.0.1-beta.3",
"vue": "^3.0.4",
"vue-class-component": "^8.0.0-rc.1",
"vue-router": "^4.0.0-rc.6",
@@ -38,4 +38,4 @@
"typescript": "~3.9.3",
"vite": "^1.0.0-rc.13"
}
-}
\ No newline at end of file
+}
diff --git a/src/App.vue b/src/App.vue
index 083049bd4..98240aef8 100644
--- a/src/App.vue
+++ b/src/App.vue
@@ -1,3 +1,3 @@
-
+
diff --git a/src/api/index.ts b/src/api/index.ts
deleted file mode 100644
index 1a074d062..000000000
--- a/src/api/index.ts
+++ /dev/null
@@ -1,3 +0,0 @@
-import EnclosureHttp from "./utils/core";
-
-export default EnclosureHttp;
diff --git a/src/assets/index.css b/src/assets/index.css
index d0248f612..532881f96 100644
--- a/src/assets/index.css
+++ b/src/assets/index.css
@@ -10,6 +10,17 @@ body {
position: relative;
}
+* {
+ touch-action: pan-y;
+ -moz-user-select: none;
+ -o-user-select: none;
+ -khtml-user-select: none;
+ -webkit-user-select: none;
+ -ms-user-select: none;
+ user-select: none;
+}
+
+
.login,
.register {
width: 100%;
diff --git a/src/components/info.vue b/src/components/info.vue
index 8285aa757..c265bc00f 100644
--- a/src/components/info.vue
+++ b/src/components/info.vue
@@ -1,44 +1,115 @@
-
-
{{ info.userName }}
-
{{ info.passWord }}
-
{{ info.dynamicText }}
+
+
+
+
+
+
+
+
+
+
+
+
+ 登录
+ 重置
+
+
-
diff --git a/src/main.ts b/src/main.ts
index f971e088c..ee047f61b 100644
--- a/src/main.ts
+++ b/src/main.ts
@@ -2,7 +2,7 @@ import { createApp } from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
-import EnclosureHttp from "./api/utils/core"
+// import EnclosureHttp from "./utils/http"
// 内置ElementPlus
import ElementPlus from 'element-plus'
@@ -14,6 +14,6 @@ import "./assets/index.css"
const app = createApp(App)
// 全局注册Axios
-app.config.globalProperties.$http = new EnclosureHttp()
+// app.config.globalProperties.$http = new EnclosureHttp()
app.use(store).use(router).use(ElementPlus).mount('#app')
diff --git a/src/api/utils/.DS_Store b/src/utils/http/.DS_Store
similarity index 100%
rename from src/api/utils/.DS_Store
rename to src/utils/http/.DS_Store
diff --git a/src/api/utils/config.ts b/src/utils/http/config.ts
similarity index 79%
rename from src/api/utils/config.ts
rename to src/utils/http/config.ts
index c41cdd599..1bc2a7e0f 100644
--- a/src/api/utils/config.ts
+++ b/src/utils/http/config.ts
@@ -1,5 +1,5 @@
-import { AxiosRequestConfig } from "axios";
-import { excludeProps } from "./utils";
+import { AxiosRequestConfig } from "axios"
+import { excludeProps } from "./utils"
/**
* 默认配置
*/
@@ -11,21 +11,21 @@ export const defaultConfig: AxiosRequestConfig = {
"Content-Type": "application/json",
"X-Requested-With": "XMLHttpRequest"
},
-};
+}
export function genConfig(config?: AxiosRequestConfig): AxiosRequestConfig {
if (!config) {
- return defaultConfig;
+ return defaultConfig
}
- const { headers } = config;
+ const { headers } = config
if (headers && typeof headers === "object") {
defaultConfig.headers = {
...defaultConfig.headers,
...headers
- };
+ }
}
- return { ...excludeProps(config!, "headers"), ...defaultConfig };
+ return { ...excludeProps(config!, "headers"), ...defaultConfig }
}
-export const METHODS = ["post", "get", "put", "delete", "option", "patch"];
+export const METHODS = ["post", "get", "put", "delete", "option", "patch"]
diff --git a/src/api/utils/core.ts b/src/utils/http/core.ts
similarity index 72%
rename from src/api/utils/core.ts
rename to src/utils/http/core.ts
index b3f8b4323..fe0c095a7 100644
--- a/src/api/utils/core.ts
+++ b/src/utils/http/core.ts
@@ -3,11 +3,11 @@ import Axios, {
CancelTokenStatic,
AxiosInstance,
Canceler
-} from "axios";
+} from "axios"
-import { genConfig } from "./config";
+import { genConfig } from "./config"
-import { transformConfigByMethod } from "./utils";
+import { transformConfigByMethod } from "./utils"
import {
cancelTokenType,
@@ -15,17 +15,17 @@ import {
EnclosureHttpRequestConfig,
EnclosureHttpResoponse,
EnclosureHttpError
-} from "./types.d";
+} from "./types.d"
class EnclosureHttp {
// 初始化配置对象
private static initConfig: EnclosureHttpRequestConfig = {};
// 保存当前Axios实例对象
- private static axiosInstance: AxiosInstance = Axios.create(genConfig());
+ private static axiosInstance: AxiosInstance = Axios.create(genConfig());
// 保存 EnclosureHttp实例
- private static EnclosureHttpInstance: EnclosureHttp;
+ private static EnclosureHttpInstance: EnclosureHttp
// axios取消对象
private CancelToken: CancelTokenStatic = Axios.CancelToken;
@@ -41,12 +41,12 @@ class EnclosureHttp {
private beforeResponseCallback: EnclosureHttpRequestConfig["beforeResponseCallback"] = undefined;
public get cancelTokenList(): Array {
- return this.sourceTokenList;
+ return this.sourceTokenList
}
// eslint-disable-next-line class-methods-use-this
public set cancelTokenList(value) {
- throw new Error("cancelTokenList不允许赋值");
+ throw new Error("cancelTokenList不允许赋值")
}
/**
@@ -62,7 +62,7 @@ class EnclosureHttp {
*/
// eslint-disable-next-line class-methods-use-this
private genUniqueKey(config: EnclosureHttpRequestConfig): string {
- return `${config.url}--${JSON.stringify(config.data)}`;
+ return `${config.url}--${JSON.stringify(config.data)}`
}
/**
@@ -70,21 +70,21 @@ class EnclosureHttp {
* @returns void 0
*/
private cancelRepeatRequest(): void {
- const temp: { [key: string]: boolean } = {};
+ const temp: { [key: string]: boolean } = {}
this.sourceTokenList = this.sourceTokenList.reduce>(
(res: Array, cancelToken: cancelTokenType) => {
- const { cancelKey, cancelExecutor } = cancelToken;
+ const { cancelKey, cancelExecutor } = cancelToken
if (!temp[cancelKey]) {
- temp[cancelKey] = true;
- res.push(cancelToken);
+ temp[cancelKey] = true
+ res.push(cancelToken)
} else {
- cancelExecutor();
+ cancelExecutor()
}
- return res;
+ return res
},
[]
- );
+ )
}
/**
@@ -97,7 +97,7 @@ class EnclosureHttp {
? this.sourceTokenList.filter(
cancelToken => cancelToken.cancelKey !== cancelKey
)
- : [];
+ : []
}
/**
@@ -108,33 +108,33 @@ class EnclosureHttp {
private httpInterceptorsRequest(): void {
EnclosureHttp.axiosInstance.interceptors.request.use(
(config: EnclosureHttpRequestConfig) => {
- const $config = config;
+ const $config = config
- const cancelKey = this.genUniqueKey($config);
+ const cancelKey = this.genUniqueKey($config)
$config.cancelToken = new this.CancelToken((cancelExecutor: (cancel: any) => void) => {
- this.sourceTokenList.push({ cancelKey, cancelExecutor });
- });
+ this.sourceTokenList.push({ cancelKey, cancelExecutor })
+ })
- this.cancelRepeatRequest();
+ this.cancelRepeatRequest()
- this.currentCancelTokenKey = cancelKey;
+ this.currentCancelTokenKey = cancelKey
// 优先判断post/get等方法是否传入回掉,否则执行初始化设置等回掉
if (typeof this.beforeRequestCallback === "function") {
- this.beforeRequestCallback($config);
- this.beforeRequestCallback = undefined;
- return $config;
+ this.beforeRequestCallback($config)
+ this.beforeRequestCallback = undefined
+ return $config
}
if (EnclosureHttp.initConfig.beforeRequestCallback) {
- EnclosureHttp.initConfig.beforeRequestCallback($config);
- return $config;
+ EnclosureHttp.initConfig.beforeRequestCallback($config)
+ return $config
}
- return $config;
+ return $config
},
error => {
- return Promise.reject(error);
+ return Promise.reject(error)
}
- );
+ )
}
/**
@@ -142,7 +142,7 @@ class EnclosureHttp {
* @returns void 0
*/
public clearCancelTokenList(): void {
- this.sourceTokenList.length = 0;
+ this.sourceTokenList.length = 0
}
/**
@@ -150,46 +150,46 @@ class EnclosureHttp {
* @returns void 0
*/
private httpInterceptorsResponse(): void {
- const instance = EnclosureHttp.axiosInstance;
+ const instance = EnclosureHttp.axiosInstance
instance.interceptors.response.use(
(response: EnclosureHttpResoponse) => {
-
+
// 请求每次成功一次就删除当前canceltoken标记
- const cancelKey = this.genUniqueKey(response.config);
- this.deleteCancelTokenByCancelKey(cancelKey);
+ const cancelKey = this.genUniqueKey(response.config)
+ this.deleteCancelTokenByCancelKey(cancelKey)
// 优先判断post/get等方法是否传入回掉,否则执行初始化设置等回掉
if (typeof this.beforeResponseCallback === "function") {
- this.beforeResponseCallback(response);
- this.beforeResponseCallback = undefined;
- return response.data;
+ this.beforeResponseCallback(response)
+ this.beforeResponseCallback = undefined
+ return response.data
}
if (EnclosureHttp.initConfig.beforeResponseCallback) {
- EnclosureHttp.initConfig.beforeResponseCallback(response);
- return response.data;
+ EnclosureHttp.initConfig.beforeResponseCallback(response)
+ return response.data
}
- return response.data;
+ return response.data
},
(error: EnclosureHttpError) => {
- const $error = error;
+ const $error = error
// 判断当前的请求中是否在 取消token数组理存在,如果存在则移除(单次请求流程)
if (this.currentCancelTokenKey) {
const haskey = this.sourceTokenList.filter(
cancelToken => cancelToken.cancelKey === this.currentCancelTokenKey
- ).length;
+ ).length
if (haskey) {
this.sourceTokenList = this.sourceTokenList.filter(
cancelToken =>
cancelToken.cancelKey !== this.currentCancelTokenKey
- );
- this.currentCancelTokenKey = "";
+ )
+ this.currentCancelTokenKey = ""
}
}
- $error.isCancelRequest = Axios.isCancel($error);
+ $error.isCancelRequest = Axios.isCancel($error)
// 所有的响应异常 区分来源为取消请求/非取消请求
- return Promise.reject($error);
+ return Promise.reject($error)
}
- );
+ )
}
public request(
@@ -202,24 +202,24 @@ class EnclosureHttp {
method,
url,
...axiosConfig
- } as EnclosureHttpRequestConfig);
+ } as EnclosureHttpRequestConfig)
// 单独处理自定义请求/响应回掉
if (axiosConfig?.beforeRequestCallback) {
- this.beforeRequestCallback = axiosConfig.beforeRequestCallback;
+ this.beforeRequestCallback = axiosConfig.beforeRequestCallback
}
if (axiosConfig?.beforeResponseCallback) {
- this.beforeResponseCallback = axiosConfig.beforeResponseCallback;
+ this.beforeResponseCallback = axiosConfig.beforeResponseCallback
}
return new Promise((resolve, reject) => {
EnclosureHttp.axiosInstance.request(config)
.then((response: EnclosureHttpResoponse) => {
- resolve(response.data);
+ resolve(response.data)
})
.catch((error: any) => {
- reject(error);
- });
- });
+ reject(error)
+ })
+ })
}
public post(
@@ -227,7 +227,7 @@ class EnclosureHttp {
params?: T,
config?: EnclosureHttpRequestConfig
): Promise {
- return this.request("post", url, params, config);
+ return this.request("post", url, params, config)
}
public get(
@@ -235,9 +235,8 @@ class EnclosureHttp {
params?: T,
config?: EnclosureHttpRequestConfig
): Promise {
- return this.request("get", url, params, config);
+ return this.request("get", url, params, config)
}
-
}
-export default EnclosureHttp;
+export default EnclosureHttp
diff --git a/src/utils/http/index.ts b/src/utils/http/index.ts
new file mode 100644
index 000000000..63ed68485
--- /dev/null
+++ b/src/utils/http/index.ts
@@ -0,0 +1,3 @@
+import EnclosureHttp from "./core"
+export const http = new EnclosureHttp()
+
diff --git a/src/api/utils/types.d.ts b/src/utils/http/types.d.ts
similarity index 98%
rename from src/api/utils/types.d.ts
rename to src/utils/http/types.d.ts
index 2195bb3c5..4c5564fe8 100644
--- a/src/api/utils/types.d.ts
+++ b/src/utils/http/types.d.ts
@@ -4,7 +4,7 @@ import Axios, {
AxiosResponse,
Method,
AxiosError
-} from "axios";
+} from "axios"
import { METHODS } from './config'
diff --git a/src/api/utils/utils.ts b/src/utils/http/utils.ts
similarity index 72%
rename from src/api/utils/utils.ts
rename to src/utils/http/utils.ts
index a5a621b7a..416248998 100644
--- a/src/api/utils/utils.ts
+++ b/src/utils/http/utils.ts
@@ -1,4 +1,4 @@
-import { EnclosureHttpRequestConfig } from "./types.d";
+import { EnclosureHttpRequestConfig } from "./types.d"
export function excludeProps(
origin: T,
@@ -7,23 +7,23 @@ export function excludeProps(
return Object.keys(origin)
.filter(key => !prop.includes(key))
.reduce((res, key) => {
- res[key] = origin[key];
- return res;
- }, {} as { [key: string]: T });
+ res[key] = origin[key]
+ return res
+ }, {} as { [key: string]: T })
}
export function transformConfigByMethod(
params: any,
config: EnclosureHttpRequestConfig
): EnclosureHttpRequestConfig {
- const { method } = config;
+ const { method } = config
const props = ["delete", "get", "head", "options"].includes(
method!.toLocaleLowerCase()
)
? "params"
- : "data";
+ : "data"
return {
...config,
[props]: params
- };
+ }
}
diff --git a/src/utils/token.ts b/src/utils/token.ts
index cd36a215b..2c922b610 100644
--- a/src/utils/token.ts
+++ b/src/utils/token.ts
@@ -9,11 +9,11 @@ export function setToken(token: string): void {
// 取
export function getToken(): string {
- let token = sessionStorage.getItem("Token") && JSON.parse(sessionStorage.getItem("Token") || "");
- return token;
+ let token = sessionStorage.getItem("Token") && JSON.parse(sessionStorage.getItem("Token") || "")
+ return token
}
// 删
export function delToken(): void {
- sessionStorage.removeItem("Token");
+ sessionStorage.removeItem("Token")
}
\ No newline at end of file
diff --git a/src/views/home.vue b/src/views/home.vue
index 1614e04ff..f7da0e65c 100644
--- a/src/views/home.vue
+++ b/src/views/home.vue
@@ -1,3 +1,14 @@
- Home
-
\ No newline at end of file
+
+
+
+
+
+
diff --git a/src/views/login.vue b/src/views/login.vue
index af67952d4..215f35cc0 100644
--- a/src/views/login.vue
+++ b/src/views/login.vue
@@ -1,32 +1,60 @@
-
+
-
-
\ No newline at end of file
diff --git a/src/views/register.vue b/src/views/register.vue
index d2ec67229..f7da0e65c 100644
--- a/src/views/register.vue
+++ b/src/views/register.vue
@@ -1,22 +1,14 @@
- {{ text }}
+
-
\ No newline at end of file
+
diff --git a/tsconfig.json b/tsconfig.json
index 4a7936773..b84cfec22 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -34,9 +34,9 @@
"src/**/*.tsx",
"src/**/*.vue",
"tests/**/*.ts",
- "tests/**/*.tsx"
+ "tests/**/*.tsx", "src/mixins/bus.js"
],
"exclude": [
"node_modules"
],
-}
+}
\ No newline at end of file