flat: 添加config项目配置文件

This commit is contained in:
Apcallover
2024-04-14 16:13:44 +08:00
parent 433bb86649
commit 6ea826b710
3 changed files with 104 additions and 56 deletions

16
App.vue
View File

@@ -37,6 +37,9 @@
return this.news.allUnread return this.news.allUnread
} }
}, },
mounted() {
this.$config.showTitle && document.documentElement.style.setProperty('--hide-title', 'block');
},
watch: { watch: {
allUnread(value) { allUnread(value) {
if (!this.$store.state.user.token) {} else if (value > 0) { if (!this.$store.state.user.token) {} else if (value > 0) {
@@ -63,7 +66,7 @@
}; };
</script> </script>
<style> <style lang="scss">
/*每个页面公共css */ /*每个页面公共css */
/* tabbar 字体大小 */ /* tabbar 字体大小 */
/* .uni-tabbar__label{ /* .uni-tabbar__label{
@@ -75,4 +78,15 @@
font-style: mormal; font-style: mormal;
src: url('/static/font/font_2225171_8kdcwk4po24.ttf') format('truetype'); src: url('/static/font/font_2225171_8kdcwk4po24.ttf') format('truetype');
} }
:root {
--hide-title: none;
}
/* #ifdef H5 */
uni-page-head {
display: var(--hide-title);
}
/* #endif */
</style> </style>

28
config.js Normal file
View File

@@ -0,0 +1,28 @@
module.exports = {
baseUrl: '',
// 图片地址
imageUrl: '',
// 显示标题
showTitle: false,
// 应用信息
appInfo: {
// 应用名称
name: "",
// 应用版本
version: "1.0.0",
// 应用logo
logo: "",
// 官方网站
site_url: "",
// 政策协议
agreements: [{
title: "隐私政策",
url: ""
},
{
title: "用户服务协议",
url: ""
}
]
}
}

14
main.js
View File

@@ -3,6 +3,7 @@ import store from './store';
import App from './App' import App from './App'
import util from './untils/func.js' import util from './untils/func.js'
import uView from '@/uni_modules/uview-ui' import uView from '@/uni_modules/uview-ui'
import config from './config';
// 注册全局组件 // 注册全局组件
// import MescrollBody from "@/components/mescroll-uni/mescroll-body.vue" // import MescrollBody from "@/components/mescroll-uni/mescroll-body.vue"
@@ -11,9 +12,10 @@ import uView from '@/uni_modules/uview-ui'
// Vue.component('mescroll-uni', MescrollUni) // Vue.component('mescroll-uni', MescrollUni)
import empty from '@/components/empty/empty.vue' import empty from '@/components/empty/empty.vue'
function navTo(url, needLogin) { function navTo(url, needLogin) {
console.log(url) console.log(url)
if(needLogin) { if (needLogin) {
return return
} }
uni.navigateTo({ uni.navigateTo({
@@ -21,7 +23,7 @@ function navTo(url, needLogin) {
}) })
} }
const msg = (title, duration=1500, mask=false, icon='none')=>{ const msg = (title, duration = 1500, mask = false, icon = 'none') => {
uni.showToast({ uni.showToast({
title, title,
duration, duration,
@@ -41,7 +43,10 @@ Vue.component('jl-form-item', JlFormItem)
Vue.component('cs-button', CSButton) Vue.component('cs-button', CSButton)
Vue.component('empty', empty) Vue.component('empty', empty)
Vue.prototype.$api = { msg } Vue.prototype.$api = {
msg
}
Vue.prototype.$config = config
Vue.prototype.navTo = navTo Vue.prototype.navTo = navTo
Vue.config.productionTip = false Vue.config.productionTip = false
@@ -50,6 +55,7 @@ Vue.use(uView)
App.mpType = 'app' App.mpType = 'app'
const app = new Vue({ const app = new Vue({
...App,store ...App,
store
}) })
app.$mount() app.$mount()