Loading...
Loading...
Compare original and translation side by side
FlowDistributionDlg.vueAbsWorkbenchView.tsvalidator.tshttp.tsconstant.tsconfig.tsFlowDistributionDlg.vueAbsWorkbenchView.tsvalidator.tshttp.tsconstant.tsconfig.tsAbsDataModelViewIDataModelmodelNamefetchData()MAX_LENGTHAPI_BASE_URL__internalStateAbsDataModelViewIDataModelmodelNamefetchData()MAX_LENGTHAPI_BASE_URL__internalState// 1. Vue/Vuex 相关
import { Component } from 'vue-property-decorator'
// 2. 第三方库
import { isObject } from '@tdio/utils'
// 3. 项目工具函数
import { getRule } from '@/utils/validator'
// 4. 类型定义
import type { IDataModel } from '../types'
// 5. 组件/视图
import AbsWorkbenchView from '../AbsView'// 1. Vue/Vuex related
import { Component } from 'vue-property-decorator'
// 2. Third-party libraries
import { isObject } from '@tdio/utils'
// 3. Project utility functions
import { getRule } from '@/utils/validator'
// 4. Type definitions
import type { IDataModel } from '../types'
// 5. Components/Views
import AbsWorkbenchView from '../AbsView'// 1. 装饰器
@Component({ ... })
export default class ComponentName extends BaseView {
// 2. Props
@Prop() value!: Kv
// 3. Refs
@Ref() formRef!: ElForm
// 4. 数据属性
model: Kv = {}
// 5. 计算属性
get computedValue () {
return this.model.value
}
// 6. 方法
validate () {
// ...
}
// 7. 生命周期
mounted () {
// ...
}
}// 1. Decorators
@Component({ ... })
export default class ComponentName extends BaseView {
// 2. Props
@Prop() value!: Kv
// 3. Refs
@Ref() formRef!: ElForm
// 4. Data properties
model: Kv = {}
// 5. Computed properties
get computedValue () {
return this.model.value
}
// 6. Methods
validate () {
// ...
}
// 7. Lifecycle hooks
mounted () {
// ...
}
}// ✅ GOOD - 解释复杂逻辑
// 验证模型名称唯一性,需要异步调用接口
async ruleValRepeatVerify (rule, value: string, callback) {
// ...
}
// ❌ BAD - 无意义的注释
// 设置值
setValue (key, value) {
this.$set(this.value, key, value)
}// ✅ GOOD - Explain complex logic
// Verify the uniqueness of the model name, requires asynchronous API call
async ruleValRepeatVerify (rule, value: string, callback) {
// ...
}
// ❌ BAD - Meaningless comment
// Set value
setValue (key, value) {
this.$set(this.value, key, value)
}// ✅ GOOD - 复杂函数添加注释
/**
* 生成必填验证规则
* @param message 错误提示信息
* @param trigger 触发时机,默认为 'change'
* @returns 验证规则对象
*/
export const genRequired = (message?: string, trigger?: string): IValidateRuleItem => {
// ...
}// ✅ GOOD - Add comments for complex functions
/**
* Generate required validation rules
* @param message Error prompt message
* @param trigger Trigger timing, default is 'change'
* @returns Validation rule object
*/
export const genRequired = (message?: string, trigger?: string): IValidateRuleItem => {
// ...
}// ✅ GOOD - 明确的错误处理
try {
await this.saveData(this.model!)
} catch (error) {
console.error('保存失败:', error)
this.$message.error('保存失败,请重试')
throw error
}
// ❌ BAD - 忽略错误
try {
await this.saveData(this.model!)
} catch (e) {}// ✅ GOOD - Clear error handling
try {
await this.saveData(this.model!)
} catch (error) {
console.error('Save failed:', error)
this.$message.error('Save failed, please try again')
throw error
}
// ❌ BAD - Ignore errors
try {
await this.saveData(this.model!)
} catch (e) {}getRulegenRequired$t()getRulegenRequired$t()