diff --git a/build/index.js b/build/index.js new file mode 100644 index 0000000..c5103f0 --- /dev/null +++ b/build/index.js @@ -0,0 +1,35 @@ +const {run} = require('runjs') +const chalk = require('chalk') +const config = require('../vue.config.js') +const rawArgv = process.argv.slice(2) +const args = rawArgv.join(' ') + +if (process.env.npm_config_preview || rawArgv.includes('--preview')) { + const report = rawArgv.includes('--report') + + run(`vue-cli-service build ${args}`) + + const port = 9526 + const publicPath = config.publicPath + + var connect = require('connect') + var serveStatic = require('serve-static') + const app = connect() + + app.use( + publicPath, + serveStatic('./dist', { + index: ['index.html', '/'] + }) + ) + + app.listen(port, function () { + console.log(chalk.green(`> Preview at http://localhost:${port}${publicPath}`)) + if (report) { + console.log(chalk.green(`> Report at http://localhost:${port}${publicPath}report.html`)) + } + + }) +} else { + run(`vue-cli-service build ${args}`) +} diff --git a/src/assets/icons/index.js b/src/assets/icons/index.js new file mode 100644 index 0000000..d5c1697 --- /dev/null +++ b/src/assets/icons/index.js @@ -0,0 +1,9 @@ +import Vue from 'vue' +import SvgIcon from '@/components/SvgIcon' // svg component + +// register globally +Vue.component('svg-icon', SvgIcon) + +const req = require.context('./svg', false, /\.svg$/) +const requireAll = requireContext => requireContext.keys().map(requireContext) +requireAll(req) diff --git a/src/components/DictData/index.js b/src/components/DictData/index.js new file mode 100644 index 0000000..b78235f --- /dev/null +++ b/src/components/DictData/index.js @@ -0,0 +1,51 @@ +import Vue from 'vue' +import store from '@/store' +import DataDict from '@/utils/dict' +import {getDicts as getDicts} from '@/api/system/dict/data' + +function searchDictByKey(dict, key) { + if (key == null && key == "") { + return null + } + try { + for (let i = 0; i < dict.length; i++) { + if (dict[i].key == key) { + return dict[i].value + } + } + } catch (e) { + return null + } +} + +function install() { + Vue.use(DataDict, { + metas: { + '*': { + labelField: 'dictLabel', + valueField: 'dictValue', + request(dictMeta) { + const storeDict = searchDictByKey(store.getters.dict, dictMeta.type) + if (storeDict) { + return new Promise(resolve => { + resolve(storeDict) + }) + } else { + return new Promise((resolve, reject) => { + getDicts(dictMeta.type).then(res => { + store.dispatch('dict/setDict', {key: dictMeta.type, value: res.data}) + resolve(res.data) + }).catch(error => { + reject(error) + }) + }) + } + }, + }, + }, + }) +} + +export default { + install, +} diff --git a/src/layout/components/index.js b/src/layout/components/index.js new file mode 100644 index 0000000..bebf056 --- /dev/null +++ b/src/layout/components/index.js @@ -0,0 +1,5 @@ +export {default as AppMain} from './AppMain' +export {default as Navbar} from './Navbar' +export {default as Settings} from './Settings' +export {default as Sidebar} from './Sidebar/index.vue' +export {default as TagsView} from './TagsView/index.vue' diff --git a/src/plugins/index.js b/src/plugins/index.js new file mode 100644 index 0000000..d000f2d --- /dev/null +++ b/src/plugins/index.js @@ -0,0 +1,20 @@ +import tab from './tab' +import auth from './auth' +import cache from './cache' +import modal from './modal' +import download from './download' + +export default { + install(Vue) { + // 页签操作 + Vue.prototype.$tab = tab + // 认证对象 + Vue.prototype.$auth = auth + // 缓存对象 + Vue.prototype.$cache = cache + // 模态框对象 + Vue.prototype.$modal = modal + // 下载文件 + Vue.prototype.$download = download + } +}