feat(系统设置): 新增微信小程序配置页(标签页 + 独立页)

- 接口:setting.warehouse.getweChatApp 拉取已授权小程序配置
- 接口:wechat.getAuthUrl 获取微信授权链接(点击按钮后在新小窗打开)
- 未授权(data 为 null)时提示需要授权,授权完成自动轮询刷新
- 新增「微信小程序」标签页与 system/setting/miniprogram 独立页路由(备用)
This commit is contained in:
liufumingren 2026-09-21 18:25:54 +08:00
parent f68c1fd301
commit 401d1aa3df
6 changed files with 762 additions and 1 deletions

View File

@ -469,11 +469,53 @@ export function settingWarehouseSaveFrontCert(
} as any)
}
/** 当前仓库已授权的微信小程序信息(setting.warehouse.getweChatApp 响应;字段名以后端为准,前端做多形态兼容) */
export type SettingWarehouseWeChatApp = {
warehouse_id?: number
/** 小程序 AppID */
app_id?: string
/** 小程序 AppSecret */
app_secret?: string
/** 小程序名称 */
nick_name?: string
/** 小程序原始ID(gh_ 开头) */
original_id?: string
/** 第三方平台授权码 */
authorization_code?: string
/** 授权时间 */
authorized_at?: string | null
updated_at?: string | null
[key: string]: unknown
}
/**
* 查询当前仓库已授权的微信小程序信息(微信小程序配置页使用)。
* 未授权时返回空配置(无小程序相关字段),前端据此提示「需要授权」并展示「去授权」入口。
*/
export function settingWarehouseGetWeChatApp(
data: Record<string, unknown> = {}
): Promise<
{ code?: number; message?: string; data?: SettingWarehouseWeChatApp } & Record<string, unknown>
> {
return request({
url: '/system',
method: 'post',
params: {
method: 'setting.warehouse.getweChatApp',
v,
timestamp: new Date().getTime()
},
data,
isSystemApi: true
} as any)
}
export const settingWarehouse = {
getSettings: settingWarehouseGetSettings,
getFieldMeta: settingWarehouseGetFieldMeta,
saveSettings: settingWarehouseSaveSettings,
getFrontConfig: settingWarehouseGetFrontConfig,
saveFrontConfig: settingWarehouseSaveFrontConfig,
saveFrontCert: settingWarehouseSaveFrontCert
saveFrontCert: settingWarehouseSaveFrontCert,
getWeChatApp: settingWarehouseGetWeChatApp
}

45
src/api/wechat/wechat.ts Normal file
View File

@ -0,0 +1,45 @@
import request from '@/utils/request'
const v = '1.0'
/**
* 微信授权相关接口(module wechat)
*
* wechat.getAuthUrl —— 获取微信授权链接:前端拿到链接后在**新小窗口**中打开,
* 用户完成授权后由后端接收微信回调并落库,前端再调用业务侧查询接口刷新。
*/
export type WeChatAuthUrlPayload = {
/** 授权链接(后端返回的字段名可能是 url / auth_url / authorize_url 等,取值时做兼容) */
url?: string
auth_url?: string
authorize_url?: string
/** 授权状态校验串 */
state?: string
[key: string]: unknown
}
/**
* 获取微信授权链接(由用户点击「去授权」时调用,避免页面加载即跳转/弹窗被拦截)。
* 返回值中链接字段名做多形态兼容,取值见页面 pickAuthUrl()。
*/
export function wechatGetAuthUrl(
data: Record<string, unknown> = {}
): Promise<{ code?: number; message?: string; data?: WeChatAuthUrlPayload } & Record<string, unknown>> {
return request({
url: '/system',
method: 'post',
params: {
method: 'wechat.getAuthUrl',
v,
timestamp: new Date().getTime()
},
data,
isSystemApi: true
} as any)
}
export const wechat = {
getAuthUrl: wechatGetAuthUrl
}
export default wechat

View File

@ -51,6 +51,9 @@ export const componentMap: Record<string, any> = {
/** 与后端菜单 component 字段兼容:部分环境为老路径 system/setting/basicManagement/index → 强制指向 newview(含投递计划/报表定义) */
'system/setting/basicManagement/index': () => import('@/views/system/setting/basicManagement/newview/index.vue'),
'system/setting/basicManagement': () => import('@/views/system/setting/basicManagement/newview/index.vue'),
/** 微信小程序配置(备用独立页;与基础管理内「微信小程序」标签页共用表单组件) */
'system/setting/miniprogram/index': () => import('@/views/system/setting/miniprogram/index.vue'),
'system/setting/miniprogram': () => import('@/views/system/setting/miniprogram/index.vue'),
'system/setting/role/index': () => import('@/views/system/setting/role/index.vue'),
// 'role/index': () => import('@/views/system/setting/role/index.vue'),
// 'system/setting/role/index': () => import('@/views/system/setting/role/index.vue'),

View File

@ -22,6 +22,7 @@ import DetailPanel from './components/DetailPanel.vue'
import LogPanel from './components/LogPanel.vue'
import WarehouseSettingsForm from '../pages/WarehouseSettingsForm.vue'
import FrontConfigForm from '../pages/FrontConfigForm.vue'
import MiniProgramConfigForm from '../pages/MiniProgramConfigForm.vue'
import ApiAppFormDialog from '../pages/ApiAppFormDialog.vue'
import DeliveryPlanFormDialog from '../pages/DeliveryPlanFormDialog.vue'
import DefinitionFormDialog from '../pages/DefinitionFormDialog.vue'
@ -57,6 +58,7 @@ export const COMPONENT_REGISTRY: Record<string, Component> = {
LogPanel,
WarehouseSettingsForm,
FrontConfigForm,
MiniProgramConfigForm,
ApiAppFormDialog,
DeliveryPlanFormDialog,
DeliveryPlanCopyDialog,
@ -1644,6 +1646,22 @@ export const tabPages: TabPageRawConfig[] = [
confirmButtonText: '删除'
}
]
},
// ===== 标签页六:微信小程序配置(备用,表单项页面;独立页入口见 views/system/setting/miniprogram/index.vue) =====
{
name: 'miniProgram',
label: '微信小程序',
viewType: 'form',
formPage: MiniProgramConfigForm,
scanBoxCacheKey: 'basic-settings-miniprogram',
scanBoxFieldKeys: [],
tableColumnKeys: [],
upperTableDefaults: {
title: '',
showSelection: false
},
detailSections: []
}
]

View File

@ -0,0 +1,605 @@
<!--
MiniProgramConfigForm — 微信小程序配置页
对接接口:
- setting.warehouse.getweChatApp(settingWarehouseGetWeChatApp):拉取当前仓库已授权的微信小程序配置
- wechat.getAuthUrl(wechatGetAuthUrl):未配置时点击「去授权」获取授权链接,并在新小窗口中打开
交互约定:
1) 页面挂载即拉取配置;无配置(未授权)时提示「需要授权」并高亮「去授权」入口
2) 授权链接**不自动打开**:必须用户点击「去授权」按钮后才请求 wechat.getAuthUrl 并弹小窗
3) 小窗口打开后:轮询配置,授权完成自动刷新;小窗关闭后做最后一次刷新
使用方:
1) basicManagement/newview 的 viewType='form' 标签页「微信小程序」
2) 独立页面 views/system/setting/miniprogram/index.vue(备用入口,共用本组件)
-->
<template>
<div v-loading="pageLoading" class="mp-config-page">
<div class="settings-header">
<div class="header-text">
<span class="title">微信小程序</span>
<span class="sub">
当前仓库已授权的微信小程序配置(数据来自微信授权,只读)
<template v-if="lastLoadedAt">|更新于 {{ lastLoadedAt }}</template>
</span>
</div>
<div class="header-actions">
<el-button :disabled="pageLoading" @click="loadConfig">刷新</el-button>
<el-button type="primary" :loading="authUrlLoading" @click="handleAuthorize">
{{ authorized ? '重新授权' : '去授权' }}
</el-button>
</div>
</div>
<!-- ===== 未授权:提示需要授权 ===== -->
<template v-if="!pageLoading && !authorized">
<el-alert
type="warning"
show-icon
:closable="false"
class="mp-config-alert"
title="当前仓库尚未授权微信小程序,需要先完成授权"
description="点击右上角「去授权」后,会在新小窗口中打开微信授权页;完成授权后本页会自动刷新。"
/>
<div class="mp-empty">
<el-empty description="暂无微信小程序配置">
<el-button type="primary" :loading="authUrlLoading" @click="handleAuthorize">
去授权
</el-button>
</el-empty>
</div>
</template>
<!-- ===== 已授权:只读回显 ===== -->
<template v-else-if="authorized">
<section class="mp-panel">
<header class="mp-panel__head">
<h3 class="mp-panel__title">小程序信息</h3>
<p class="mp-panel__desc">来源:setting.warehouse.getweChatApp(如需变更请重新授权)</p>
</header>
<el-descriptions :column="2" border size="small" class="mp-descriptions">
<el-descriptions-item
v-for="item in infoItems"
:key="`mp-info-${item.key}`"
:label="item.label"
:span="item.wide ? 2 : 1"
>
<div class="mp-value">
<el-image
v-if="item.isImage"
:src="item.value"
fit="contain"
class="mp-value__image"
>
<template #error><span class="mp-value__tip">{{ item.value }}</span></template>
</el-image>
<el-tag v-else-if="item.isStatus" :type="item.statusType" size="small" effect="light">
{{ item.value }}
</el-tag>
<span v-else class="mp-value__text" :title="item.value">{{ item.value }}</span>
<el-button
v-if="item.isSecret"
link
type="primary"
size="small"
@click="copyText(config[item.key])"
>复制</el-button>
</div>
</el-descriptions-item>
</el-descriptions>
</section>
<!-- 未纳管字段(后端新增字段自动展示,便于核对) -->
<section v-if="otherItems.length" class="mp-panel">
<header class="mp-panel__head">
<h3 class="mp-panel__title">其他信息</h3>
<p class="mp-panel__desc">接口返回的其余字段</p>
</header>
<el-descriptions :column="2" border size="small" class="mp-descriptions">
<el-descriptions-item
v-for="item in otherItems"
:key="`mp-other-${item.key}`"
:label="item.label"
:span="item.wide ? 2 : 1"
>
<div class="mp-value">
<el-image
v-if="item.isImage"
:src="item.value"
fit="contain"
class="mp-value__image"
>
<template #error><span class="mp-value__tip">{{ item.value }}</span></template>
</el-image>
<span v-else class="mp-value__text" :title="item.value">{{ item.value }}</span>
<el-button
v-if="item.isSecret"
link
type="primary"
size="small"
@click="copyText(config[item.key])"
>复制</el-button>
</div>
</el-descriptions-item>
</el-descriptions>
</section>
</template>
</div>
</template>
<script setup lang="ts">
import { computed, onBeforeUnmount, onMounted, ref } from 'vue'
import { ElMessage } from 'element-plus'
import {
settingWarehouseGetWeChatApp,
unwrapSettingWarehousePayload
} from '@/api/setting.warehouse/settingwarehouse'
import { wechatGetAuthUrl } from '@/api/wechat/wechat'
defineOptions({ name: 'MiniProgramConfigForm' })
const okCode = (code: unknown) => code === 1 || code === 200 || code === 0
// ============================================================
// 常量
// ============================================================
/** 与「已授权」判定无关的字段(未授权时后端只回这些,不应视为已配置) */
const NEUTRAL_KEYS = new Set([
'id',
'warehouse_id',
'code',
'message',
'msg',
'data',
'created_at',
'updated_at'
])
/** 已知字段展示映射(按顺序取第一个命中且非空的字段;后端字段名以后端为准,多形态兼容) */
type FieldDefinition = {
label: string
keys: string[]
wide?: boolean
/** 值翻译(如 1=启用 / 0=停用) */
valueMap?: Record<string, string>
/** 用 el-tag 渲染 */
tag?: boolean
}
const FIELD_DEFINITIONS: FieldDefinition[] = [
{ label: '小程序名称', keys: ['nickname', 'nick_name', 'mini_name', 'app_name', 'authorizer_nick_name', 'name'] },
{ label: 'AppID', keys: ['appid', 'app_id', 'authorizer_appid', 'mini_appid'] },
{ label: 'AppSecret', keys: ['app_secret', 'appsecret', 'secret', 'authorizer_secret'] },
{ label: '原始ID', keys: ['user_name', 'original_id', 'gh_id', 'username'] },
{ label: '主体名称', keys: ['principal_name', 'principal'] },
{ label: '微信号/别名', keys: ['alias', 'wechat_id'] },
{
label: '启用状态',
keys: ['is_enabled', 'enabled'],
valueMap: { '1': '启用', '0': '停用' },
tag: true
},
{ label: '授权状态', keys: ['auth_status', 'status', 'is_authorized', 'authorized'], tag: true },
{ label: '所属仓库', keys: ['warehouse_id'] },
{ label: '授权码', keys: ['authorization_code', 'auth_code'] },
{ label: '授权时间', keys: ['auth_time', 'authorized_at', 'authorize_time', 'auth_at'] },
{ label: '到期时间', keys: ['expires_at', 'expire_time', 'authorization_expires_at', 'expired_at'] },
{ label: '授权功能集', keys: ['func_info'], wide: true },
{ label: '头像/二维码', keys: ['head_img', 'headimgurl', 'head_img_url', 'qrcode_url', 'avatar'] },
{ label: '记录ID', keys: ['id'] },
{ label: '更新时间', keys: ['updated_at'] },
{ label: '创建时间', keys: ['created_at'] }
]
/** 授权链接可能的字段名(按优先级取值) */
const AUTH_URL_KEYS = [
'url',
'auth_url',
'authUrl',
'authorize_url',
'authorizeUrl',
'authorization_url',
'redirect_url',
'link'
]
/** 授权小窗打开后的轮询间隔 / 最长时长 */
const AUTH_WATCH_INTERVAL = 3000
const AUTH_WATCH_MAX_DURATION = 5 * 60 * 1000
/** 需要打码 + 支持复制的字段 */
const SECRET_KEY_PATTERN = /secret|token|key|password/i
/** 视为图片地址的字段 */
const IMAGE_KEY_PATTERN = /img|image|avatar|logo|qrcode|qr_code/i
type DisplayItem = {
key: string
label: string
value: string
wide?: boolean
isImage: boolean
isSecret: boolean
isStatus: boolean
statusType: 'success' | 'info' | 'warning' | 'danger'
}
// ============================================================
// 状态
// ============================================================
const pageLoading = ref(false)
const authUrlLoading = ref(false)
const config = ref<Record<string, unknown>>({})
const lastLoadedAt = ref('')
/** 授权小窗句柄与轮询计时器 */
let authWindow: Window | null = null
let authWatchTimer: number | null = null
let authWatchStartedAt = 0
let authWatchBusy = false
// ============================================================
// 取值 / 归一化
// ============================================================
/** 非空判定:null/undefined/空串/空数组/空对象均视为空 */
function isEmptyValue(value: unknown): boolean {
if (value === null || value === undefined) return true
if (typeof value === 'string') return value.trim() === ''
if (Array.isArray(value)) return value.length === 0
if (typeof value === 'object') return Object.keys(value as Record<string, unknown>).length === 0
return false
}
/** 展示文本归一化(对象/数组转 JSON 字符串) */
function toDisplayText(value: unknown): string {
if (value === null || value === undefined) return ''
if (typeof value === 'object') {
try {
return JSON.stringify(value)
} catch {
return String(value)
}
}
return String(value)
}
/** 敏感值打码:保留前 4 / 后 4 位 */
function maskSecret(text: string): string {
if (text.length <= 8) return '******'
return `${text.slice(0, 4)}******${text.slice(-4)}`
}
/** 配置中的有效字段(剔除 meta / neutral 字段,且值非空) */
const entries = computed<[string, unknown][]>(() =>
Object.entries(config.value).filter(([key, value]) => {
const lower = key.toLowerCase()
if (NEUTRAL_KEYS.has(lower) && isEmptyValue(value)) return false
return !isEmptyValue(value)
})
)
/** 是否已授权:存在任一「非中性」且有值的字段即视为已配置 */
const authorized = computed(() =>
entries.value.some(([key]) => !NEUTRAL_KEYS.has(key.toLowerCase()))
)
/** 已命中展示映射的字段 key(避免在「其他信息」重复展示) */
const mappedKeys = computed(() => {
const used = new Set<string>()
const keys = new Set(entries.value.map(([key]) => key))
for (const def of FIELD_DEFINITIONS) {
const hit = def.keys.find((key) => keys.has(key))
if (hit) used.add(hit)
}
return used
})
function buildItem(def: FieldDefinition, key: string, rawValue: unknown): DisplayItem {
const rawText = toDisplayText(rawValue)
const mappedText = def.valueMap ? (def.valueMap[rawText] ?? rawText) : rawText
const displayText = formatDateTimeValue(mappedText)
const isSecret = SECRET_KEY_PATTERN.test(key)
const isImage = IMAGE_KEY_PATTERN.test(key) && /^https?:\/\//i.test(rawText)
const isStatus = Boolean(def.tag)
return {
key,
label: def.label,
value: isSecret ? maskSecret(displayText) : displayText,
wide: def.wide,
isImage,
isSecret,
isStatus,
statusType: resolveStatusType(rawText, mappedText)
}
}
/** ISO 时间(2026-09-21T18:14:44.000Z)统一展示为本地 YYYY-MM-DD HH:mm:ss */
function formatDateTimeValue(text: string): string {
if (!/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}/.test(text)) return text
const date = new Date(text)
if (Number.isNaN(date.getTime())) return text
const pad = (num: number) => String(num).padStart(2, '0')
return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())} ${pad(date.getHours())}:${pad(date.getMinutes())}:${pad(date.getSeconds())}`
}
/** 状态类标签颜色(先看翻译后的中文,再看原值) */
function resolveStatusType(rawText: string, mappedText: string): DisplayItem['statusType'] {
const text = mappedText || rawText
if (/停用|禁用|失败|异常|无效|过期|未授权|false|^0$/i.test(text)) return 'danger'
if (/启用|正常|成功|已授权|是|true|^1$/i.test(text)) return 'success'
return 'info'
}
/** 已知字段展示项 */
const infoItems = computed<DisplayItem[]>(() => {
const items: DisplayItem[] = []
for (const def of FIELD_DEFINITIONS) {
const hit = def.keys.find((key) => !isEmptyValue(config.value[key]))
if (!hit) continue
items.push(buildItem(def, hit, config.value[hit]))
}
return items
})
/** 其余字段展示项(后端新增字段兜底展示) */
const otherItems = computed<DisplayItem[]>(() =>
entries.value
.filter(([key]) => !mappedKeys.value.has(key))
.map(([key, value]) =>
buildItem(
{ label: key, keys: [key], wide: toDisplayText(value).length > 60 },
key,
value
)
)
)
// ============================================================
// 拉取配置
// ============================================================
async function loadConfig(options: { silent?: boolean } = {}) {
if (!options.silent) pageLoading.value = true
try {
const res: any = await settingWarehouseGetWeChatApp()
if (!res || !okCode(res.code)) {
if (!options.silent) ElMessage.error(res?.message || '获取微信小程序配置失败')
return
}
// 未授权时后端返回 data:null(不能用整包 res 兜底,否则 flag/timestamp 会被误判为已配置)
const payload = res.data
config.value =
payload && typeof payload === 'object' && !Array.isArray(payload)
? (payload as Record<string, unknown>)
: {}
lastLoadedAt.value = new Date().toLocaleTimeString('zh-CN', { hour12: false })
return config.value
} catch (e: unknown) {
if (!options.silent) {
ElMessage.error(e instanceof Error ? e.message : '获取微信小程序配置失败')
}
} finally {
if (!options.silent) pageLoading.value = false
}
}
// ============================================================
// 授权(点击按钮后才获取链接并弹小窗)
// ============================================================
/** 从响应中取授权链接(字段名多形态兼容,兜底扫描 http 开头的字符串) */
function pickAuthUrl(raw: Record<string, unknown>): string {
for (const key of AUTH_URL_KEYS) {
const value = raw[key]
if (typeof value === 'string' && /^https?:\/\//i.test(value.trim())) return value.trim()
}
for (const value of Object.values(raw)) {
if (typeof value === 'string' && /^https?:\/\//i.test(value.trim())) return value.trim()
}
return ''
}
/** 在新小窗口中打开授权链接 */
function openAuthWindow(url: string) {
const width = 760
const height = 780
const left = Math.max(0, Math.round((window.screen.width - width) / 2))
const top = Math.max(0, Math.round((window.screen.height - height) / 2))
const features = `width=${width},height=${height},left=${left},top=${top},resizable=yes,scrollbars=yes`
authWindow = window.open(url, 'wx-miniprogram-authorize', features)
if (!authWindow) {
ElMessage.warning('授权窗口被浏览器拦截:请允许本站弹出窗口后重试')
return
}
ElMessage.info('请在新打开的小窗口中完成微信授权,完成后本页会自动刷新')
startAuthWatch()
}
/** 点击「去授权」:获取授权链接 → 打开小窗 */
async function handleAuthorize() {
authUrlLoading.value = true
try {
const res: any = await wechatGetAuthUrl()
if (!res || !okCode(res.code)) {
ElMessage.error(res?.message || '获取微信授权链接失败')
return
}
const url = pickAuthUrl({ ...unwrapSettingWarehousePayload(res) })
if (!url) {
ElMessage.error('未获取到授权链接,请稍后重试')
return
}
openAuthWindow(url)
} catch (e: unknown) {
ElMessage.error(e instanceof Error ? e.message : '获取微信授权链接失败')
} finally {
authUrlLoading.value = false
}
}
/** 授权小窗打开期间轮询配置:授权完成即自动刷新 */
function startAuthWatch() {
stopAuthWatch()
authWatchStartedAt = Date.now()
authWatchTimer = window.setInterval(async () => {
if (authWatchBusy) return
if (Date.now() - authWatchStartedAt > AUTH_WATCH_MAX_DURATION) {
stopAuthWatch()
return
}
// 小窗已关闭:做最后一次刷新后停止
if (authWindow && authWindow.closed) {
stopAuthWatch()
authWindow = null
await loadConfig({ silent: true })
return
}
authWatchBusy = true
try {
const payload = await loadConfig({ silent: true })
if (payload && Object.entries(payload).some(([key, value]) => !NEUTRAL_KEYS.has(key.toLowerCase()) && !isEmptyValue(value))) {
stopAuthWatch()
ElMessage.success('微信小程序授权成功,配置已刷新')
}
} finally {
authWatchBusy = false
}
}, AUTH_WATCH_INTERVAL)
}
function stopAuthWatch() {
if (authWatchTimer !== null) {
window.clearInterval(authWatchTimer)
authWatchTimer = null
}
}
/** 复制文本 */
async function copyText(value: unknown) {
const text = toDisplayText(value).trim()
if (!text) {
ElMessage.warning('无内容可复制')
return
}
try {
await navigator.clipboard.writeText(text)
ElMessage.success('已复制到剪贴板')
} catch {
ElMessage.warning('复制失败,请手动选中复制')
}
}
onMounted(() => {
void loadConfig()
})
onBeforeUnmount(() => {
stopAuthWatch()
})
</script>
<style lang="scss" scoped>
.mp-config-page {
padding: 12px 16px 24px;
box-sizing: border-box;
background: #fff;
}
.settings-header {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
flex-wrap: wrap;
margin-bottom: 12px;
}
.header-text {
display: flex;
flex-direction: column;
gap: 4px;
}
.title {
font-size: 16px;
font-weight: 600;
color: #303133;
}
.sub {
font-size: 13px;
color: #909399;
}
.header-actions {
display: flex;
gap: 8px;
}
.mp-config-alert {
margin-bottom: 16px;
}
.mp-empty {
border: 1px solid #ebeef5;
border-radius: 6px;
padding: 24px 16px;
background: #fff;
}
.mp-panel {
border: 1px solid #ebeef5;
border-radius: 6px;
padding: 12px 16px;
margin-bottom: 16px;
background: #fff;
}
.mp-panel__head {
margin-bottom: 12px;
}
.mp-panel__title {
margin: 0;
font-size: 14px;
font-weight: 600;
color: #303133;
}
.mp-panel__desc {
margin: 4px 0 0;
font-size: 12px;
color: #909399;
line-height: 18px;
}
.mp-descriptions {
max-width: 900px;
}
.mp-value {
display: flex;
align-items: center;
gap: 8px;
min-width: 0;
}
.mp-value__text {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.mp-value__image {
width: 48px;
height: 48px;
border-radius: 4px;
background: #f5f7fa;
}
.mp-value__tip {
font-size: 12px;
color: #c0c4cc;
}
</style>

View File

@ -0,0 +1,48 @@
<!--
微信小程序配置 — 独立页面(备用)
说明:
1) 与「系统设置 → 基础管理 → 微信小程序」标签页共用同一套组件
(basicManagement/newview/pages/MiniProgramConfigForm.vue),避免双份维护。
2) 本页作为独立菜单/路由入口备用:后端菜单配置 component 为
system/setting/miniprogram/index(或 system/setting/miniprogram)时即可访问,
见 src/router/map.ts 的 componentMap。
3) 数据来源:setting.warehouse.getweChatApp(拉取已授权的小程序配置);
未配置时提示需要授权,点击「去授权」后由 wechat.getAuthUrl 取链接并在新小窗打开。
-->
<template>
<div class="miniprogram-page" :style="{ height: containerHeight }">
<div class="miniprogram-page__body">
<MiniProgramConfigForm />
</div>
</div>
</template>
<script setup lang="ts">
import { computed } from 'vue'
import { useSettingsStore } from '@/stores/modules/settings'
import MiniProgramConfigForm from '@/views/system/setting/basicManagement/newview/pages/MiniProgramConfigForm.vue'
defineOptions({ name: 'MiniProgramSetting' })
const settingsStore = useSettingsStore()
const shortcutExpanded = computed(() => settingsStore.shortcutExpanded)
const containerHeight = computed(() =>
shortcutExpanded.value ? 'calc(100vh - 150px)' : 'calc(100vh - 100px)'
)
</script>
<style lang="scss" scoped>
.miniprogram-page {
display: flex;
flex-direction: column;
box-sizing: border-box;
background: #fff;
overflow: hidden;
}
.miniprogram-page__body {
flex: 1;
min-height: 0;
overflow: auto;
}
</style>