feat:初始化 -融骅

This commit is contained in:
2023-10-17 09:15:30 +08:00
parent c9ff84e6a2
commit 405e152b38
1190 changed files with 138344 additions and 455 deletions

View File

@@ -0,0 +1,19 @@
/* eslint-env node */
require('@rushstack/eslint-patch/modern-module-resolution')
module.exports = {
root: true,
'extends': [
'plugin:vue/vue3-essential',
'eslint:recommended',
'@vue/eslint-config-typescript',
'@vue/eslint-config-prettier/skip-formatting'
],
parserOptions: {
ecmaVersion: 'latest'
},
"rules": {
"vue/multi-word-component-names": "off"
}
}

28
front/sub-base/.gitignore vendored Normal file
View File

@@ -0,0 +1,28 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*
node_modules
.DS_Store
dist
dist-ssr
coverage
*.local
/cypress/videos/
/cypress/screenshots/
# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?

View File

@@ -0,0 +1,8 @@
{
"$schema": "https://json.schemastore.org/prettierrc",
"semi": false,
"tabWidth": 2,
"singleQuote": true,
"printWidth": 100,
"trailingComma": "none"
}

View File

@@ -0,0 +1,8 @@
{
"recommendations": [
"Vue.volar",
"Vue.vscode-typescript-vue-plugin",
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode"
]
}

46
front/sub-base/README.md Normal file
View File

@@ -0,0 +1,46 @@
# sub-base
This template should help get you started developing with Vue 3 in Vite.
## Recommended IDE Setup
[VSCode](https://code.visualstudio.com/) + [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar) (and disable Vetur) + [TypeScript Vue Plugin (Volar)](https://marketplace.visualstudio.com/items?itemName=Vue.vscode-typescript-vue-plugin).
## Type Support for `.vue` Imports in TS
TypeScript cannot handle type information for `.vue` imports by default, so we replace the `tsc` CLI with `vue-tsc` for type checking. In editors, we need [TypeScript Vue Plugin (Volar)](https://marketplace.visualstudio.com/items?itemName=Vue.vscode-typescript-vue-plugin) to make the TypeScript language service aware of `.vue` types.
If the standalone TypeScript plugin doesn't feel fast enough to you, Volar has also implemented a [Take Over Mode](https://github.com/johnsoncodehk/volar/discussions/471#discussioncomment-1361669) that is more performant. You can enable it by the following steps:
1. Disable the built-in TypeScript Extension
1) Run `Extensions: Show Built-in Extensions` from VSCode's command palette
2) Find `TypeScript and JavaScript Language Features`, right click and select `Disable (Workspace)`
2. Reload the VSCode window by running `Developer: Reload Window` from the command palette.
## Customize configuration
See [Vite Configuration Reference](https://vitejs.dev/config/).
## Project Setup
```sh
npm install
```
### Compile and Hot-Reload for Development
```sh
npm run dev
```
### Type-Check, Compile and Minify for Production
```sh
npm run build
```
### Lint with [ESLint](https://eslint.org/)
```sh
npm run lint
```

1
front/sub-base/env.d.ts vendored Normal file
View File

@@ -0,0 +1 @@
/// <reference types="vite/client" />

13
front/sub-base/index.html Normal file
View File

@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<link rel="icon" href="/favicon.ico">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Vite App</title>
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.ts"></script>
</body>
</html>

6377
front/sub-base/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,36 @@
{
"name": "sub-base",
"version": "0.0.0",
"private": true,
"scripts": {
"dev": "vite",
"build": "run-p type-check \"build-only {@}\" --",
"preview": "vite preview",
"build-only": "vite build",
"type-check": "vue-tsc --noEmit -p tsconfig.app.json --composite false",
"lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore",
"format": "prettier --write src/"
},
"dependencies": {
"qiankun": "^3.0.0-alpha.1",
"vite-plugin-qiankun": "^1.0.15",
"vue": "^3.3.4",
"vue-router": "^4.2.4"
},
"devDependencies": {
"@rushstack/eslint-patch": "^1.3.3",
"@tsconfig/node18": "^18.2.2",
"@types/node": "^18.17.17",
"@vitejs/plugin-vue": "^4.3.4",
"@vue/eslint-config-prettier": "^8.0.0",
"@vue/eslint-config-typescript": "^12.0.0",
"@vue/tsconfig": "^0.4.0",
"eslint": "^8.49.0",
"eslint-plugin-vue": "^9.17.0",
"npm-run-all2": "^6.0.6",
"prettier": "^3.0.3",
"typescript": "~5.2.0",
"vite": "^4.4.9",
"vue-tsc": "^1.8.11"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

View File

@@ -0,0 +1,10 @@
<script setup lang="ts">
import { RouterLink, RouterView } from "vue-router";
import HelloWorld from "./components/HelloWorld.vue";
</script>
<template>
<RouterView />
</template>
<style scoped></style>

View File

View File

@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 261.76 226.69"><path d="M161.096.001l-30.225 52.351L100.647.001H-.005l130.877 226.688L261.749.001z" fill="#41b883"/><path d="M161.096.001l-30.225 52.351L100.647.001H52.346l78.526 136.01L209.398.001z" fill="#34495e"/></svg>

After

Width:  |  Height:  |  Size: 276 B

View File

View File

@@ -0,0 +1,49 @@
import './assets/main.css'
import './publice-path'
import { createApp } from 'vue'
import App from './App.vue'
import router from './router'
import {
renderWithQiankun,
qiankunWindow
} from 'vite-plugin-qiankun/dist/helper'
let instance: any = null;
function render(props: any = null) {
instance = createApp(App);
instance.use(router)
instance.mount(props ? props.container.querySelector('#app') : '#app')
}
// 独立运行时
if (!qiankunWindow.__POWERED_BY_QIANKUN__) {
const token =
"Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiI0NTRkYWMxMy1jZjVmLTQ3MTgtOWQ4MC00MjM5MzM5YWVhZDUiLCJhdXRoIjoxLCJiYXNlIjoxLCJvcmciOjEsImlhdCI6MTY5NTA5MDAwNiwiZXhwIjoxNjk1Njk0ODA2fQ.-ub4h04wpIY227ZJbamtuTv_XUjNG7YdX7VN6nMO4W4";
localStorage.setItem('token', JSON.stringify(token));
render();
console.log('独立运行');
}
// 抛出qiankun执行依赖----------START
renderWithQiankun({
mount(props) {
console.log(router);
console.log(props)
render(props)
},
bootstrap() {
// console.log(props, 'aaaaaaaaaaaaaa');
console.log('bootstrap')
},
unmount(props) {
console.log(props)
instance.unmount()
instance._container.innerHTML = ''
router.options.history.destroy() // 不卸载 router 会导致其他应用路由失败
// history.destroy() // 不卸载 router 会导致其他应用路由失败
instance = null
},
update() { }
})

View File

@@ -0,0 +1,9 @@
interface Window {
__POWERED_BY_QIANKUN__: any,
__INJECTED_PUBLIC_PATH_BY_QIANKUN__: any
}
// 判断是否为乾坤模式运行并调整打包环境
if (window.__POWERED_BY_QIANKUN__) {
__webpack_public_path__= window.__INJECTED_PUBLIC_PATH_BY_QIANKUN__;
}

View File

@@ -0,0 +1,24 @@
import { createRouter, createWebHashHistory, createWebHistory } from 'vue-router'
import HomeView from '../views/home/index.vue'
const router = createRouter({
// history: createWebHistory(import.meta.env.BASE_URL),
history: createWebHistory('/app2'),
routes: [
{
path: '/',
name: 'home',
component: HomeView
}
]
})
router.beforeEach((to, from, next) => {
console.log(to,';aaaaaaaaaaaaaaa');
if (to.fullPath === '/undefined') {
next('/');
} else {
next();
}
})
export default router

View File

@@ -0,0 +1,15 @@
<template>
<div :class="$style['container']">
{{ a }}
</div>
</template>
<script setup lang="ts">
import { ref } from "vue";
const a = ref("子应用2");
</script>
<style lang="less" module>
.container {
}
</style>

View File

@@ -0,0 +1,51 @@
{
// compilerOptions编译器的选项
"compilerOptions": {
"moduleResolution": "node",
// target 用来指定ts被编译为ES的版本默认是ES3
// 可以是 'es3', 'es5', 'es6', 'es2015', 'es2016', 'es2017','es2018','es2019','es2020','esnext'.
"target": "ES6",
// module 指定要使用的模块化的规范
"module": "ESNext",
// outDir 用来指定编译后文件所在的目录
"outDir": "./js",
// 将代码合并为一个文件
// "outFile": "./js/index.js",
// 是否对js文件进行编译默认是false
"allowJs": false,
// 是否检查js代码是否符合语法规范默认是false
"checkJs": false,
// 是否移除注释
"removeComments": true,
// 不生成编译后的文件
"noEmit": false,
// 当有错误时不生成编译文件
"noEmitOnError": false,
// 所有严格检查的总开关
"strict": false,
// 用来设置编译后的文件是否使用严格模式默认false
"alwaysStrict": false,
// 不允许隐式的any类型
"noImplicitAny": false,
// 不允许不明确类型的this
"noImplicitThis": false,
// 严格的检查空值
"strictNullChecks": false,
},
/**
"include" ts
**
*
*/
"include": [
"./**/*" //代表编译包含src目录下的任意目录的任意文件其余的不编译
],
/**
"exclude" ts
:[node moduesbower_componentsSspm_packages]
*/
// exclude该选项一般不设置用不到
"exclude": [
"./test/**/*" //不编译test下的所有文件
]
}

View File

@@ -0,0 +1,16 @@
{
"extends": "@tsconfig/node18/tsconfig.json",
"include": [
"vite.config.*",
"vitest.config.*",
"cypress.config.*",
"nightwatch.conf.*",
"playwright.config.*"
],
"compilerOptions": {
"composite": true,
"module": "ESNext",
"moduleResolution": "node",
"types": ["node"]
}
}

View File

@@ -0,0 +1,25 @@
import { fileURLToPath, URL } from 'node:url'
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import qiankun from 'vite-plugin-qiankun'
// https://vitejs.dev/config/
export default defineConfig({
plugins: [
vue(),
qiankun('子应用2', {
useDevMode: true
})
],
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url))
}
},
server: {
port: 8888,
headers: {
'Access-Control-Allow-Origin': '*', // 主应用获取子应用时跨域响应头
},
},
})