update: 优化打包
This commit is contained in:
parent
d3bdbe8909
commit
80b7436717
|
@ -1,4 +1,5 @@
|
|||
node_modules/
|
||||
dist/
|
||||
index.html
|
||||
.vscode
|
||||
.vscode
|
||||
docker
|
|
@ -0,0 +1,6 @@
|
|||
FROM nginx
|
||||
ADD nginx.conf /etc/nginx/conf.d/default.conf
|
||||
ADD docker-entrypoint.sh /docker-entrypoint.sh
|
||||
COPY dist /usr/share/nginx/html
|
||||
CMD ["sh","/docker-entrypoint.sh"]
|
||||
#ADD oauth2 /usr/share/nginx/html/oauth2
|
|
@ -0,0 +1,3 @@
|
|||
#!/usr/bin/env bash
|
||||
docker build -t registry.cn-shenzhen.aliyuncs.com/jetlinks/jetlinks-ui-vue:1.0.0 .
|
||||
docker push registry.cn-shenzhen.aliyuncs.com/jetlinks/jetlinks-ui-vue:1.0.0
|
|
@ -0,0 +1,15 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
API_BASE_PATH=$API_BASE_PATH;
|
||||
NAMESERVERS=$(cat /etc/resolv.conf | grep "nameserver" | awk '{print $2}' | tr '\n' ' ')
|
||||
if [ -z "$API_BASE_PATH" ]; then
|
||||
API_BASE_PATH="http://jetlinks:8844/";
|
||||
fi
|
||||
|
||||
apiUrl="proxy_pass $API_BASE_PATH\$1;"
|
||||
resolver="resolver $NAMESERVERS ipv6=off;"
|
||||
|
||||
sed -i '11c '"$resolver"'' /etc/nginx/conf.d/default.conf
|
||||
sed -i '20c '"$apiUrl"'' /etc/nginx/conf.d/default.conf
|
||||
|
||||
nginx -g "daemon off;"
|
|
@ -0,0 +1,38 @@
|
|||
server {
|
||||
listen 80;
|
||||
listen [::]:80;
|
||||
# gzip config
|
||||
gzip on;
|
||||
gzip_min_length 1k;
|
||||
gzip_comp_level 9;
|
||||
gzip_types text/plain text/css text/javascript application/json application/javascript application/x-javascript application/xml;
|
||||
gzip_vary on;
|
||||
gzip_disable "MSIE [1-6]\.";
|
||||
resolver $NAMESERVERS ipv6=off;
|
||||
root /usr/share/nginx/html;
|
||||
include /etc/nginx/mime.types;
|
||||
location / {
|
||||
index index.html;
|
||||
}
|
||||
|
||||
location ^~/api/ {
|
||||
if ($request_uri ~* ^/api/(.*)$) {
|
||||
proxy_pass http://host.docker.internal:8840/$1;
|
||||
}
|
||||
#proxy_pass http://host.docker.internal:8840/;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
proxy_connect_timeout 1;
|
||||
proxy_buffering off;
|
||||
chunked_transfer_encoding off;
|
||||
proxy_cache off;
|
||||
proxy_send_timeout 30m;
|
||||
proxy_read_timeout 30m;
|
||||
client_max_body_size 500m;
|
||||
}
|
||||
}
|
|
@ -2,10 +2,9 @@
|
|||
"name": "jetlinks-vue",
|
||||
"private": true,
|
||||
"version": "0.0.0",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite --mode develop",
|
||||
"build": "vite build --mode production",
|
||||
"build": "node --max_old_space_size=1024000 ./node_modules/vite/bin/vite.js build",
|
||||
"preview": "vite preview",
|
||||
"eslint": "eslint --ext .js,.vue --ignore-path .gitignore --fix src",
|
||||
"lint": "eslint src --fix --ext .ts,.tsx,.vue,.js,.jsx",
|
||||
|
@ -22,6 +21,7 @@
|
|||
"driver.js": "^0.9.8",
|
||||
"echarts": "^5.4.1",
|
||||
"event-source-polyfill": "^1.0.31",
|
||||
"global": "^4.4.0",
|
||||
"jetlinks-store": "^0.0.3",
|
||||
"js-cookie": "^3.0.1",
|
||||
"less": "^4.1.3",
|
||||
|
@ -31,9 +31,11 @@
|
|||
"mavon-editor": "^2.10.4",
|
||||
"moment": "^2.29.4",
|
||||
"monaco-editor": "^0.24.0",
|
||||
"nrm": "^1.2.5",
|
||||
"pinia": "^2.0.28",
|
||||
"unplugin-auto-import": "^0.12.1",
|
||||
"unplugin-vue-components": "^0.22.12",
|
||||
"vite-plugin-monaco-editor": "^1.1.0",
|
||||
"vue": "^3.2.45",
|
||||
"vue-router": "^4.1.6",
|
||||
"vue3-markdown-it": "^1.0.10"
|
||||
|
|
|
@ -6,29 +6,29 @@
|
|||
<script setup>
|
||||
import * as monaco from 'monaco-editor';
|
||||
|
||||
import editorWorker from 'monaco-editor/esm/vs/editor/editor.worker?worker';
|
||||
import jsonWorker from 'monaco-editor/esm/vs/language/json/json.worker?worker';
|
||||
import cssWorker from 'monaco-editor/esm/vs/language/css/css.worker?worker';
|
||||
import htmlWorker from 'monaco-editor/esm/vs/language/html/html.worker?worker';
|
||||
import tsWorker from 'monaco-editor/esm/vs/language/typescript/ts.worker?worker';
|
||||
|
||||
self.MonacoEnvironment = {
|
||||
getWorker(_, label) {
|
||||
if (label === 'json') {
|
||||
return new jsonWorker();
|
||||
}
|
||||
if (label === 'css') {
|
||||
return new cssWorker();
|
||||
}
|
||||
if (label === 'html') {
|
||||
return new htmlWorker();
|
||||
}
|
||||
if (['typescript', 'javascript'].includes(label)) {
|
||||
return new tsWorker();
|
||||
}
|
||||
return new editorWorker();
|
||||
},
|
||||
};
|
||||
// import editorWorker from 'monaco-editor/esm/vs/editor/editor.worker?worker';
|
||||
// import jsonWorker from 'monaco-editor/esm/vs/language/json/json.worker?worker';
|
||||
// import cssWorker from 'monaco-editor/esm/vs/language/css/css.worker?worker';
|
||||
// import htmlWorker from 'monaco-editor/esm/vs/language/html/html.worker?worker';
|
||||
// import tsWorker from 'monaco-editor/esm/vs/language/typescript/ts.worker?worker';
|
||||
//
|
||||
// self.MonacoEnvironment = {
|
||||
// getWorker(_, label) {
|
||||
// if (label === 'json') {
|
||||
// return new jsonWorker();
|
||||
// }
|
||||
// if (label === 'css') {
|
||||
// return new cssWorker();
|
||||
// }
|
||||
// if (label === 'html') {
|
||||
// return new htmlWorker();
|
||||
// }
|
||||
// if (['typescript', 'javascript'].includes(label)) {
|
||||
// return new tsWorker();
|
||||
// }
|
||||
// return new editorWorker();
|
||||
// },
|
||||
// };
|
||||
|
||||
const props = defineProps({
|
||||
modelValue: [String, Number],
|
||||
|
|
|
@ -10,4 +10,5 @@ declare module '*.gif';
|
|||
declare module '*.bmp';
|
||||
declare module '*.js';
|
||||
declare module '*.ts';
|
||||
declare module 'js-cookie';
|
||||
declare module 'js-cookie';
|
||||
declare module 'jetlinks-ui-components';
|
|
@ -5,10 +5,13 @@ import components from './components'
|
|||
import router from './router'
|
||||
import './style.less'
|
||||
import 'ant-design-vue/es/notification/style/css';
|
||||
// import jConmonents from 'jetlinks-ui-components'
|
||||
// import 'jetlinks-ui-components/lib/style'
|
||||
|
||||
const app = createApp(App)
|
||||
|
||||
app.use(store)
|
||||
.use(router)
|
||||
.use(components)
|
||||
// .use(jConmonents)
|
||||
.mount('#app')
|
||||
|
|
|
@ -1,17 +1,73 @@
|
|||
import { defineStore } from "pinia";
|
||||
import { defineStore } from 'pinia'
|
||||
import { queryOwnThree } from '@/api/system/menu'
|
||||
import { filterAsnycRouter } from '@/utils/menu'
|
||||
import { cloneDeep } from 'lodash-es'
|
||||
import { filterAsnycRouter, MenuItem } from '@/utils/menu'
|
||||
import { isArray } from 'lodash-es'
|
||||
import router from '@/router'
|
||||
|
||||
const defaultOwnParams = [
|
||||
{
|
||||
terms: [
|
||||
{
|
||||
terms: [
|
||||
{
|
||||
column: 'owner',
|
||||
termType: 'eq',
|
||||
value: 'iot'
|
||||
},
|
||||
{
|
||||
column: 'owner',
|
||||
termType: 'isnull',
|
||||
value: '1',
|
||||
type: 'or'
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
type MenuStateType = {
|
||||
menus: {
|
||||
[key: string]: {
|
||||
buttons?: string[]
|
||||
path: string
|
||||
}
|
||||
}
|
||||
siderMenus: MenuItem[]
|
||||
}
|
||||
|
||||
// export const useMenusStore = defineStore('menu', () => {
|
||||
// const state = reactive<MenuStateType>({
|
||||
// menus: {},
|
||||
// siderMenus: []
|
||||
// })
|
||||
//
|
||||
// const hasPermission = (code: string | string[]) => {
|
||||
// if (!code || !(code as string[]).length) {
|
||||
// console.warn(`function hasPermission: 没有传入${code}`)
|
||||
// return false
|
||||
// }
|
||||
//
|
||||
// }
|
||||
//
|
||||
// const queryMenuTree = (): Promise<any[]> => {
|
||||
//
|
||||
// }
|
||||
//
|
||||
// return {
|
||||
// state,
|
||||
// hasPermission,
|
||||
// queryMenuTree
|
||||
// }
|
||||
// })
|
||||
|
||||
export const useMenuStore = defineStore({
|
||||
id: 'menu',
|
||||
state: () => ({
|
||||
menus: {},
|
||||
menuData: [],
|
||||
siderMenus: [],
|
||||
menusKey: []
|
||||
siderMenus: []
|
||||
}),
|
||||
getters: {
|
||||
getters: {
|
||||
hasPermission(state) {
|
||||
return (menuCode: string | string[]) => {
|
||||
if (!menuCode) {
|
||||
|
@ -19,42 +75,37 @@ export const useMenuStore = defineStore({
|
|||
}
|
||||
if (!!Object.keys(state.menus).length) {
|
||||
if (typeof menuCode === 'string') {
|
||||
return !!this.menus[menuCode]
|
||||
return !!this.menus[menuCode].buttons
|
||||
}
|
||||
return menuCode.some(code => !!this.menus[code])
|
||||
}
|
||||
return false
|
||||
}
|
||||
},
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
queryMenuTree(isCommunity = false): Promise<any[]> {
|
||||
return new Promise(async (res) => {
|
||||
//过滤非集成的菜单
|
||||
const params = [
|
||||
{
|
||||
terms: [
|
||||
{
|
||||
terms: [
|
||||
{
|
||||
column: 'owner',
|
||||
termType: 'eq',
|
||||
value: 'iot',
|
||||
},
|
||||
{
|
||||
column: 'owner',
|
||||
termType: 'isnull',
|
||||
value: '1',
|
||||
type: 'or',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
const resp = await queryOwnThree({ paging: false, terms: params })
|
||||
const resp = await queryOwnThree({ paging: false, terms: defaultOwnParams })
|
||||
if (resp.success) {
|
||||
const { menusData, silderMenus } = filterAsnycRouter(resp.result)
|
||||
this.menus = {}
|
||||
const handleMenuItem = (menu: any) => {
|
||||
if (isArray(menu)) {
|
||||
menu.forEach(menuItem => {
|
||||
this.menus[menuItem.code] = {
|
||||
path: menuItem.path,
|
||||
buttons: menuItem.buttons
|
||||
}
|
||||
if (menuItem.children && menuItem.length) {
|
||||
handleMenuItem(menuItem.children)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
handleMenuItem(menusData)
|
||||
menusData.push({
|
||||
path: '/',
|
||||
redirect: menusData[0]?.path,
|
||||
|
|
|
@ -95,4 +95,30 @@ export const modifySearchColumnValue = (e: any, column: object) => {
|
|||
});
|
||||
});
|
||||
return e;
|
||||
};
|
||||
};
|
||||
|
||||
// /**
|
||||
// * 根据code返回对应的菜单path
|
||||
// * @param code 菜单code
|
||||
// */
|
||||
// export const getMenu = (code: string): string | undefined => {
|
||||
// const menuStore = useMenuStore()
|
||||
// return menuStore.menus[code]?.path
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 根据菜单code跳转对应路由
|
||||
// * @param code 菜单code
|
||||
// * @param params 路由params参数
|
||||
// * @param query 路由query参数
|
||||
// */
|
||||
// export const jumpPath = (code: string, params?: any, query?: any) => {
|
||||
// const path = getMenu(code)
|
||||
// if (path) {
|
||||
// router.push({
|
||||
// path, params, query
|
||||
// })
|
||||
// } else {
|
||||
// console.warn(`menus中没有${code}`)
|
||||
// }
|
||||
// }
|
|
@ -1,7 +1,6 @@
|
|||
import { cloneDeep } from 'lodash-es'
|
||||
import NotFindPage from '@/views/404.vue'
|
||||
import { BlankLayoutPage, BasicLayoutPage } from 'components/Layout'
|
||||
const pagesComponent = import.meta.glob('../views/**/*.vue', { eager: true });
|
||||
const pagesComponent = import.meta.glob('../views/**/index.vue', { eager: true });
|
||||
|
||||
/**
|
||||
* 权限信息
|
||||
|
@ -205,11 +204,12 @@ export function filterAsnycRouter(asyncRouterMap: any, parentCode = '', level =
|
|||
_asyncRouterMap.forEach((route: any) => {
|
||||
const _route: any = {
|
||||
path: `${route.url}`,
|
||||
name: route.code,
|
||||
meta: {
|
||||
icon: route.icon,
|
||||
title: route.name,
|
||||
hideInMenu: route.isShow === false,
|
||||
buttons: route.buttons || []
|
||||
buttons: route.buttons?.map((b: any) => b.id) || []
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
<template>
|
||||
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: 'index'
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
|
@ -0,0 +1,17 @@
|
|||
<template>
|
||||
<page-container>
|
||||
<search
|
||||
|
||||
/>
|
||||
<j-table
|
||||
/>
|
||||
</page-container>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
|
@ -10,6 +10,7 @@ import {VueAmapResolver} from '@vuemap/unplugin-resolver'
|
|||
import VueSetupExtend from 'vite-plugin-vue-setup-extend'
|
||||
import { createStyleImportPlugin, AndDesignVueResolve } from 'vite-plugin-style-import'
|
||||
import * as path from 'path'
|
||||
import monacoEditorPlugin from 'vite-plugin-monaco-editor';
|
||||
|
||||
|
||||
// https://vitejs.dev/config/
|
||||
|
@ -47,7 +48,9 @@ export default defineConfig(({ mode}) => {
|
|||
},
|
||||
},
|
||||
plugins: [
|
||||
|
||||
vue(),
|
||||
monacoEditorPlugin({}),
|
||||
vueJsx(),
|
||||
Components({
|
||||
resolvers: [AntDesignVueResolver({ importStyle: 'less' }), VueAmapResolver()],
|
||||
|
|
Loading…
Reference in New Issue