fix:format

This commit is contained in:
wangzenghua 2025-02-12 09:26:19 +00:00
parent 479a3dfc0d
commit 511974f590
4 changed files with 110 additions and 113 deletions

View File

@ -1,68 +1,68 @@
import Vue from 'vue';
import Cookies from 'js-cookie';
import Element from 'element-ui';
import Vue from 'vue'
import Cookies from 'js-cookie'
import Element from 'element-ui'
import App from './App';
import store from './store';
import router from './router';
import './assets/styles/element-variables.scss';
import '@/assets/styles/index.scss'; // global css
import '@/assets/styles/ruoyi.scss'; // ruoyi css
import 'element-ui/lib/theme-chalk/index.css';
import directive from './directive'; // directive
import plugins from './plugins'; // plugins
import { download } from '@/utils/request';
import App from './App'
import store from './store'
import router from './router'
import './assets/styles/element-variables.scss'
import '@/assets/styles/index.scss' // global css
import '@/assets/styles/ruoyi.scss' // ruoyi css
import 'element-ui/lib/theme-chalk/index.css'
import directive from './directive' // directive
import plugins from './plugins' // plugins
import { download } from '@/utils/request'
import './assets/icons'; // icon
import './permission'; // permission control
import { getDicts } from '@/api/system/dict/data';
import { getConfigKey } from '@/api/system/config';
import { parseTime, resetForm, addDateRange, selectDictLabel, selectDictLabels, handleTree } from '@/utils/ruoyi';
import './assets/icons' // icon
import './permission' // permission control
import { getDicts } from '@/api/system/dict/data'
import { getConfigKey } from '@/api/system/config'
import { parseTime, resetForm, addDateRange, selectDictLabel, selectDictLabels, handleTree } from '@/utils/ruoyi'
// 分页组件
import Pagination from '@/components/Pagination';
import Pagination from '@/components/Pagination'
// 自定义表格工具组件
import RightToolbar from '@/components/RightToolbar';
import RightToolbar from '@/components/RightToolbar'
// 富文本组件
import Editor from '@/components/Editor';
import Editor from '@/components/Editor'
// 文件上传组件
import FileUpload from '@/components/FileUpload';
import FileUpload from '@/components/FileUpload'
// 图片上传组件
import ImageUpload from '@/components/ImageUpload';
import ImageUpload from '@/components/ImageUpload'
// 图片预览组件
import ImagePreview from '@/components/ImagePreview';
import ImagePreview from '@/components/ImagePreview'
// 字典标签组件
import DictTag from '@/components/DictTag';
import DictTag from '@/components/DictTag'
// 头部标签组件
import VueMeta from 'vue-meta';
import VueMeta from 'vue-meta'
// 字典数据组件
import DictData from '@/components/DictData';
import DictData from '@/components/DictData'
// import render from './plugins/micro';
// export * from './plugins/micro';
// 全局方法挂载
Vue.prototype.getDicts = getDicts;
Vue.prototype.getConfigKey = getConfigKey;
Vue.prototype.parseTime = parseTime;
Vue.prototype.resetForm = resetForm;
Vue.prototype.addDateRange = addDateRange;
Vue.prototype.selectDictLabel = selectDictLabel;
Vue.prototype.selectDictLabels = selectDictLabels;
Vue.prototype.download = download;
Vue.prototype.handleTree = handleTree;
Vue.prototype.getDicts = getDicts
Vue.prototype.getConfigKey = getConfigKey
Vue.prototype.parseTime = parseTime
Vue.prototype.resetForm = resetForm
Vue.prototype.addDateRange = addDateRange
Vue.prototype.selectDictLabel = selectDictLabel
Vue.prototype.selectDictLabels = selectDictLabels
Vue.prototype.download = download
Vue.prototype.handleTree = handleTree
// 全局组件挂载
Vue.component('DictTag', DictTag);
Vue.component('Pagination', Pagination);
Vue.component('RightToolbar', RightToolbar);
Vue.component('Editor', Editor);
Vue.component('FileUpload', FileUpload);
Vue.component('ImageUpload', ImageUpload);
Vue.component('ImagePreview', ImagePreview);
Vue.component('DictTag', DictTag)
Vue.component('Pagination', Pagination)
Vue.component('RightToolbar', RightToolbar)
Vue.component('Editor', Editor)
Vue.component('FileUpload', FileUpload)
Vue.component('ImageUpload', ImageUpload)
Vue.component('ImagePreview', ImagePreview)
Vue.use(directive);
Vue.use(plugins);
Vue.use(VueMeta);
DictData.install();
Vue.use(directive)
Vue.use(plugins)
Vue.use(VueMeta)
DictData.install()
/**
* If you don't want to use mock-server
@ -75,36 +75,36 @@ DictData.install();
Vue.use(Element, {
size: Cookies.get('size') || 'medium', // set element-ui default size
});
})
Vue.config.productionTip = false;
Vue.config.productionTip = false
let instance = null;
let instance = null
export function render(props = {}) {
const { container } = props;
const { container } = props
instance = new Vue({
router,
store,
render: (h) => h(App),
}).$mount(container ? container.querySelector('#app') : '#app');
}).$mount(container ? container.querySelector('#app') : '#app')
}
export async function bootstrap() {}
export async function mount(props) {
render(props);
render(props)
}
export async function unmount() {
instance.$destroy();
instance.$el.innerHTML = '';
instance = null;
instance.$destroy()
instance.$el.innerHTML = ''
instance = null
}
if (window.__POWERED_BY_QIANKUN__) {
// eslint-disable-next-line no-undef
__webpack_public_path__ = window.__INJECTED_PUBLIC_PATH_BY_QIANKUN__;
__webpack_public_path__ = window.__INJECTED_PUBLIC_PATH_BY_QIANKUN__
} else {
render();
render()
}

View File

@ -1,66 +1,66 @@
import router from './router';
import store from './store';
import { Message } from 'element-ui';
import NProgress from 'nprogress';
import 'nprogress/nprogress.css';
import { getToken } from '@/utils/auth';
import { isPathMatch } from '@/utils/validate';
import { isRelogin } from '@/utils/request';
import router from './router'
import store from './store'
import { Message } from 'element-ui'
import NProgress from 'nprogress'
import 'nprogress/nprogress.css'
import { getToken } from '@/utils/auth'
import { isPathMatch } from '@/utils/validate'
import { isRelogin } from '@/utils/request'
NProgress.configure({ showSpinner: false });
NProgress.configure({ showSpinner: false })
const whiteList = ['/login', '/register'];
const whiteList = ['/login', '/register']
const isWhiteList = (path) => {
return whiteList.some((pattern) => isPathMatch(pattern, path));
};
return whiteList.some((pattern) => isPathMatch(pattern, path))
}
router.beforeEach((to, from, next) => {
NProgress.start();
NProgress.start()
if (getToken()) {
to.meta.title && store.dispatch('settings/setTitle', to.meta.title);
to.meta.title && store.dispatch('settings/setTitle', to.meta.title)
/* has token*/
if (to.path === '/login') {
next({ path: '/' });
NProgress.done();
next({ path: '/' })
NProgress.done()
} else if (isWhiteList(to.path)) {
next();
next()
} else {
if (store.getters.roles.length === 0) {
isRelogin.show = true;
isRelogin.show = true
// 判断当前用户是否已拉取完user_info信息
store
.dispatch('GetInfo')
.then(() => {
isRelogin.show = false;
isRelogin.show = false
store.dispatch('GenerateRoutes').then((accessRoutes) => {
// 根据roles权限生成可访问的路由表
router.addRoutes(accessRoutes); // 动态添加可访问路由表
next({ ...to, replace: true }); // hack方法 确保addRoutes已完成
});
router.addRoutes(accessRoutes) // 动态添加可访问路由表
next({ ...to, replace: true }) // hack方法 确保addRoutes已完成
})
})
.catch((err) => {
store.dispatch('LogOut').then(() => {
Message.error(err);
next({ path: '/' });
});
});
Message.error(err)
next({ path: '/' })
})
})
} else {
next();
next()
}
}
} else {
// 没有token
if (isWhiteList(to.path)) {
// 在免登录白名单,直接进入
next();
next()
} else {
next(`/login?redirect=${encodeURIComponent(to.fullPath)}`); // 否则全部重定向到登录页
NProgress.done();
next(`/login?redirect=${encodeURIComponent(to.fullPath)}`) // 否则全部重定向到登录页
NProgress.done()
}
}
});
})
router.afterEach(() => {
NProgress.done();
});
NProgress.done()
})

View File

@ -41,4 +41,4 @@ module.exports = {
* If you want to also use it in dev, you can pass ['production', 'development']
*/
errorLog: 'production',
};
}

View File

@ -1,15 +1,15 @@
'use strict';
const path = require('path');
'use strict'
const path = require('path')
function resolve(dir) {
return path.join(__dirname, dir);
return path.join(__dirname, dir)
}
const CompressionPlugin = require('compression-webpack-plugin');
const CompressionPlugin = require('compression-webpack-plugin')
const name = process.env.VUE_APP_TITLE || '若依管理系统'; // 网页标题
const name = process.env.VUE_APP_TITLE || '若依管理系统' // 网页标题
const port = process.env.VUE_APP_PORT; // 端口
const port = process.env.VUE_APP_PORT // 端口
// vue.config.js 配置说明
// 官方vue.config.js 参考文档 https://cli.vuejs.org/zh/config/#css-loaderoptions
@ -64,13 +64,11 @@ module.exports = {
},
},
output: {
// qiankun need
library: `${name}-[name]`,
libraryTarget: 'umd', // 把微应用打包成 umd 库格式
jsonpFunction: `${name}`,
},
plugins: [
// http://doc.ruoyi.vip/ruoyi-vue/other/faq.html#使用gzip解压缩静态文件
new CompressionPlugin({
cache: false, // 不启用文件缓存
test: /\.(js|css|html|jpe?g|png|gif|svg)?$/i, // 压缩文件格式
@ -82,11 +80,11 @@ module.exports = {
],
},
chainWebpack(config) {
config.plugins.delete('preload'); // TODO: need test
config.plugins.delete('prefetch'); // TODO: need test
config.plugins.delete('preload') // TODO: need test
config.plugins.delete('prefetch') // TODO: need test
// set svg-sprite-loader
config.module.rule('svg').exclude.add(resolve('src/assets/icons')).end();
config.module.rule('svg').exclude.add(resolve('src/assets/icons')).end()
config.module
.rule('icons')
.test(/\.svg$/)
@ -97,9 +95,8 @@ module.exports = {
.options({
symbolId: 'icon-[name]',
})
.end();
.end()
// fix:Solve the problem of accessing element-ui icon on the qiankun application
config.module
.rule('fonts')
.test(/\.(ttf|woff)(\?.*)?$/)
@ -110,10 +107,10 @@ module.exports = {
...options,
limit: 99999999,
name: '[name].[hash:7].[ext]',
};
return options;
}
return options
})
.end();
.end()
config.when(process.env.NODE_ENV !== 'development', (config) => {
config
@ -125,7 +122,7 @@ module.exports = {
inline: /runtime\..*\.js$/,
},
])
.end();
.end()
config.optimization.splitChunks({
chunks: 'all',
@ -149,8 +146,8 @@ module.exports = {
reuseExistingChunk: true,
},
},
});
config.optimization.runtimeChunk('single');
});
})
config.optimization.runtimeChunk('single')
})
},
};
}