parent
e09ad35a4a
commit
7e5d5aa067
@ -0,0 +1,11 @@ |
||||
node_modules/ |
||||
public/ |
||||
es/ |
||||
lib/ |
||||
dist/ |
||||
package.json |
||||
src/assets/ |
||||
plop-templates/ |
||||
handlebars/ |
||||
website/ |
||||
build/ |
@ -1,23 +1,24 @@ |
||||
module.exports = { |
||||
root: true, |
||||
env: { |
||||
node: true, |
||||
parser: 'vue-eslint-parser', |
||||
globals: { |
||||
postMessage: true |
||||
}, |
||||
extends: ["plugin:vue/vue3-essential", "eslint:recommended", "@vue/prettier"], |
||||
parserOptions: { |
||||
parser: "babel-eslint", |
||||
parser: '@typescript-eslint/parser', |
||||
sourceType: 'module', |
||||
ecmaFeatures: { |
||||
jsx: true, |
||||
tsx: true, |
||||
}, |
||||
}, |
||||
env: { |
||||
node: true, |
||||
}, |
||||
extends: ["plugin:vue/vue3-essential", "eslint:recommended"], |
||||
rules: { |
||||
"no-console": process.env.NODE_ENV === "production" ? "warn" : "off", |
||||
"no-debugger": process.env.NODE_ENV === "production" ? "warn" : "off", |
||||
"prettier/prettier": [ |
||||
"warn", |
||||
{ |
||||
// singleQuote: none,
|
||||
// semi: false,
|
||||
trailingComma: "es5", |
||||
}, |
||||
], |
||||
}, |
||||
}; |
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,12 +1,12 @@ |
||||
module.exports = { |
||||
printWidth: 80, // 每行代码长度(默认80)
|
||||
tabWidth: 2, // 每个tab相当于多少个空格(默认2)
|
||||
useTabs: false, // 是否使用tab进行缩进(默认false)
|
||||
singleQuote: false, // 使用单引号(默认false)
|
||||
semi: true, // 声明结尾使用分号(默认true)
|
||||
trailingComma: 'es5', // 多行使用拖尾逗号(默认none)
|
||||
bracketSpacing: true, // 对象字面量的大括号间使用空格(默认true)
|
||||
jsxBracketSameLine: false, // 多行JSX中的>放置在最后一行的结尾,而不是另起一行(默认false)
|
||||
arrowParens: "avoid", // 只有一个参数的箭头函数的参数是否带圆括号(默认avoid)
|
||||
}; |
||||
|
||||
printWidth: 80, |
||||
tabWidth: 2, |
||||
useTabs: false, |
||||
singleQuote: true, |
||||
semi: false, |
||||
trailingComma: "es5", |
||||
bracketSpacing: true, |
||||
jsxSingleQuote: true, |
||||
jsxBracketSameLine: false, |
||||
arrowParens: "avoid" |
||||
} |
@ -0,0 +1,38 @@ |
||||
import axios, { AxiosResponse, AxiosRequestConfig } from 'axios' |
||||
import { ResultEnum } from "@/enums/httpEnum" |
||||
import { ErrorPageNameMap } from "@/enums/pageEnum" |
||||
import { redirectErrorPage } from '@/utils' |
||||
|
||||
const axiosInstance = axios.create({ |
||||
baseURL: import.meta.env.DEV ? import.meta.env.VITE_DEV_PATH : import.meta.env.VITE_PRO_PATH, |
||||
timeout: ResultEnum.TIMEOUT, |
||||
}) |
||||
|
||||
axiosInstance.interceptors.request.use( |
||||
(config: AxiosRequestConfig) => { |
||||
config.headers = {} |
||||
config.data = {} |
||||
return config |
||||
}, |
||||
(error: AxiosRequestConfig) => { |
||||
Promise.reject(error) |
||||
} |
||||
) |
||||
|
||||
// 响应拦截器
|
||||
axiosInstance.interceptors.response.use( |
||||
(res: AxiosResponse) => { |
||||
const { code } = res.data as { code: number } |
||||
if (code === ResultEnum.DATA_SUCCESS) return Promise.resolve(res.data) |
||||
// 重定向
|
||||
if (ErrorPageNameMap.get(code)) redirectErrorPage(code) |
||||
return Promise.reject(res.data) |
||||
}, |
||||
(err: AxiosResponse) => { |
||||
const { code } = err.data as { code: number } |
||||
if (ErrorPageNameMap.get(code)) redirectErrorPage(code) |
||||
Promise.reject(err) |
||||
} |
||||
) |
||||
|
||||
export default axiosInstance |
@ -0,0 +1,34 @@ |
||||
import axiosInstance from './axios' |
||||
import { RequestEnum, ContentTypeEnum } from '@/enums/httpEnum' |
||||
|
||||
// 缓存处理
|
||||
const filterUrl = (url: string) => { |
||||
return url.indexOf('?') !== -1 ? `${url}&time=${new Date().getTime()}` : `${url}?time=${new Date().getTime()}` |
||||
} |
||||
|
||||
export const get = (params: object, url: string) => { |
||||
return axiosInstance({ |
||||
url: filterUrl(url), |
||||
method: RequestEnum.GET, |
||||
params |
||||
}) |
||||
} |
||||
|
||||
export const post = (params: object, url: string, headersType: string) => { |
||||
return axiosInstance({ |
||||
url: url, |
||||
method: RequestEnum.POST, |
||||
data: params, |
||||
headers: { |
||||
'Content-Type': headersType || ContentTypeEnum.JSON |
||||
} |
||||
}) |
||||
} |
||||
|
||||
export const del = (params: object, url: string) => { |
||||
return axiosInstance({ |
||||
url: filterUrl(url), |
||||
method: RequestEnum.DELETE, |
||||
params |
||||
}) |
||||
} |
@ -1,15 +1,26 @@ |
||||
import { ResultEnum } from "@/enums/httpEnum" |
||||
|
||||
export enum PageEnum { |
||||
// 登录
|
||||
BASE_LOGIN = '/login', |
||||
BASE_LOGIN_NAME = 'Login', |
||||
|
||||
//重定向
|
||||
REDIRECT = '/redirect', |
||||
REDIRECT_NAME = 'Redirect', |
||||
|
||||
// 首页
|
||||
BASE_HOME = '/project', |
||||
BASE_HOME_NAME = 'Project', |
||||
//首页跳转默认路由
|
||||
BASE_HOME_REDIRECT = '/project', |
||||
|
||||
// 错误
|
||||
ERROR_PAGE_NAME = 'ErrorPage', |
||||
ERROR_PAGE_NAME_403 = 'ErrorPage403', |
||||
ERROR_PAGE_NAME_404 = 'ErrorPage404', |
||||
ERROR_PAGE_NAME_500 = 'ErrorPage500', |
||||
} |
||||
|
||||
export const ErrorPageNameMap = new Map([ |
||||
[ResultEnum.NOT_FOUND, PageEnum.ERROR_PAGE_NAME_404], |
||||
[ResultEnum.SERVER_FORBIDDEN, PageEnum.ERROR_PAGE_NAME_403], |
||||
[ResultEnum.SERVER_ERROR, PageEnum.ERROR_PAGE_NAME_500], |
||||
]) |
@ -1,5 +1,5 @@ |
||||
/** |
||||
* 注册全局方法 待完善 |
||||
* 注册全局方法 |
||||
* @param app |
||||
*/ |
||||
export function setupGlobalMethods() {} |
||||
|
@ -0,0 +1,4 @@ |
||||
$namespace: 'go'; |
||||
$theme-light: 'light'; |
||||
$theme-dart: 'dart'; |
||||
$state-prefix: 'is-'; |
@ -0,0 +1,30 @@ |
||||
@import './config.scss'; |
||||
|
||||
@mixin go($block) { |
||||
$B: $namespace + '-' + $block !global; |
||||
.#{$B} { |
||||
@content; |
||||
} |
||||
} |
||||
|
||||
@mixin go-l($block) { |
||||
$B: $namespace + '-' + $theme-light + '-' + $block !global; |
||||
.#{$B} { |
||||
@content; |
||||
} |
||||
} |
||||
|
||||
@mixin go-d($block) { |
||||
$B: $namespace + '-' + $theme-dart + '-' + $block !global; |
||||
.#{$B} { |
||||
@content; |
||||
} |
||||
} |
||||
|
||||
@mixin when($state) { |
||||
@at-root { |
||||
&.#{$state-prefix + $state} { |
||||
@content; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,13 @@ |
||||
@import './var.scss'; |
||||
|
||||
// 毛玻璃 |
||||
.--background-filter { |
||||
backdrop-filter: $--filter-blur; |
||||
background-color: $--filter-color; |
||||
} |
||||
|
||||
// 边框圆角 |
||||
.--border-radius { |
||||
border-radius: $--border-radius; |
||||
overflow: hidden; |
||||
} |
@ -0,0 +1,6 @@ |
||||
// 模糊 |
||||
$--filter-blur: blur(2px); |
||||
// 毛玻璃 |
||||
$--filter-color: rgba(0, 0, 0, 0.07); |
||||
// 边框 |
||||
$--border-radius: 5px; |
@ -1,9 +0,0 @@ |
||||
@import url(./var.scss); |
||||
// 毛玻璃 |
||||
.bg-filter { |
||||
backdrop-filter: blur(2px); |
||||
background-color: rgba(0, 0, 0, 0.07); |
||||
} |
||||
.border { |
||||
border-radius: $radius; |
||||
} |
@ -1,2 +0,0 @@ |
||||
// 边框 |
||||
$radius: 5px; |
@ -1,40 +1,43 @@ |
||||
<template> |
||||
<div class="flex flex-col justify-center page-container"> |
||||
<div class="go-error"> |
||||
<div class="text-center"> |
||||
<img src="~@/assets/images/exception/404.svg" alt="" /> |
||||
</div> |
||||
<div class="text-center"> |
||||
<h1 class="text-base text-gray-500">抱歉,你访问的页面不存在</h1> |
||||
<n-button type="info" @click="goHome">回到首页</n-button> |
||||
</div> |
||||
<n-button type="info" @click="goHome">回到首页</n-button> |
||||
</div> |
||||
</template> |
||||
|
||||
<script lang="ts" setup> |
||||
import { useRouter } from 'vue-router'; |
||||
const router = useRouter(); |
||||
function goHome() { |
||||
router.push('/'); |
||||
} |
||||
import { useRouter } from 'vue-router' |
||||
import { PageEnum } from '@/enums/pageEnum' |
||||
const router = useRouter() |
||||
function goHome() { |
||||
router.push({ |
||||
name: PageEnum.BASE_HOME_NAME |
||||
}) |
||||
} |
||||
</script> |
||||
|
||||
<style lang="scss" scoped> |
||||
.page-container { |
||||
width: 100%; |
||||
border-radius: 4px; |
||||
padding: 50px 0; |
||||
height: 100vh; |
||||
|
||||
.text-center { |
||||
h1 { |
||||
color: #666; |
||||
padding: 20px 0; |
||||
} |
||||
@include go(error) { |
||||
display: flex; |
||||
flex-direction: column; |
||||
align-items: center; |
||||
width: 100%; |
||||
padding: 100px 0; |
||||
.text-center { |
||||
h1 { |
||||
color: #666; |
||||
padding: 20px 0; |
||||
} |
||||
} |
||||
|
||||
img { |
||||
width: 350px; |
||||
margin: 0 auto; |
||||
} |
||||
img { |
||||
width: 350px; |
||||
margin: 0 auto; |
||||
} |
||||
} |
||||
</style> |
||||
|
@ -1,6 +1 @@ |
||||
export interface GlobEnvConfig { |
||||
// 标题
|
||||
VITE_GLOB_APP_TITLE: string; |
||||
// 端口
|
||||
VITE_PORT: number; |
||||
} |
||||
|
||||
|
@ -1 +1,12 @@ |
||||
/// <reference types="vite/client" />
|
||||
|
||||
interface ImportMetaEnv { |
||||
// 标题
|
||||
VITE_GLOB_APP_TITLE: string; |
||||
// 端口
|
||||
VITE_DEV_PORT: number; |
||||
// 开发地址
|
||||
VITE_DEV_PATH: string |
||||
// 生产地址
|
||||
VITE_PRO_PATH: string |
||||
} |
Loading…
Reference in new issue