1. uniapp 添加公共样式

2. uniapp  config 优化
3. uniapp 代理功能
4. uniapp 路径优化
5. uniapp 开发者模式
DLC
鹿和sa0ChunLuyu 2 years ago
parent c844d9fed3
commit 56edb338d1

@ -36,4 +36,26 @@
.navbar_blank_wrapper {
height: calc(100rpx + var(--safe-area-inset-top));
}
.input_line_wrapper {
display: flex;
align-items: center;
flex-wrap: wrap;
justify-content: space-between;
}
.input_line_tag_wrapper {
width: 200rpx;
height: 60rpx;
line-height: 60rpx;
text-align: center;
background: #f9f9f9;
font-size: 26rpx;
font-weight: bold;
border-radius: 6rpx;
}
.input_line_input_wrapper {
width: 500rpx;
}
</style>

@ -3,17 +3,31 @@ import {
} from '@/lu/axios.js'
import $config from '@/config.js'
const app_path = 'App'
export const OpenGzhAuthUrl = `${$config.url}/open/Gzh/auth`
let url = ''
const urlPick = () => {
if ($config.config.length > 0) {
url = $config.config[0].url
for (let i in $config.config) {
if (!!$config.config[i].active) {
url = $config.config[i].url
break
}
}
}
}
urlPick()
export const OpenGzhAuthUrl = `${url}/open/Gzh/auth`
export const WeChatPayPayTestAction = async (data) => await $post({
url: `${$config.url}/api/Test/WeChatPay/pay_test`,
url: `${url}/api/Test/WeChatPay/pay_test`,
data
})
export const WeChatLoginTestAction = async (data) => await $post({
url: `${$config.url}/api/Test/WeChat/login_test`,
url: `${url}/api/Test/WeChat/login_test`,
data
})
export const yo = async (data) => await $post({
url: `${$config.url}/api/yo`,
url: `${url}/api/yo`,
data
})

@ -0,0 +1,160 @@
<script setup>
/**
* name
* usersa0ChunLuyu
* date2023年8月14日 06:57:50
*/
import {
ref
} from 'vue'
import {
$response
} from '@/api'
import {
onShow
} from '@dcloudio/uni-app'
const clicks = ref(0);
const env = ref(process.env.NODE_ENV)
const last_click_time = ref(0);
const magicButtonClick = () => {
const current_time = new Date().getTime();
if (current_time - last_click_time.value <= 1000) {
clicks.value++;
} else {
clicks.value = 1;
}
last_click_time.value = current_time;
if (clicks.value === 10) {
magic_popup_ref.value.open()
clicks.value = 0;
}
}
const quitDevClick = () => {
quit_popup_ref.value.open()
}
const magic_popup_ref = ref(null)
const magicPopupRef = (e) => {
magic_popup_ref.value = e
}
const quit_popup_ref = ref(null)
const quitPopupRef = (e) => {
quit_popup_ref.value = e
}
const magicConfirmClick = () => {
uni.setStorageSync(dev_status_key, '1')
uni.reLaunch({
url: '/pages/main/index/index'
})
}
const quitConfirmClick = () => {
uni.setStorageSync(dev_status_key, '0')
uni.reLaunch({
url: '/pages/main/index/index'
})
}
const dev_status_key = 'DEV_STATUS'
const dev_status = ref(2)
const checkDevStatus = () => {
const status = uni.getStorageSync(dev_status_key)
dev_status.value = Number(!!status ? status : '0')
}
const devStatusChangeClick = () => {
dev_status.value = dev_status.value === 1 ? 2 : 1
}
const jumpTo = (url) => {
uni.navigateTo({
url
})
}
onShow(() => {
checkDevStatus()
})
</script>
<template>
<view class="dev_wrapper">
<uni-popup :ref="magicPopupRef" type="dialog">
<uni-popup-dialog type="error" cancelText="取消" confirmText="重启" title="提示" content="点击重启进入开发者模式"
@confirm="magicConfirmClick()"></uni-popup-dialog>
</uni-popup>
<uni-popup :ref="quitPopupRef" type="dialog">
<uni-popup-dialog type="error" cancelText="取消" confirmText="确定" title="提示" content="点击确认退出开发者模式"
@confirm="quitConfirmClick()"></uni-popup-dialog>
</uni-popup>
<view v-if="Number(dev_status) === 0" @click="magicButtonClick()" class="dev_magic_button_wrapper" :style="{
background: env === 'development' ? '#000000' : '#00000000'
}">
</view>
<view v-else class="dev_box_wrapper" :style="{
width: Number(dev_status) === 1 ? '80rpx' : '730rpx',
height: Number(dev_status) === 1 ? '80rpx' : 'calc(100vh - 20rpx)',
}">
<view @click="devStatusChangeClick()" class="dev_button_wrapper">
<uni-icons v-if="Number(dev_status) === 1" type="tune" size="40rpx"></uni-icons>
<uni-icons v-else type="closeempty" size="40rpx"></uni-icons>
</view>
<view v-if="Number(dev_status) === 2" class="dev_panel_wrapper">
<view @click="jumpTo('/pages/dev/example/example?name=yo')" class="dev_button_item_wrapper">示例</view>
<view @click="jumpTo('/pages/dev/proxy/proxy')" class="dev_button_item_wrapper">代理设置</view>
<view @click="quitDevClick()" class="dev_button_item_wrapper">退出开发者模式</view>
</view>
</view>
</view>
</template>
<style scoped>
.dev_panel_wrapper {
height: calc(100% - 100rpx);
overflow-y: auto;
}
.dev_button_item_wrapper {
width: 600rpx;
height: 60rpx;
line-height: 60rpx;
text-align: center;
margin: 15rpx auto;
background: #f9f9f9;
font-size: 26rpx;
font-weight: bold;
border-radius: 6rpx;
}
.dev_wrapper {
position: relative;
z-index: 10;
}
.dev_button_wrapper {
width: 80rpx;
height: 80rpx;
line-height: 80rpx;
text-align: center;
}
.dev_box_wrapper {
position: fixed;
top: 10rpx;
left: 10rpx;
width: 80rpx;
height: 80rpx;
background: #ffffff;
border-radius: 10rpx;
text-align: center;
transition: all 0.5s ease-in-out;
overflow: hidden;
}
.dev_magic_button_wrapper {
position: fixed;
top: 0;
left: 0;
width: 30rpx;
height: 30rpx;
}
</style>

@ -1,20 +1,29 @@
let url = 'http://lucode3.sa0.online'
let login = 'http://127.0.0.1:5173/h5/#/pages/package/gzh_auth/gzh_auth?'
let env = 'online'
if (process.env.NODE_ENV == 'development') {
env = 'dev'
}
// env = 'online'
// env = 'dev'
if (env === 'dev') {
url = 'http://127.0.0.1:8000'
login = 'http://127.0.0.1:5173/h5/#/pages/package/gzh_auth/gzh_auth?'
const config = [{
active: true,
url: 'http://lucode3.sa0.online',
gzh: {
id: 'wx526430047d34c85c',
jump: 'http://node/h5/#/pages/package/gzh_auth/gzh_auth?'
},
}, {
active: false,
url: 'http://127.0.0.1:8000',
gzh: {
id: 'wx526430047d34c85c',
jump: 'http://127.0.0.1:5173/h5/#/pages/gzh/login/login?'
},
}]
uni.$config = JSON.parse(JSON.stringify(config))
const config_str_key = "CONFIG_STR"
let config_str = uni.getStorageSync(config_str_key)
if (!config_str) {
config_str = JSON.stringify(config)
uni.setStorageSync(config_str_key, config_str)
}
const config_data = JSON.parse(config_str)
export default {
title: '鹿和开发套件',
app_id: 'wx0d92d2990ec16a55',
gzh_id: 'wx526430047d34c85c',
login,
token: '0995452A-0D59-44B6-B6CA-88D8B1E257A0',
url,
config: config_data,
token: '0995452A-0D59-44B6-B6CA-88D8B1E257A0'
}

@ -11,7 +11,7 @@
}
}],
"subPackages": [{
"root": "pages/package",
"root": "pages/dev",
"pages": [{
"path": "example/example",
"style": {
@ -20,12 +20,23 @@
"navigationStyle": "custom"
}
}, {
"path": "gzh_auth/gzh_auth",
"path": "proxy/proxy",
"style": {
"navigationBarTitleText": "",
"navigationBarTitleText": "代理设置",
"enablePullDownRefresh": false
}
}]
}, {
"root": "pages/gzh",
"pages": [{
"path": "login/login",
"style": {
"navigationBarTitleText": "公众号登录跳转",
"enablePullDownRefresh": false,
"navigationStyle": "custom"
}
}]
}],
"tabBar": {

@ -10,14 +10,17 @@
import PiniaComponent from './Pinia/Pinia.vue' // Pinia
import RouterPushComponent from './RouterPush/RouterPush.vue' //
import FatherComponent from './SonFather/Father.vue' //
// #ifdef MP-WEIXIN
import UserAvatarComponent from './UserAvatar/UserAvatar.vue' //
import UserNicknameComponent from './UserNickname/UserNickname.vue' //
import UserInfoComponent from './UserInfo/UserInfo.vue' //
import UserCodeComponent from './UserCode/UserCode.vue' //
import UserGzhComponent from './UserGzh/UserGzh.vue' //
import UserPhoneComponent from './UserPhone/UserPhone.vue' //
import PayTestComponent from './PayTest/PayTest.vue' //
// #endif
// #ifdef H5
import UserGzhComponent from './UserGzh/UserGzh.vue' //
// #endif
//
// URL
const $props = defineProps({
@ -35,13 +38,17 @@
<PiniaComponent></PiniaComponent>
<RouterPushComponent></RouterPushComponent>
<FatherComponent></FatherComponent>
<!-- #ifdef MP-WEIXIN -->
<UserAvatarComponent></UserAvatarComponent>
<UserNicknameComponent></UserNicknameComponent>
<UserInfoComponent></UserInfoComponent>
<UserCodeComponent></UserCodeComponent>
<UserGzhComponent></UserGzhComponent>
<UserPhoneComponent></UserPhoneComponent>
<PayTestComponent></PayTestComponent>
<!-- #endif -->
<!-- #ifdef H5 -->
<UserGzhComponent></UserGzhComponent>
<!-- #endif -->
<view class="bottom_blank_wrapper"></view>
</template>
<style>

@ -0,0 +1,258 @@
<script setup>
/**
* name
* usersa0ChunLuyu
* date2023年8月14日 08:08:44
*/
import {
ref
} from 'vue'
import {
$response
} from '@/api'
import {
onShow
} from '@dcloudio/uni-app'
import $config from '@/config.js'
const config_arr = ref($config.config)
const config_item_create_default = {
active: false,
url: '',
gzh: {
id: '',
jump: ''
}
}
const config_item_create = ref(JSON.parse(JSON.stringify(config_item_create_default)))
const switchChange = (e, key) => {
if (key === -1) {
config_item_create.value.active = e.detail.value
} else {
if (!!e.detail.value) {
config_arr.value.forEach((item) => {
item.active = false
})
config_arr.value[key].active = true
} else {
config_arr.value[key].active = false
config_arr.value[0].active = true
}
}
}
const del_popup_ref = ref(null)
const delPopupRef = (e) => {
del_popup_ref.value = e
}
const addClick = () => {
if (!config_item_create.value.url) return uni.$lu.toast('请填写URL')
if (config_item_create.value.url.indexOf('http') !== 0) return uni.$lu.toast('请填写正确的URL')
if (config_item_create.value.active) {
config_arr.value.forEach((item) => {
item.active = false
})
}
config_arr.value.unshift(config_item_create.value)
}
const del_active = ref(-1)
const delClick = (index) => {
del_active.value = index
del_popup_ref.value.open()
}
const delConfirmClick = () => {
if (del_active.value === -1) return
if (config_arr.value[del_active.value].active) return
config_arr.value.splice(del_active.value, 1)
del_active.value = -1
}
const save_popup_ref = ref(null)
const savePopupRef = (e) => {
save_popup_ref.value = e
}
const saveConfigClick = () => {
save_popup_ref.value.open()
}
const saveConfirmClick = () => {
uni.setStorageSync("CONFIG_STR", JSON.stringify(config_arr.value))
uni.$lu.toast('保存成功,重启后生效')
}
const reset_popup_ref = ref(null)
const resetPopupRef = (e) => {
reset_popup_ref.value = e
}
const resetConfirmClick = () => {
uni.setStorageSync("CONFIG_STR", JSON.stringify(uni.$config))
config_arr.value = uni.$config
uni.$lu.toast('保存成功,重启后生效')
}
const resetConfigClick = () => {
reset_popup_ref.value.open()
}
onShow(() => {})
</script>
<template>
<view>
<uni-popup :ref="delPopupRef" type="dialog">
<uni-popup-dialog type="error" cancelText="取消" confirmText="确定" title="提示" content="是否删除该代理?"
@confirm="delConfirmClick()"></uni-popup-dialog>
</uni-popup>
<uni-popup :ref="savePopupRef" type="dialog">
<uni-popup-dialog type="error" cancelText="取消" confirmText="确定" title="提示" content="是否保存代理配置?"
@confirm="saveConfirmClick()"></uni-popup-dialog>
</uni-popup>
<uni-popup :ref="resetPopupRef" type="dialog">
<uni-popup-dialog type="error" cancelText="取消" confirmText="确定" title="提示" content="是否重置代理配置?"
@confirm="resetConfirmClick()"></uni-popup-dialog>
</uni-popup>
<view class="config_list_wrapper">
<view class="config_item_wrapper">
<view class="input_line_wrapper">
<view class="input_line_tag_wrapper">URL</view>
<view class="input_line_input_wrapper">
<uni-easyinput v-model="config_item_create.url" placeholder="请输入"></uni-easyinput>
</view>
</view>
<view class="input_line_wrapper">
<view class="input_line_tag_wrapper">公众号</view>
<view class="input_line_tag_wrapper error_tip_wrapper">用不到可以不填</view>
</view>
<view class="input_line_wrapper">
<view class="input_line_tag_wrapper">APPID</view>
<view class="input_line_input_wrapper">
<uni-easyinput v-model="config_item_create.gzh.id" placeholder="请输入"></uni-easyinput>
</view>
</view>
<view class="input_line_wrapper">
<view class="input_line_tag_wrapper">授权地址</view>
<view class="input_line_input_wrapper">
<uni-easyinput v-model="config_item_create.gzh.jump" placeholder="请输入"></uni-easyinput>
</view>
</view>
<view class="input_line_wrapper">
<view class="input_line_tag_wrapper">激活状态</view>
<view class="input_line_input_wrapper">
<switch :checked="config_item_create.active" @change="(e)=>{switchChange(e,-1)}"
style="transform:scale(0.7)" />
<view class="input_line_tag_wrapper">
<button @click="addClick()" class="add_button_wrapper">添加</button>
</view>
</view>
</view>
</view>
<view @click="saveConfigClick()" class="save_config_button_wrapper">保存配置</view>
<view @click="resetConfigClick()" class="reset_config_button_wrapper">重置配置</view>
<view class="config_item_wrapper" v-for="(i,k) in config_arr" :key="k">
<view class="input_line_wrapper">
<view class="input_line_tag_wrapper">URL</view>
<view class="input_line_input_wrapper">
<uni-easyinput v-model="config_arr[k].url" placeholder="请输入"></uni-easyinput>
</view>
</view>
<view class="input_line_wrapper">
<view class="input_line_tag_wrapper">公众号</view>
<view class="input_line_tag_wrapper error_tip_wrapper">用不到可以不填</view>
</view>
<view class="input_line_wrapper">
<view class="input_line_tag_wrapper">APPID</view>
<view class="input_line_input_wrapper">
<uni-easyinput v-model="config_arr[k].gzh.id" placeholder="请输入"></uni-easyinput>
</view>
</view>
<view class="input_line_wrapper">
<view class="input_line_tag_wrapper">授权地址</view>
<view class="input_line_input_wrapper">
<uni-easyinput v-model="config_arr[k].gzh.jump" placeholder="请输入"></uni-easyinput>
</view>
</view>
<view class="input_line_wrapper">
<view class="input_line_tag_wrapper">激活状态</view>
<view class="input_line_input_wrapper">
<switch :disabled="config_arr[k].active" :checked="config_arr[k].active" @change="(e)=>{switchChange(e,k)}"
style="transform:scale(0.7)" />
<view class="input_line_tag_wrapper">
<button :disabled="config_arr.length <= 1 || config_arr[k].active" @click="delClick(k)"
class="del_button_wrapper">删除</button>
</view>
</view>
</view>
</view>
</view>
<view class="bottom_blank_wrapper"></view>
</view>
</template>
<style>
page {
background: #ffffff;
}
</style>
<style scoped>
.save_config_button_wrapper {
width: 700rpx;
height: 60rpx;
line-height: 60rpx;
background: #56bb37;
color: #ffffff;
text-align: center;
margin: 20rpx auto;
}
.reset_config_button_wrapper {
width: 700rpx;
height: 60rpx;
line-height: 60rpx;
background: #c3494e;
color: #ffffff;
text-align: center;
margin: 20rpx auto;
}
.del_button_wrapper {
background: #c3494e;
color: #ffffff;
width: 200rpx;
height: 60rpx;
line-height: 60rpx;
text-align: center;
font-size: 26rpx;
font-weight: bold;
border-radius: 6rpx;
}
.add_button_wrapper {
background: #56bb37;
color: #ffffff;
width: 200rpx;
height: 60rpx;
line-height: 60rpx;
text-align: center;
font-size: 26rpx;
font-weight: bold;
border-radius: 6rpx;
}
.input_line_input_wrapper {
display: flex;
align-items: center;
justify-content: space-between;
}
.config_item_wrapper {
margin-top: 10rpx;
padding-bottom: 10rpx;
border-bottom: 1rpx #cccccc40 solid;
}
.input_line_wrapper {
margin-top: 10rpx;
}
.config_list_wrapper {
width: 730rpx;
margin: 0 auto;
}
.error_tip_wrapper {
color: #c3494e;
}
</style>

@ -2,7 +2,7 @@
/**
* name
* usersa0ChunLuyu
* date2023年8月13日 23:56:28
* date2023年8月14日 06:41:42
*/
import {
ref
@ -13,16 +13,10 @@
import {
onShow
} from '@dcloudio/uni-app'
const $props = defineProps({
code: {
type: String,
default: ''
}
});
</script>
<template>
<view>
Yo {{ $props.code }}
Yo
<view class="blank_wrapper"></view>
</view>
</template>

@ -13,21 +13,15 @@
import {
onShow
} from '@dcloudio/uni-app'
import dev from '@/components/dev/dev.vue'
const title = uni.$lu.config.title
const toExample = () => {
uni.navigateTo({
url: '/pages/package/example/example?name=yo'
})
}
</script>
<template>
<view class="page_wrapper">
<view>
<view>
<view class="page_wrapper">
<view>Yo {{ title }}</view>
<view class="button_wrapper">
<button size="mini" @click="toExample()"></button>
</view>
</view>
<dev></dev>
</view>
</template>
<style scoped>

Loading…
Cancel
Save