diff --git a/initializer-ui/.env.development b/initializer-ui/.env.development new file mode 100644 index 0000000000000000000000000000000000000000..5e9c49a627b86efde988c34dee53b31b107fa36b --- /dev/null +++ b/initializer-ui/.env.development @@ -0,0 +1 @@ +VITE_APP_BASE_URL= 'http://localhost:8080' \ No newline at end of file diff --git a/initializer-ui/.env.production b/initializer-ui/.env.production new file mode 100644 index 0000000000000000000000000000000000000000..da981bfa0dbf9e55aab1bbc2f7570a4b0d6e4566 --- /dev/null +++ b/initializer-ui/.env.production @@ -0,0 +1 @@ +VITE_APP_BASE_URL= 'https://start.develop.schbrain.com' \ No newline at end of file diff --git a/initializer-ui/README.md b/initializer-ui/README.md deleted file mode 100644 index b038297f7c8705d3733a1b1118a7c65ffa069227..0000000000000000000000000000000000000000 --- a/initializer-ui/README.md +++ /dev/null @@ -1,24 +0,0 @@ -# schbrain-archetype-initializer - -## Project setup -``` -npm install -``` - -### Compiles and hot-reloads for development -``` -npm run serve -``` - -### Compiles and minifies for production -``` -npm run build -``` - -### Lints and fixes files -``` -npm run lint -``` - -### Customize configuration -See [Configuration Reference](https://cli.vuejs.org/config/). diff --git a/initializer-ui/babel.config.js b/initializer-ui/babel.config.js deleted file mode 100644 index a6ef69e0ede37f96733440038ec067bcca1d556c..0000000000000000000000000000000000000000 --- a/initializer-ui/babel.config.js +++ /dev/null @@ -1,5 +0,0 @@ -module.exports = { - presets: [ - '@vue/cli-plugin-babel/preset' - ] -} \ No newline at end of file diff --git a/initializer-ui/index.html b/initializer-ui/index.html new file mode 100644 index 0000000000000000000000000000000000000000..6705006892662148812d668ba110d8c9ba2abf5f --- /dev/null +++ b/initializer-ui/index.html @@ -0,0 +1,13 @@ + + + + + + + Schbrain Code Initializer + + +
+ + + \ No newline at end of file diff --git a/initializer-ui/package.json b/initializer-ui/package.json index f847244c342e49ebeb05074a28e4f7650fcaf3f0..44265fa84afed4abbfd2131594f98bbcd8013b63 100644 --- a/initializer-ui/package.json +++ b/initializer-ui/package.json @@ -1,26 +1,23 @@ { - "name": "schbrain-archetype-initializer-ui", - "version": "0.1.0", - "private": true, + "name": "initializer-ui", + "version": "0.0.0", "scripts": { - "serve": "vue-cli-service serve", - "build": "vue-cli-service build ", - "lint": "vue-cli-service lint" + "dev": "vite --mode development", + "build": "vite build --mode production" }, "dependencies": { + "@vitejs/plugin-vue": "^2.3.1", + "ant-design-vue": "^3.1.1", "axios": "^0.26.1", - "element-plus": "^2.1.8", + "consola": "^2.15.3", + "vite-plugin-style-import": "^1.4.1", "vue": "^3.2.31" }, "devDependencies": { - "@babel/core": "^7.17.9", - "@vue/cli-plugin-babel": "~5.0.4", - "@vue/cli-service": "^5.0.4" - }, - "browserslist": [ - "> 1%", - "last 2 versions", - "not dead", - "not ie 11" - ] + "@vue/compiler-sfc": "^3.2.31", + "less": "^4.1.2", + "sass": "^1.50.0", + "unplugin-vue-components": "^0.18.5", + "vite": "^2.9.1" + } } \ No newline at end of file diff --git a/initializer-ui/public/index.html b/initializer-ui/public/index.html deleted file mode 100644 index 1afeb9ea972b115ac6637d8d7ab80e66630e4375..0000000000000000000000000000000000000000 --- a/initializer-ui/public/index.html +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - Schbrain Code Initializer - - - -
- - - \ No newline at end of file diff --git a/initializer-ui/src/App.vue b/initializer-ui/src/App.vue index e96abc08eb433f7fba78595b7d8bab6ff49164af..3d09499fb5c2b89cfd0cac36435ea90964cbe1ed 100644 --- a/initializer-ui/src/App.vue +++ b/initializer-ui/src/App.vue @@ -1,193 +1,6 @@ - - - \ No newline at end of file + \ No newline at end of file diff --git a/initializer-ui/src/components/starter.vue b/initializer-ui/src/components/starter.vue new file mode 100644 index 0000000000000000000000000000000000000000..65c8c42cc3ed4effe36e595875741880a1be823a --- /dev/null +++ b/initializer-ui/src/components/starter.vue @@ -0,0 +1,182 @@ + + + + + \ No newline at end of file diff --git a/initializer-ui/src/index.css b/initializer-ui/src/index.css new file mode 100644 index 0000000000000000000000000000000000000000..d75858f18f95c210327a17139001f202fd4395ef --- /dev/null +++ b/initializer-ui/src/index.css @@ -0,0 +1,8 @@ +#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; +} \ No newline at end of file diff --git a/initializer-ui/src/main.js b/initializer-ui/src/main.js deleted file mode 100644 index 139ecb9ef226bb2172a5ece5dae7935aaf3e9569..0000000000000000000000000000000000000000 --- a/initializer-ui/src/main.js +++ /dev/null @@ -1,8 +0,0 @@ -import {createApp} from 'vue' -import ElementPlus from 'element-plus' -import 'element-plus/dist/index.css' -import App from './App.vue' - -const app = createApp(App) -app.use(ElementPlus) -app.mount('#app') \ No newline at end of file diff --git a/initializer-ui/src/main.ts b/initializer-ui/src/main.ts new file mode 100644 index 0000000000000000000000000000000000000000..59c1e47f039702080b370b2557224463efbdb610 --- /dev/null +++ b/initializer-ui/src/main.ts @@ -0,0 +1,5 @@ +import {createApp} from 'vue' +import App from './App.vue' +import './index.css' + +createApp(App).mount('#app') \ No newline at end of file diff --git a/initializer-ui/src/models/BaseResponse.ts b/initializer-ui/src/models/BaseResponse.ts new file mode 100644 index 0000000000000000000000000000000000000000..ef54e5d0bb17b66a52126d33a22a71760c4ef09b --- /dev/null +++ b/initializer-ui/src/models/BaseResponse.ts @@ -0,0 +1,9 @@ +import {AxiosResponse} from "axios"; + +export default interface BaseResponse extends AxiosResponse { + code?: number + action?: number + message?: string + uuid?: string + result?: T +} \ No newline at end of file diff --git a/initializer-ui/src/shims-vue.d.ts b/initializer-ui/src/shims-vue.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..8342608fb86b3eb3d9a46c80ce0864b0ba40c893 --- /dev/null +++ b/initializer-ui/src/shims-vue.d.ts @@ -0,0 +1,6 @@ +declare module '*.vue' { + import type {DefineComponent} from 'vue' + // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/ban-types + const component: DefineComponent<{}, {}, any> + export default component +} \ No newline at end of file diff --git a/initializer-ui/src/util/loading.js b/initializer-ui/src/util/loading.js deleted file mode 100644 index 85a1f67e84c28904dba88311394c1892876dc851..0000000000000000000000000000000000000000 --- a/initializer-ui/src/util/loading.js +++ /dev/null @@ -1,33 +0,0 @@ -/** - * 全局loading效果:合并多次loading请求,避免重复请求 - * 当调用一次showLoading,则次数+1;当次数为0时,则显示loading - * 当调用一次hideLoading,则次数-1; 当次数为0时,则结束loading - */ -import {ElLoading} from 'element-plus'; - -// 定义一个请求次数的变量,用来记录当前页面总共请求的次数 -let loadingRequestCount = 0; -// 初始化loading -let loadingInstance; - -// 编写一个显示loading的函数 并且记录请求次数 ++ -const showLoading = () => { - if (loadingRequestCount === 0) { - loadingInstance = ElLoading.service({}); - } - loadingRequestCount++ -} - -// 编写一个隐藏loading的函数,并且记录请求次数 -- -const hideLoading = () => { - if (loadingRequestCount <= 0) return - loadingRequestCount-- - if (loadingRequestCount === 0) { - loadingInstance.close(); - } -} - -export { - showLoading, - hideLoading -} \ No newline at end of file diff --git a/initializer-ui/src/util/request.js b/initializer-ui/src/util/request.js deleted file mode 100644 index fa40f55c1842d6f10fdd517c7cc161b8bff0aa74..0000000000000000000000000000000000000000 --- a/initializer-ui/src/util/request.js +++ /dev/null @@ -1,32 +0,0 @@ -import axios from 'axios'; -import {hideLoading, showLoading} from './loading' - -const envDict = { - 'development': 'http://localhost:8080', - 'production': 'https://start.develop.schbrain.com' -} - -axios.defaults.baseURL = envDict[process.env.NODE_ENV] -axios.defaults.timeout = 10000 - -const service = axios.create() - -service.interceptors.request.use(config => { - showLoading() - return config -}) - -service.interceptors.response.use(response => { - hideLoading() - if (response.headers['content-type'] === 'application/json') { - if (response.data.code !== 0) { - return Promise.reject(response); - } - } - return response -}, error => { - hideLoading() - return Promise.reject(error) -}) - -export default service \ No newline at end of file diff --git a/initializer-ui/src/utils/request.ts b/initializer-ui/src/utils/request.ts new file mode 100644 index 0000000000000000000000000000000000000000..ac3debd7df89723999c57f7df848743354fe9c31 --- /dev/null +++ b/initializer-ui/src/utils/request.ts @@ -0,0 +1,22 @@ +import type {AxiosResponse} from "axios"; +import axios from "axios"; +import {message} from "ant-design-vue"; + +// @ts-ignore +axios.defaults.baseURL = import.meta.env.VITE_APP_BASE_URL +axios.interceptors.response.use((config: AxiosResponse) => { + const {data} = config + if (config.headers['content-type'] === 'application/json') { + switch (data.code) { + case 0: + return Promise.resolve(data) + default: + message.error(data.message) + return Promise.reject(data) + } + } else { + return Promise.resolve(config) + } +}) + +export default axios \ No newline at end of file diff --git a/initializer-ui/tsconfig.json b/initializer-ui/tsconfig.json new file mode 100644 index 0000000000000000000000000000000000000000..92110fa276e5bff843f6c3a723d8398002be5cce --- /dev/null +++ b/initializer-ui/tsconfig.json @@ -0,0 +1,25 @@ +{ + "compilerOptions": { + "target": "esnext", + "module": "esnext", + "moduleResolution": "node", + "strict": true, + "jsx": "preserve", + "sourceMap": true, + "resolveJsonModule": true, + "esModuleInterop": true, + "lib": [ + "esnext", + "dom" + ], + "types": [ + "vite/client" + ] + }, + "include": [ + "src/**/*.ts", + "src/**/*.d.ts", + "src/**/*.tsx", + "src/**/*.vue" + ] +} \ No newline at end of file diff --git a/initializer-ui/vite.config.ts b/initializer-ui/vite.config.ts new file mode 100644 index 0000000000000000000000000000000000000000..67cd5b79cae3a5d7f615c47341662cf8944ca425 --- /dev/null +++ b/initializer-ui/vite.config.ts @@ -0,0 +1,47 @@ +import Components from 'unplugin-vue-components/vite' +import {AntDesignVueResolver} from 'unplugin-vue-components/resolvers' +import styleImport, {AndDesignVueResolve, AntdResolve} from 'vite-plugin-style-import' +import {defineConfig} from 'vite' +// @ts-ignore +import vue from '@vitejs/plugin-vue' + +export default defineConfig({ + plugins: [ + vue(), + // antd自动按需引入 + Components({ + resolvers: [ + AntDesignVueResolver(), + ] + }), + // @ts-ignore + styleImport({ + resolves: [ + AndDesignVueResolve(), + AntdResolve() + ], + // 自定义规则 + libs: [ + { + libraryName: 'ant-design-vue', + esModule: true, + resolveStyle: (name: any) => { + return `ant-design-vue/es/${name}/style/index` + } + } + ] + }) + ], + // 引用使用less的库要配置一下 + css: { + preprocessorOptions: { + less: { + javascriptEnabled: true + } + } + }, + // 让terminal显示network地址 + server: { + host: '0.0.0.0' + } +}) \ No newline at end of file diff --git a/initializer-ui/vue.config.js b/initializer-ui/vue.config.js deleted file mode 100644 index 70cc47447c94384accf7ccb09193e24cf38772ae..0000000000000000000000000000000000000000 --- a/initializer-ui/vue.config.js +++ /dev/null @@ -1,6 +0,0 @@ -const {defineConfig} = require('@vue/cli-service') - -module.exports = defineConfig({ - transpileDependencies: true, - productionSourceMap: false -}) \ No newline at end of file