feat(shop): 新增商城基础设置组件
- 新增商城基础信息配置界面支持店铺名称、Logo、描述、电话、地址和开关配置 - 实现图片选择和删除功能,支持Logo的上传回显 - 集成表单校验和保存接口调用,提供保存状态反馈 - 优化响应式布局适配不同屏幕尺寸 fix(cms): 防止文章编辑内容的XSS攻击 - 在文章编辑组件中对动态HTML内容添加DOMPurify消毒 - 替换 v-html 渲染为安全消毒后的内容展现 - 确保富文本内容安全,防止跨站脚本漏洞 refactor(system-setting): 优化系统设置基本信息组件逻辑 - 替换ico文件上传组件,改用SelectFile实现图片选择和删除功能 - 简化图标上传流程,移除上传接口调用相关代码 - 统一表单数据处理,增强设置数据解析和回显兼容性 - 调整保存逻辑,支持根据是否存在主键调用新增或更新接口 - 改进watch数据响应逻辑,支持多种数据结构兼容 fix(system-setting): 修正清理设置组件数据重置逻辑 - 统一清理设置组件的 settingKey 值为 clear,避免混淆 - 优化数据监听回调,支持不同数据结构和空数据重置表单 - 确保组件初始化状态正确,避免遗留数据影响展示 fix(store): 修正 chat store 定义方式 - 按 pinia 官方规范简化 store 定义参数 - 修复 store id 错误传递问题,确保正确注册和使用
This commit is contained in:
56
scripts/antd4-less-compat.js
Normal file
56
scripts/antd4-less-compat.js
Normal file
@@ -0,0 +1,56 @@
|
||||
/**
|
||||
* AntDv4 兼容:替换 ele-admin-pro Less 中的 colorPalette JS 调用
|
||||
* AntDv4 移除了 Less 的 colorPalette 函数,此脚本在 postinstall 时
|
||||
* 将 common.less 中的 ~`colorPalette(...)` 替换为实际颜色值。
|
||||
*/
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const rootDir = path.resolve(__dirname, '..');
|
||||
|
||||
// 尝试多个可能的位置(pnpm 的 .pnpm store 和直接链接)
|
||||
const possiblePaths = [
|
||||
path.join(rootDir, 'node_modules/ele-admin-pro/es/style/common.less'),
|
||||
path.join(rootDir, 'node_modules/.pnpm/node_modules/ele-admin-pro/es/style/common.less'),
|
||||
];
|
||||
|
||||
// 也搜索 .pnpm 目录下的实际路径
|
||||
const pnpmDir = path.join(rootDir, 'node_modules/.pnpm');
|
||||
if (fs.existsSync(pnpmDir)) {
|
||||
const entries = fs.readdirSync(pnpmDir).filter(e => e.startsWith('ele-admin-pro'));
|
||||
for (const entry of entries) {
|
||||
possiblePaths.push(path.join(pnpmDir, entry, 'node_modules/ele-admin-pro/es/style/common.less'));
|
||||
}
|
||||
}
|
||||
|
||||
let filePath = null;
|
||||
for (const p of possiblePaths) {
|
||||
if (fs.existsSync(p)) {
|
||||
filePath = p;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!fs.existsSync(filePath)) {
|
||||
console.log('[antd4-compat] common.less not found, skipping');
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
let content = fs.readFileSync(filePath, 'utf8');
|
||||
const original = content;
|
||||
|
||||
const primaryColors = { 1: '#e6f4ff', 2: '#bae0ff', 3: '#91caff', 4: '#69b1ff', 5: '#4096ff', 6: '#1677ff', 7: '#0958d9', 8: '#003eb3', 9: '#002c8c', 10: '#001d66' };
|
||||
const successColors = { 1: '#f6ffed', 2: '#d9f7be', 3: '#b7eb8f', 4: '#95de64', 5: '#73d13d', 6: '#52c41a', 7: '#389e0d', 8: '#237804', 9: '#135200', 10: '#092b00' };
|
||||
const warningColors = { 1: '#fffbe6', 2: '#fff1b8', 3: '#ffe58f', 4: '#ffd666', 5: '#ffc53d', 6: '#faad14', 7: '#d48806', 8: '#ad6800', 9: '#874d00', 10: '#612500' };
|
||||
const errorColors = { 1: '#fff2f0', 2: '#ffccc7', 3: '#ffa39e', 4: '#ff7875', 5: '#ff4d4f', 6: '#f5222d', 7: '#cf1322', 8: '#a8071a', 9: '#820014', 10: '#5c0011' };
|
||||
|
||||
content = content.replace(/~`colorPalette\('@\{primary-color\}',\s*(\d+)\)\s*`/g, (m, idx) => primaryColors[idx] || '#1677ff');
|
||||
content = content.replace(/~`colorPalette\('@\{success-color\}',\s*(\d+)\)\s*`/g, (m, idx) => successColors[idx] || '#52c41a');
|
||||
content = content.replace(/~`colorPalette\('@\{warning-color\}',\s*(\d+)\)\s*`/g, (m, idx) => warningColors[idx] || '#faad14');
|
||||
content = content.replace(/~`colorPalette\('@\{error-color\}',\s*(\d+)\)\s*`/g, (m, idx) => errorColors[idx] || '#ff4d4f');
|
||||
|
||||
if (content !== original) {
|
||||
fs.writeFileSync(filePath, content);
|
||||
console.log('[antd4-compat] Replaced colorPalette calls in common.less');
|
||||
} else {
|
||||
console.log('[antd4-compat] No colorPalette calls found, skipping');
|
||||
}
|
||||
73
scripts/fix-ele-admin-pro.sh
Executable file
73
scripts/fix-ele-admin-pro.sh
Executable file
@@ -0,0 +1,73 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Post-install script to fix ele-admin-pro compatibility with AntDv4
|
||||
# This script replaces colorPalette() calls with hardcoded color values
|
||||
|
||||
echo "🔧 Fixing ele-admin-pro for AntDv4 compatibility..."
|
||||
|
||||
ELE_ADMIN_PATH="node_modules/ele-admin-pro"
|
||||
|
||||
if [ ! -d "$ELE_ADMIN_PATH" ]; then
|
||||
echo "⚠️ ele-admin-pro not found in node_modules, skipping fix"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Find all Less files with colorPalette calls and fix them
|
||||
find "$ELE_ADMIN_PATH" -name "*.less" -type f | while read file; do
|
||||
if grep -q "colorPalette" "$file" 2>/dev/null; then
|
||||
echo " 🔨 Fixing: $file"
|
||||
|
||||
# Replace primary color palette
|
||||
sed -i.bak "s/~colorPalette('@\{primary-color\}',[[:space:]]*1)/#e6f4ff/g" "$file"
|
||||
sed -i.bak "s/~colorPalette('@\{primary-color\}',[[:space:]]*2)/#bae0ff/g" "$file"
|
||||
sed -i.bak "s/~colorPalette('@\{primary-color\}',[[:space:]]*3)/#91caff/g" "$file"
|
||||
sed -i.bak "s/~colorPalette('@\{primary-color\}',[[:space:]]*4)/#69b1ff/g" "$file"
|
||||
sed -i.bak "s/~colorPalette('@\{primary-color\}',[[:space:]]*5)/#4096ff/g" "$file"
|
||||
sed -i.bak "s/~colorPalette('@\{primary-color\}',[[:space:]]*6)/#1677ff/g" "$file"
|
||||
sed -i.bak "s/~colorPalette('@\{primary-color\}',[[:space:]]*7)/#0958d9/g" "$file"
|
||||
sed -i.bak "s/~colorPalette('@\{primary-color\}',[[:space:]]*8)/#003eb3/g" "$file"
|
||||
sed -i.bak "s/~colorPalette('@\{primary-color\}',[[:space:]]*9)/#002c8c/g" "$file"
|
||||
sed -i.bak "s/~colorPalette('@\{primary-color\}',[[:space:]]*10)/#001d66/g" "$file"
|
||||
|
||||
# Replace success color palette
|
||||
sed -i.bak "s/~colorPalette('@\{success-color\}',[[:space:]]*1)/#f6ffed/g" "$file"
|
||||
sed -i.bak "s/~colorPalette('@\{success-color\}',[[:space:]]*2)/#d9f7be/g" "$file"
|
||||
sed -i.bak "s/~colorPalette('@\{success-color\}',[[:space:]]*3)/#b7eb8f/g" "$file"
|
||||
sed -i.bak "s/~colorPalette('@\{success-color\}',[[:space:]]*4)/#95de64/g" "$file"
|
||||
sed -i.bak "s/~colorPalette('@\{success-color\}',[[:space:]]*5)/#73d13d/g" "$file"
|
||||
sed -i.bak "s/~colorPalette('@\{success-color\}',[[:space:]]*6)/#52c41a/g" "$file"
|
||||
sed -i.bak "s/~colorPalette('@\{success-color\}',[[:space:]]*7)/#389e0d/g" "$file"
|
||||
sed -i.bak "s/~colorPalette('@\{success-color\}',[[:space:]]*8)/#237804/g" "$file"
|
||||
sed -i.bak "s/~colorPalette('@\{success-color\}',[[:space:]]*9)/#135200/g" "$file"
|
||||
sed -i.bak "s/~colorPalette('@\{success-color\}',[[:space:]]*10)/#092b00/g" "$file"
|
||||
|
||||
# Replace warning color palette
|
||||
sed -i.bak "s/~colorPalette('@\{warning-color\}',[[:space:]]*1)/#fffbe6/g" "$file"
|
||||
sed -i.bak "s/~colorPalette('@\{warning-color\}',[[:space:]]*2)/#fff1b8/g" "$file"
|
||||
sed -i.bak "s/~colorPalette('@\{warning-color\}',[[:space:]]*3)/#ffe58f/g" "$file"
|
||||
sed -i.bak "s/~colorPalette('@\{warning-color\}',[[:space:]]*4)/#ffd666/g" "$file"
|
||||
sed -i.bak "s/~colorPalette('@\{warning-color\}',[[:space:]]*5)/#ffc53d/g" "$file"
|
||||
sed -i.bak "s/~colorPalette('@\{warning-color\}',[[:space:]]*6)/#faad14/g" "$file"
|
||||
sed -i.bak "s/~colorPalette('@\{warning-color\}',[[:space:]]*7)/#d48806/g" "$file"
|
||||
sed -i.bak "s/~colorPalette('@\{warning-color\}',[[:space:]]*8)/#ad6800/g" "$file"
|
||||
sed -i.bak "s/~colorPalette('@\{warning-color\}',[[:space:]]*9)/#874d00/g" "$file"
|
||||
sed -i.bak "s/~colorPalette('@\{warning-color\}',[[:space:]]*10)/#612500/g" "$file"
|
||||
|
||||
# Replace error color palette
|
||||
sed -i.bak "s/~colorPalette('@\{error-color\}',[[:space:]]*1)/#fff2f0/g" "$file"
|
||||
sed -i.bak "s/~colorPalette('@\{error-color\}',[[:space:]]*2)/#ffccc7/g" "$file"
|
||||
sed -i.bak "s/~colorPalette('@\{error-color\}',[[:space:]]*3)/#ffa39e/g" "$file"
|
||||
sed -i.bak "s/~colorPalette('@\{error-color\}',[[:space:]]*4)/#ff7875/g" "$file"
|
||||
sed -i.bak "s/~colorPalette('@\{error-color\}',[[:space:]]*5)/#ff4d4f/g" "$file"
|
||||
sed -i.bak "s/~colorPalette('@\{error-color\}',[[:space:]]*6)/#f5222d/g" "$file"
|
||||
sed -i.bak "s/~colorPalette('@\{error-color\}',[[:space:]]*7)/#cf1322/g" "$file"
|
||||
sed -i.bak "s/~colorPalette('@\{error-color\}',[[:space:]]*8)/#a8071a/g" "$file"
|
||||
sed -i.bak "s/~colorPalette('@\{error-color\}',[[:space:]]*9)/#820014/g" "$file"
|
||||
sed -i.bak "s/~colorPalette('@\{error-color\}',[[:space:]]*10)/#5c0011/g" "$file"
|
||||
|
||||
# Remove backup files
|
||||
rm -f "$file.bak"
|
||||
fi
|
||||
done
|
||||
|
||||
echo "✅ Fixed ele-admin-pro for AntDv4 compatibility"
|
||||
217
scripts/scan-missing-less-vars.py
Normal file
217
scripts/scan-missing-less-vars.py
Normal file
@@ -0,0 +1,217 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Scan ele-admin-pro Less files for AntDv3 variable references,
|
||||
then add missing variables to antd-less-stub/default.less
|
||||
"""
|
||||
import re
|
||||
import os
|
||||
import sys
|
||||
|
||||
# Paths
|
||||
ELE_ADMIN_PATH = "/Users/gxwebsoft/VUE/paopao-vue/node_modules/.pnpm/ele-admin-pro@1.11.1_ant-design-vue@4.2.6_vue@3.5.3_typescript@5.9.3___vue@3.5.3_typescript@5.9.3_/node_modules/ele-admin-pro/es"
|
||||
STUB_FILE = "/Users/gxwebsoft/VUE/paopao-vue/src/styles/antd-less-stub/default.less"
|
||||
|
||||
# Common AntDv3 variable default values
|
||||
ANTDV3_DEFAULTS = {
|
||||
# Select
|
||||
'select-multiple-item-height': '24px',
|
||||
'select-multiple-item-spacing-half': '4px',
|
||||
'select-selection-item-bg': '#f5f5f5',
|
||||
'select-selection-item-border-color': '#d9d9d9',
|
||||
'select-selection-item-disabled-color': 'rgba(0, 0, 0, 0.25)',
|
||||
'select-selection-item-disabled-border-color': '#d9d9d9',
|
||||
'select-background': '#ffffff',
|
||||
'select-border-color': '#d9d9d9',
|
||||
'select-dropdown-bg': '#ffffff',
|
||||
'select-dropdown-height': '200px',
|
||||
'select-clear-width': '20px',
|
||||
'select-padding-horizontal': '12px',
|
||||
'select-font-size': '14px',
|
||||
# Input
|
||||
'input-padding-vertical-base': '4px',
|
||||
'input-padding-horizontal-base': '12px',
|
||||
'input-height-base': '32px',
|
||||
'input-placeholder-color': 'rgba(0, 0, 0, 0.25)',
|
||||
'input-color': 'rgba(0, 0, 0, 0.88)',
|
||||
'input-border-color': '#d9d9d9',
|
||||
'input-bg': '#ffffff',
|
||||
'input-disabled-bg': '#f5f5f5',
|
||||
'input-hover-border-color': '#1677ff',
|
||||
'input-focus-border-color': '#1677ff',
|
||||
# Form
|
||||
'form-item-margin-bottom': '24px',
|
||||
'form-vertical-label-padding': '0 0 8px',
|
||||
'form-vertical-label-margin': '0',
|
||||
'form-item-label-width': 'auto',
|
||||
'form-item-label-margin-right': '8px',
|
||||
# Button
|
||||
'btn-height-base': '32px',
|
||||
'btn-height-lg': '40px',
|
||||
'btn-height-sm': '24px',
|
||||
'btn-font-size-base': '14px',
|
||||
'btn-font-size-lg': '16px',
|
||||
'btn-font-size-sm': '12px',
|
||||
'btn-padding-horizontal-base': '15px',
|
||||
'btn-padding-horizontal-lg': '23px',
|
||||
'btn-padding-horizontal-sm': '7px',
|
||||
'btn-border-radius-base': '6px',
|
||||
'btn-primary-bg': '#1677ff',
|
||||
'btn-primary-color': '#fff',
|
||||
'btn-default-bg': '#ffffff',
|
||||
'btn-default-color': 'rgba(0, 0, 0, 0.88)',
|
||||
'btn-default-border-color': '#d9d9d9',
|
||||
# Menu
|
||||
'menu-item-height': '40px',
|
||||
'menu-inline-toplevel-item-height': '40px',
|
||||
'menu-collapsed-width': '80px',
|
||||
'menu-bg': '#ffffff',
|
||||
'menu-item-color': 'rgba(0, 0, 0, 0.65)',
|
||||
'menu-highlight-color': '#1677ff',
|
||||
'menu-item-active-bg': '#e6f4ff',
|
||||
# Table
|
||||
'table-header-bg': '#fafafa',
|
||||
'table-header-color': 'rgba(0, 0, 0, 0.88)',
|
||||
'table-row-hover-bg': '#fafafa',
|
||||
'table-border-color': '#f0f0f0',
|
||||
'table-header-cell-split-color': '#f0f0f0',
|
||||
'table-padding-vertical': '8px',
|
||||
'table-padding-horizontal': '8px',
|
||||
# Modal
|
||||
'modal-header-padding': '16px 24px',
|
||||
'modal-content-bg': '#ffffff',
|
||||
'modal-heading-color': 'rgba(0, 0, 0, 0.88)',
|
||||
'modal-close-color': 'rgba(0, 0, 0, 0.45)',
|
||||
'modal-mask-bg': 'rgba(0, 0, 0, 0.45)',
|
||||
# Layout
|
||||
'layout-header-height': '64px',
|
||||
'layout-sider-width': '200px',
|
||||
'layout-trigger-height': '48px',
|
||||
# Checkbox
|
||||
'checkbox-check-color': '#fff',
|
||||
# Radio
|
||||
'radio-dot-size': '8px',
|
||||
'radio-dot-color': '#1677ff',
|
||||
# Switch
|
||||
'switch-height': '22px',
|
||||
'switch-small-height': '16px',
|
||||
'switch-min-width': '44px',
|
||||
# Slider
|
||||
'slider-rail-height': '4px',
|
||||
'slider-handle-size': '14px',
|
||||
'slider-dot-border-color': '#d9d9d9',
|
||||
# DatePicker
|
||||
'datepicker-bg': '#ffffff',
|
||||
'datepicker-border-color': '#d9d9d9',
|
||||
# TimePicker
|
||||
'timepicker-bg': '#ffffff',
|
||||
'timepicker-border-color': '#d9d9d9',
|
||||
# Upload
|
||||
'upload-actions-color': 'rgba(0, 0, 0, 0.45)',
|
||||
# Progress
|
||||
'progress-remaining-color': 'rgba(0, 0, 0, 0.04)',
|
||||
# Spin
|
||||
'spin-dot-size': '20px',
|
||||
# Anchor
|
||||
'anchor-border-color': '#f0f0f0',
|
||||
# BackTop
|
||||
'backtop-bg': 'rgba(0, 0, 0, 0.45)',
|
||||
'backtop-color': '#fff',
|
||||
# Typography
|
||||
'typography-title-margin-top': '1.2em',
|
||||
'typography-title-margin-bottom': '0.5em',
|
||||
}
|
||||
|
||||
def find_less_files(base_path):
|
||||
"""Find all .less files in ele-admin-pro"""
|
||||
less_files = []
|
||||
for root, dirs, files in os.walk(base_path):
|
||||
for f in files:
|
||||
if f.endswith('.less'):
|
||||
less_files.append(os.path.join(root, f))
|
||||
return less_files
|
||||
|
||||
def extract_variable_references(less_files):
|
||||
"""Extract all @variable references from Less files (not definitions)"""
|
||||
refs = set()
|
||||
# Pattern matches @var-name not followed by : (not a definition)
|
||||
# Also exclude @{var} interpolation syntax
|
||||
for fpath in less_files:
|
||||
try:
|
||||
with open(fpath, 'r', encoding='utf-8') as f:
|
||||
content = f.read()
|
||||
# Find all @var-name patterns
|
||||
matches = re.findall(r'@([a-zA-Z_][a-zA-Z0-9_-]*)', content)
|
||||
for m in matches:
|
||||
refs.add(m)
|
||||
except Exception as e:
|
||||
print(f"Error reading {fpath}: {e}", file=sys.stderr)
|
||||
return refs
|
||||
|
||||
def get_defined_variables(stub_file):
|
||||
"""Get all variables already defined in stub file"""
|
||||
defined = set()
|
||||
try:
|
||||
with open(stub_file, 'r', encoding='utf-8') as f:
|
||||
content = f.read()
|
||||
# Find all @var: definitions
|
||||
matches = re.findall(r'@([a-zA-Z_][a-zA-Z0-9_-]*)\s*:', content)
|
||||
for m in matches:
|
||||
defined.add(m)
|
||||
except Exception as e:
|
||||
print(f"Error reading stub {stub_file}: {e}", file=sys.stderr)
|
||||
return defined
|
||||
|
||||
def main():
|
||||
print("Scanning ele-admin-pro Less files...")
|
||||
less_files = find_less_files(ELE_ADMIN_PATH)
|
||||
print(f"Found {len(less_files)} .less files")
|
||||
|
||||
print("Extracting variable references...")
|
||||
refs = extract_variable_references(less_files)
|
||||
print(f"Found {len(refs)} unique variable references")
|
||||
|
||||
print("Reading defined variables from stub...")
|
||||
defined = get_defined_variables(STUB_FILE)
|
||||
print(f"Found {len(defined)} already defined variables")
|
||||
|
||||
# Find missing variables
|
||||
missing = refs - defined
|
||||
# Filter out variables that look like JS interpolation (less.js names)
|
||||
missing = {v for v in missing if not v.startswith('_')}
|
||||
|
||||
print(f"\nMissing variables: {len(missing)}")
|
||||
|
||||
if not missing:
|
||||
print("All variables are defined! Nothing to do.")
|
||||
return
|
||||
|
||||
# Generate lines to add
|
||||
lines_to_add = []
|
||||
for var in sorted(missing):
|
||||
if var in ANTDV3_DEFAULTS:
|
||||
default_val = ANTDV3_DEFAULTS[var]
|
||||
lines_to_add.append(f"@{var}: {default_val};")
|
||||
else:
|
||||
# Use empty string as default for unknown variables
|
||||
lines_to_add.append(f"@{var}: ; // FIXME: needs proper value")
|
||||
|
||||
print(f"\nAdding {len(lines_to_add)} variables to stub file...")
|
||||
|
||||
# Read stub file
|
||||
with open(STUB_FILE, 'r', encoding='utf-8') as f:
|
||||
content = f.read()
|
||||
|
||||
# Append missing variables before the end of file
|
||||
append_text = "\n// ========== Auto-added missing variables ==========\n" + "\n".join(lines_to_add) + "\n"
|
||||
|
||||
with open(STUB_FILE, 'a', encoding='utf-8') as f:
|
||||
f.write(append_text)
|
||||
|
||||
print("Done! Added variables:")
|
||||
for line in lines_to_add[:20]:
|
||||
print(f" {line}")
|
||||
if len(lines_to_add) > 20:
|
||||
print(f" ... and {len(lines_to_add) - 20} more")
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
Reference in New Issue
Block a user