1
0
mirror of https://github.com/ialley-workshop-open/uni-halo.git synced 2026-06-12 13:19:31 +08:00

refactor: 将页面配置通过插件动态化配置(plugin-uni-halo)

This commit is contained in:
小莫唐尼
2024-06-24 18:59:05 +08:00
parent 959acab9c7
commit e17edade28
54 changed files with 5299 additions and 5653 deletions
+3 -4
View File
@@ -1,5 +1,5 @@
/**
* 功能:请求工具
* 功能:请求工具
* 作者:小莫唐尼
* 邮箱:studio@925i.cn
* 时间:2022年07月21日 18:58:03
@@ -10,7 +10,6 @@
* 修改时间:
*/
import HaloConfig from '@/config/halo.config.js'
import HaloTokenConfig from '@/config/token.config.js'
import {
setInterceptors
@@ -25,13 +24,13 @@ http.setConfig((config) => {
config.baseURL = HaloTokenConfig.BASE_API;
config.header = {
...config.header,
...config.header,
ContentType: 'application/json',
dataType: 'json'
}
return config
})
setInterceptors(http)
export {
+6 -4
View File
@@ -2,7 +2,9 @@
* markdown配置
*/
import HaloConfig from '@/config/halo.config.js'
import {
getAppConfigs
} from '@/config/index.js'
import HaloTokenConfig from '@/config/token.config.js'
export default {
domain: HaloTokenConfig.BASE_API,
@@ -93,6 +95,6 @@ export default {
},
containStyle: 'font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, "PingFang SC", Cambria, Cochin, Georgia, Times, "Times New Roman", serif;padding:12px;font-size: 14px;color: #606266;word-spacing: 0.8px;letter-spacing: 0.8px;border-radius: 6px;background-color:#FFFFFF;',
loadingGif: HaloConfig.loadingGifUrl,
emptyGif: HaloConfig.loadingEmptyUrl,
}
loadingGif: getAppConfigs().imagesConfig.loadingGifUrl,
emptyGif: getAppConfigs().imagesConfig.loadingEmptyUrl,
}
+82 -78
View File
@@ -9,85 +9,89 @@
* 修改人员:
* 修改时间:
*/
import HaloConfig from '@/config/halo.config.js';
import HaloAdConfig from '@/config/ad.config.js';
import HaloPluginsConfig from '@/config/plugins.config.js';
export default {
install(Vue) {
Vue.mixin({
data() {
return {
author: HaloConfig.author,
_isWechat: true,
haloConfig: HaloConfig,
haloAdConfig: HaloAdConfig,
haloPluginsConfig: HaloPluginsConfig,
_aniWaitIndex: 0, // 动画索引
};
},
computed: {
// 获取全局应用设置
globalAppSettings() {
return uni.$tm.vx.getters().getSettings;
},
// 计算动画索引
calcAniWait() {
return (index) => {
if ((index + 1) % 10 == 0) {
this._aniWaitIndex = 1;
} else {
this._aniWaitIndex += 1;
}
console.log('this._aniWaitIndex', this._aniWaitIndex);
return this._aniWaitIndex * 50
}
}
},
onLoad() {
this.fnResetSetAniWaitIndex()
},
created() {
// #ifdef MP-WEIXIN
this._isWechat = true;
uni.$tm.vx.commit('setWxShare', HaloConfig.wxShareConfig);
// #endif
// #ifndef MP-WEIXIN
this._isWechat = false;
// #endif
},
onShow() {
this.fnResetSetAniWaitIndex()
},
methods: {
/**
* 设置页面标题
* @param {Object} title 标题
*/
fnSetPageTitle(title) {
uni.setNavigationBarTitle({
title: title || HaloConfig.title
})
},
install(Vue) {
Vue.mixin({
data() {
return {
_isWechat: true,
_aniWaitIndex: 0
};
},
computed: {
haloConfig() {
return this.$tm.vx.getters().getConfigs;
},
haloPluginsConfig() {
return this.$tm.vx.getters().getConfigs?.pluginConfig;
},
// 获取全局应用设置
globalAppSettings() {
return uni.$tm.vx.getters().getSettings;
},
// 计算动画索引
calcAniWait() {
return (index) => {
if ((index + 1) % 10 === 0) {
this._aniWaitIndex = 1;
} else {
this._aniWaitIndex += 1;
}
return this._aniWaitIndex * 50
}
}
},
watch: {
haloConfig: {
deep: true,
immediate: true,
handler(newVal) {
if (!newVal) return;
// #ifdef MP-WEIXIN
uni.$tm.vx.commit('setWxShare', newVal.shareConfig);
// #endif
}
}
},
onLoad() {
this.fnResetSetAniWaitIndex()
},
created() {
// #ifdef MP-WEIXIN
this._isWechat = true;
// #endif
// #ifndef MP-WEIXIN
this._isWechat = false;
// #endif
},
onShow() {
this.fnResetSetAniWaitIndex()
},
methods: {
// 设置页面标题
fnSetPageTitle(title) {
uni.setNavigationBarTitle({
title: title || (this.haloConfig && this.haloConfig.startConfig.title) || "uni-halo",
})
},
/**
* 页面返回顶部
*/
fnToTopPage(duration = 500) {
duration = isNaN(duration) ? 500 : duration
uni.pageScrollTo({
scrollTop: 0,
duration: duration,
fail: (err) => {
console.log('err', err);
},
});
},
// 初始化动画索引值(需要在每个页面调用)
fnResetSetAniWaitIndex() {
this._aniWaitIndex = 0
}
},
});
},
// 页面返回顶部
fnToTopPage(duration = 500) {
duration = isNaN(duration) ? 500 : duration
uni.pageScrollTo({
scrollTop: 0,
duration: duration,
fail: (err) => {
console.log('err', err);
},
});
},
// 初始化动画索引值(需要在每个页面调用)
fnResetSetAniWaitIndex() {
this._aniWaitIndex = 0
}
},
});
},
};
+8 -9
View File
@@ -1,16 +1,15 @@
// 微信分享配置
import haloConfig from '@/config/halo.config.js'
import HaloTokenConfig from '@/config/token.config.js'
import { jsonToUrlParams2 } from '@/utils/url.params.js'
import {
jsonToUrlParams2
} from '@/utils/url.params.js'
export const haloWxShareMixin = {
data() {
return {
haloWxShareData: {
...haloConfig.wxShareConfig
},
computed: {
haloWxShareData() {
const configs = this.$tm.vx.getters().getConfigs;
return configs.shareConfig || {}
}
},
//#ifdef MP-WEIXIN
onShareAppMessage(res) {
return {
@@ -64,4 +63,4 @@ export const haloWxShareMixin = {
this.haloWxShareData = _config;
}
}
}
}