Skip to content

Commit d963cb2

Browse files
author
xiaoqunLiu
committed
frontend
1 parent 390f071 commit d963cb2

File tree

5 files changed

+80
-5
lines changed

5 files changed

+80
-5
lines changed

docs-web/src/main/webapp/src/app/docs/controller/document/FileModalView.js

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/**
44
* File modal view controller.
55
*/
6-
angular.module('docs').controller('FileModalView', function ($uibModalInstance, $scope, $state, $stateParams, $sce, Restangular, $transitions) {
6+
angular.module('docs').controller('FileModalView', function ($uibModal, $uibModalInstance, $scope, $state, $stateParams, $sce, Restangular, $transitions) {
77
var setFile = function (files) {
88
// Search current file
99
_.each(files, function (value) {
@@ -123,4 +123,48 @@ angular.module('docs').controller('FileModalView', function ($uibModalInstance,
123123
$scope.canDisplayPreview = function () {
124124
return $scope.file && $scope.file.mimetype !== 'application/pdf';
125125
};
126+
127+
// 语言列表
128+
$scope.langList = [
129+
{ code: 'zh-CHS', name: '中文' },
130+
{ code: 'en', name: 'English' },
131+
{ code: 'fr', name: 'Français' }
132+
];
133+
$scope.targetLang = $scope.langList[0].code;
134+
135+
// 使用$uibModal弹出语言选择框
136+
$scope.translateFile = function () {
137+
$uibModal.open({
138+
templateUrl: 'partial/docs/file.translate.modal.html',
139+
controller: function($scope, $uibModalInstance, langList, targetLang) {
140+
$scope.langList = langList;
141+
$scope.targetLang = targetLang;
142+
$scope.ok = function() {
143+
$uibModalInstance.close($scope.targetLang);
144+
};
145+
$scope.cancel = function() {
146+
$uibModalInstance.dismiss();
147+
};
148+
},
149+
resolve: {
150+
langList: function() { return $scope.langList; },
151+
targetLang: function() { return $scope.targetLang; }
152+
}
153+
}).result.then(function(selectedLang) {
154+
$scope.targetLang = selectedLang;
155+
$scope.doTranslate();
156+
});
157+
};
158+
159+
// 执行翻译
160+
$scope.doTranslate = function () {
161+
// 这里调用后端API进行翻译
162+
Restangular.one('file/' + $stateParams.fileId + '/translate').post('', {
163+
to: $scope.targetLang
164+
}).then(function (resp) {
165+
alert('翻译成功,已生成新文件!');
166+
}, function (err) {
167+
alert('翻译失败,请重试!');
168+
});
169+
};
126170
});
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<div class="modal-header">
2+
<h4 class="modal-title">{{ '选择目标语言' }}</h4>
3+
</div>
4+
<div class="modal-body">
5+
<label for="targetLang">目标语言</label>
6+
<select id="targetLang" class="form-control" ng-model="targetLang" ng-options="lang.code as lang.name for lang in langList"></select>
7+
</div>
8+
<div class="modal-footer">
9+
<button type="button" class="btn btn-primary" ng-click="ok()">确定</button>
10+
<button type="button" class="btn btn-default" ng-click="cancel()">取消</button>
11+
</div>

docs-web/src/main/webapp/src/partial/docs/file.view.html

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,24 @@
6262
<span class="fas fa-exclamation-triangle"></span>
6363
{{ 'file.view.not_found' | translate }}
6464
</p>
65-
</div>
65+
</div>
66+
67+
<!-- 语言选择模态框(已弃用,改用$uibModal弹窗,防止冲突) -->
68+
<!-- <div class="modal fade" id="translateModal" tabindex="-1" role="dialog" aria-labelledby="translateModalLabel">
69+
<div class="modal-dialog" role="document">
70+
<div class="modal-content">
71+
<div class="modal-header">
72+
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
73+
<h4 class="modal-title" id="translateModalLabel">{{ 'file.view.select_language' | translate }}</h4>
74+
</div>
75+
<div class="modal-body">
76+
<label for="targetLang">{{ 'file.view.target_language' | translate }}</label>
77+
<select id="targetLang" class="form-control" ng-model="targetLang" ng-options="lang.code as lang.name for lang in langList"></select>
78+
</div>
79+
<div class="modal-footer">
80+
<button type="button" class="btn btn-primary" ng-click="doTranslate()">{{ 'file.view.translate_confirm' | translate }}</button>
81+
<button type="button" class="btn btn-default" data-dismiss="modal">{{ 'file.view.cancel' | translate }}</button>
82+
</div>
83+
</div>
84+
</div>
85+
</div> -->

docs.lock.db

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#FileLock
2-
#Sun Jun 01 19:08:00 CST 2025
2+
#Sun Jun 01 19:32:23 CST 2025
33
hostName=localhost
4-
id=1972b2d557f2029feb4ab643b92b980b1d1e001b3c6
4+
id=1972b43a84d871b22a7e3a3d5421250dbf93dbaf63b
55
method=file
6-
server=localhost\:51000
6+
server=localhost\:56977

docs.mv.db

-236 KB
Binary file not shown.

0 commit comments

Comments
 (0)