主题切换及其管理

简介:

想做一个更换主题的功能

第一步,做主题管理:


?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
< entity-model id = "theme" name = "theme" title = "主题"
     enable-delete = "true" enable-modity = "true" version = "2.0" cache-enabled = "true" >
     < operations >
         < operation id = "thememodelopadduuid" name = "addTheme" title = "新增"
             enable-delete = "true" enable-modity = "true" type = "add" fixed-size = "false"
             modal = "true" >
             < condition-fields >
                 < condition-field editable = "false" hidden = "false"
                     field-id = "theme_id" connect-mode = "AND" />
             </ condition-fields >
             < operation-group id = "addopbasicgroup" name = "basicgroup"
                 title = "操作字段" enable-delete = "true" enable-modity = "true" >
                 < operation-fields >
                     < operation-field editable = "false" hidden = "true"
                         field-id = "theme_id" />
                     < operation-field editable = "true" hidden = "false"
                         field-id = "theme_code" />
                     < operation-field editable = "true" hidden = "false"
                         field-id = "theme_title" />
                     < operation-field editable = "true" hidden = "false"
                         field-id = "theme_css_path" >
                         < input-mode type = "textWholeLineMode" ></ input-mode >
                     </ operation-field >
                     < operation-field editable = "true" hidden = "false"
                         field-id = "theme_thumbnail" >
                         < input-mode type = "textWholeLineMode" ></ input-mode >
                     </ operation-field >
                 </ operation-fields >
             </ operation-group >
         </ operation >
         < operation id = "thememodelopupdateuuid" name = "modifyTheme"
             title = "修改" enable-delete = "true" enable-modity = "true" type = "modify"
             fixed-size = "false" modal = "true" >
             < condition-fields >
                 < condition-field editable = "false" hidden = "false"
                     field-id = "theme_id" connect-mode = "AND" />
             </ condition-fields >
             < operation-group id = "modifyopbasicgroup" name = "basicgroup"
                 title = "操作字段" enable-delete = "true" enable-modity = "true" >
                 < operation-fields >
                     < operation-field editable = "false" hidden = "true"
                         field-id = "theme_id" />
                     < operation-field editable = "true" hidden = "false"
                         field-id = "theme_code" />
                     < operation-field editable = "true" hidden = "false"
                         field-id = "theme_title" />
                     < operation-field editable = "true" hidden = "false"
                         field-id = "theme_css_path" >
                         < input-mode type = "textWholeLineMode" ></ input-mode >
                     </ operation-field >
                     < operation-field editable = "true" hidden = "false"
                         field-id = "theme_thumbnail" >
                         < input-mode type = "textWholeLineMode" ></ input-mode >
                     </ operation-field >
                 </ operation-fields >
             </ operation-group >
         </ operation >
         < operation id = "thememodelopdeleteuuid" name = "deleteTheme"
             title = "删除" enable-delete = "true" enable-modity = "true" type = "delete"
             fixed-size = "false" modal = "true" >
             < condition-fields >
                 < condition-field editable = "false" hidden = "false"
                     field-id = "theme_id" connect-mode = "AND" />
             </ condition-fields >
             < operation-group id = "deleteopbasicgroup" name = "basicgroup"
                 title = "操作字段" enable-delete = "true" enable-modity = "true" >
                 < operation-fields >
                     < operation-field editable = "false" hidden = "true"
                         field-id = "theme_id" />
                     < operation-field editable = "true" hidden = "false"
                         field-id = "theme_code" />
                     < operation-field editable = "true" hidden = "false"
                         field-id = "theme_title" />
                     < operation-field editable = "true" hidden = "false"
                         field-id = "theme_css_path" />
                     < operation-field editable = "true" hidden = "false"
                         field-id = "theme_thumbnail" />
                 </ operation-fields >
             </ operation-group >
         </ operation >
         < operation id = "thememodelopqueryuuid" name = "viewTheme"
             title = "查看" enable-delete = "true" enable-modity = "true" type = "view"
             fixed-size = "false" modal = "true" >
             < condition-fields >
                 < condition-field editable = "false" hidden = "false"
                     field-id = "theme_id" connect-mode = "AND" />
             </ condition-fields >
             < operation-group id = "viewopbasicgroup" name = "basicgroup"
                 title = "操作字段" enable-delete = "true" enable-modity = "true" >
                 < operation-fields >
                     < operation-field editable = "false" hidden = "true"
                         field-id = "theme_id" />
                     < operation-field editable = "true" hidden = "false"
                         field-id = "theme_code" />
                     < operation-field editable = "true" hidden = "false"
                         field-id = "theme_title" />
                     < operation-field editable = "true" hidden = "false"
                         field-id = "theme_css_path" >
                         < input-mode type = "labelWholeLineMode" ></ input-mode >
                     </ operation-field >
                     < operation-field editable = "true" hidden = "false"
                         field-id = "theme_thumbnail" >
                         < input-mode type = "labelWholeLineMode" ></ input-mode >
                     </ operation-field >
                 </ operation-fields >
             </ operation-group >
         </ operation >
         < operation id = "thememodelopaddcopyuuid" name = "copyAddTheme"
             title = "拷贝新增" enable-delete = "true" enable-modity = "true" type = "copyAdd"
             fixed-size = "false" modal = "true" >
             < condition-fields >
                 < condition-field editable = "false" hidden = "false"
                     field-id = "theme_id" connect-mode = "AND" />
             </ condition-fields >
             < operation-group id = "copyAddopbasicgroup" name = "basicgroup"
                 title = "操作字段" enable-delete = "true" enable-modity = "true" >
                 < operation-fields >
                     < operation-field editable = "true" hidden = "false"
                         field-id = "theme_code" />
                     < operation-field editable = "true" hidden = "false"
                         field-id = "theme_title" />
                     < operation-field editable = "true" hidden = "false"
                         field-id = "theme_css_path" >
                         < input-mode type = "textWholeLineMode" ></ input-mode >
                     </ operation-field >
                     < operation-field editable = "true" hidden = "false"
                         field-id = "theme_thumbnail" >
                         < input-mode type = "textWholeLineMode" ></ input-mode >
                     </ operation-field >
                 </ operation-fields >
             </ operation-group >
         </ operation >
     </ operations >
     < views >
         < view id = "thememodeloptableuuid" name = "tabletheme" title = "主题管理"
             enable-delete = "true" enable-modity = "true" type = "table" page-size = "10"
             allow-edit = "false" allow-filter-front = "false" fixed-size = "false"
             modal = "false" front-paging = "false" >
             < view-groups >
                 < view-group id = "viewbasicgroup" name = "basicgroup" title = "基本信息"
                     enable-delete = "true" enable-modity = "true" >
                     < display-field editable = "false" hidden = "true"
                         field-id = "theme_id" aggregate-by-view = "false" />
                     < display-field editable = "false" hidden = "false"
                         field-id = "theme_code" aggregate-by-view = "false" />
                     < display-field editable = "false" hidden = "false"
                         field-id = "theme_title" aggregate-by-view = "false" />
                 </ view-group >
             </ view-groups >
             < references >
                 < operation-reference type = "operation" id = "thememodelopadduuid" />
                 < operation-reference type = "operation"
                     id = "thememodelopaddcopyuuid" />
                 < operation-reference type = "operation"
                     id = "thememodelopdeleteuuid" />
                 < operation-reference type = "operation"
                     id = "thememodelopupdateuuid" />
                 < operation-reference type = "operation"
                     id = "thememodelopqueryuuid" />
             </ references >
         </ view >
     </ views >
     < groups >
         < group id = "basicgroup" name = "basicgroup" title = "基本字段"
             enable-delete = "true" enable-modity = "true" >
             < field standard-field-id = "theme_id" primary = "true" unique = "true"
                 display = "false" not-null = "false" auto-increase = "false" editable = "false"
                 hidden = "false" table-field = "true" id = "theme_id" />
             < field standard-field-id = "theme_code" primary = "false" unique = "false"
                 display = "false" not-null = "false" auto-increase = "false" editable = "false"
                 hidden = "false" table-field = "true" id = "theme_code" />
             < field standard-field-id = "theme_title" primary = "false" unique = "false"
                 display = "false" not-null = "false" auto-increase = "false" editable = "false"
                 hidden = "false" table-field = "true" id = "theme_title" />
             < field standard-field-id = "theme_css_path" primary = "false"
                 unique = "false" display = "false" not-null = "false" auto-increase = "false"
                 editable = "false" hidden = "false" table-field = "true" id = "theme_css_path" />
             < field standard-field-id = "theme_thumbnail" primary = "false"
                 unique = "false" display = "false" not-null = "false" auto-increase = "false"
                 editable = "false" hidden = "false" table-field = "true" id = "theme_thumbnail" />
         </ group >
     </ groups >
</ entity-model >
OK,管理功能就算开发完毕了。


主窗口如下:

新增窗口如下:

复制新增如下:

修改窗口:

查看窗口:

删除确认窗口:

至此,通过配置xml,主题的管理功能开发完毕。

于是,增加数据,由于有拷贝新增,因此增加起来还是比较快速的。

第二步,做主题选择对话框:

增加一个新的view

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
< view id = "thememodelopcarduuid" name = "cardtheme" title = "主题选择"
     enable-delete = "true" enable-modity = "true" type = "card" page-size = "0"
     allow-edit = "false" allow-filter-front = "true" fixed-size = "false"
     modal = "false" front-paging = "false" >
     < customize-stage-configs >
         < customize-stage-config stage-name = "card"
             view-path = "/biz/theme/theme_card.page" >
         </ customize-stage-config >
     </ customize-stage-configs >
     < condition-fields >
     </ condition-fields >
     < view-groups >
         < view-group id = "viewbasicgroup" name = "basicgroup" title = "基本信息"
             enable-delete = "true" enable-modity = "true" >
             < display-field editable = "false" hidden = "true"
                 field-id = "theme_id" aggregate-by-view = "false" />
             < display-field editable = "false" hidden = "false"
                 field-id = "theme_code" aggregate-by-view = "false" />
             < display-field editable = "false" hidden = "false"
                 field-id = "theme_title" aggregate-by-view = "false" />
             < display-field editable = "false" hidden = "false"
                 field-id = "theme_css_path" aggregate-by-view = "false" />
             < display-field editable = "false" hidden = "false"
                 field-id = "theme_thumbnail" aggregate-by-view = "false" />
         </ view-group >
     </ view-groups >
</ view >
编写视图中指定的模板文件:

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#@wijDialog("${modelDefine.id}_${operationDefine.id}" "${operationDefine.title}")
#foreach($bean in $modelProcessResult.beans)
     < a href = "javascript:doChangeTheme('${TINY_CONTEXT_PATH}$bean.themeCssPath')" >< img title = "$bean.themeTitle" style = "float:left;border:1px solid;margin:5px 5px;width:50pt;" src = "${TINY_CONTEXT_PATH}$bean.themeThumbnail" /></ a >
#end
#end
 
< script >
     function doChangeTheme(path){
         var list=$("link");
         for(var i=0;i< list.length ;i++){
             var link = list .get(i);
             var pos = link .href.indexOf("/themes/");
             if(pos>0){
                 pos=link.href.indexOf(contextPath+"/");
                 link.href=link.href.substr(0,pos)+ path;
                 return;
             }
         }
     }
 
</ script >
至此开发任务完成,看一下模板选择界面


第三步,验证实际效果:

OK,收工。

相关文章
|
7月前
|
前端开发
三种方式实现主题切换方案
三种方式实现主题切换方案
WPF疑难问题之Treeview中HierarchicalDataTemplate多级样式
WPF疑难问题之Treeview中HierarchicalDataTemplate多级样式
405 0
|
7月前
|
前端开发 JavaScript
uniapp如何制作一个收缩通讯录(布局篇)
uniapp如何制作一个收缩通讯录(布局篇)
84 0
|
7月前
|
JavaScript 前端开发
使用styled-components控制主题切换(有手就行)
使用styled-components控制主题切换(有手就行)
143 0
54EasyUI 树形菜单- 树形菜单拖放控制
54EasyUI 树形菜单- 树形菜单拖放控制
49 0
|
JSON 前端开发 数据格式
人事管理项目-动态加载用户菜单3
人事管理项目-动态加载用户菜单3
人事管理项目-动态加载用户菜单3
|
UED 开发者
构建可访问的自定义表单控件
在现代Web应用程序中,表单是一个至关重要的组件。用户可以通过表单输入数据并与应用程序进行交互。为了提高用户体验,并让所有用户都能轻松地使用您的应用程序,构建可访问的自定义表单控件是非常重要的。
108 0
|
JSON JavaScript 前端开发
人事管理项目-动态加载用户菜单2
人事管理项目-动态加载用户菜单2
|
SQL Java Spring
人事管理项目-动态加载用户菜单
人事管理项目-动态加载用户菜单
|
JavaScript
后台管理系统——03解决联动效果以及面包屑导航以及添加Echarts
解决联动效果以及面包屑导航以及添加Echarts
208 0