Commit 7e30d13c authored by huanglu's avatar huanglu

feat: 新增 cos upload

parent 6ca29ee1
VUE_APP_API_HOST = '' VUE_APP_API_HOST = ''
\ No newline at end of file BASE_URL = '/'
\ No newline at end of file
const { isProd } = require('./util');
module.exports = {
secretId: 'AKIDmMhgQGAJbkjZ8bfpa5LNAoJfuvkJJuwh',
secretKey: 'gCTs8h8btRo00mIcgYBZh16zd7YpvqRn',
enable: isProd,
bucket: 'test-1257124244',
region: 'ap-chengdu',
path: 'static',
}
\ No newline at end of file
const path = require('path'); const { isProd, resolve } = require('./util');
const cosConfig = require('./cos-config')
const resolve = (dir) => path.join(__dirname, '..', dir);
const isProd = ['production', 'prod'].includes(process.env.NODE_ENV)
module.exports = { module.exports = {
outputDir: 'mobile', outputDir: 'dist',
proxy: { proxy: {
'/service-profile': { '/service-profile': {
target: 'http://192.168.32.57:3000', target: 'http://192.168.32.57:3000',
changeOrigin: true, changeOrigin: true,
}, },
}, },
publicPath: isProd ? 'http://test-1257124244.file.myqcloud.com/static/' : '/', publicPath: isProd ? `http://${cosConfig.bucket}.file.myqcloud.com/${cosConfig.path}/dist` : '/',
alias: { alias: {
// 配置这个,注意配置 jsconfig.json 文件,方便 vscode 能够跳进 // 配置这个,注意配置 jsconfig.json 文件,方便 vscode 能够跳进
'@': resolve('src'), '@': resolve('src'),
...@@ -22,12 +19,5 @@ module.exports = { ...@@ -22,12 +19,5 @@ module.exports = {
skeletonRoutes: [ skeletonRoutes: [
'/', '/normal/about' '/', '/normal/about'
], ],
cosConfig: { cosConfig
secretId: '',
secretKey: '',
enable: process.env.NODE_ENV === 'production',
bucket: 'test-1257124244',
region: 'ap-chengdu',
path: 'static/',
}
}; };
...@@ -3,25 +3,28 @@ const fs = require('fs') ...@@ -3,25 +3,28 @@ const fs = require('fs')
const multiPages = () => { const multiPages = () => {
const pagesPath = path.join(__dirname, '../src/pages') const pagesPath = path.join(__dirname, '../src/pages')
const pages = {} const pages = {}
if(fs.existsSync(pagesPath)) { if (fs.existsSync(pagesPath)) {
const files = fs.readdirSync(pagesPath) const files = fs.readdirSync(pagesPath)
console.log(files) console.log(files)
files.forEach(item => { files.forEach((item) => {
const fileName = item.split('.')[0]; const fileName = item.split('.')[0];
pages[fileName] = `src/pages/${fileName}/index.js` pages[fileName] = `src/pages/${fileName}/index.js`
})
}) } else {
} else { return null
return null }
} return pages
return pages
} }
const isProd = ['production', 'prod'].includes(process.env.NODE_ENV)
const resolve = (dir) => path.join(__dirname, '..', dir);
module.exports = { module.exports = {
multiPages multiPages,
isProd,
resolve
} }
<template> <template>
<div id="app"> <div id="app">
<router-view /> <router-view />
<!-- <loading /> -->
</div> </div>
</template> </template>
<script> <script>
......
...@@ -37,9 +37,11 @@ export { ...@@ -37,9 +37,11 @@ export {
routes routes
} }
console.log('baseurl: ',process.env.BASE_URL)
const router = new VueRouter({ const router = new VueRouter({
mode: 'history', mode: 'history',
base: process.env.BASE_URL, base: '/',
routes, routes,
scrollBehavior(to, from, savedPosition) { scrollBehavior(to, from, savedPosition) {
if (savedPosition) { if (savedPosition) {
......
<template> <template>
<div> <div>
this is index path
<button @click="home">home</button>
</div> </div>
</template> </template>
<script> <script>
...@@ -11,6 +13,9 @@ export default { ...@@ -11,6 +13,9 @@ export default {
return {}; return {};
}, },
methods: { methods: {
home() {
this.$router.push('/home')
}
}, },
mounted() { mounted() {
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment