Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0b8f873a4c | ||
|
|
d580fc53b9 | ||
|
|
9746be581d |
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "shrimp-admin",
|
"name": "shrimp-admin",
|
||||||
"version": "0.2.0",
|
"version": "0.2.3",
|
||||||
"private": true,
|
"private": true,
|
||||||
"description": "Shrimp 框架前端 — 消费 ShrimpServer + ShrimpTable 契约的经典 Vue3 + Element Plus 实现",
|
"description": "Shrimp 框架前端 — 消费 ShrimpServer + ShrimpTable 契约的经典 Vue3 + Element Plus 实现",
|
||||||
"main": "src/index.ts",
|
"main": "src/index.ts",
|
||||||
|
|||||||
+24
-8
@@ -12,6 +12,22 @@ import { IShrimpResponse, ILabel } from './IShrimpType'
|
|||||||
import { ShrimpClient, handleShrimpResponse, type IShrimpTipper, type IRouteInfo } from './ShrimpClient'
|
import { ShrimpClient, handleShrimpResponse, type IShrimpTipper, type IRouteInfo } from './ShrimpClient'
|
||||||
import FieldString from './components/fields/FieldString.vue'
|
import FieldString from './components/fields/FieldString.vue'
|
||||||
|
|
||||||
|
// ============== 工具 ==============
|
||||||
|
|
||||||
|
/** locale 深合并:嵌套对象按 key 递归 merge,非对象值 src 覆盖 dst。仅服务于 i18n messages,没必要拉 lodash。 */
|
||||||
|
function deepMerge(dst: Record<string, any>, src: Record<string, any>): Record<string, any> {
|
||||||
|
const out: Record<string, any> = { ...dst }
|
||||||
|
for (const key in src) {
|
||||||
|
const sv = src[key], dv = out[key]
|
||||||
|
if (sv && typeof sv === 'object' && !Array.isArray(sv) && dv && typeof dv === 'object' && !Array.isArray(dv)) {
|
||||||
|
out[key] = deepMerge(dv, sv)
|
||||||
|
} else {
|
||||||
|
out[key] = sv
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return out
|
||||||
|
}
|
||||||
|
|
||||||
// ============== Options ==============
|
// ============== Options ==============
|
||||||
|
|
||||||
export interface ShrimpAdminConfig {
|
export interface ShrimpAdminConfig {
|
||||||
@@ -169,14 +185,14 @@ export class VueAdmin extends ShrimpClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
initI18n(extraLocales?: Record<string, any>) {
|
initI18n(extraLocales?: Record<string, any>) {
|
||||||
const merged: Record<string, any> = {
|
// 深合并:框架自带 locale 在底,业务侧叠在上。
|
||||||
'zh-cn': { ...zh_cn, ...(extraLocales?.['zh-cn'] || {}) },
|
// 旧版用 spread 浅合并,业务侧只要定义了同名一级键(如 user)就会把框架的 user.* 全部替换,
|
||||||
'en': { ...en, ...(extraLocales?.['en'] || {}) },
|
// 表现是控制台 [intlify] Not found 'user.operationLog' key 之类的报错。
|
||||||
}
|
const builtins: Record<string, any> = { 'zh-cn': zh_cn, 'en': en }
|
||||||
if (extraLocales) {
|
const merged: Record<string, any> = {}
|
||||||
for (const key in extraLocales) {
|
const langs = new Set([...Object.keys(builtins), ...Object.keys(extraLocales || {})])
|
||||||
if (!(key in merged)) merged[key] = extraLocales[key]
|
for (const lang of langs) {
|
||||||
}
|
merged[lang] = deepMerge(builtins[lang] || {}, extraLocales?.[lang] || {})
|
||||||
}
|
}
|
||||||
this.i18n = createI18n({
|
this.i18n = createI18n({
|
||||||
locale: this.localData.get("lang") || 'zh-cn',
|
locale: this.localData.get("lang") || 'zh-cn',
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ function buildRules(field: IFieldConfig): FormItemRule[] {
|
|||||||
if (field.required) {
|
if (field.required) {
|
||||||
rules.push({
|
rules.push({
|
||||||
required: true,
|
required: true,
|
||||||
message: vueAdmin.t('shrimp.fieldRequired'),
|
message: vueAdmin.t({ t: 'shrimp.fieldRequired', params: { field: field.label } }),
|
||||||
trigger: 'change',
|
trigger: 'change',
|
||||||
...(field.type === 'string' || field.type === 'textarea' || field.type === 'password' ? { trigger: 'blur' } : {}),
|
...(field.type === 'string' || field.type === 'textarea' || field.type === 'password' ? { trigger: 'blur' } : {}),
|
||||||
})
|
})
|
||||||
|
|||||||
+4
-1
@@ -25,7 +25,10 @@
|
|||||||
"enabled": "Enabled",
|
"enabled": "Enabled",
|
||||||
"pressEnter": "Press Enter to add",
|
"pressEnter": "Press Enter to add",
|
||||||
"expand": "Expand",
|
"expand": "Expand",
|
||||||
"collapse": "Collapse"
|
"collapse": "Collapse",
|
||||||
|
"back": "Back",
|
||||||
|
"refresh": "Refresh",
|
||||||
|
"notFound": "Not Found"
|
||||||
},
|
},
|
||||||
"user": {
|
"user": {
|
||||||
"username": "Username",
|
"username": "Username",
|
||||||
|
|||||||
@@ -38,6 +38,7 @@
|
|||||||
"active": "启用状态",
|
"active": "启用状态",
|
||||||
"createdAt": "创建时间",
|
"createdAt": "创建时间",
|
||||||
"updatedAt": "更新时间",
|
"updatedAt": "更新时间",
|
||||||
|
"menuManage": "用户",
|
||||||
"operationLog": "操作日志"
|
"operationLog": "操作日志"
|
||||||
},
|
},
|
||||||
"operationLog": {
|
"operationLog": {
|
||||||
@@ -55,6 +56,7 @@
|
|||||||
"powers": "权限",
|
"powers": "权限",
|
||||||
"createdAt": "创建时间",
|
"createdAt": "创建时间",
|
||||||
"updatedAt": "更新时间",
|
"updatedAt": "更新时间",
|
||||||
|
"menuManage": "角色",
|
||||||
"menuList": "角色列表",
|
"menuList": "角色列表",
|
||||||
"empty": "暂无角色",
|
"empty": "暂无角色",
|
||||||
"addRole": "新增角色",
|
"addRole": "新增角色",
|
||||||
@@ -91,6 +93,9 @@
|
|||||||
"PWError": "请输入密码"
|
"PWError": "请输入密码"
|
||||||
},
|
},
|
||||||
"power": {
|
"power": {
|
||||||
|
"user": "用户",
|
||||||
|
"role": "角色",
|
||||||
|
"zerobase": "Zero Base",
|
||||||
"add": "新增",
|
"add": "新增",
|
||||||
"edit": "编辑",
|
"edit": "编辑",
|
||||||
"delete": "删除",
|
"delete": "删除",
|
||||||
|
|||||||
Reference in New Issue
Block a user