Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"eslint.enable": true,
"eslint.format.enable": true,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
"source.fixAll.eslint": "explicit"
},
"eslint.validate": [
"javascript",
Expand Down
15 changes: 13 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# 微后台主应用模版

[在线预览](https://micro-admin-template.lammu.cn/micromain/) | [使用文档](https://micro-admin-docs.lammu.cn) | [加入社区](https://micro-admin-docs.lammu.cn/About/discussion.html)
[在线预览](https://micro-admin-template.lammu.cn/micromain/) | [使用文档](https://micro-admin-template.lammu.cn/docs/) | [加入社区](https://micro-admin-template.lammu.cn/docs/About/discussion.html)

## 相关仓库

Expand All @@ -9,6 +9,9 @@
- [vue2+vite 子应用模板](https://github.com/LAMMUpro/subapp-vue2-vite-template.git)
- [react18 子应用模板](https://github.com/LAMMUpro/subapp-react18-template.git)

- [nest 后端](https://gitee.com/LAMMUpro/ali-lowcode-nest.git)
- [低代码](https://gitee.com/LAMMUpro/ali-lowcode-designer.git)

## 下载项目模板

```sh
Expand All @@ -30,7 +33,7 @@ git clone https://github.com/LAMMUpro/subapp-vue2-vite-template.git

```sh
# node版本建议16.18.0
# 如果没有安装pnpm先全局安装
# 如果没有安装yarn先全局安装
npm i yarn -g
# 安装依赖(忽略版本冲突)主目录下运行, 会安装packages/*下项目的所有依赖
yarn install --ignore-engines
Expand Down Expand Up @@ -65,6 +68,7 @@ yarn dev
- vue2 子应用 ✔
- MicroApp 封装 ✔
- init 显式初始化 ✔
- UnoCSS ✔

## micro-app-tools 发包

Expand All @@ -74,3 +78,10 @@ npm login
npm publish --access=public
npm config set registry https://registry.npmmirror.com
```

## /public/js/micro-app.xxx_h.js 改造规则

1. 复制 node_modules\@micro-zoe\micro-app\lib\index.esm.js
2. 全局替换`process.env.NODE_ENV !== 'production'`为`true`
3. 代码混淆/压缩
4. [文件内容取 hash](https://www.lddgo.net/encrypt/hash)后四位作为文件部分
61 changes: 61 additions & 0 deletions docs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# 缓存文件
.cache
# serveless缓存
.s
# 编译产物
build/*
# 编译产物
build_*/*
# 编译产物
dist
target
# 第三方包
node_modules
# yarn版本锁定
yarn.lock
# pnpm版本锁定
pnpm-lock.yaml
# package版本锁定
package-lock.json
# 生成的文档
swagger.yaml
# 后端配置文件
.env
# 后端配置文件
.env.*
#日志文件
logs
# 日志文件
npm-debug.log*
# 日志文件
pnpm-debug.log*
# 日志文件
yarn-debug.log*
# 日志文件
yarn-error.log*
# mac特有
.DS_Store
# storybook日志文件
storybook.log
# storybook编译产物
storybook-static

# 字体图标多余文件
src/assets/iconfont/*demo*
src/assets/iconfont/iconfont.js
src/assets/iconfont/iconfont.json

# element自动导入生成的文件
auto-imports.d.ts
components.d.ts

.vite
.vitepress/*
!.vitepress/config.mts
!.vitepress/themeConfig.mts

# obsidian 软件配置
obsidian/.obsidian

# 忽略idea编译文件
.idea
25 changes: 25 additions & 0 deletions docs/.vitepress/config.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { defineConfig } from 'vitepress';
import themeConfig from './themeConfig.mjs';

/** [docs](https://vitepress.dev/reference/site-config) */
export default defineConfig({
title: "微前端后台模板",
description: "微前端后台模板",
srcDir: './src',
outDir: './build',
cacheDir: './.vite',
/** 网页favicon */
head: [
['link', { rel: 'icon', href: '/favicon.ico' }],
],
// 路由前缀
base: '/docs/',
/** vite相关配置 */
vite: {
server: {
port: 5151,
},
},
/** 路由配置 / 主题配置 */
themeConfig: themeConfig,
})
128 changes: 128 additions & 0 deletions docs/.vitepress/themeConfig.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
import { DefaultTheme, UserConfig } from "vitepress";
import fse from "fs-extra";
import path from "path";

/**
* /src/Docs/目录下的文件/文件夹
* ps: 过滤掉非.md的文件 / 只是Docs目录下第一层
*/
const dirList = fse
.readdirSync("./src/Docs")
.filter(
(name) =>
/** 过滤掉_前缀的目录 */
(!name.startsWith("_") &&
(fse.statSync(path.resolve("./src/Docs", name)).isDirectory()) ||
name.endsWith(".md"))
);

/**
* 动态生成目录
*/
const sidebar = dirList
.map((name) => generateCatalog(path.resolve("./src/Docs"), `${name}`))
.filter(Boolean);

/**
* 生成目录
*/
function generateCatalog(
/** md文件所在路径 */
_path: string,
/** 目录名 / 文件名 */
name: string,
/** 前缀(相对于_path后的) */
_prefix: string = "/Docs"
) {

if (name.startsWith('_')) return;
const prefix = `${_prefix}/${name}`;
/** name是文件名 */
if (fse.statSync(path.resolve(_path, name)).isFile()) {
return {
text: name.slice(0, -3),
items: [{ text: name, link: name }],
};
/** name是目录名 */
} else if (fse.statSync(path.resolve(_path, name)).isDirectory()) {
return {
text: name,
items: fse
.readdirSync(path.resolve(_path, name))
.map((_name) => {
/** 过滤掉_前缀的目录 */
if (_name.startsWith("_")) return;
if (fse.statSync(path.resolve(_path, name, _name)).isFile()) {

// 处理文件
if (_name.endsWith(".md")) {
const name_without_type = _name.slice(0, -3);
return {
text: name_without_type,
link: `${prefix}/${_name}`,
};
}
} else if (
fse.statSync(path.resolve(_path, name, _name)).isDirectory()
) {
// 处理目录
return generateCatalog(path.resolve(_path, name), _name, prefix); // 循环处理
}
})
.filter(Boolean),
};
}
}

/**
* 取第一个有效路由
*/
function getFirstRoute(sidebar: DefaultTheme.SidebarItem[]) {
for (let i = 0; i < sidebar.length; i++) {
const item = sidebar[i];
if (item.link) {
return item.link;
} else if (item.items) {
const link = getFirstRoute(item.items);
if (link) return link;
}
}
}

/** [docs](https://vitepress.dev/reference/default-theme-config) */
const themeConfig: UserConfig<DefaultTheme.Config>["themeConfig"] = {
/** 启用本地搜索 */
search: {
provider: 'local',
},
/** 左上角图标 */
logo: "/favicon.ico",
nav: [
{ text: "首页", link: "/" },
{ text: "文档", activeMatch: `^/Docs/`, link: getFirstRoute(sidebar) },
{
text: "🔗在线预览",
link: "https://micro-admin-template.lammu.cn/micromain/introduce",
}, // 跳到介绍页
{
text: "关于",
activeMatch: `^/About/`,
items: [
{ text: "更新历史", link: "/About/history" },
{ text: "加入社区", link: "/About/discussion" },
],
},
],
/** sidebar用object指定前缀, 不要直接写array, 不然其它页面的上下页会有问题 */
sidebar: {
"/Docs/": sidebar,
},
socialLinks: [
{
icon: "github",
link: "https://github.com/LAMMUpro/micro-admin-template",
},
],
};

export default themeConfig;
10 changes: 10 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
## vitepress ssg文档

配置文件: /.vitepress/config.mts

.md文件写在 /src/下

建议使用Typora编辑/预览.md文件

# 安装依赖(忽略版本冲突)主目录下运行, 会安装packages/*下项目的所有依赖
yarn install --ignore-engines
47 changes: 47 additions & 0 deletions docs/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# nginx -c /code/nginx.conf -g 'daemon off;'
# serveless的nginx配置有点奇怪,gzip不能关闭,gzip_static可以开启,源文件也需要上传,优先使用静态的.gz,没有就动态压缩,不符合压缩标准的采用源文件

events { worker_connections 1024; }
http {
gzip off; # 是否开启动态压缩
gzip_static on; #是否开启静态压缩,默认后缀为.gz
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_http_version 1.1;
gzip_comp_level 2;
gzip_types application/wasm text/html text/plain application/javascript application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png image/svg+xml;
gzip_vary on;
gzip_disable "MSIE [1-6]\.";

server {
error_log /dev/stderr;
access_log /dev/stdout;

include /etc/nginx/mime.types;
# incluede /code/mime.types; # 添加新Mime类型,mime.types和nginx.conf放在同一目录

listen 9000;

location / {
root /code;
index index.html;
add_header Cache-Control "max-age=0";
try_files $uri $uri/ /index.html =404;

# 跨域配置
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range';
add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range';
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range';
add_header 'Access-Control-Max-Age' 1728000;
add_header 'Content-Type' 'text/plain; charset=utf-8';
add_header 'Content-Length' 0;
return 204;
}
}
}
}
Loading