diff --git a/sf-ui/build/index.js b/sf-ui/build/index.js index 385da08..0c57de2 100644 --- a/sf-ui/build/index.js +++ b/sf-ui/build/index.js @@ -1,35 +1,35 @@ -const { run } = require('runjs') -const chalk = require('chalk') -const config = require('../vue.config.js') -const rawArgv = process.argv.slice(2) -const args = rawArgv.join(' ') - -if (process.env.npm_config_preview || rawArgv.includes('--preview')) { - const report = rawArgv.includes('--report') - - run(`vue-cli-service build ${args}`) - - const port = 9526 - const publicPath = config.publicPath - - var connect = require('connect') - var serveStatic = require('serve-static') - const app = connect() - - app.use( - publicPath, - serveStatic('./dist', { - index: ['index.html', '/'] - }) - ) - - app.listen(port, function () { - console.log(chalk.green(`> Preview at http://localhost:${port}${publicPath}`)) - if (report) { - console.log(chalk.green(`> Report at http://localhost:${port}${publicPath}report.html`)) - } - - }) -} else { - run(`vue-cli-service build ${args}`) -} +const { run } = require('runjs') +const chalk = require('chalk') +const config = require('../vue.config.js') +const rawArgv = process.argv.slice(2) +const args = rawArgv.join(' ') + +if (process.env.npm_config_preview || rawArgv.includes('--preview')) { + const report = rawArgv.includes('--report') + + run(`vue-cli-service build ${args}`) + + const port = 9526 + const publicPath = config.publicPath + + var connect = require('connect') + var serveStatic = require('serve-static') + const app = connect() + + app.use( + publicPath, + serveStatic('./dist', { + index: ['index.html', '/'] + }) + ) + + app.listen(port, function () { + console.log(chalk.green(`> Preview at http://localhost:${port}${publicPath}`)) + if (report) { + console.log(chalk.green(`> Report at http://localhost:${port}${publicPath}report.html`)) + } + + }) +} else { + run(`vue-cli-service build ${args}`) +} diff --git a/sf-ui/public/favicon.ico b/sf-ui/public/favicon.ico index e263760..4fa5a44 100644 Binary files a/sf-ui/public/favicon.ico and b/sf-ui/public/favicon.ico differ diff --git a/sf-ui/public/html/ie.html b/sf-ui/public/html/ie.html index 390ce8a..052ffcd 100644 --- a/sf-ui/public/html/ie.html +++ b/sf-ui/public/html/ie.html @@ -1,46 +1,46 @@ - - - - - - 请升级您的浏览器 - - - - - - -

请升级您的浏览器,以便我们更好的为您提供服务!

-

您正在使用 Internet Explorer 的早期版本(IE11以下版本或使用该内核的浏览器)。这意味着在升级浏览器前,您将无法访问此网站。

-
-

请注意:微软公司对Windows XP 及 Internet Explorer 早期版本的支持已经结束

-

自 2016 年 1 月 12 日起,Microsoft 不再为 IE 11 以下版本提供相应支持和更新。没有关键的浏览器安全更新,您的电脑可能易受有害病毒、间谍软件和其他恶意软件的攻击,它们可以窃取或损害您的业务数据和信息。请参阅 微软对 Internet Explorer 早期版本的支持将于 2016 年 1 月 12 日结束的说明

-
-

您可以选择更先进的浏览器

-

推荐使用以下浏览器的最新版本。如果您的电脑已有以下浏览器的最新版本则直接使用该浏览器访问即可。

- -
- + + + + + + 请升级您的浏览器 + + + + + + +

请升级您的浏览器,以便我们更好的为您提供服务!

+

您正在使用 Internet Explorer 的早期版本(IE11以下版本或使用该内核的浏览器)。这意味着在升级浏览器前,您将无法访问此网站。

+
+

请注意:微软公司对Windows XP 及 Internet Explorer 早期版本的支持已经结束

+

自 2016 年 1 月 12 日起,Microsoft 不再为 IE 11 以下版本提供相应支持和更新。没有关键的浏览器安全更新,您的电脑可能易受有害病毒、间谍软件和其他恶意软件的攻击,它们可以窃取或损害您的业务数据和信息。请参阅 微软对 Internet Explorer 早期版本的支持将于 2016 年 1 月 12 日结束的说明

+
+

您可以选择更先进的浏览器

+

推荐使用以下浏览器的最新版本。如果您的电脑已有以下浏览器的最新版本则直接使用该浏览器访问即可。

+ +
+ \ No newline at end of file diff --git a/sf-ui/public/index.html b/sf-ui/public/index.html index 56fd45b..925455c 100644 --- a/sf-ui/public/index.html +++ b/sf-ui/public/index.html @@ -1,208 +1,208 @@ - - - - - - - - - <%= webpackConfig.name %> - - - - -
-
-
-
-
-
正在加载系统资源,请耐心等待
-
-
- - + + + + + + + + + <%= webpackConfig.name %> + + + + +
+
+
+
+
+
正在加载系统资源,请耐心等待
+
+
+ + diff --git a/sf-ui/public/robots.txt b/sf-ui/public/robots.txt index c2aab7e..77470cb 100644 --- a/sf-ui/public/robots.txt +++ b/sf-ui/public/robots.txt @@ -1,2 +1,2 @@ -User-agent: * +User-agent: * Disallow: / \ No newline at end of file diff --git a/sf-ui/src/App.vue b/sf-ui/src/App.vue index a2c4b87..29de49f 100644 --- a/sf-ui/src/App.vue +++ b/sf-ui/src/App.vue @@ -1,28 +1,28 @@ - - - - + + + + diff --git a/sf-ui/src/api/FDS/whiteList.js b/sf-ui/src/api/FDS/whiteList.js index 0999bef..b4d0831 100644 --- a/sf-ui/src/api/FDS/whiteList.js +++ b/sf-ui/src/api/FDS/whiteList.js @@ -42,3 +42,72 @@ export function delWhitelist (id) { method: 'delete' }) } +// 查询白名单成员列列表 +export function listWhitelistMember (query) { + return request({ + url: '/deployment/whitelistMember/list', + method: 'get', + params: query + }) +} + +// 查询白名单成员列详细 +export function getWhitelistMember (id) { + return request({ + url: '/deployment/whitelistMember/' + id, + method: 'get' + }) +} + +// 新增白名单成员列 +export function addWhitelistMember (data) { + return request({ + url: '/deployment/whitelistMember', + method: 'post', + data: data + }) +} + +// 修改白名单成员列 +export function updateWhitelistMember (data) { + return request({ + url: '/deployment/whitelistMember', + method: 'put', + data: data + }) +} + +// 删除白名单成员列 +export function delWhitelistMember (id) { + return request({ + url: '/deployment/whitelistMember/' + id, + method: 'delete' + }) +} + + + +// 发布白名单 +export function publishWhitelist (id) { + return request({ + url: '/deployment/whitelist/publish/' + id, + method: 'get', + }) +} + +// 下架白名单 +export function soldOutWhitelist (id) { + return request({ + url: '/deployment/whitelist/sold/out/' + id, + method: 'get', + }) +} + +// 批量上传白名单 +export function importWhitelist (data) { + return request({ + url: 'deployment/whitelistMember/batch/import', + method: 'post', + data: data + }) +} diff --git a/sf-ui/src/api/forms/api/gen/Logback1692261745000.js b/sf-ui/src/api/forms/api/gen/Logback1692261745000.js index eff3b44..48a7b0c 100644 --- a/sf-ui/src/api/forms/api/gen/Logback1692261745000.js +++ b/sf-ui/src/api/forms/api/gen/Logback1692261745000.js @@ -1,44 +1,44 @@ -import request from '@/utils/request' - -// 查询日志列表 -export function listLogback1692261745000(query) { - return request({ - url: '/forms/api/gen/Logback1692261745000/list', - method: 'get', - params: query - }) -} - -// 查询日志详细 -export function getLogback1692261745000(id) { - return request({ - url: '/forms/api/gen/Logback1692261745000/' + id, - method: 'get' - }) -} - -// 新增日志 -export function addLogback1692261745000(data) { - return request({ - url: '/forms/api/gen/Logback1692261745000', - method: 'post', - data: data - }) -} - -// 修改日志 -export function updateLogback1692261745000(data) { - return request({ - url: '/forms/api/gen/Logback1692261745000', - method: 'put', - data: data - }) -} - -// 删除日志 -export function delLogback1692261745000(id) { - return request({ - url: '/forms/api/gen/Logback1692261745000/' + id, - method: 'delete' - }) -} +import request from '@/utils/request' + +// 查询日志列表 +export function listLogback1692261745000(query) { + return request({ + url: '/forms/api/gen/Logback1692261745000/list', + method: 'get', + params: query + }) +} + +// 查询日志详细 +export function getLogback1692261745000(id) { + return request({ + url: '/forms/api/gen/Logback1692261745000/' + id, + method: 'get' + }) +} + +// 新增日志 +export function addLogback1692261745000(data) { + return request({ + url: '/forms/api/gen/Logback1692261745000', + method: 'post', + data: data + }) +} + +// 修改日志 +export function updateLogback1692261745000(data) { + return request({ + url: '/forms/api/gen/Logback1692261745000', + method: 'put', + data: data + }) +} + +// 删除日志 +export function delLogback1692261745000(id) { + return request({ + url: '/forms/api/gen/Logback1692261745000/' + id, + method: 'delete' + }) +} diff --git a/sf-ui/src/api/forms/api/gen/Logback1708504771000.js b/sf-ui/src/api/forms/api/gen/Logback1708504771000.js index 86bbad1..a223c6f 100644 --- a/sf-ui/src/api/forms/api/gen/Logback1708504771000.js +++ b/sf-ui/src/api/forms/api/gen/Logback1708504771000.js @@ -1,44 +1,44 @@ -import request from '@/utils/request' - -// 查询岗位信息3列表 -export function listLogback1708504771000(query) { - return request({ - url: '/forms/api/gen/Logback1708504771000/list', - method: 'get', - params: query - }) -} - -// 查询岗位信息3详细 -export function getLogback1708504771000(id) { - return request({ - url: '/forms/api/gen/Logback1708504771000/' + id, - method: 'get' - }) -} - -// 新增岗位信息3 -export function addLogback1708504771000(data) { - return request({ - url: '/forms/api/gen/Logback1708504771000', - method: 'post', - data: data - }) -} - -// 修改岗位信息3 -export function updateLogback1708504771000(data) { - return request({ - url: '/forms/api/gen/Logback1708504771000', - method: 'put', - data: data - }) -} - -// 删除岗位信息3 -export function delLogback1708504771000(id) { - return request({ - url: '/forms/api/gen/Logback1708504771000/' + id, - method: 'delete' - }) -} +import request from '@/utils/request' + +// 查询岗位信息3列表 +export function listLogback1708504771000(query) { + return request({ + url: '/forms/api/gen/Logback1708504771000/list', + method: 'get', + params: query + }) +} + +// 查询岗位信息3详细 +export function getLogback1708504771000(id) { + return request({ + url: '/forms/api/gen/Logback1708504771000/' + id, + method: 'get' + }) +} + +// 新增岗位信息3 +export function addLogback1708504771000(data) { + return request({ + url: '/forms/api/gen/Logback1708504771000', + method: 'post', + data: data + }) +} + +// 修改岗位信息3 +export function updateLogback1708504771000(data) { + return request({ + url: '/forms/api/gen/Logback1708504771000', + method: 'put', + data: data + }) +} + +// 删除岗位信息3 +export function delLogback1708504771000(id) { + return request({ + url: '/forms/api/gen/Logback1708504771000/' + id, + method: 'delete' + }) +} diff --git a/sf-ui/src/api/forms/api/gen/Ordermaster1692279150000.js b/sf-ui/src/api/forms/api/gen/Ordermaster1692279150000.js index 6d7f1fd..dd8c511 100644 --- a/sf-ui/src/api/forms/api/gen/Ordermaster1692279150000.js +++ b/sf-ui/src/api/forms/api/gen/Ordermaster1692279150000.js @@ -1,45 +1,45 @@ -import request from '@/utils/request' - -// 查询订单列表 -export function listOrdermaster1692279150000(query) { - return request({ - url: '/forms/api/gen/Ordermaster1692279150000/list', - method: 'get', - params: query - }) -} - -// 查询订单详细 -export function getOrdermaster1692279150000(orderNo) { - return request({ - url: '/forms/api/gen/Ordermaster1692279150000/' + orderNo, - method: 'get' - }) -} - -// 新增订单 -export function addOrdermaster1692279150000(data) { - return request({ - url: '/forms/api/gen/Ordermaster1692279150000', - method: 'post', - data: data - }) -} - -// 修改订单 -export function updateOrdermaster1692279150000(data) { - return request({ - url: '/forms/api/gen/Ordermaster1692279150000', - method: 'put', - data: data - }) -} - -// 删除订单 -export function delOrdermaster1692279150000(orderNo) { - return request({ - url: '/forms/api/gen/Ordermaster1692279150000/' + orderNo, - method: 'delete' - }) -} +import request from '@/utils/request' + +// 查询订单列表 +export function listOrdermaster1692279150000(query) { + return request({ + url: '/forms/api/gen/Ordermaster1692279150000/list', + method: 'get', + params: query + }) +} + +// 查询订单详细 +export function getOrdermaster1692279150000(orderNo) { + return request({ + url: '/forms/api/gen/Ordermaster1692279150000/' + orderNo, + method: 'get' + }) +} + +// 新增订单 +export function addOrdermaster1692279150000(data) { + return request({ + url: '/forms/api/gen/Ordermaster1692279150000', + method: 'post', + data: data + }) +} + +// 修改订单 +export function updateOrdermaster1692279150000(data) { + return request({ + url: '/forms/api/gen/Ordermaster1692279150000', + method: 'put', + data: data + }) +} + +// 删除订单 +export function delOrdermaster1692279150000(orderNo) { + return request({ + url: '/forms/api/gen/Ordermaster1692279150000/' + orderNo, + method: 'delete' + }) +} \ No newline at end of file diff --git a/sf-ui/src/api/forms/api/gen/Post1692343037000.js b/sf-ui/src/api/forms/api/gen/Post1692343037000.js index 54a2dd8..c441bfc 100644 --- a/sf-ui/src/api/forms/api/gen/Post1692343037000.js +++ b/sf-ui/src/api/forms/api/gen/Post1692343037000.js @@ -1,44 +1,44 @@ -import request from '@/utils/request' - -// 查询岗位信息列表 -export function listPost1692343037000(query) { - return request({ - url: '/forms/api/gen/Post1692343037000/list', - method: 'get', - params: query - }) -} - -// 查询岗位信息详细 -export function getPost1692343037000(postId) { - return request({ - url: '/forms/api/gen/Post1692343037000/' + postId, - method: 'get' - }) -} - -// 新增岗位信息 -export function addPost1692343037000(data) { - return request({ - url: '/forms/api/gen/Post1692343037000', - method: 'post', - data: data - }) -} - -// 修改岗位信息 -export function updatePost1692343037000(data) { - return request({ - url: '/forms/api/gen/Post1692343037000', - method: 'put', - data: data - }) -} - -// 删除岗位信息 -export function delPost1692343037000(postId) { - return request({ - url: '/forms/api/gen/Post1692343037000/' + postId, - method: 'delete' - }) -} +import request from '@/utils/request' + +// 查询岗位信息列表 +export function listPost1692343037000(query) { + return request({ + url: '/forms/api/gen/Post1692343037000/list', + method: 'get', + params: query + }) +} + +// 查询岗位信息详细 +export function getPost1692343037000(postId) { + return request({ + url: '/forms/api/gen/Post1692343037000/' + postId, + method: 'get' + }) +} + +// 新增岗位信息 +export function addPost1692343037000(data) { + return request({ + url: '/forms/api/gen/Post1692343037000', + method: 'post', + data: data + }) +} + +// 修改岗位信息 +export function updatePost1692343037000(data) { + return request({ + url: '/forms/api/gen/Post1692343037000', + method: 'put', + data: data + }) +} + +// 删除岗位信息 +export function delPost1692343037000(postId) { + return request({ + url: '/forms/api/gen/Post1692343037000/' + postId, + method: 'delete' + }) +} diff --git a/sf-ui/src/api/gateway/config.js b/sf-ui/src/api/gateway/config.js new file mode 100644 index 0000000..bc6f3a4 --- /dev/null +++ b/sf-ui/src/api/gateway/config.js @@ -0,0 +1,28 @@ +import request from '@/utils/request' + +// 查询网关配置信息 +export function getGatewayConfig(params) { + return request({ + url: '/gateway/config', + method: 'get', + params + }) +} + +// 更新网关配置 +export function updateGatewayConfig(data) { + return request({ + url: '/gateway/config', + method: 'put', + data + }) +} + +// 同步网关配置 +export function updateGatewaySync(data) { + return request({ + url: '/gateway/config/sync', + method: 'post', + data + }) +} \ No newline at end of file diff --git a/sf-ui/src/api/gateway/route.js b/sf-ui/src/api/gateway/route.js index a2bdf24..2ae9fd3 100644 --- a/sf-ui/src/api/gateway/route.js +++ b/sf-ui/src/api/gateway/route.js @@ -42,3 +42,12 @@ export function delRoute(id) { method: 'delete' }) } + +// 查询可绑定的路由列表(不分页) +export function getBindableList(params) { + return request({ + url: '/gateway/route/bindableList', + method: 'get', + params + }) +} \ No newline at end of file diff --git a/sf-ui/src/api/gateway/server.js b/sf-ui/src/api/gateway/server.js index 5f3a940..f1bbf5d 100644 --- a/sf-ui/src/api/gateway/server.js +++ b/sf-ui/src/api/gateway/server.js @@ -51,3 +51,12 @@ export function changeServerStatus(data) { data: data }) } + +// 查询可绑定的服务列表(状态为启用的,不分页) +export function bindableServerList(params) { + return request({ + url: '/gateway/server/bindableList', + method: 'get', + params + }) +} diff --git a/sf-ui/src/api/gateway/strategy.js b/sf-ui/src/api/gateway/strategy.js index f5b6fc0..2e33a0c 100644 --- a/sf-ui/src/api/gateway/strategy.js +++ b/sf-ui/src/api/gateway/strategy.js @@ -50,4 +50,13 @@ export function changeStrategyStatus(data) { method: 'put', data: data }) +} + +// 查询可绑定的策略列表(状态为启用的,不分页) +export function bindableStrategyList(params) { + return request({ + url: '/gateway/strategy/bindableList', + method: 'get', + params + }) } \ No newline at end of file diff --git a/sf-ui/src/api/login.js b/sf-ui/src/api/login.js index 26742e7..649f59c 100644 --- a/sf-ui/src/api/login.js +++ b/sf-ui/src/api/login.js @@ -1,59 +1,59 @@ -import request from '@/utils/request' - -// 登录方法 -export function login(username, password, code, uuid) { - const data = { - username, - password, - code, - uuid - } - return request({ - url: '/login', - headers: { - isToken: false - }, - method: 'post', - data: data - }) -} - -// 注册方法 -export function register(data) { - return request({ - url: '/register', - headers: { - isToken: false - }, - method: 'post', - data: data - }) -} - -// 获取用户详细信息 -export function getInfo() { - return request({ - url: '/getInfo', - method: 'get' - }) -} - -// 退出方法 -export function logout() { - return request({ - url: '/logout', - method: 'post' - }) -} - -// 获取验证码 -export function getCodeImg() { - return request({ - url: '/captchaImage', - headers: { - isToken: false - }, - method: 'get', - timeout: 20000 - }) +import request from '@/utils/request' + +// 登录方法 +export function login(username, password, code, uuid) { + const data = { + username, + password, + code, + uuid + } + return request({ + url: '/login', + headers: { + isToken: false + }, + method: 'post', + data: data + }) +} + +// 注册方法 +export function register(data) { + return request({ + url: '/register', + headers: { + isToken: false + }, + method: 'post', + data: data + }) +} + +// 获取用户详细信息 +export function getInfo() { + return request({ + url: '/getInfo', + method: 'get' + }) +} + +// 退出方法 +export function logout() { + return request({ + url: '/logout', + method: 'post' + }) +} + +// 获取验证码 +export function getCodeImg() { + return request({ + url: '/captchaImage', + headers: { + isToken: false + }, + method: 'get', + timeout: 20000 + }) } \ No newline at end of file diff --git a/sf-ui/src/api/mandate/appMandate.js b/sf-ui/src/api/mandate/appMandate.js new file mode 100644 index 0000000..688b2cf --- /dev/null +++ b/sf-ui/src/api/mandate/appMandate.js @@ -0,0 +1,66 @@ +import request from '@/utils/request' + +// 查询应用授权列表 +export function listAppMandate (query) { + return request({ + url: '/mandate/appMandate/list', + method: 'get', + params: query + }) +} + +// 查询应用授权详细 +export function getAppMandate (id) { + return request({ + url: '/mandate/appMandate/' + id, + method: 'get' + }) +} + +// 新增应用授权 +export function addAppMandate (data) { + return request({ + url: '/mandate/appMandate', + method: 'post', + data: data + }) +} + +// 新增应用授权批量 +export function addAppMandateList (data) { + return request({ + url: '/mandate/appMandate/addList', + method: 'post', + data: data + }) +} + + +// 修改应用授权 +export function updateAppMandate (data) { + return request({ + url: '/mandate/appMandate', + method: 'put', + data: data + }) +} + +// 删除应用授权 +export function delAppMandate (id) { + return request({ + url: '/mandate/appMandate/' + id, + method: 'delete' + }) +} + + + + +// 查询应用授权列表 +export function appMandateUser () { + return request({ + url: '/mandate/appMandate/queryUser', + method: 'get', + + }) +} diff --git a/sf-ui/src/api/menu.js b/sf-ui/src/api/menu.js index 6e52e6e..faef101 100644 --- a/sf-ui/src/api/menu.js +++ b/sf-ui/src/api/menu.js @@ -1,9 +1,9 @@ -import request from '@/utils/request' - -// 获取路由 -export const getRouters = () => { - return request({ - url: '/getRouters', - method: 'get' - }) +import request from '@/utils/request' + +// 获取路由 +export const getRouters = () => { + return request({ + url: '/getRouters', + method: 'get' + }) } \ No newline at end of file diff --git a/sf-ui/src/api/monitor/cache.js b/sf-ui/src/api/monitor/cache.js index e1f2c87..72c5f6a 100644 --- a/sf-ui/src/api/monitor/cache.js +++ b/sf-ui/src/api/monitor/cache.js @@ -1,57 +1,57 @@ -import request from '@/utils/request' - -// 查询缓存详细 -export function getCache() { - return request({ - url: '/monitor/cache', - method: 'get' - }) -} - -// 查询缓存名称列表 -export function listCacheName() { - return request({ - url: '/monitor/cache/getNames', - method: 'get' - }) -} - -// 查询缓存键名列表 -export function listCacheKey(cacheName) { - return request({ - url: '/monitor/cache/getKeys/' + cacheName, - method: 'get' - }) -} - -// 查询缓存内容 -export function getCacheValue(cacheName, cacheKey) { - return request({ - url: '/monitor/cache/getValue/' + cacheName + '/' + cacheKey, - method: 'get' - }) -} - -// 清理指定名称缓存 -export function clearCacheName(cacheName) { - return request({ - url: '/monitor/cache/clearCacheName/' + cacheName, - method: 'delete' - }) -} - -// 清理指定键名缓存 -export function clearCacheKey(cacheKey) { - return request({ - url: '/monitor/cache/clearCacheKey/' + cacheKey, - method: 'delete' - }) -} - -// 清理全部缓存 -export function clearCacheAll() { - return request({ - url: '/monitor/cache/clearCacheAll', - method: 'delete' - }) -} +import request from '@/utils/request' + +// 查询缓存详细 +export function getCache() { + return request({ + url: '/monitor/cache', + method: 'get' + }) +} + +// 查询缓存名称列表 +export function listCacheName() { + return request({ + url: '/monitor/cache/getNames', + method: 'get' + }) +} + +// 查询缓存键名列表 +export function listCacheKey(cacheName) { + return request({ + url: '/monitor/cache/getKeys/' + cacheName, + method: 'get' + }) +} + +// 查询缓存内容 +export function getCacheValue(cacheName, cacheKey) { + return request({ + url: '/monitor/cache/getValue/' + cacheName + '/' + cacheKey, + method: 'get' + }) +} + +// 清理指定名称缓存 +export function clearCacheName(cacheName) { + return request({ + url: '/monitor/cache/clearCacheName/' + cacheName, + method: 'delete' + }) +} + +// 清理指定键名缓存 +export function clearCacheKey(cacheKey) { + return request({ + url: '/monitor/cache/clearCacheKey/' + cacheKey, + method: 'delete' + }) +} + +// 清理全部缓存 +export function clearCacheAll() { + return request({ + url: '/monitor/cache/clearCacheAll', + method: 'delete' + }) +} diff --git a/sf-ui/src/api/monitor/logininfor.js b/sf-ui/src/api/monitor/logininfor.js index c49a40e..4d112b7 100644 --- a/sf-ui/src/api/monitor/logininfor.js +++ b/sf-ui/src/api/monitor/logininfor.js @@ -1,34 +1,34 @@ -import request from '@/utils/request' - -// 查询登录日志列表 -export function list(query) { - return request({ - url: '/monitor/logininfor/list', - method: 'get', - params: query - }) -} - -// 删除登录日志 -export function delLogininfor(infoId) { - return request({ - url: '/monitor/logininfor/' + infoId, - method: 'delete' - }) -} - -// 解锁用户登录状态 -export function unlockLogininfor(userName) { - return request({ - url: '/monitor/logininfor/unlock/' + userName, - method: 'get' - }) -} - -// 清空登录日志 -export function cleanLogininfor() { - return request({ - url: '/monitor/logininfor/clean', - method: 'delete' - }) -} +import request from '@/utils/request' + +// 查询登录日志列表 +export function list(query) { + return request({ + url: '/monitor/logininfor/list', + method: 'get', + params: query + }) +} + +// 删除登录日志 +export function delLogininfor(infoId) { + return request({ + url: '/monitor/logininfor/' + infoId, + method: 'delete' + }) +} + +// 解锁用户登录状态 +export function unlockLogininfor(userName) { + return request({ + url: '/monitor/logininfor/unlock/' + userName, + method: 'get' + }) +} + +// 清空登录日志 +export function cleanLogininfor() { + return request({ + url: '/monitor/logininfor/clean', + method: 'delete' + }) +} diff --git a/sf-ui/src/api/monitor/online.js b/sf-ui/src/api/monitor/online.js index 288ebe0..bd22137 100644 --- a/sf-ui/src/api/monitor/online.js +++ b/sf-ui/src/api/monitor/online.js @@ -1,18 +1,18 @@ -import request from '@/utils/request' - -// 查询在线用户列表 -export function list(query) { - return request({ - url: '/monitor/online/list', - method: 'get', - params: query - }) -} - -// 强退用户 -export function forceLogout(tokenId) { - return request({ - url: '/monitor/online/' + tokenId, - method: 'delete' - }) -} +import request from '@/utils/request' + +// 查询在线用户列表 +export function list(query) { + return request({ + url: '/monitor/online/list', + method: 'get', + params: query + }) +} + +// 强退用户 +export function forceLogout(tokenId) { + return request({ + url: '/monitor/online/' + tokenId, + method: 'delete' + }) +} diff --git a/sf-ui/src/api/monitor/operlog.js b/sf-ui/src/api/monitor/operlog.js index 6e881df..a04bca8 100644 --- a/sf-ui/src/api/monitor/operlog.js +++ b/sf-ui/src/api/monitor/operlog.js @@ -1,26 +1,26 @@ -import request from '@/utils/request' - -// 查询操作日志列表 -export function list(query) { - return request({ - url: '/monitor/operlog/list', - method: 'get', - params: query - }) -} - -// 删除操作日志 -export function delOperlog(operId) { - return request({ - url: '/monitor/operlog/' + operId, - method: 'delete' - }) -} - -// 清空操作日志 -export function cleanOperlog() { - return request({ - url: '/monitor/operlog/clean', - method: 'delete' - }) -} +import request from '@/utils/request' + +// 查询操作日志列表 +export function list(query) { + return request({ + url: '/monitor/operlog/list', + method: 'get', + params: query + }) +} + +// 删除操作日志 +export function delOperlog(operId) { + return request({ + url: '/monitor/operlog/' + operId, + method: 'delete' + }) +} + +// 清空操作日志 +export function cleanOperlog() { + return request({ + url: '/monitor/operlog/clean', + method: 'delete' + }) +} diff --git a/sf-ui/src/api/monitor/server.js b/sf-ui/src/api/monitor/server.js index cac7791..e1f9ca2 100644 --- a/sf-ui/src/api/monitor/server.js +++ b/sf-ui/src/api/monitor/server.js @@ -1,9 +1,9 @@ -import request from '@/utils/request' - -// 获取服务信息 -export function getServer() { - return request({ - url: '/monitor/server', - method: 'get' - }) +import request from '@/utils/request' + +// 获取服务信息 +export function getServer() { + return request({ + url: '/monitor/server', + method: 'get' + }) } \ No newline at end of file diff --git a/sf-ui/src/api/system/config.js b/sf-ui/src/api/system/config.js index 7858c69..a404d82 100644 --- a/sf-ui/src/api/system/config.js +++ b/sf-ui/src/api/system/config.js @@ -1,60 +1,60 @@ -import request from '@/utils/request' - -// 查询参数列表 -export function listConfig(query) { - return request({ - url: '/system/config/list', - method: 'get', - params: query - }) -} - -// 查询参数详细 -export function getConfig(configId) { - return request({ - url: '/system/config/' + configId, - method: 'get' - }) -} - -// 根据参数键名查询参数值 -export function getConfigKey(configKey) { - return request({ - url: '/system/config/configKey/' + configKey, - method: 'get' - }) -} - -// 新增参数配置 -export function addConfig(data) { - return request({ - url: '/system/config', - method: 'post', - data: data - }) -} - -// 修改参数配置 -export function updateConfig(data) { - return request({ - url: '/system/config', - method: 'put', - data: data - }) -} - -// 删除参数配置 -export function delConfig(configId) { - return request({ - url: '/system/config/' + configId, - method: 'delete' - }) -} - -// 刷新参数缓存 -export function refreshCache() { - return request({ - url: '/system/config/refreshCache', - method: 'delete' - }) -} +import request from '@/utils/request' + +// 查询参数列表 +export function listConfig(query) { + return request({ + url: '/system/config/list', + method: 'get', + params: query + }) +} + +// 查询参数详细 +export function getConfig(configId) { + return request({ + url: '/system/config/' + configId, + method: 'get' + }) +} + +// 根据参数键名查询参数值 +export function getConfigKey(configKey) { + return request({ + url: '/system/config/configKey/' + configKey, + method: 'get' + }) +} + +// 新增参数配置 +export function addConfig(data) { + return request({ + url: '/system/config', + method: 'post', + data: data + }) +} + +// 修改参数配置 +export function updateConfig(data) { + return request({ + url: '/system/config', + method: 'put', + data: data + }) +} + +// 删除参数配置 +export function delConfig(configId) { + return request({ + url: '/system/config/' + configId, + method: 'delete' + }) +} + +// 刷新参数缓存 +export function refreshCache() { + return request({ + url: '/system/config/refreshCache', + method: 'delete' + }) +} diff --git a/sf-ui/src/api/system/dept.js b/sf-ui/src/api/system/dept.js index 9ca6966..fc943cd 100644 --- a/sf-ui/src/api/system/dept.js +++ b/sf-ui/src/api/system/dept.js @@ -1,52 +1,52 @@ -import request from '@/utils/request' - -// 查询部门列表 -export function listDept(query) { - return request({ - url: '/system/dept/list', - method: 'get', - params: query - }) -} - -// 查询部门列表(排除节点) -export function listDeptExcludeChild(deptId) { - return request({ - url: '/system/dept/list/exclude/' + deptId, - method: 'get' - }) -} - -// 查询部门详细 -export function getDept(deptId) { - return request({ - url: '/system/dept/' + deptId, - method: 'get' - }) -} - -// 新增部门 -export function addDept(data) { - return request({ - url: '/system/dept', - method: 'post', - data: data - }) -} - -// 修改部门 -export function updateDept(data) { - return request({ - url: '/system/dept', - method: 'put', - data: data - }) -} - -// 删除部门 -export function delDept(deptId) { - return request({ - url: '/system/dept/' + deptId, - method: 'delete' - }) +import request from '@/utils/request' + +// 查询部门列表 +export function listDept(query) { + return request({ + url: '/system/dept/list', + method: 'get', + params: query + }) +} + +// 查询部门列表(排除节点) +export function listDeptExcludeChild(deptId) { + return request({ + url: '/system/dept/list/exclude/' + deptId, + method: 'get' + }) +} + +// 查询部门详细 +export function getDept(deptId) { + return request({ + url: '/system/dept/' + deptId, + method: 'get' + }) +} + +// 新增部门 +export function addDept(data) { + return request({ + url: '/system/dept', + method: 'post', + data: data + }) +} + +// 修改部门 +export function updateDept(data) { + return request({ + url: '/system/dept', + method: 'put', + data: data + }) +} + +// 删除部门 +export function delDept(deptId) { + return request({ + url: '/system/dept/' + deptId, + method: 'delete' + }) } \ No newline at end of file diff --git a/sf-ui/src/api/system/dict/data.js b/sf-ui/src/api/system/dict/data.js index 2a6e481..6c9eb79 100644 --- a/sf-ui/src/api/system/dict/data.js +++ b/sf-ui/src/api/system/dict/data.js @@ -1,52 +1,52 @@ -import request from '@/utils/request' - -// 查询字典数据列表 -export function listData(query) { - return request({ - url: '/system/dict/data/list', - method: 'get', - params: query - }) -} - -// 查询字典数据详细 -export function getData(dictCode) { - return request({ - url: '/system/dict/data/' + dictCode, - method: 'get' - }) -} - -// 根据字典类型查询字典数据信息 -export function getDicts(dictType) { - return request({ - url: '/system/dict/data/type/' + dictType, - method: 'get' - }) -} - -// 新增字典数据 -export function addData(data) { - return request({ - url: '/system/dict/data', - method: 'post', - data: data - }) -} - -// 修改字典数据 -export function updateData(data) { - return request({ - url: '/system/dict/data', - method: 'put', - data: data - }) -} - -// 删除字典数据 -export function delData(dictCode) { - return request({ - url: '/system/dict/data/' + dictCode, - method: 'delete' - }) -} +import request from '@/utils/request' + +// 查询字典数据列表 +export function listData(query) { + return request({ + url: '/system/dict/data/list', + method: 'get', + params: query + }) +} + +// 查询字典数据详细 +export function getData(dictCode) { + return request({ + url: '/system/dict/data/' + dictCode, + method: 'get' + }) +} + +// 根据字典类型查询字典数据信息 +export function getDicts(dictType) { + return request({ + url: '/system/dict/data/type/' + dictType, + method: 'get' + }) +} + +// 新增字典数据 +export function addData(data) { + return request({ + url: '/system/dict/data', + method: 'post', + data: data + }) +} + +// 修改字典数据 +export function updateData(data) { + return request({ + url: '/system/dict/data', + method: 'put', + data: data + }) +} + +// 删除字典数据 +export function delData(dictCode) { + return request({ + url: '/system/dict/data/' + dictCode, + method: 'delete' + }) +} diff --git a/sf-ui/src/api/system/dict/type.js b/sf-ui/src/api/system/dict/type.js index 526977d..a7a6e01 100644 --- a/sf-ui/src/api/system/dict/type.js +++ b/sf-ui/src/api/system/dict/type.js @@ -1,60 +1,60 @@ -import request from '@/utils/request' - -// 查询字典类型列表 -export function listType(query) { - return request({ - url: '/system/dict/type/list', - method: 'get', - params: query - }) -} - -// 查询字典类型详细 -export function getType(dictId) { - return request({ - url: '/system/dict/type/' + dictId, - method: 'get' - }) -} - -// 新增字典类型 -export function addType(data) { - return request({ - url: '/system/dict/type', - method: 'post', - data: data - }) -} - -// 修改字典类型 -export function updateType(data) { - return request({ - url: '/system/dict/type', - method: 'put', - data: data - }) -} - -// 删除字典类型 -export function delType(dictId) { - return request({ - url: '/system/dict/type/' + dictId, - method: 'delete' - }) -} - -// 刷新字典缓存 -export function refreshCache() { - return request({ - url: '/system/dict/type/refreshCache', - method: 'delete' - }) -} - -// 获取字典选择框列表 -export function optionselect() { - return request({ - url: '/system/dict/type/optionselect', - method: 'get' - }) +import request from '@/utils/request' + +// 查询字典类型列表 +export function listType(query) { + return request({ + url: '/system/dict/type/list', + method: 'get', + params: query + }) +} + +// 查询字典类型详细 +export function getType(dictId) { + return request({ + url: '/system/dict/type/' + dictId, + method: 'get' + }) +} + +// 新增字典类型 +export function addType(data) { + return request({ + url: '/system/dict/type', + method: 'post', + data: data + }) +} + +// 修改字典类型 +export function updateType(data) { + return request({ + url: '/system/dict/type', + method: 'put', + data: data + }) +} + +// 删除字典类型 +export function delType(dictId) { + return request({ + url: '/system/dict/type/' + dictId, + method: 'delete' + }) +} + +// 刷新字典缓存 +export function refreshCache() { + return request({ + url: '/system/dict/type/refreshCache', + method: 'delete' + }) +} + +// 获取字典选择框列表 +export function optionselect() { + return request({ + url: '/system/dict/type/optionselect', + method: 'get' + }) } \ No newline at end of file diff --git a/sf-ui/src/api/system/menu.js b/sf-ui/src/api/system/menu.js index 97258ee..f6415c6 100644 --- a/sf-ui/src/api/system/menu.js +++ b/sf-ui/src/api/system/menu.js @@ -1,60 +1,60 @@ -import request from '@/utils/request' - -// 查询菜单列表 -export function listMenu(query) { - return request({ - url: '/system/menu/list', - method: 'get', - params: query - }) -} - -// 查询菜单详细 -export function getMenu(menuId) { - return request({ - url: '/system/menu/' + menuId, - method: 'get' - }) -} - -// 查询菜单下拉树结构 -export function treeselect() { - return request({ - url: '/system/menu/treeselect', - method: 'get' - }) -} - -// 根据角色ID查询菜单下拉树结构 -export function roleMenuTreeselect(roleId) { - return request({ - url: '/system/menu/roleMenuTreeselect/' + roleId, - method: 'get' - }) -} - -// 新增菜单 -export function addMenu(data) { - return request({ - url: '/system/menu', - method: 'post', - data: data - }) -} - -// 修改菜单 -export function updateMenu(data) { - return request({ - url: '/system/menu', - method: 'put', - data: data - }) -} - -// 删除菜单 -export function delMenu(menuId) { - return request({ - url: '/system/menu/' + menuId, - method: 'delete' - }) +import request from '@/utils/request' + +// 查询菜单列表 +export function listMenu(query) { + return request({ + url: '/system/menu/list', + method: 'get', + params: query + }) +} + +// 查询菜单详细 +export function getMenu(menuId) { + return request({ + url: '/system/menu/' + menuId, + method: 'get' + }) +} + +// 查询菜单下拉树结构 +export function treeselect() { + return request({ + url: '/system/menu/treeselect', + method: 'get' + }) +} + +// 根据角色ID查询菜单下拉树结构 +export function roleMenuTreeselect(roleId) { + return request({ + url: '/system/menu/roleMenuTreeselect/' + roleId, + method: 'get' + }) +} + +// 新增菜单 +export function addMenu(data) { + return request({ + url: '/system/menu', + method: 'post', + data: data + }) +} + +// 修改菜单 +export function updateMenu(data) { + return request({ + url: '/system/menu', + method: 'put', + data: data + }) +} + +// 删除菜单 +export function delMenu(menuId) { + return request({ + url: '/system/menu/' + menuId, + method: 'delete' + }) } \ No newline at end of file diff --git a/sf-ui/src/api/system/notice.js b/sf-ui/src/api/system/notice.js index 737fc16..c274ea5 100644 --- a/sf-ui/src/api/system/notice.js +++ b/sf-ui/src/api/system/notice.js @@ -1,44 +1,44 @@ -import request from '@/utils/request' - -// 查询公告列表 -export function listNotice(query) { - return request({ - url: '/system/notice/list', - method: 'get', - params: query - }) -} - -// 查询公告详细 -export function getNotice(noticeId) { - return request({ - url: '/system/notice/' + noticeId, - method: 'get' - }) -} - -// 新增公告 -export function addNotice(data) { - return request({ - url: '/system/notice', - method: 'post', - data: data - }) -} - -// 修改公告 -export function updateNotice(data) { - return request({ - url: '/system/notice', - method: 'put', - data: data - }) -} - -// 删除公告 -export function delNotice(noticeId) { - return request({ - url: '/system/notice/' + noticeId, - method: 'delete' - }) +import request from '@/utils/request' + +// 查询公告列表 +export function listNotice(query) { + return request({ + url: '/system/notice/list', + method: 'get', + params: query + }) +} + +// 查询公告详细 +export function getNotice(noticeId) { + return request({ + url: '/system/notice/' + noticeId, + method: 'get' + }) +} + +// 新增公告 +export function addNotice(data) { + return request({ + url: '/system/notice', + method: 'post', + data: data + }) +} + +// 修改公告 +export function updateNotice(data) { + return request({ + url: '/system/notice', + method: 'put', + data: data + }) +} + +// 删除公告 +export function delNotice(noticeId) { + return request({ + url: '/system/notice/' + noticeId, + method: 'delete' + }) } \ No newline at end of file diff --git a/sf-ui/src/api/system/post.js b/sf-ui/src/api/system/post.js index 8faa266..1a8e9ca 100644 --- a/sf-ui/src/api/system/post.js +++ b/sf-ui/src/api/system/post.js @@ -1,44 +1,44 @@ -import request from '@/utils/request' - -// 查询岗位列表 -export function listPost(query) { - return request({ - url: '/system/post/list', - method: 'get', - params: query - }) -} - -// 查询岗位详细 -export function getPost(postId) { - return request({ - url: '/system/post/' + postId, - method: 'get' - }) -} - -// 新增岗位 -export function addPost(data) { - return request({ - url: '/system/post', - method: 'post', - data: data - }) -} - -// 修改岗位 -export function updatePost(data) { - return request({ - url: '/system/post', - method: 'put', - data: data - }) -} - -// 删除岗位 -export function delPost(postId) { - return request({ - url: '/system/post/' + postId, - method: 'delete' - }) -} +import request from '@/utils/request' + +// 查询岗位列表 +export function listPost(query) { + return request({ + url: '/system/post/list', + method: 'get', + params: query + }) +} + +// 查询岗位详细 +export function getPost(postId) { + return request({ + url: '/system/post/' + postId, + method: 'get' + }) +} + +// 新增岗位 +export function addPost(data) { + return request({ + url: '/system/post', + method: 'post', + data: data + }) +} + +// 修改岗位 +export function updatePost(data) { + return request({ + url: '/system/post', + method: 'put', + data: data + }) +} + +// 删除岗位 +export function delPost(postId) { + return request({ + url: '/system/post/' + postId, + method: 'delete' + }) +} diff --git a/sf-ui/src/api/system/role.js b/sf-ui/src/api/system/role.js index 528cd18..f13e6f4 100644 --- a/sf-ui/src/api/system/role.js +++ b/sf-ui/src/api/system/role.js @@ -1,119 +1,119 @@ -import request from '@/utils/request' - -// 查询角色列表 -export function listRole(query) { - return request({ - url: '/system/role/list', - method: 'get', - params: query - }) -} - -// 查询角色详细 -export function getRole(roleId) { - return request({ - url: '/system/role/' + roleId, - method: 'get' - }) -} - -// 新增角色 -export function addRole(data) { - return request({ - url: '/system/role', - method: 'post', - data: data - }) -} - -// 修改角色 -export function updateRole(data) { - return request({ - url: '/system/role', - method: 'put', - data: data - }) -} - -// 角色数据权限 -export function dataScope(data) { - return request({ - url: '/system/role/dataScope', - method: 'put', - data: data - }) -} - -// 角色状态修改 -export function changeRoleStatus(roleId, status) { - const data = { - roleId, - status - } - return request({ - url: '/system/role/changeStatus', - method: 'put', - data: data - }) -} - -// 删除角色 -export function delRole(roleId) { - return request({ - url: '/system/role/' + roleId, - method: 'delete' - }) -} - -// 查询角色已授权用户列表 -export function allocatedUserList(query) { - return request({ - url: '/system/role/authUser/allocatedList', - method: 'get', - params: query - }) -} - -// 查询角色未授权用户列表 -export function unallocatedUserList(query) { - return request({ - url: '/system/role/authUser/unallocatedList', - method: 'get', - params: query - }) -} - -// 取消用户授权角色 -export function authUserCancel(data) { - return request({ - url: '/system/role/authUser/cancel', - method: 'put', - data: data - }) -} - -// 批量取消用户授权角色 -export function authUserCancelAll(data) { - return request({ - url: '/system/role/authUser/cancelAll', - method: 'put', - params: data - }) -} - -// 授权用户选择 -export function authUserSelectAll(data) { - return request({ - url: '/system/role/authUser/selectAll', - method: 'put', - params: data - }) -} - -// 根据角色ID查询部门树结构 -export function deptTreeSelect(roleId) { - return request({ - url: '/system/role/deptTree/' + roleId, - method: 'get' - }) -} +import request from '@/utils/request' + +// 查询角色列表 +export function listRole(query) { + return request({ + url: '/system/role/list', + method: 'get', + params: query + }) +} + +// 查询角色详细 +export function getRole(roleId) { + return request({ + url: '/system/role/' + roleId, + method: 'get' + }) +} + +// 新增角色 +export function addRole(data) { + return request({ + url: '/system/role', + method: 'post', + data: data + }) +} + +// 修改角色 +export function updateRole(data) { + return request({ + url: '/system/role', + method: 'put', + data: data + }) +} + +// 角色数据权限 +export function dataScope(data) { + return request({ + url: '/system/role/dataScope', + method: 'put', + data: data + }) +} + +// 角色状态修改 +export function changeRoleStatus(roleId, status) { + const data = { + roleId, + status + } + return request({ + url: '/system/role/changeStatus', + method: 'put', + data: data + }) +} + +// 删除角色 +export function delRole(roleId) { + return request({ + url: '/system/role/' + roleId, + method: 'delete' + }) +} + +// 查询角色已授权用户列表 +export function allocatedUserList(query) { + return request({ + url: '/system/role/authUser/allocatedList', + method: 'get', + params: query + }) +} + +// 查询角色未授权用户列表 +export function unallocatedUserList(query) { + return request({ + url: '/system/role/authUser/unallocatedList', + method: 'get', + params: query + }) +} + +// 取消用户授权角色 +export function authUserCancel(data) { + return request({ + url: '/system/role/authUser/cancel', + method: 'put', + data: data + }) +} + +// 批量取消用户授权角色 +export function authUserCancelAll(data) { + return request({ + url: '/system/role/authUser/cancelAll', + method: 'put', + params: data + }) +} + +// 授权用户选择 +export function authUserSelectAll(data) { + return request({ + url: '/system/role/authUser/selectAll', + method: 'put', + params: data + }) +} + +// 根据角色ID查询部门树结构 +export function deptTreeSelect(roleId) { + return request({ + url: '/system/role/deptTree/' + roleId, + method: 'get' + }) +} diff --git a/sf-ui/src/api/system/user.js b/sf-ui/src/api/system/user.js index 9b949e9..f2f76ef 100644 --- a/sf-ui/src/api/system/user.js +++ b/sf-ui/src/api/system/user.js @@ -1,135 +1,135 @@ -import request from '@/utils/request' -import { parseStrEmpty } from "@/utils/ruoyi"; - -// 查询用户列表 -export function listUser(query) { - return request({ - url: '/system/user/list', - method: 'get', - params: query - }) -} - -// 查询用户详细 -export function getUser(userId) { - return request({ - url: '/system/user/' + parseStrEmpty(userId), - method: 'get' - }) -} - -// 新增用户 -export function addUser(data) { - return request({ - url: '/system/user', - method: 'post', - data: data - }) -} - -// 修改用户 -export function updateUser(data) { - return request({ - url: '/system/user', - method: 'put', - data: data - }) -} - -// 删除用户 -export function delUser(userId) { - return request({ - url: '/system/user/' + userId, - method: 'delete' - }) -} - -// 用户密码重置 -export function resetUserPwd(userId, password) { - const data = { - userId, - password - } - return request({ - url: '/system/user/resetPwd', - method: 'put', - data: data - }) -} - -// 用户状态修改 -export function changeUserStatus(userId, status) { - const data = { - userId, - status - } - return request({ - url: '/system/user/changeStatus', - method: 'put', - data: data - }) -} - -// 查询用户个人信息 -export function getUserProfile() { - return request({ - url: '/system/user/profile', - method: 'get' - }) -} - -// 修改用户个人信息 -export function updateUserProfile(data) { - return request({ - url: '/system/user/profile', - method: 'put', - data: data - }) -} - -// 用户密码重置 -export function updateUserPwd(oldPassword, newPassword) { - const data = { - oldPassword, - newPassword - } - return request({ - url: '/system/user/profile/updatePwd', - method: 'put', - params: data - }) -} - -// 用户头像上传 -export function uploadAvatar(data) { - return request({ - url: '/system/user/profile/avatar', - method: 'post', - data: data - }) -} - -// 查询授权角色 -export function getAuthRole(userId) { - return request({ - url: '/system/user/authRole/' + userId, - method: 'get' - }) -} - -// 保存授权角色 -export function updateAuthRole(data) { - return request({ - url: '/system/user/authRole', - method: 'put', - params: data - }) -} - -// 查询部门下拉树结构 -export function deptTreeSelect() { - return request({ - url: '/system/user/deptTree', - method: 'get' - }) -} +import request from '@/utils/request' +import { parseStrEmpty } from "@/utils/ruoyi"; + +// 查询用户列表 +export function listUser(query) { + return request({ + url: '/system/user/list', + method: 'get', + params: query + }) +} + +// 查询用户详细 +export function getUser(userId) { + return request({ + url: '/system/user/' + parseStrEmpty(userId), + method: 'get' + }) +} + +// 新增用户 +export function addUser(data) { + return request({ + url: '/system/user', + method: 'post', + data: data + }) +} + +// 修改用户 +export function updateUser(data) { + return request({ + url: '/system/user', + method: 'put', + data: data + }) +} + +// 删除用户 +export function delUser(userId) { + return request({ + url: '/system/user/' + userId, + method: 'delete' + }) +} + +// 用户密码重置 +export function resetUserPwd(userId, password) { + const data = { + userId, + password + } + return request({ + url: '/system/user/resetPwd', + method: 'put', + data: data + }) +} + +// 用户状态修改 +export function changeUserStatus(userId, status) { + const data = { + userId, + status + } + return request({ + url: '/system/user/changeStatus', + method: 'put', + data: data + }) +} + +// 查询用户个人信息 +export function getUserProfile() { + return request({ + url: '/system/user/profile', + method: 'get' + }) +} + +// 修改用户个人信息 +export function updateUserProfile(data) { + return request({ + url: '/system/user/profile', + method: 'put', + data: data + }) +} + +// 用户密码重置 +export function updateUserPwd(oldPassword, newPassword) { + const data = { + oldPassword, + newPassword + } + return request({ + url: '/system/user/profile/updatePwd', + method: 'put', + params: data + }) +} + +// 用户头像上传 +export function uploadAvatar(data) { + return request({ + url: '/system/user/profile/avatar', + method: 'post', + data: data + }) +} + +// 查询授权角色 +export function getAuthRole(userId) { + return request({ + url: '/system/user/authRole/' + userId, + method: 'get' + }) +} + +// 保存授权角色 +export function updateAuthRole(data) { + return request({ + url: '/system/user/authRole', + method: 'put', + params: data + }) +} + +// 查询部门下拉树结构 +export function deptTreeSelect() { + return request({ + url: '/system/user/deptTree', + method: 'get' + }) +} diff --git a/sf-ui/src/api/tool/gen.js b/sf-ui/src/api/tool/gen.js index 30f2239..29a0933 100644 --- a/sf-ui/src/api/tool/gen.js +++ b/sf-ui/src/api/tool/gen.js @@ -1,76 +1,76 @@ -import request from '@/utils/request' - -// 查询生成表数据 -export function listTable(query) { - return request({ - url: '/tool/gen/list', - method: 'get', - params: query - }) -} -// 查询db数据库列表 -export function listDbTable(query) { - return request({ - url: '/tool/gen/db/list', - method: 'get', - params: query - }) -} - -// 查询表详细信息 -export function getGenTable(tableId) { - return request({ - url: '/tool/gen/' + tableId, - method: 'get' - }) -} - -// 修改代码生成信息 -export function updateGenTable(data) { - return request({ - url: '/tool/gen', - method: 'put', - data: data - }) -} - -// 导入表 -export function importTable(data) { - return request({ - url: '/tool/gen/importTable', - method: 'post', - params: data - }) -} - -// 预览生成代码 -export function previewTable(tableId, json) { - return request({ - url: '/tool/gen/preview/' + tableId+'/'+json, - method: 'get' - }) -} - -// 删除表数据 -export function delTable(tableId) { - return request({ - url: '/tool/gen/' + tableId, - method: 'delete' - }) -} - -// 生成代码(自定义路径) -export function genCode(tableName,json) { - return request({ - url: '/tool/gen/genCode/' + tableName+'/'+json, - method: 'get' - }) -} - -// 同步数据库 -export function synchDb(tableName) { - return request({ - url: '/tool/gen/synchDb/' + tableName, - method: 'get' - }) -} +import request from '@/utils/request' + +// 查询生成表数据 +export function listTable(query) { + return request({ + url: '/tool/gen/list', + method: 'get', + params: query + }) +} +// 查询db数据库列表 +export function listDbTable(query) { + return request({ + url: '/tool/gen/db/list', + method: 'get', + params: query + }) +} + +// 查询表详细信息 +export function getGenTable(tableId) { + return request({ + url: '/tool/gen/' + tableId, + method: 'get' + }) +} + +// 修改代码生成信息 +export function updateGenTable(data) { + return request({ + url: '/tool/gen', + method: 'put', + data: data + }) +} + +// 导入表 +export function importTable(data) { + return request({ + url: '/tool/gen/importTable', + method: 'post', + params: data + }) +} + +// 预览生成代码 +export function previewTable(tableId, json) { + return request({ + url: '/tool/gen/preview/' + tableId+'/'+json, + method: 'get' + }) +} + +// 删除表数据 +export function delTable(tableId) { + return request({ + url: '/tool/gen/' + tableId, + method: 'delete' + }) +} + +// 生成代码(自定义路径) +export function genCode(tableName,json) { + return request({ + url: '/tool/gen/genCode/' + tableName+'/'+json, + method: 'get' + }) +} + +// 同步数据库 +export function synchDb(tableName) { + return request({ + url: '/tool/gen/synchDb/' + tableName, + method: 'get' + }) +} diff --git a/sf-ui/src/assets/icons/index.js b/sf-ui/src/assets/icons/index.js index d79e164..2c6b309 100644 --- a/sf-ui/src/assets/icons/index.js +++ b/sf-ui/src/assets/icons/index.js @@ -1,9 +1,9 @@ -import Vue from 'vue' -import SvgIcon from '@/components/SvgIcon'// svg component - -// register globally -Vue.component('svg-icon', SvgIcon) - -const req = require.context('./svg', false, /\.svg$/) -const requireAll = requireContext => requireContext.keys().map(requireContext) -requireAll(req) +import Vue from 'vue' +import SvgIcon from '@/components/SvgIcon'// svg component + +// register globally +Vue.component('svg-icon', SvgIcon) + +const req = require.context('./svg', false, /\.svg$/) +const requireAll = requireContext => requireContext.keys().map(requireContext) +requireAll(req) diff --git a/sf-ui/src/assets/icons/svg/monitor.svg b/sf-ui/src/assets/icons/svg/monitor.svg index 70db62b..bc308cb 100644 --- a/sf-ui/src/assets/icons/svg/monitor.svg +++ b/sf-ui/src/assets/icons/svg/monitor.svg @@ -1,2 +1,2 @@ -{{ item.label + ' ' }}{{ item.label + " " }} - {{ item.label + ' ' }} + {{ item.label + " " }} @@ -29,63 +29,61 @@ diff --git a/sf-ui/src/components/DropDown/MyDropDownItem.vue b/sf-ui/src/components/DropDown/MyDropDownItem.vue new file mode 100644 index 0000000..44891b1 --- /dev/null +++ b/sf-ui/src/components/DropDown/MyDropDownItem.vue @@ -0,0 +1,75 @@ + + + diff --git a/sf-ui/src/components/DropDown/MyDropDownMenu.vue b/sf-ui/src/components/DropDown/MyDropDownMenu.vue new file mode 100644 index 0000000..be8241d --- /dev/null +++ b/sf-ui/src/components/DropDown/MyDropDownMenu.vue @@ -0,0 +1,96 @@ + + + diff --git a/sf-ui/src/components/DropDown/emitter.js b/sf-ui/src/components/DropDown/emitter.js new file mode 100644 index 0000000..2a9d250 --- /dev/null +++ b/sf-ui/src/components/DropDown/emitter.js @@ -0,0 +1,45 @@ +/** + * @Description 由于涉及到跨组件之间通信,因此我们只有自己实现发布订阅的模式,来实现组件之间通信,灵感主要来源于element-ui组件库源码中跨层级父子组件通信方案,本质上也是发布订阅和$emit和$on + * @param { String } componentName 组件名 + * @param { String } eventName 事件名 + * @param { argument } params 参数 + **/ +// 广播通知事件 +function _broadcast (componentName, eventName, params) { + // 遍历当前组件的子组件 + this.$children.forEach(function (child) { + // 取出componentName,组件options上面可以自己配置 + var name = child.$options.componentName; + // 如果找到了需要通知的组件名,触发组件上面的$eimit方法,触发自定义事件 + if (name === componentName) { + child.$emit.apply(child, [eventName].concat(params)); + } else { + // 没找到,递归往下找 + _broadcast.apply(child, [componentName, eventName].concat([params])); + } + }); +} +const emiiter = { + methods: { + // 派发事件(通知父组件) + dispatch (componentName, eventName, params) { + var parent = this.$parent || this.$root; + var name = parent.$options.componentName; + // 循环往上层父组件,知道知道组件名和需要触发的组件名相同即可,然后触发对应组件的事件 + while (parent && (!name || name !== componentName)) { + parent = parent.$parent; + if (parent) { + name = parent.$options.componentName; + } + } + if (parent) { + parent.$emit.apply(parent, [eventName].concat(params)); + } + }, + // 广播事件(通知子组件) + broadcast (componentName, eventName, params) { + _broadcast.call(this, componentName, eventName, params); + }, + }, +}; +export default emiiter; diff --git a/sf-ui/src/components/FileUpload/index.vue b/sf-ui/src/components/FileUpload/index.vue index 8055550..038d340 100644 --- a/sf-ui/src/components/FileUpload/index.vue +++ b/sf-ui/src/components/FileUpload/index.vue @@ -2,7 +2,7 @@
- 选取文件 + 选取文件
- 请上传 + + 支持扩展名:{{ suffixArr.join(' ') }}...
@@ -30,7 +31,7 @@
  • - {{ getFileName(file.name) }} + {{ getFileName(file) }}
    删除 @@ -72,12 +73,12 @@ export default { type: String, default: () => '/system/oss/zip/upload' }, - accept: { - type: Array, - default: () => [] + multiple: { + type: Boolean, + default: true } }, - data() { + data () { return { number: 0, uploadList: [], @@ -91,8 +92,9 @@ export default { }, watch: { value: { - handler(val) { + handler (val) { if (val) { + console.log(val) let temp = 1 // 首先将值转为数组 const list = Array.isArray(val) ? val : this.value.split(',') @@ -115,18 +117,23 @@ export default { }, computed: { // 是否显示提示 - showTip() { + showTip () { return this.isShowTip && (this.fileType || this.fileSize) + }, + suffixArr() { + return this.fileType.map(item => { + return `.${item}` + }) } }, methods: { // 上传前校检格式和大小 - handleBeforeUpload(file) { + handleBeforeUpload (file) { // 校检文件类型 if (this.fileType) { const fileName = file.name.split('.') const fileExt = fileName[fileName.length - 1] - const isTypeOk = this.fileType.indexOf(fileExt) >= 0 + const isTypeOk = this.fileType.indexOf(fileExt.toLocaleUpperCase()) >= 0 || this.fileType.indexOf(fileExt.toLocaleLowerCase()) >= 0 if (!isTypeOk) { this.$modal.msgError(`文件格式不正确, 请上传${this.fileType.join('/')}格式文件!`) return false @@ -145,19 +152,21 @@ export default { return true }, // 文件个数超出 - handleExceed() { + handleExceed () { this.$modal.msgError(`上传文件数量不能超过 ${this.limit} 个!`) }, // 上传失败 - handleUploadError(err) { + handleUploadError (err) { this.$modal.msgError('上传文件失败,请重试') this.$modal.closeLoading() }, // 上传成功回调 - handleUploadSuccess(res, file) { + handleUploadSuccess (res, file) { if (res.code === 200) { - this.uploadList.push({ name: res.data.url, url: res.data.url, size: res.data.size }) - + const { data } = res; + data.name = data.url; + this.uploadList.push(data) + this.uploadedSuccessfully() } else { this.number-- @@ -168,23 +177,28 @@ export default { } }, // 删除文件 - handleDelete(index) { + handleDelete (index) { this.fileList.splice(index, 1) this.$emit('input', this.listToString(this.fileList)) + this.$emit('change', this.fileList) + this.$emit('getSize', this.fileList) }, // 上传结束处理 - uploadedSuccessfully() { + uploadedSuccessfully () { if (this.number > 0 && this.uploadList.length === this.number) { this.fileList = this.fileList.concat(this.uploadList) this.uploadList = [] this.number = 0 this.$emit('input', this.listToString(this.fileList)) + this.$emit('change', this.fileList) this.$emit('getSize', this.fileList) this.$modal.closeLoading() } }, // 获取文件名称 - getFileName(name) { + getFileName(file) { + const {name, originalName} = file; + if (originalName) return originalName; if (name.lastIndexOf('/') > -1) { return name.slice(name.lastIndexOf('/') + 1) } else { @@ -192,7 +206,7 @@ export default { } }, // 对象转成指定字符串分隔 - listToString(list, separator) { + listToString (list, separator) { let strs = '' separator = separator || ',' for (let i in list) { diff --git a/sf-ui/src/components/Hamburger/index.vue b/sf-ui/src/components/Hamburger/index.vue index c6a4359..368b002 100644 --- a/sf-ui/src/components/Hamburger/index.vue +++ b/sf-ui/src/components/Hamburger/index.vue @@ -1,44 +1,44 @@ - - - - - + + + + + diff --git a/sf-ui/src/components/HeaderSearch/index.vue b/sf-ui/src/components/HeaderSearch/index.vue index 6e9b72f..c4d76bb 100644 --- a/sf-ui/src/components/HeaderSearch/index.vue +++ b/sf-ui/src/components/HeaderSearch/index.vue @@ -1,189 +1,189 @@ - - - - - + + + + + diff --git a/sf-ui/src/components/IconSelect/requireIcons.js b/sf-ui/src/components/IconSelect/requireIcons.js index 5d3005d..99e5c54 100644 --- a/sf-ui/src/components/IconSelect/requireIcons.js +++ b/sf-ui/src/components/IconSelect/requireIcons.js @@ -1,11 +1,11 @@ - -const req = require.context('../../assets/icons/svg', false, /\.svg$/) -const requireAll = requireContext => requireContext.keys() - -const re = /\.\/(.*)\.svg/ - -const icons = requireAll(req).map(i => { - return i.match(re)[1] -}) - -export default icons + +const req = require.context('../../assets/icons/svg', false, /\.svg$/) +const requireAll = requireContext => requireContext.keys() + +const re = /\.\/(.*)\.svg/ + +const icons = requireAll(req).map(i => { + return i.match(re)[1] +}) + +export default icons diff --git a/sf-ui/src/components/ImageUpload/index.vue b/sf-ui/src/components/ImageUpload/index.vue index 8aa25f1..1973047 100644 --- a/sf-ui/src/components/ImageUpload/index.vue +++ b/sf-ui/src/components/ImageUpload/index.vue @@ -1,242 +1,223 @@ - - - - - + + + + + diff --git a/sf-ui/src/components/Pagination/index.vue b/sf-ui/src/components/Pagination/index.vue index 1617af0..56f5a6b 100644 --- a/sf-ui/src/components/Pagination/index.vue +++ b/sf-ui/src/components/Pagination/index.vue @@ -1,114 +1,114 @@ - - - - - + + + + + diff --git a/sf-ui/src/components/PanThumb/index.vue b/sf-ui/src/components/PanThumb/index.vue index 796b01b..1bcf417 100644 --- a/sf-ui/src/components/PanThumb/index.vue +++ b/sf-ui/src/components/PanThumb/index.vue @@ -1,142 +1,142 @@ - - - - - + + + + + diff --git a/sf-ui/src/components/RightPanel/index.vue b/sf-ui/src/components/RightPanel/index.vue index 25ce3f8..5abeecb 100644 --- a/sf-ui/src/components/RightPanel/index.vue +++ b/sf-ui/src/components/RightPanel/index.vue @@ -1,106 +1,106 @@ - - - - - + + + + + diff --git a/sf-ui/src/components/RightToolbar/index.vue b/sf-ui/src/components/RightToolbar/index.vue index 776fcee..527e07c 100644 --- a/sf-ui/src/components/RightToolbar/index.vue +++ b/sf-ui/src/components/RightToolbar/index.vue @@ -1,104 +1,104 @@ - - - + + + diff --git a/sf-ui/src/components/RuoYi/Doc/index.vue b/sf-ui/src/components/RuoYi/Doc/index.vue index cc829b2..75fa864 100644 --- a/sf-ui/src/components/RuoYi/Doc/index.vue +++ b/sf-ui/src/components/RuoYi/Doc/index.vue @@ -1,21 +1,21 @@ - - - \ No newline at end of file diff --git a/sf-ui/src/components/RuoYi/Git/index.vue b/sf-ui/src/components/RuoYi/Git/index.vue index 517c448..bdafbae 100644 --- a/sf-ui/src/components/RuoYi/Git/index.vue +++ b/sf-ui/src/components/RuoYi/Git/index.vue @@ -1,21 +1,21 @@ - - - \ No newline at end of file diff --git a/sf-ui/src/components/Screenfull/index.vue b/sf-ui/src/components/Screenfull/index.vue index 85937c9..d4e539c 100644 --- a/sf-ui/src/components/Screenfull/index.vue +++ b/sf-ui/src/components/Screenfull/index.vue @@ -1,57 +1,57 @@ - - - - - + + + + + diff --git a/sf-ui/src/components/SizeSelect/index.vue b/sf-ui/src/components/SizeSelect/index.vue index 00496f7..2ba215d 100644 --- a/sf-ui/src/components/SizeSelect/index.vue +++ b/sf-ui/src/components/SizeSelect/index.vue @@ -1,56 +1,56 @@ - - - + + + diff --git a/sf-ui/src/components/SvgIcon/index.vue b/sf-ui/src/components/SvgIcon/index.vue index 340ace4..e4bf5ad 100644 --- a/sf-ui/src/components/SvgIcon/index.vue +++ b/sf-ui/src/components/SvgIcon/index.vue @@ -1,61 +1,61 @@ - - - - - + + + + + diff --git a/sf-ui/src/components/ThemePicker/index.vue b/sf-ui/src/components/ThemePicker/index.vue index 4ba9bd2..1714e1f 100644 --- a/sf-ui/src/components/ThemePicker/index.vue +++ b/sf-ui/src/components/ThemePicker/index.vue @@ -1,173 +1,173 @@ - - - - - + + + + + diff --git a/sf-ui/src/components/iFrame/index.vue b/sf-ui/src/components/iFrame/index.vue index 4b85f36..426857f 100644 --- a/sf-ui/src/components/iFrame/index.vue +++ b/sf-ui/src/components/iFrame/index.vue @@ -1,36 +1,36 @@ - - - + + + diff --git a/sf-ui/src/layout/components/Navbar.vue b/sf-ui/src/layout/components/Navbar.vue index 7506ba1..5bffc6a 100644 --- a/sf-ui/src/layout/components/Navbar.vue +++ b/sf-ui/src/layout/components/Navbar.vue @@ -1,205 +1,206 @@ - - - - - + + + + + diff --git a/sf-ui/src/layout/components/Settings/index.vue b/sf-ui/src/layout/components/Settings/index.vue index 068acbf..e681fd5 100644 --- a/sf-ui/src/layout/components/Settings/index.vue +++ b/sf-ui/src/layout/components/Settings/index.vue @@ -1,260 +1,260 @@ - - - - - + + + + + diff --git a/sf-ui/src/layout/components/Sidebar/FixiOSBug.js b/sf-ui/src/layout/components/Sidebar/FixiOSBug.js index 3d8cc21..6823726 100644 --- a/sf-ui/src/layout/components/Sidebar/FixiOSBug.js +++ b/sf-ui/src/layout/components/Sidebar/FixiOSBug.js @@ -1,25 +1,25 @@ -export default { - computed: { - device() { - return this.$store.state.app.device - } - }, - mounted() { - // In order to fix the click on menu on the ios device will trigger the mouseleave bug - this.fixBugIniOS() - }, - methods: { - fixBugIniOS() { - const $subMenu = this.$refs.subMenu - if ($subMenu) { - const handleMouseleave = $subMenu.handleMouseleave - $subMenu.handleMouseleave = (e) => { - if (this.device === 'mobile') { - return - } - handleMouseleave(e) - } - } - } - } -} +export default { + computed: { + device() { + return this.$store.state.app.device + } + }, + mounted() { + // In order to fix the click on menu on the ios device will trigger the mouseleave bug + this.fixBugIniOS() + }, + methods: { + fixBugIniOS() { + const $subMenu = this.$refs.subMenu + if ($subMenu) { + const handleMouseleave = $subMenu.handleMouseleave + $subMenu.handleMouseleave = (e) => { + if (this.device === 'mobile') { + return + } + handleMouseleave(e) + } + } + } + } +} diff --git a/sf-ui/src/layout/components/Sidebar/Item.vue b/sf-ui/src/layout/components/Sidebar/Item.vue index 37214aa..be3285d 100644 --- a/sf-ui/src/layout/components/Sidebar/Item.vue +++ b/sf-ui/src/layout/components/Sidebar/Item.vue @@ -1,33 +1,33 @@ - + diff --git a/sf-ui/src/layout/components/Sidebar/Link.vue b/sf-ui/src/layout/components/Sidebar/Link.vue index cc62468..8b0bc93 100644 --- a/sf-ui/src/layout/components/Sidebar/Link.vue +++ b/sf-ui/src/layout/components/Sidebar/Link.vue @@ -1,43 +1,43 @@ - - - + + + diff --git a/sf-ui/src/layout/components/Sidebar/Logo.vue b/sf-ui/src/layout/components/Sidebar/Logo.vue index 35cc528..b17f37f 100644 --- a/sf-ui/src/layout/components/Sidebar/Logo.vue +++ b/sf-ui/src/layout/components/Sidebar/Logo.vue @@ -1,93 +1,93 @@ - - - - - + + + + + diff --git a/sf-ui/src/layout/components/Sidebar/SidebarItem.vue b/sf-ui/src/layout/components/Sidebar/SidebarItem.vue index 1baf540..4853fbb 100644 --- a/sf-ui/src/layout/components/Sidebar/SidebarItem.vue +++ b/sf-ui/src/layout/components/Sidebar/SidebarItem.vue @@ -1,100 +1,100 @@ - - - + + + diff --git a/sf-ui/src/layout/components/Sidebar/index.vue b/sf-ui/src/layout/components/Sidebar/index.vue index 24fb533..51d0839 100644 --- a/sf-ui/src/layout/components/Sidebar/index.vue +++ b/sf-ui/src/layout/components/Sidebar/index.vue @@ -1,57 +1,57 @@ - - - + + + diff --git a/sf-ui/src/layout/components/TagsView/index.vue b/sf-ui/src/layout/components/TagsView/index.vue index 1fc2323..96585a5 100644 --- a/sf-ui/src/layout/components/TagsView/index.vue +++ b/sf-ui/src/layout/components/TagsView/index.vue @@ -1,332 +1,332 @@ - - - - - - - + + + + + + + diff --git a/sf-ui/src/layout/components/index.js b/sf-ui/src/layout/components/index.js index d60f9ef..104bd3a 100644 --- a/sf-ui/src/layout/components/index.js +++ b/sf-ui/src/layout/components/index.js @@ -1,6 +1,5 @@ -export { default as AppMain } from './AppMain' -export { default as Navbar } from './Navbar' -// export { default as NavbarNew } from './NavbarNew' -export { default as Settings } from './Settings' -export { default as Sidebar } from './Sidebar/index.vue' -export { default as TagsView } from './TagsView/index.vue' +export { default as AppMain } from './AppMain' +export { default as Navbar } from './Navbar' +export { default as Settings } from './Settings' +export { default as Sidebar } from './Sidebar/index.vue' +export { default as TagsView } from './TagsView/index.vue' diff --git a/sf-ui/src/layout/mixin/ResizeHandler.js b/sf-ui/src/layout/mixin/ResizeHandler.js index b3fc8b2..e8d0df8 100644 --- a/sf-ui/src/layout/mixin/ResizeHandler.js +++ b/sf-ui/src/layout/mixin/ResizeHandler.js @@ -1,45 +1,45 @@ -import store from '@/store' - -const { body } = document -const WIDTH = 992 // refer to Bootstrap's responsive design - -export default { - watch: { - $route(route) { - if (this.device === 'mobile' && this.sidebar.opened) { - store.dispatch('app/closeSideBar', { withoutAnimation: false }) - } - } - }, - beforeMount() { - window.addEventListener('resize', this.$_resizeHandler) - }, - beforeDestroy() { - window.removeEventListener('resize', this.$_resizeHandler) - }, - mounted() { - const isMobile = this.$_isMobile() - if (isMobile) { - store.dispatch('app/toggleDevice', 'mobile') - store.dispatch('app/closeSideBar', { withoutAnimation: true }) - } - }, - methods: { - // use $_ for mixins properties - // https://vuejs.org/v2/style-guide/index.html#Private-property-names-essential - $_isMobile() { - const rect = body.getBoundingClientRect() - return rect.width - 1 < WIDTH - }, - $_resizeHandler() { - if (!document.hidden) { - const isMobile = this.$_isMobile() - store.dispatch('app/toggleDevice', isMobile ? 'mobile' : 'desktop') - - if (isMobile) { - store.dispatch('app/closeSideBar', { withoutAnimation: true }) - } - } - } - } -} +import store from '@/store' + +const { body } = document +const WIDTH = 992 // refer to Bootstrap's responsive design + +export default { + watch: { + $route(route) { + if (this.device === 'mobile' && this.sidebar.opened) { + store.dispatch('app/closeSideBar', { withoutAnimation: false }) + } + } + }, + beforeMount() { + window.addEventListener('resize', this.$_resizeHandler) + }, + beforeDestroy() { + window.removeEventListener('resize', this.$_resizeHandler) + }, + mounted() { + const isMobile = this.$_isMobile() + if (isMobile) { + store.dispatch('app/toggleDevice', 'mobile') + store.dispatch('app/closeSideBar', { withoutAnimation: true }) + } + }, + methods: { + // use $_ for mixins properties + // https://vuejs.org/v2/style-guide/index.html#Private-property-names-essential + $_isMobile() { + const rect = body.getBoundingClientRect() + return rect.width - 1 < WIDTH + }, + $_resizeHandler() { + if (!document.hidden) { + const isMobile = this.$_isMobile() + store.dispatch('app/toggleDevice', isMobile ? 'mobile' : 'desktop') + + if (isMobile) { + store.dispatch('app/closeSideBar', { withoutAnimation: true }) + } + } + } + } +} diff --git a/sf-ui/src/main.js b/sf-ui/src/main.js index ebd94b9..3c54e19 100644 --- a/sf-ui/src/main.js +++ b/sf-ui/src/main.js @@ -1,86 +1,90 @@ -import Vue from 'vue' - -import Cookies from 'js-cookie' - -import Element from 'element-ui' -import './assets/styles/element-variables.scss' - -import '@/assets/styles/index.scss' // global css -import '@/assets/styles/ruoyi.scss' // ruoyi css -import App from './App' -import store from './store' -import router from './router' -import directive from './directive' // directive -import plugins from './plugins' // plugins -import { download } from '@/utils/request' - -import './assets/icons' // icon -import './permission' // permission control -import { getDicts } from "@/api/system/dict/data"; -import { getConfigKey } from "@/api/system/config"; -import { parseTime, resetForm, addDateRange, selectDictLabel, selectDictLabels, handleTree } from "@/utils/ruoyi"; -// 分页组件 -import Pagination from "@/components/Pagination"; -// 自定义表格工具组件 -import RightToolbar from "@/components/RightToolbar" -// 富文本组件 -import Editor from "@/components/Editor" -// 文件上传组件 -import FileUpload from "@/components/FileUpload" -// 图片上传组件 -import ImageUpload from "@/components/ImageUpload" -// 图片预览组件 -import ImagePreview from "@/components/ImagePreview" -// 字典标签组件 -import DictTag from '@/components/DictTag' -// 头部标签组件 -import VueMeta from 'vue-meta' -// 字典数据组件 -import DictData from '@/components/DictData' - -// 全局方法挂载 -Vue.prototype.getDicts = getDicts -Vue.prototype.getConfigKey = getConfigKey -Vue.prototype.parseTime = parseTime -Vue.prototype.resetForm = resetForm -Vue.prototype.addDateRange = addDateRange -Vue.prototype.selectDictLabel = selectDictLabel -Vue.prototype.selectDictLabels = selectDictLabels -Vue.prototype.download = download -Vue.prototype.handleTree = handleTree - -// 全局组件挂载 -Vue.component('DictTag', DictTag) -Vue.component('Pagination', Pagination) -Vue.component('RightToolbar', RightToolbar) -Vue.component('Editor', Editor) -Vue.component('FileUpload', FileUpload) -Vue.component('ImageUpload', ImageUpload) -Vue.component('ImagePreview', ImagePreview) - -Vue.use(directive) -Vue.use(plugins) -Vue.use(VueMeta) -DictData.install() - -/** - * If you don't want to use mock-server - * you want to use MockJs for mock api - * you can execute: mockXHR() - * - * Currently MockJs will be used in the production environment, - * please remove it before going online! ! ! - */ - -Vue.use(Element, { - size: Cookies.get('size') || 'medium' // set element-ui default size -}) - -Vue.config.productionTip = false - -new Vue({ - el: '#app', - router, - store, - render: h => h(App) -}) +import Vue from 'vue' + +import Cookies from 'js-cookie' + +import Element from 'element-ui' +import './assets/styles/element-variables.scss' + +import '@/assets/styles/index.scss' // global css +import '@/assets/styles/ruoyi.scss' // ruoyi css +import App from './App' +import store from './store' +import router from './router' +import directive from './directive' // directive +import plugins from './plugins' // plugins +import { download } from '@/utils/request' + +import './assets/icons' // icon +import './permission' // permission control +import { getDicts } from "@/api/system/dict/data"; +import { getConfigKey } from "@/api/system/config"; +import { parseTime, resetForm, addDateRange, selectDictLabel, selectDictLabels, handleTree, addDateRange2 } from "@/utils/ruoyi"; +// 分页组件 +import Pagination from "@/components/Pagination"; +// 自定义表格工具组件 +import RightToolbar from "@/components/RightToolbar" +// 富文本组件 +import Editor from "@/components/Editor" +// 文件上传组件 +import FileUpload from "@/components/FileUpload" +// 图片上传组件 +import ImageUpload from "@/components/ImageUpload" +// 图片预览组件 +import ImagePreview from "@/components/ImagePreview" +// 字典标签组件 +import DictTag from '@/components/DictTag' +// 头部标签组件 +import VueMeta from 'vue-meta' +// 字典数据组件 +import DictData from '@/components/DictData' + +// 全局方法挂载 +Vue.prototype.getDicts = getDicts +Vue.prototype.getConfigKey = getConfigKey +Vue.prototype.parseTime = parseTime +Vue.prototype.resetForm = resetForm +Vue.prototype.addDateRange = addDateRange +Vue.prototype.selectDictLabel = selectDictLabel +Vue.prototype.selectDictLabels = selectDictLabels +Vue.prototype.download = download +Vue.prototype.handleTree = handleTree +Vue.prototype.addDateRange2 = addDateRange2 + +// 全局组件挂载 +Vue.component('DictTag', DictTag) +Vue.component('Pagination', Pagination) +Vue.component('RightToolbar', RightToolbar) +Vue.component('Editor', Editor) +Vue.component('FileUpload', FileUpload) +Vue.component('ImageUpload', ImageUpload) +Vue.component('ImagePreview', ImagePreview) + +Vue.use(directive) +Vue.use(plugins) +Vue.use(VueMeta) +DictData.install() + +/** + * If you don't want to use mock-server + * you want to use MockJs for mock api + * you can execute: mockXHR() + * + * Currently MockJs will be used in the production environment, + * please remove it before going online! ! ! + */ +Element.Table.props.stripe = { type: Boolean, default: true } +Element.Dialog.props.closeOnPressEscape = { type: Boolean, default: false } +// Element.Dialog.props.width = { type: Boolean, default: '700' } +// Element.Radio.props.border = { type: Boolean, default: true } +Vue.use(Element, { + size: Cookies.get('size') || 'medium' // set element-ui default size +}) + +Vue.config.productionTip = false + +new Vue({ + el: '#app', + router, + store, + render: h => h(App) +}) diff --git a/sf-ui/src/permission.js b/sf-ui/src/permission.js index 73fd6bf..7d87f5f 100644 --- a/sf-ui/src/permission.js +++ b/sf-ui/src/permission.js @@ -10,7 +10,7 @@ import { getApplicationId } from './utils/application' NProgress.configure({ showSpinner: false }) const whiteList = ['/login', '/register'] -const needApplicationList = ['/build/installationList', '/build/whiteListManagement', '/build/publish'] +const needApplicationList = ['/build', '/gateway'] router.beforeEach((to, from, next) => { NProgress.start() @@ -65,7 +65,8 @@ router.beforeEach((to, from, next) => { }) function checkApplication(path) { - return needApplicationList.includes(path) && !getApplicationId(); + return needApplicationList.some(item => path.startsWith(item)) && !getApplicationId() + // return needApplicationList.includes(path) && !getApplicationId(); } router.afterEach(() => { diff --git a/sf-ui/src/plugins/auth.js b/sf-ui/src/plugins/auth.js index af740aa..6c6bc24 100644 --- a/sf-ui/src/plugins/auth.js +++ b/sf-ui/src/plugins/auth.js @@ -1,60 +1,60 @@ -import store from '@/store' - -function authPermission(permission) { - const all_permission = "*:*:*"; - const permissions = store.getters && store.getters.permissions - if (permission && permission.length > 0) { - return permissions.some(v => { - return all_permission === v || v === permission - }) - } else { - return false - } -} - -function authRole(role) { - const super_admin = "admin"; - const roles = store.getters && store.getters.roles - if (role && role.length > 0) { - return roles.some(v => { - return super_admin === v || v === role - }) - } else { - return false - } -} - -export default { - // 验证用户是否具备某权限 - hasPermi(permission) { - return authPermission(permission); - }, - // 验证用户是否含有指定权限,只需包含其中一个 - hasPermiOr(permissions) { - return permissions.some(item => { - return authPermission(item) - }) - }, - // 验证用户是否含有指定权限,必须全部拥有 - hasPermiAnd(permissions) { - return permissions.every(item => { - return authPermission(item) - }) - }, - // 验证用户是否具备某角色 - hasRole(role) { - return authRole(role); - }, - // 验证用户是否含有指定角色,只需包含其中一个 - hasRoleOr(roles) { - return roles.some(item => { - return authRole(item) - }) - }, - // 验证用户是否含有指定角色,必须全部拥有 - hasRoleAnd(roles) { - return roles.every(item => { - return authRole(item) - }) - } -} +import store from '@/store' + +function authPermission(permission) { + const all_permission = "*:*:*"; + const permissions = store.getters && store.getters.permissions + if (permission && permission.length > 0) { + return permissions.some(v => { + return all_permission === v || v === permission + }) + } else { + return false + } +} + +function authRole(role) { + const super_admin = "admin"; + const roles = store.getters && store.getters.roles + if (role && role.length > 0) { + return roles.some(v => { + return super_admin === v || v === role + }) + } else { + return false + } +} + +export default { + // 验证用户是否具备某权限 + hasPermi(permission) { + return authPermission(permission); + }, + // 验证用户是否含有指定权限,只需包含其中一个 + hasPermiOr(permissions) { + return permissions.some(item => { + return authPermission(item) + }) + }, + // 验证用户是否含有指定权限,必须全部拥有 + hasPermiAnd(permissions) { + return permissions.every(item => { + return authPermission(item) + }) + }, + // 验证用户是否具备某角色 + hasRole(role) { + return authRole(role); + }, + // 验证用户是否含有指定角色,只需包含其中一个 + hasRoleOr(roles) { + return roles.some(item => { + return authRole(item) + }) + }, + // 验证用户是否含有指定角色,必须全部拥有 + hasRoleAnd(roles) { + return roles.every(item => { + return authRole(item) + }) + } +} diff --git a/sf-ui/src/plugins/cache.js b/sf-ui/src/plugins/cache.js index 6f71b8e..6b5c00b 100644 --- a/sf-ui/src/plugins/cache.js +++ b/sf-ui/src/plugins/cache.js @@ -1,77 +1,77 @@ -const sessionCache = { - set (key, value) { - if (!sessionStorage) { - return - } - if (key != null && value != null) { - sessionStorage.setItem(key, value) - } - }, - get (key) { - if (!sessionStorage) { - return null - } - if (key == null) { - return null - } - return sessionStorage.getItem(key) - }, - setJSON (key, jsonValue) { - if (jsonValue != null) { - this.set(key, JSON.stringify(jsonValue)) - } - }, - getJSON (key) { - const value = this.get(key) - if (value != null) { - return JSON.parse(value) - } - }, - remove (key) { - sessionStorage.removeItem(key); - } -} -const localCache = { - set (key, value) { - if (!localStorage) { - return - } - if (key != null && value != null) { - localStorage.setItem(key, value) - } - }, - get (key) { - if (!localStorage) { - return null - } - if (key == null) { - return null - } - return localStorage.getItem(key) - }, - setJSON (key, jsonValue) { - if (jsonValue != null) { - this.set(key, JSON.stringify(jsonValue)) - } - }, - getJSON (key) { - const value = this.get(key) - if (value != null) { - return JSON.parse(value) - } - }, - remove (key) { - localStorage.removeItem(key); - } -} - -export default { - /** - * 会话级缓存 - */ - session: sessionCache, - /** - * 本地缓存 - */ - local: localCache -} +const sessionCache = { + set (key, value) { + if (!sessionStorage) { + return + } + if (key != null && value != null) { + sessionStorage.setItem(key, value) + } + }, + get (key) { + if (!sessionStorage) { + return null + } + if (key == null) { + return null + } + return sessionStorage.getItem(key) + }, + setJSON (key, jsonValue) { + if (jsonValue != null) { + this.set(key, JSON.stringify(jsonValue)) + } + }, + getJSON (key) { + const value = this.get(key) + if (value != null) { + return JSON.parse(value) + } + }, + remove (key) { + sessionStorage.removeItem(key); + } +} +const localCache = { + set (key, value) { + if (!localStorage) { + return + } + if (key != null && value != null) { + localStorage.setItem(key, value) + } + }, + get (key) { + if (!localStorage) { + return null + } + if (key == null) { + return null + } + return localStorage.getItem(key) + }, + setJSON (key, jsonValue) { + if (jsonValue != null) { + this.set(key, JSON.stringify(jsonValue)) + } + }, + getJSON (key) { + const value = this.get(key) + if (value != null) { + return JSON.parse(value) + } + }, + remove (key) { + localStorage.removeItem(key); + } +} + +export default { + /** + * 会话级缓存 + */ + session: sessionCache, + /** + * 本地缓存 + */ + local: localCache +} diff --git a/sf-ui/src/plugins/index.js b/sf-ui/src/plugins/index.js index 9bc6eac..d000f2d 100644 --- a/sf-ui/src/plugins/index.js +++ b/sf-ui/src/plugins/index.js @@ -1,20 +1,20 @@ -import tab from './tab' -import auth from './auth' -import cache from './cache' -import modal from './modal' -import download from './download' - -export default { - install(Vue) { - // 页签操作 - Vue.prototype.$tab = tab - // 认证对象 - Vue.prototype.$auth = auth - // 缓存对象 - Vue.prototype.$cache = cache - // 模态框对象 - Vue.prototype.$modal = modal - // 下载文件 - Vue.prototype.$download = download - } -} +import tab from './tab' +import auth from './auth' +import cache from './cache' +import modal from './modal' +import download from './download' + +export default { + install(Vue) { + // 页签操作 + Vue.prototype.$tab = tab + // 认证对象 + Vue.prototype.$auth = auth + // 缓存对象 + Vue.prototype.$cache = cache + // 模态框对象 + Vue.prototype.$modal = modal + // 下载文件 + Vue.prototype.$download = download + } +} diff --git a/sf-ui/src/plugins/modal.js b/sf-ui/src/plugins/modal.js index 503a16f..b37ca14 100644 --- a/sf-ui/src/plugins/modal.js +++ b/sf-ui/src/plugins/modal.js @@ -1,83 +1,83 @@ -import { Message, MessageBox, Notification, Loading } from 'element-ui' - -let loadingInstance; - -export default { - // 消息提示 - msg(content) { - Message.info(content) - }, - // 错误消息 - msgError(content) { - Message.error(content) - }, - // 成功消息 - msgSuccess(content) { - Message.success(content) - }, - // 警告消息 - msgWarning(content) { - Message.warning(content) - }, - // 弹出提示 - alert(content) { - MessageBox.alert(content, "系统提示") - }, - // 错误提示 - alertError(content) { - MessageBox.alert(content, "系统提示", { type: 'error' }) - }, - // 成功提示 - alertSuccess(content) { - MessageBox.alert(content, "系统提示", { type: 'success' }) - }, - // 警告提示 - alertWarning(content) { - MessageBox.alert(content, "系统提示", { type: 'warning' }) - }, - // 通知提示 - notify(content) { - Notification.info(content) - }, - // 错误通知 - notifyError(content) { - Notification.error(content); - }, - // 成功通知 - notifySuccess(content) { - Notification.success(content) - }, - // 警告通知 - notifyWarning(content) { - Notification.warning(content) - }, - // 确认窗体 - confirm(content) { - return MessageBox.confirm(content, "系统提示", { - confirmButtonText: '确定', - cancelButtonText: '取消', - type: "warning", - }) - }, - // 提交内容 - prompt(content) { - return MessageBox.prompt(content, "系统提示", { - confirmButtonText: '确定', - cancelButtonText: '取消', - type: "warning", - }) - }, - // 打开遮罩层 - loading(content) { - loadingInstance = Loading.service({ - lock: true, - text: content, - spinner: "el-icon-loading", - background: "rgba(0, 0, 0, 0.7)", - }) - }, - // 关闭遮罩层 - closeLoading() { - loadingInstance.close(); - } -} +import { Message, MessageBox, Notification, Loading } from 'element-ui' + +let loadingInstance; + +export default { + // 消息提示 + msg(content) { + Message.info(content) + }, + // 错误消息 + msgError(content) { + Message.error(content) + }, + // 成功消息 + msgSuccess(content) { + Message.success(content) + }, + // 警告消息 + msgWarning(content) { + Message.warning(content) + }, + // 弹出提示 + alert(content) { + MessageBox.alert(content, "系统提示") + }, + // 错误提示 + alertError(content) { + MessageBox.alert(content, "系统提示", { type: 'error' }) + }, + // 成功提示 + alertSuccess(content) { + MessageBox.alert(content, "系统提示", { type: 'success' }) + }, + // 警告提示 + alertWarning(content) { + MessageBox.alert(content, "系统提示", { type: 'warning' }) + }, + // 通知提示 + notify(content) { + Notification.info(content) + }, + // 错误通知 + notifyError(content) { + Notification.error(content); + }, + // 成功通知 + notifySuccess(content) { + Notification.success(content) + }, + // 警告通知 + notifyWarning(content) { + Notification.warning(content) + }, + // 确认窗体 + confirm(content) { + return MessageBox.confirm(content, "系统提示", { + confirmButtonText: '确定', + cancelButtonText: '取消', + type: "warning", + }) + }, + // 提交内容 + prompt(content) { + return MessageBox.prompt(content, "系统提示", { + confirmButtonText: '确定', + cancelButtonText: '取消', + type: "warning", + }) + }, + // 打开遮罩层 + loading(content) { + loadingInstance = Loading.service({ + lock: true, + text: content, + spinner: "el-icon-loading", + background: "rgba(0, 0, 0, 0.7)", + }) + }, + // 关闭遮罩层 + closeLoading() { + loadingInstance.close(); + } +} diff --git a/sf-ui/src/plugins/tab.js b/sf-ui/src/plugins/tab.js index 60ceb5f..b029c0e 100644 --- a/sf-ui/src/plugins/tab.js +++ b/sf-ui/src/plugins/tab.js @@ -1,71 +1,71 @@ -import store from '@/store' -import router from '@/router'; - -export default { - // 刷新当前tab页签 - refreshPage(obj) { - const { path, query, matched } = router.currentRoute; - if (obj === undefined) { - matched.forEach((m) => { - if (m.components && m.components.default && m.components.default.name) { - if (!['Layout', 'ParentView'].includes(m.components.default.name)) { - obj = { name: m.components.default.name, path: path, query: query }; - } - } - }); - } - return store.dispatch('tagsView/delCachedView', obj).then(() => { - const { path, query } = obj - router.replace({ - path: '/redirect' + path, - query: query - }) - }) - }, - // 关闭当前tab页签,打开新页签 - closeOpenPage(obj) { - store.dispatch("tagsView/delView", router.currentRoute); - if (obj !== undefined) { - return router.push(obj); - } - }, - // 关闭指定tab页签 - closePage(obj) { - if (obj === undefined) { - return store.dispatch('tagsView/delView', router.currentRoute).then(({ visitedViews }) => { - const latestView = visitedViews.slice(-1)[0] - if (latestView) { - return router.push(latestView.fullPath) - } - return router.push('/'); - }); - } - return store.dispatch('tagsView/delView', obj); - }, - // 关闭所有tab页签 - closeAllPage() { - return store.dispatch('tagsView/delAllViews'); - }, - // 关闭左侧tab页签 - closeLeftPage(obj) { - return store.dispatch('tagsView/delLeftTags', obj || router.currentRoute); - }, - // 关闭右侧tab页签 - closeRightPage(obj) { - return store.dispatch('tagsView/delRightTags', obj || router.currentRoute); - }, - // 关闭其他tab页签 - closeOtherPage(obj) { - return store.dispatch('tagsView/delOthersViews', obj || router.currentRoute); - }, - // 添加tab页签 - openPage(title, url, params) { - var obj = { path: url, meta: { title: title } } - store.dispatch('tagsView/addView', obj); - return router.push({ path: url, query: params }); - }, - // 修改tab页签 - updatePage(obj) { - return store.dispatch('tagsView/updateVisitedView', obj); - } -} +import store from '@/store' +import router from '@/router'; + +export default { + // 刷新当前tab页签 + refreshPage(obj) { + const { path, query, matched } = router.currentRoute; + if (obj === undefined) { + matched.forEach((m) => { + if (m.components && m.components.default && m.components.default.name) { + if (!['Layout', 'ParentView'].includes(m.components.default.name)) { + obj = { name: m.components.default.name, path: path, query: query }; + } + } + }); + } + return store.dispatch('tagsView/delCachedView', obj).then(() => { + const { path, query } = obj + router.replace({ + path: '/redirect' + path, + query: query + }) + }) + }, + // 关闭当前tab页签,打开新页签 + closeOpenPage(obj) { + store.dispatch("tagsView/delView", router.currentRoute); + if (obj !== undefined) { + return router.push(obj); + } + }, + // 关闭指定tab页签 + closePage(obj) { + if (obj === undefined) { + return store.dispatch('tagsView/delView', router.currentRoute).then(({ visitedViews }) => { + const latestView = visitedViews.slice(-1)[0] + if (latestView) { + return router.push(latestView.fullPath) + } + return router.push('/'); + }); + } + return store.dispatch('tagsView/delView', obj); + }, + // 关闭所有tab页签 + closeAllPage() { + return store.dispatch('tagsView/delAllViews'); + }, + // 关闭左侧tab页签 + closeLeftPage(obj) { + return store.dispatch('tagsView/delLeftTags', obj || router.currentRoute); + }, + // 关闭右侧tab页签 + closeRightPage(obj) { + return store.dispatch('tagsView/delRightTags', obj || router.currentRoute); + }, + // 关闭其他tab页签 + closeOtherPage(obj) { + return store.dispatch('tagsView/delOthersViews', obj || router.currentRoute); + }, + // 添加tab页签 + openPage(title, url, params) { + var obj = { path: url, meta: { title: title } } + store.dispatch('tagsView/addView', obj); + return router.push({ path: url, query: params }); + }, + // 修改tab页签 + updatePage(obj) { + return store.dispatch('tagsView/updateVisitedView', obj); + } +} diff --git a/sf-ui/src/router/index.js b/sf-ui/src/router/index.js index 94ab3e2..db75a18 100644 --- a/sf-ui/src/router/index.js +++ b/sf-ui/src/router/index.js @@ -19,12 +19,12 @@ Vue.use(Router) * roles: ['admin', 'common'] // 访问路由的角色权限 * permissions: ['a:a:a', 'b:b:b'] // 访问路由的菜单权限 * meta : { - noCache: true // 如果设置为true,则不会被 缓存(默认 false) - title: 'title' // 设置该路由在侧边栏和面包屑中展示的名字 - icon: 'svg-name' // 设置该路由的图标,对应路径src/assets/icons/svg - breadcrumb: false // 如果设置为false,则不会在breadcrumb面包屑中显示 - activeMenu: '/system/user' // 当路由设置了该属性,则会高亮相对应的侧边栏。 - } + noCache: true // 如果设置为true,则不会被 缓存(默认 false) + title: 'title' // 设置该路由在侧边栏和面包屑中展示的名字 + icon: 'svg-name' // 设置该路由的图标,对应路径src/assets/icons/svg + breadcrumb: false // 如果设置为false,则不会在breadcrumb面包屑中显示 + activeMenu: '/system/user' // 当路由设置了该属性,则会高亮相对应的侧边栏。 + } */ // 公共路由 @@ -88,20 +88,44 @@ export const constantRoutes = [ ] }, // 本地测试----------- - { - path: '/gateway', - component: Layout, - hidden: true, - redirect: 'server-config', - children: [ - { - path: 'server-config', - component: () => import('@/views/gateway/server/config/index'), - name: 'serverConfig', - meta: { title: '新增服务配置', breadcrumb: false, } - } - ] - }, + // { + // path: '/gateway', + // component: Layout, + // hidden: true, + // redirect: 'server-config', + // children: [ + // // { + // // path: 'server-config', + // // component: () => import('@/views/gateway/server/config/index'), + // // name: 'serverConfig', + // // meta: { title: '新增服务配置', breadcrumb: false, } + // // }, + // // { + // // path: 'server-detail', + // // component: () => import('@/views/gateway/server/detail'), + // // name: 'serverDetail', + // // meta: { title: '服务详情', breadcrumb: false, } + // // }, + // // { + // // path: 'route-edit', + // // component: () => import('@/views/gateway/route/edit'), + // // name: 'routeEdit', + // // meta: { title: '路由配置', breadcrumb: false, } + // // }, + // // { + // // path: 'strategy-edit', + // // component: () => import('@/views/gateway/strategy/edit'), + // // name: 'strategyEdit', + // // meta: { title: '策略配置', breadcrumb: false, } + // // }, + // // { + // // path: 'interface-edit', + // // component: () => import('@/views/gateway/interface/edit'), + // // name: 'interfaceEdit', + // // meta: { title: '接口配置', breadcrumb: false, } + // // } + // ] + // }, // 本地测试----------- ] @@ -115,8 +139,7 @@ export const dynamicRoutes = [ children: [ { path: 'role/:userId(\\d+)', - // component: () => import('@/views/system/user/authRole'), - component: (resolve) => require(['@/views/system/user/authRole'], resolve), + component: () => import('@/views/system/user/authRole'), name: 'AuthRole', meta: { title: '分配角色', activeMenu: '/system/user' } } @@ -178,139 +201,7 @@ export const dynamicRoutes = [ } ] }, - { - path: '/build/install', - component: Layout, - hidden: true, - permissions: ['build:install:add'], - children: [ - { - path: 'add', - component: () => import('@/views/FDS/installationList/add'), - name: 'InstallAdd', - meta: { title: '新增安装包', activeMenu: '/build/installationList' } - } - ] - }, - { - path: '/build/install', - component: Layout, - hidden: true, - permissions: ['build:install:edit'], - children: [ - { - path: 'edit', - component: () => import('@/views/FDS/installationList/edit'), - name: 'InstallEdit', - meta: { title: '编辑安装包', activeMenu: '/build/installationList' } - } - ] - }, - - { - path: '/build/install', - component: Layout, - hidden: true, - permissions: ['build:install:detail'], - children: [ - { - path: 'detail', - component: () => import('@/views/FDS/installationList/detail'), - name: 'InstallDetail', - meta: { title: '安装包详情', activeMenu: '/build/installationList' } - } - ] - }, - - { - path: '/build/publishList', - component: Layout, - hidden: true, - permissions: ['build:publishList:add'], - children: [ - { - path: 'add', - component: () => import('@/views/FDS/publishList/add'), - name: 'PublishAdd', - meta: { title: '新增发布', activeMenu: '/build/publish' } - } - ] - }, - { - path: '/build/publishList', - component: Layout, - hidden: true, - permissions: ['build:publishList:detail'], - children: [ - { - path: 'detail', - component: () => import('@/views/FDS/publishList/detail'), - name: 'PublishDetail', - meta: { title: '发布详情', activeMenu: '/build/publish' } - } - ] - }, - - { - path: '/build/whiteList', - component: Layout, - hidden: true, - permissions: ['build:whiteListManagement:add'], - children: [ - { - path: 'add', - component: () => import('@/views/FDS/whiteListManagement/add'), - name: 'WhiteListManagementAdd', - meta: { title: '新增白名单', activeMenu: '/build/whiteListManagement' } - } - ] - }, - - { - path: '/build/whiteList', - component: Layout, - hidden: true, - permissions: ['build:whiteListManagement:detail'], - children: [ - { - path: 'detail', - component: () => import('@/views/FDS/whiteListManagement/detail'), - name: 'WhiteListManagementDetail', - meta: { title: '白名单详情', activeMenu: '/build/whiteListManagement' } - } - ] - }, - - { - path: '/build/whiteList', - component: Layout, - hidden: true, - permissions: ['build:whiteListManagement:equepDetail'], - children: [ - { - path: 'equepDetail', - component: () => import('@/views/FDS/whiteListManagement/equepDetail'), - name: 'WhiteListManagementEquepDetail', - meta: { title: '白名单设备详情', activeMenu: '/build/whiteListManagement' } - } - ] - }, - - { - path: '/build/whiteList', - component: Layout, - hidden: true, - permissions: ['build:whiteListManagement:addConfig'], - children: [ - { - path: 'addConfig', - component: () => import('@/views/FDS/whiteListManagement/addConfig'), - name: 'WhiteListManagementConfigAdd', - meta: { title: '新增白名单配置', activeMenu: '/build/whiteListManagement' } - } - ] - } ] @@ -318,11 +209,11 @@ export const dynamicRoutes = [ let routerPush = Router.prototype.push let routerReplace = Router.prototype.replace // push -Router.prototype.push = function push(location) { +Router.prototype.push = function push (location) { return routerPush.call(this, location).catch(err => err) } // replace -Router.prototype.replace = function push(location) { +Router.prototype.replace = function push (location) { return routerReplace.call(this, location).catch(err => err) } diff --git a/sf-ui/src/settings.js b/sf-ui/src/settings.js index 059c74d..6a0b09f 100644 --- a/sf-ui/src/settings.js +++ b/sf-ui/src/settings.js @@ -1,44 +1,44 @@ -module.exports = { - /** - * 侧边栏主题 深色主题theme-dark,浅色主题theme-light - */ - sideTheme: 'theme-dark', - - /** - * 是否系统布局配置 - */ - showSettings: false, - - /** - * 是否显示顶部导航 - */ - topNav: false, - - /** - * 是否显示 tagsView - */ - tagsView: true, - - /** - * 是否固定头部 - */ - fixedHeader: false, - - /** - * 是否显示logo - */ - sidebarLogo: true, - - /** - * 是否显示动态标题 - */ - dynamicTitle: false, - - /** - * @type {string | array} 'production' | ['production', 'development'] - * @description Need show err logs component. - * The default is only used in the production env - * If you want to also use it in dev, you can pass ['production', 'development'] - */ - errorLog: 'production' -} +module.exports = { + /** + * 侧边栏主题 深色主题theme-dark,浅色主题theme-light + */ + sideTheme: 'theme-dark', + + /** + * 是否系统布局配置 + */ + showSettings: false, + + /** + * 是否显示顶部导航 + */ + topNav: false, + + /** + * 是否显示 tagsView + */ + tagsView: true, + + /** + * 是否固定头部 + */ + fixedHeader: false, + + /** + * 是否显示logo + */ + sidebarLogo: true, + + /** + * 是否显示动态标题 + */ + dynamicTitle: false, + + /** + * @type {string | array} 'production' | ['production', 'development'] + * @description Need show err logs component. + * The default is only used in the production env + * If you want to also use it in dev, you can pass ['production', 'development'] + */ + errorLog: 'production' +} diff --git a/sf-ui/src/store/getters.js b/sf-ui/src/store/getters.js index 46e2bee..bb20fab 100644 --- a/sf-ui/src/store/getters.js +++ b/sf-ui/src/store/getters.js @@ -1,20 +1,20 @@ -const getters = { - sidebar: state => state.app.sidebar, - size: state => state.app.size, - device: state => state.app.device, - dict: state => state.dict.dict, - visitedViews: state => state.tagsView.visitedViews, - cachedViews: state => state.tagsView.cachedViews, - token: state => state.user.token, - avatar: state => state.user.avatar, - name: state => state.user.name, - introduction: state => state.user.introduction, - roles: state => state.user.roles, - permissions: state => state.user.permissions, - applicationId: state => state.user.applicationId, - permission_routes: state => state.permission.routes, - topbarRouters:state => state.permission.topbarRouters, - defaultRoutes:state => state.permission.defaultRoutes, - sidebarRouters:state => state.permission.sidebarRouters, -} -export default getters +const getters = { + sidebar: state => state.app.sidebar, + size: state => state.app.size, + device: state => state.app.device, + dict: state => state.dict.dict, + visitedViews: state => state.tagsView.visitedViews, + cachedViews: state => state.tagsView.cachedViews, + token: state => state.user.token, + avatar: state => state.user.avatar, + name: state => state.user.name, + introduction: state => state.user.introduction, + roles: state => state.user.roles, + permissions: state => state.user.permissions, + applicationId: state => state.user.applicationId, + permission_routes: state => state.permission.routes, + topbarRouters:state => state.permission.topbarRouters, + defaultRoutes:state => state.permission.defaultRoutes, + sidebarRouters:state => state.permission.sidebarRouters, +} +export default getters diff --git a/sf-ui/src/store/index.js b/sf-ui/src/store/index.js index 2ee6e43..97aaef8 100644 --- a/sf-ui/src/store/index.js +++ b/sf-ui/src/store/index.js @@ -1,25 +1,25 @@ -import Vue from 'vue' -import Vuex from 'vuex' -import app from './modules/app' -import dict from './modules/dict' -import user from './modules/user' -import tagsView from './modules/tagsView' -import permission from './modules/permission' -import settings from './modules/settings' -import getters from './getters' - -Vue.use(Vuex) - -const store = new Vuex.Store({ - modules: { - app, - dict, - user, - tagsView, - permission, - settings - }, - getters -}) - -export default store +import Vue from 'vue' +import Vuex from 'vuex' +import app from './modules/app' +import dict from './modules/dict' +import user from './modules/user' +import tagsView from './modules/tagsView' +import permission from './modules/permission' +import settings from './modules/settings' +import getters from './getters' + +Vue.use(Vuex) + +const store = new Vuex.Store({ + modules: { + app, + dict, + user, + tagsView, + permission, + settings + }, + getters +}) + +export default store diff --git a/sf-ui/src/store/modules/app.js b/sf-ui/src/store/modules/app.js index 5a0ed6c..3e22d1c 100644 --- a/sf-ui/src/store/modules/app.js +++ b/sf-ui/src/store/modules/app.js @@ -1,66 +1,66 @@ -import Cookies from 'js-cookie' - -const state = { - sidebar: { - opened: Cookies.get('sidebarStatus') ? !!+Cookies.get('sidebarStatus') : true, - withoutAnimation: false, - hide: false - }, - device: 'desktop', - size: Cookies.get('size') || 'medium' -} - -const mutations = { - TOGGLE_SIDEBAR: state => { - if (state.sidebar.hide) { - return false; - } - state.sidebar.opened = !state.sidebar.opened - state.sidebar.withoutAnimation = false - if (state.sidebar.opened) { - Cookies.set('sidebarStatus', 1) - } else { - Cookies.set('sidebarStatus', 0) - } - }, - CLOSE_SIDEBAR: (state, withoutAnimation) => { - Cookies.set('sidebarStatus', 0) - state.sidebar.opened = false - state.sidebar.withoutAnimation = withoutAnimation - }, - TOGGLE_DEVICE: (state, device) => { - state.device = device - }, - SET_SIZE: (state, size) => { - state.size = size - Cookies.set('size', size) - }, - SET_SIDEBAR_HIDE: (state, status) => { - state.sidebar.hide = status - } -} - -const actions = { - toggleSideBar({ commit }) { - commit('TOGGLE_SIDEBAR') - }, - closeSideBar({ commit }, { withoutAnimation }) { - commit('CLOSE_SIDEBAR', withoutAnimation) - }, - toggleDevice({ commit }, device) { - commit('TOGGLE_DEVICE', device) - }, - setSize({ commit }, size) { - commit('SET_SIZE', size) - }, - toggleSideBarHide({ commit }, status) { - commit('SET_SIDEBAR_HIDE', status) - } -} - -export default { - namespaced: true, - state, - mutations, - actions -} +import Cookies from 'js-cookie' + +const state = { + sidebar: { + opened: Cookies.get('sidebarStatus') ? !!+Cookies.get('sidebarStatus') : true, + withoutAnimation: false, + hide: false + }, + device: 'desktop', + size: Cookies.get('size') || 'medium' +} + +const mutations = { + TOGGLE_SIDEBAR: state => { + if (state.sidebar.hide) { + return false; + } + state.sidebar.opened = !state.sidebar.opened + state.sidebar.withoutAnimation = false + if (state.sidebar.opened) { + Cookies.set('sidebarStatus', 1) + } else { + Cookies.set('sidebarStatus', 0) + } + }, + CLOSE_SIDEBAR: (state, withoutAnimation) => { + Cookies.set('sidebarStatus', 0) + state.sidebar.opened = false + state.sidebar.withoutAnimation = withoutAnimation + }, + TOGGLE_DEVICE: (state, device) => { + state.device = device + }, + SET_SIZE: (state, size) => { + state.size = size + Cookies.set('size', size) + }, + SET_SIDEBAR_HIDE: (state, status) => { + state.sidebar.hide = status + } +} + +const actions = { + toggleSideBar({ commit }) { + commit('TOGGLE_SIDEBAR') + }, + closeSideBar({ commit }, { withoutAnimation }) { + commit('CLOSE_SIDEBAR', withoutAnimation) + }, + toggleDevice({ commit }, device) { + commit('TOGGLE_DEVICE', device) + }, + setSize({ commit }, size) { + commit('SET_SIZE', size) + }, + toggleSideBarHide({ commit }, status) { + commit('SET_SIDEBAR_HIDE', status) + } +} + +export default { + namespaced: true, + state, + mutations, + actions +} diff --git a/sf-ui/src/store/modules/dict.js b/sf-ui/src/store/modules/dict.js index f48df42..f95bead 100644 --- a/sf-ui/src/store/modules/dict.js +++ b/sf-ui/src/store/modules/dict.js @@ -1,50 +1,50 @@ -const state = { - dict: new Array() -} -const mutations = { - SET_DICT: (state, { key, value }) => { - if (key !== null && key !== "") { - state.dict.push({ - key: key, - value: value - }) - } - }, - REMOVE_DICT: (state, key) => { - try { - for (let i = 0; i < state.dict.length; i++) { - if (state.dict[i].key == key) { - state.dict.splice(i, i) - return true - } - } - } catch (e) { - } - }, - CLEAN_DICT: (state) => { - state.dict = new Array() - } -} - -const actions = { - // 设置字典 - setDict({ commit }, data) { - commit('SET_DICT', data) - }, - // 删除字典 - removeDict({ commit }, key) { - commit('REMOVE_DICT', key) - }, - // 清空字典 - cleanDict({ commit }) { - commit('CLEAN_DICT') - } -} - -export default { - namespaced: true, - state, - mutations, - actions -} - +const state = { + dict: new Array() +} +const mutations = { + SET_DICT: (state, { key, value }) => { + if (key !== null && key !== "") { + state.dict.push({ + key: key, + value: value + }) + } + }, + REMOVE_DICT: (state, key) => { + try { + for (let i = 0; i < state.dict.length; i++) { + if (state.dict[i].key == key) { + state.dict.splice(i, i) + return true + } + } + } catch (e) { + } + }, + CLEAN_DICT: (state) => { + state.dict = new Array() + } +} + +const actions = { + // 设置字典 + setDict({ commit }, data) { + commit('SET_DICT', data) + }, + // 删除字典 + removeDict({ commit }, key) { + commit('REMOVE_DICT', key) + }, + // 清空字典 + cleanDict({ commit }) { + commit('CLEAN_DICT') + } +} + +export default { + namespaced: true, + state, + mutations, + actions +} + diff --git a/sf-ui/src/store/modules/permission.js b/sf-ui/src/store/modules/permission.js index 3577229..f77686b 100644 --- a/sf-ui/src/store/modules/permission.js +++ b/sf-ui/src/store/modules/permission.js @@ -1,134 +1,134 @@ -import auth from '@/plugins/auth' -import router, { constantRoutes, dynamicRoutes } from '@/router' -import { getRouters } from '@/api/menu' -import Layout from '@/layout/index' -import ParentView from '@/components/ParentView' -import InnerLink from '@/layout/components/InnerLink' - -const permission = { - state: { - routes: [], - addRoutes: [], - defaultRoutes: [], - topbarRouters: [], - sidebarRouters: [] - }, - mutations: { - SET_ROUTES: (state, routes) => { - state.addRoutes = routes - state.routes = constantRoutes.concat(routes) - }, - SET_DEFAULT_ROUTES: (state, routes) => { - state.defaultRoutes = constantRoutes.concat(routes) - }, - SET_TOPBAR_ROUTES: (state, routes) => { - state.topbarRouters = routes - }, - SET_SIDEBAR_ROUTERS: (state, routes) => { - state.sidebarRouters = routes - }, - }, - actions: { - // 生成路由 - GenerateRoutes({ commit }) { - return new Promise(resolve => { - // 向后端请求路由数据 - getRouters().then(res => { - const sdata = JSON.parse(JSON.stringify(res.data)) - const rdata = JSON.parse(JSON.stringify(res.data)) - const sidebarRoutes = filterAsyncRouter(sdata) - const rewriteRoutes = filterAsyncRouter(rdata, false, true) - const asyncRoutes = filterDynamicRoutes(dynamicRoutes); - rewriteRoutes.push({ path: '*', redirect: '/404', hidden: true }) - router.addRoutes(asyncRoutes); - commit('SET_ROUTES', rewriteRoutes) - commit('SET_SIDEBAR_ROUTERS', constantRoutes.concat(sidebarRoutes)) - commit('SET_DEFAULT_ROUTES', sidebarRoutes) - commit('SET_TOPBAR_ROUTES', sidebarRoutes) - resolve(rewriteRoutes) - }) - }) - } - } -} - -// 遍历后台传来的路由字符串,转换为组件对象 -function filterAsyncRouter(asyncRouterMap, lastRouter = false, type = false) { - return asyncRouterMap.filter(route => { - if (type && route.children) { - route.children = filterChildren(route.children) - } - if (route.component) { - // Layout ParentView 组件特殊处理 - if (route.component === 'Layout') { - route.component = Layout - } else if (route.component === 'ParentView') { - route.component = ParentView - } else if (route.component === 'InnerLink') { - route.component = InnerLink - } else { - route.component = loadView(route.component) - } - } - if (route.children != null && route.children && route.children.length) { - route.children = filterAsyncRouter(route.children, route, type) - } else { - delete route['children'] - delete route['redirect'] - } - return true - }) -} - -function filterChildren(childrenMap, lastRouter = false) { - var children = [] - childrenMap.forEach((el, index) => { - if (el.children && el.children.length) { - if (el.component === 'ParentView' && !lastRouter) { - el.children.forEach(c => { - c.path = el.path + '/' + c.path - if (c.children && c.children.length) { - children = children.concat(filterChildren(c.children, c)) - return - } - children.push(c) - }) - return - } - } - if (lastRouter) { - el.path = lastRouter.path + '/' + el.path - } - children = children.concat(el) - }) - return children -} - -// 动态路由遍历,验证是否具备权限 -export function filterDynamicRoutes(routes) { - const res = [] - routes.forEach(route => { - if (route.permissions) { - if (auth.hasPermiOr(route.permissions)) { - res.push(route) - } - } else if (route.roles) { - if (auth.hasRoleOr(route.roles)) { - res.push(route) - } - } - }) - return res -} - -export const loadView = (view) => { - if (process.env.NODE_ENV === 'development') { - return (resolve) => require([`@/views/${view}`], resolve) - } else { - // 使用 import 实现生产环境的路由懒加载 - //return () => require([`@/views/${view}`], resolve) - return (resolve) => require([`@/views/${view}`], resolve) - } -} - -export default permission +import auth from '@/plugins/auth' +import router, { constantRoutes, dynamicRoutes } from '@/router' +import { getRouters } from '@/api/menu' +import Layout from '@/layout/index' +import ParentView from '@/components/ParentView' +import InnerLink from '@/layout/components/InnerLink' + +const permission = { + state: { + routes: [], + addRoutes: [], + defaultRoutes: [], + topbarRouters: [], + sidebarRouters: [] + }, + mutations: { + SET_ROUTES: (state, routes) => { + state.addRoutes = routes + state.routes = constantRoutes.concat(routes) + }, + SET_DEFAULT_ROUTES: (state, routes) => { + state.defaultRoutes = constantRoutes.concat(routes) + }, + SET_TOPBAR_ROUTES: (state, routes) => { + state.topbarRouters = routes + }, + SET_SIDEBAR_ROUTERS: (state, routes) => { + state.sidebarRouters = routes + }, + }, + actions: { + // 生成路由 + GenerateRoutes({ commit }) { + return new Promise(resolve => { + // 向后端请求路由数据 + getRouters().then(res => { + const sdata = JSON.parse(JSON.stringify(res.data)) + const rdata = JSON.parse(JSON.stringify(res.data)) + const sidebarRoutes = filterAsyncRouter(sdata) + const rewriteRoutes = filterAsyncRouter(rdata, false, true) + const asyncRoutes = filterDynamicRoutes(dynamicRoutes); + rewriteRoutes.push({ path: '*', redirect: '/404', hidden: true }) + router.addRoutes(asyncRoutes); + commit('SET_ROUTES', rewriteRoutes) + commit('SET_SIDEBAR_ROUTERS', constantRoutes.concat(sidebarRoutes)) + commit('SET_DEFAULT_ROUTES', sidebarRoutes) + commit('SET_TOPBAR_ROUTES', sidebarRoutes) + resolve(rewriteRoutes) + }) + }) + } + } +} + +// 遍历后台传来的路由字符串,转换为组件对象 +function filterAsyncRouter(asyncRouterMap, lastRouter = false, type = false) { + return asyncRouterMap.filter(route => { + if (type && route.children) { + route.children = filterChildren(route.children) + } + if (route.component) { + // Layout ParentView 组件特殊处理 + if (route.component === 'Layout') { + route.component = Layout + } else if (route.component === 'ParentView') { + route.component = ParentView + } else if (route.component === 'InnerLink') { + route.component = InnerLink + } else { + route.component = loadView(route.component) + } + } + if (route.children != null && route.children && route.children.length) { + route.children = filterAsyncRouter(route.children, route, type) + } else { + delete route['children'] + delete route['redirect'] + } + return true + }) +} + +function filterChildren(childrenMap, lastRouter = false) { + var children = [] + childrenMap.forEach((el, index) => { + if (el.children && el.children.length) { + if (el.component === 'ParentView' && !lastRouter) { + el.children.forEach(c => { + c.path = el.path + '/' + c.path + if (c.children && c.children.length) { + children = children.concat(filterChildren(c.children, c)) + return + } + children.push(c) + }) + return + } + } + if (lastRouter) { + el.path = lastRouter.path + '/' + el.path + } + children = children.concat(el) + }) + return children +} + +// 动态路由遍历,验证是否具备权限 +export function filterDynamicRoutes(routes) { + const res = [] + routes.forEach(route => { + if (route.permissions) { + if (auth.hasPermiOr(route.permissions)) { + res.push(route) + } + } else if (route.roles) { + if (auth.hasRoleOr(route.roles)) { + res.push(route) + } + } + }) + return res +} + +export const loadView = (view) => { + if (process.env.NODE_ENV === 'development') { + return (resolve) => require([`@/views/${view}`], resolve) + } else { + // 使用 import 实现生产环境的路由懒加载 + //return () => require([`@/views/${view}`], resolve) + return (resolve) => require([`@/views/${view}`], resolve) + } +} + +export default permission diff --git a/sf-ui/src/store/modules/settings.js b/sf-ui/src/store/modules/settings.js index d08d8c2..7187b08 100644 --- a/sf-ui/src/store/modules/settings.js +++ b/sf-ui/src/store/modules/settings.js @@ -1,42 +1,42 @@ -import defaultSettings from '@/settings' - -const { sideTheme, showSettings, topNav, tagsView, fixedHeader, sidebarLogo, dynamicTitle } = defaultSettings - -const storageSetting = JSON.parse(localStorage.getItem('layout-setting')) || '' -const state = { - title: '', - theme: storageSetting.theme || '#409EFF', - sideTheme: storageSetting.sideTheme || sideTheme, - showSettings: showSettings, - topNav: storageSetting.topNav === undefined ? topNav : storageSetting.topNav, - tagsView: storageSetting.tagsView === undefined ? tagsView : storageSetting.tagsView, - fixedHeader: storageSetting.fixedHeader === undefined ? fixedHeader : storageSetting.fixedHeader, - sidebarLogo: storageSetting.sidebarLogo === undefined ? sidebarLogo : storageSetting.sidebarLogo, - dynamicTitle: storageSetting.dynamicTitle === undefined ? dynamicTitle : storageSetting.dynamicTitle -} -const mutations = { - CHANGE_SETTING: (state, { key, value }) => { - if (state.hasOwnProperty(key)) { - state[key] = value - } - } -} - -const actions = { - // 修改布局设置 - changeSetting({ commit }, data) { - commit('CHANGE_SETTING', data) - }, - // 设置网页标题 - setTitle({ commit }, title) { - state.title = title - } -} - -export default { - namespaced: true, - state, - mutations, - actions -} - +import defaultSettings from '@/settings' + +const { sideTheme, showSettings, topNav, tagsView, fixedHeader, sidebarLogo, dynamicTitle } = defaultSettings + +const storageSetting = JSON.parse(localStorage.getItem('layout-setting')) || '' +const state = { + title: '', + theme: storageSetting.theme || '#3F68FF', + sideTheme: storageSetting.sideTheme || sideTheme, + showSettings: showSettings, + topNav: storageSetting.topNav === undefined ? topNav : storageSetting.topNav, + tagsView: storageSetting.tagsView === undefined ? tagsView : storageSetting.tagsView, + fixedHeader: storageSetting.fixedHeader === undefined ? fixedHeader : storageSetting.fixedHeader, + sidebarLogo: storageSetting.sidebarLogo === undefined ? sidebarLogo : storageSetting.sidebarLogo, + dynamicTitle: storageSetting.dynamicTitle === undefined ? dynamicTitle : storageSetting.dynamicTitle +} +const mutations = { + CHANGE_SETTING: (state, { key, value }) => { + if (state.hasOwnProperty(key)) { + state[key] = value + } + } +} + +const actions = { + // 修改布局设置 + changeSetting({ commit }, data) { + commit('CHANGE_SETTING', data) + }, + // 设置网页标题 + setTitle({ commit }, title) { + state.title = title + } +} + +export default { + namespaced: true, + state, + mutations, + actions +} + diff --git a/sf-ui/src/store/modules/tagsView.js b/sf-ui/src/store/modules/tagsView.js index 9a88c2b..5fc011c 100644 --- a/sf-ui/src/store/modules/tagsView.js +++ b/sf-ui/src/store/modules/tagsView.js @@ -1,228 +1,228 @@ -const state = { - visitedViews: [], - cachedViews: [], - iframeViews: [] -} - -const mutations = { - ADD_IFRAME_VIEW: (state, view) => { - if (state.iframeViews.some(v => v.path === view.path)) return - state.iframeViews.push( - Object.assign({}, view, { - title: view.meta.title || 'no-name' - }) - ) - }, - ADD_VISITED_VIEW: (state, view) => { - if (state.visitedViews.some(v => v.path === view.path)) return - state.visitedViews.push( - Object.assign({}, view, { - title: view.meta.title || 'no-name' - }) - ) - }, - ADD_CACHED_VIEW: (state, view) => { - if (state.cachedViews.includes(view.name)) return - if (view.meta && !view.meta.noCache) { - state.cachedViews.push(view.name) - } - }, - DEL_VISITED_VIEW: (state, view) => { - for (const [i, v] of state.visitedViews.entries()) { - if (v.path === view.path) { - state.visitedViews.splice(i, 1) - break - } - } - state.iframeViews = state.iframeViews.filter(item => item.path !== view.path) - }, - DEL_IFRAME_VIEW: (state, view) => { - state.iframeViews = state.iframeViews.filter(item => item.path !== view.path) - }, - DEL_CACHED_VIEW: (state, view) => { - const index = state.cachedViews.indexOf(view.name) - index > -1 && state.cachedViews.splice(index, 1) - }, - - DEL_OTHERS_VISITED_VIEWS: (state, view) => { - state.visitedViews = state.visitedViews.filter(v => { - return v.meta.affix || v.path === view.path - }) - state.iframeViews = state.iframeViews.filter(item => item.path === view.path) - }, - DEL_OTHERS_CACHED_VIEWS: (state, view) => { - const index = state.cachedViews.indexOf(view.name) - if (index > -1) { - state.cachedViews = state.cachedViews.slice(index, index + 1) - } else { - state.cachedViews = [] - } - }, - DEL_ALL_VISITED_VIEWS: state => { - // keep affix tags - const affixTags = state.visitedViews.filter(tag => tag.meta.affix) - state.visitedViews = affixTags - state.iframeViews = [] - }, - DEL_ALL_CACHED_VIEWS: state => { - state.cachedViews = [] - }, - UPDATE_VISITED_VIEW: (state, view) => { - for (let v of state.visitedViews) { - if (v.path === view.path) { - v = Object.assign(v, view) - break - } - } - }, - DEL_RIGHT_VIEWS: (state, view) => { - const index = state.visitedViews.findIndex(v => v.path === view.path) - if (index === -1) { - return - } - state.visitedViews = state.visitedViews.filter((item, idx) => { - if (idx <= index || (item.meta && item.meta.affix)) { - return true - } - const i = state.cachedViews.indexOf(item.name) - if (i > -1) { - state.cachedViews.splice(i, 1) - } - if(item.meta.link) { - const fi = state.iframeViews.findIndex(v => v.path === item.path) - state.iframeViews.splice(fi, 1) - } - return false - }) - }, - DEL_LEFT_VIEWS: (state, view) => { - const index = state.visitedViews.findIndex(v => v.path === view.path) - if (index === -1) { - return - } - state.visitedViews = state.visitedViews.filter((item, idx) => { - if (idx >= index || (item.meta && item.meta.affix)) { - return true - } - const i = state.cachedViews.indexOf(item.name) - if (i > -1) { - state.cachedViews.splice(i, 1) - } - if(item.meta.link) { - const fi = state.iframeViews.findIndex(v => v.path === item.path) - state.iframeViews.splice(fi, 1) - } - return false - }) - } -} - -const actions = { - addView({ dispatch }, view) { - dispatch('addVisitedView', view) - dispatch('addCachedView', view) - }, - addIframeView({ commit }, view) { - commit('ADD_IFRAME_VIEW', view) - }, - addVisitedView({ commit }, view) { - commit('ADD_VISITED_VIEW', view) - }, - addCachedView({ commit }, view) { - commit('ADD_CACHED_VIEW', view) - }, - delView({ dispatch, state }, view) { - return new Promise(resolve => { - dispatch('delVisitedView', view) - dispatch('delCachedView', view) - resolve({ - visitedViews: [...state.visitedViews], - cachedViews: [...state.cachedViews] - }) - }) - }, - delVisitedView({ commit, state }, view) { - return new Promise(resolve => { - commit('DEL_VISITED_VIEW', view) - resolve([...state.visitedViews]) - }) - }, - delIframeView({ commit, state }, view) { - return new Promise(resolve => { - commit('DEL_IFRAME_VIEW', view) - resolve([...state.iframeViews]) - }) - }, - delCachedView({ commit, state }, view) { - return new Promise(resolve => { - commit('DEL_CACHED_VIEW', view) - resolve([...state.cachedViews]) - }) - }, - delOthersViews({ dispatch, state }, view) { - return new Promise(resolve => { - dispatch('delOthersVisitedViews', view) - dispatch('delOthersCachedViews', view) - resolve({ - visitedViews: [...state.visitedViews], - cachedViews: [...state.cachedViews] - }) - }) - }, - delOthersVisitedViews({ commit, state }, view) { - return new Promise(resolve => { - commit('DEL_OTHERS_VISITED_VIEWS', view) - resolve([...state.visitedViews]) - }) - }, - delOthersCachedViews({ commit, state }, view) { - return new Promise(resolve => { - commit('DEL_OTHERS_CACHED_VIEWS', view) - resolve([...state.cachedViews]) - }) - }, - delAllViews({ dispatch, state }, view) { - return new Promise(resolve => { - dispatch('delAllVisitedViews', view) - dispatch('delAllCachedViews', view) - resolve({ - visitedViews: [...state.visitedViews], - cachedViews: [...state.cachedViews] - }) - }) - }, - delAllVisitedViews({ commit, state }) { - return new Promise(resolve => { - commit('DEL_ALL_VISITED_VIEWS') - resolve([...state.visitedViews]) - }) - }, - delAllCachedViews({ commit, state }) { - return new Promise(resolve => { - commit('DEL_ALL_CACHED_VIEWS') - resolve([...state.cachedViews]) - }) - }, - updateVisitedView({ commit }, view) { - commit('UPDATE_VISITED_VIEW', view) - }, - delRightTags({ commit }, view) { - return new Promise(resolve => { - commit('DEL_RIGHT_VIEWS', view) - resolve([...state.visitedViews]) - }) - }, - delLeftTags({ commit }, view) { - return new Promise(resolve => { - commit('DEL_LEFT_VIEWS', view) - resolve([...state.visitedViews]) - }) - }, -} - -export default { - namespaced: true, - state, - mutations, - actions -} +const state = { + visitedViews: [], + cachedViews: [], + iframeViews: [] +} + +const mutations = { + ADD_IFRAME_VIEW: (state, view) => { + if (state.iframeViews.some(v => v.path === view.path)) return + state.iframeViews.push( + Object.assign({}, view, { + title: view.meta.title || 'no-name' + }) + ) + }, + ADD_VISITED_VIEW: (state, view) => { + if (state.visitedViews.some(v => v.path === view.path)) return + state.visitedViews.push( + Object.assign({}, view, { + title: view.meta.title || 'no-name' + }) + ) + }, + ADD_CACHED_VIEW: (state, view) => { + if (state.cachedViews.includes(view.name)) return + if (view.meta && !view.meta.noCache) { + state.cachedViews.push(view.name) + } + }, + DEL_VISITED_VIEW: (state, view) => { + for (const [i, v] of state.visitedViews.entries()) { + if (v.path === view.path) { + state.visitedViews.splice(i, 1) + break + } + } + state.iframeViews = state.iframeViews.filter(item => item.path !== view.path) + }, + DEL_IFRAME_VIEW: (state, view) => { + state.iframeViews = state.iframeViews.filter(item => item.path !== view.path) + }, + DEL_CACHED_VIEW: (state, view) => { + const index = state.cachedViews.indexOf(view.name) + index > -1 && state.cachedViews.splice(index, 1) + }, + + DEL_OTHERS_VISITED_VIEWS: (state, view) => { + state.visitedViews = state.visitedViews.filter(v => { + return v.meta.affix || v.path === view.path + }) + state.iframeViews = state.iframeViews.filter(item => item.path === view.path) + }, + DEL_OTHERS_CACHED_VIEWS: (state, view) => { + const index = state.cachedViews.indexOf(view.name) + if (index > -1) { + state.cachedViews = state.cachedViews.slice(index, index + 1) + } else { + state.cachedViews = [] + } + }, + DEL_ALL_VISITED_VIEWS: state => { + // keep affix tags + const affixTags = state.visitedViews.filter(tag => tag.meta.affix) + state.visitedViews = affixTags + state.iframeViews = [] + }, + DEL_ALL_CACHED_VIEWS: state => { + state.cachedViews = [] + }, + UPDATE_VISITED_VIEW: (state, view) => { + for (let v of state.visitedViews) { + if (v.path === view.path) { + v = Object.assign(v, view) + break + } + } + }, + DEL_RIGHT_VIEWS: (state, view) => { + const index = state.visitedViews.findIndex(v => v.path === view.path) + if (index === -1) { + return + } + state.visitedViews = state.visitedViews.filter((item, idx) => { + if (idx <= index || (item.meta && item.meta.affix)) { + return true + } + const i = state.cachedViews.indexOf(item.name) + if (i > -1) { + state.cachedViews.splice(i, 1) + } + if(item.meta.link) { + const fi = state.iframeViews.findIndex(v => v.path === item.path) + state.iframeViews.splice(fi, 1) + } + return false + }) + }, + DEL_LEFT_VIEWS: (state, view) => { + const index = state.visitedViews.findIndex(v => v.path === view.path) + if (index === -1) { + return + } + state.visitedViews = state.visitedViews.filter((item, idx) => { + if (idx >= index || (item.meta && item.meta.affix)) { + return true + } + const i = state.cachedViews.indexOf(item.name) + if (i > -1) { + state.cachedViews.splice(i, 1) + } + if(item.meta.link) { + const fi = state.iframeViews.findIndex(v => v.path === item.path) + state.iframeViews.splice(fi, 1) + } + return false + }) + } +} + +const actions = { + addView({ dispatch }, view) { + dispatch('addVisitedView', view) + dispatch('addCachedView', view) + }, + addIframeView({ commit }, view) { + commit('ADD_IFRAME_VIEW', view) + }, + addVisitedView({ commit }, view) { + commit('ADD_VISITED_VIEW', view) + }, + addCachedView({ commit }, view) { + commit('ADD_CACHED_VIEW', view) + }, + delView({ dispatch, state }, view) { + return new Promise(resolve => { + dispatch('delVisitedView', view) + dispatch('delCachedView', view) + resolve({ + visitedViews: [...state.visitedViews], + cachedViews: [...state.cachedViews] + }) + }) + }, + delVisitedView({ commit, state }, view) { + return new Promise(resolve => { + commit('DEL_VISITED_VIEW', view) + resolve([...state.visitedViews]) + }) + }, + delIframeView({ commit, state }, view) { + return new Promise(resolve => { + commit('DEL_IFRAME_VIEW', view) + resolve([...state.iframeViews]) + }) + }, + delCachedView({ commit, state }, view) { + return new Promise(resolve => { + commit('DEL_CACHED_VIEW', view) + resolve([...state.cachedViews]) + }) + }, + delOthersViews({ dispatch, state }, view) { + return new Promise(resolve => { + dispatch('delOthersVisitedViews', view) + dispatch('delOthersCachedViews', view) + resolve({ + visitedViews: [...state.visitedViews], + cachedViews: [...state.cachedViews] + }) + }) + }, + delOthersVisitedViews({ commit, state }, view) { + return new Promise(resolve => { + commit('DEL_OTHERS_VISITED_VIEWS', view) + resolve([...state.visitedViews]) + }) + }, + delOthersCachedViews({ commit, state }, view) { + return new Promise(resolve => { + commit('DEL_OTHERS_CACHED_VIEWS', view) + resolve([...state.cachedViews]) + }) + }, + delAllViews({ dispatch, state }, view) { + return new Promise(resolve => { + dispatch('delAllVisitedViews', view) + dispatch('delAllCachedViews', view) + resolve({ + visitedViews: [...state.visitedViews], + cachedViews: [...state.cachedViews] + }) + }) + }, + delAllVisitedViews({ commit, state }) { + return new Promise(resolve => { + commit('DEL_ALL_VISITED_VIEWS') + resolve([...state.visitedViews]) + }) + }, + delAllCachedViews({ commit, state }) { + return new Promise(resolve => { + commit('DEL_ALL_CACHED_VIEWS') + resolve([...state.cachedViews]) + }) + }, + updateVisitedView({ commit }, view) { + commit('UPDATE_VISITED_VIEW', view) + }, + delRightTags({ commit }, view) { + return new Promise(resolve => { + commit('DEL_RIGHT_VIEWS', view) + resolve([...state.visitedViews]) + }) + }, + delLeftTags({ commit }, view) { + return new Promise(resolve => { + commit('DEL_LEFT_VIEWS', view) + resolve([...state.visitedViews]) + }) + }, +} + +export default { + namespaced: true, + state, + mutations, + actions +} diff --git a/sf-ui/src/store/modules/user.js b/sf-ui/src/store/modules/user.js index f917886..0d0ca01 100644 --- a/sf-ui/src/store/modules/user.js +++ b/sf-ui/src/store/modules/user.js @@ -1,133 +1,141 @@ -import { getInfo, login, logout } from '@/api/login' -import { getToken, removeToken, setToken } from '@/utils/auth' -import { - getApplicationId, - removeApplicationId, - removeApplicationName, - setApplicationId, - setApplicationName -} from '@/utils/application' -import Cookies from 'js-cookie' - -const user = { - state: { - token: getToken(), - name: '', - avatar: '', - roles: [], - permissions: [], - applicationId: getApplicationId(), - applicationInfo: {} // 用户选中的项目/应用 - }, - - mutations: { - SET_TOKEN: (state, token) => { - state.token = token - }, - SET_NAME: (state, name) => { - state.name = name - }, - SET_AVATAR: (state, avatar) => { - state.avatar = avatar - }, - SET_ROLES: (state, roles) => { - state.roles = roles - }, - SET_PERMISSIONS: (state, permissions) => { - state.permissions = permissions - }, - SET_APPLICATION: (state, applicationInfo) => { - const { id } = applicationInfo - state.applicationId = id || '' - state.applicationInfo = applicationInfo - } - }, - - actions: { - // 登录 - Login({ commit }, userInfo) { - const username = userInfo.username.trim() - const password = userInfo.password - const code = userInfo.code - const uuid = userInfo.uuid - return new Promise((resolve, reject) => { - login(username, password, code, uuid).then(res => { - setToken(res.token) - commit('SET_TOKEN', res.token) - resolve() - }).catch(error => { - reject(error) - }) - }) - }, - - // 获取用户信息 - GetInfo({ commit, state }) { - return new Promise((resolve, reject) => { - getInfo().then(res => { - const user = res.user - const avatar = (user.avatar == '' || user.avatar == null) ? require('@/assets/images/profile.jpg') : process.env.VUE_APP_BASE_API + user.avatar - if (res.roles && res.roles.length > 0) { // 验证返回的roles是否是一个非空数组 - commit('SET_ROLES', res.roles) - commit('SET_PERMISSIONS', res.permissions) - } else { - commit('SET_ROLES', ['ROLE_DEFAULT']) - } - commit('SET_NAME', user.userName) - commit('SET_AVATAR', avatar) - resolve(res) - }).catch(error => { - reject(error) - }) - }) - }, - - // 退出系统 - LogOut({ commit, state }) { - return new Promise((resolve, reject) => { - logout(state.token).then(() => { - commit('SET_TOKEN', '') - commit('SET_ROLES', []) - commit('SET_PERMISSIONS', []) - commit('SET_APPLICATION', {}) - removeApplicationId() - removeToken() - resolve() - }).catch(error => { - reject(error) - }) - }) - }, - - // 前端 登出 - FedLogOut({ commit }) { - return new Promise(resolve => { - commit('SET_TOKEN', '') - commit('SET_APPLICATION', {}) - removeApplicationId() - removeToken() - resolve() - }) - }, - - // 设置选中的项目应用信息 - SetApplication({ commit }, applicationInfo) { - commit('SET_APPLICATION', applicationInfo) - const { id, appName } = applicationInfo || {} - if (id) { - setApplicationId(applicationInfo.id) - Cookies.set('Admin-Application-appCode', applicationInfo.appCode) - } else { - removeApplicationId() - Cookies.remove('Admin-Application-appCode') - } - if (appName) { - setApplicationName(applicationInfo.appName) - } else { - removeApplicationName() - } - } - } -} - -export default user +import { getInfo, login, logout } from '@/api/login' +import { getToken, removeToken, setToken } from '@/utils/auth' +import { + getApplicationId, + removeApplicationId, + removeApplicationName, + setApplicationId, + setApplicationName +} from '@/utils/application' +import Cookies from 'js-cookie' + +const user = { + state: { + token: getToken(), + name: '', + avatar: '', + roles: [], + permissions: [], + applicationId: getApplicationId(), + applicationInfo: {} // 用户选中的项目/应用 + }, + + mutations: { + SET_TOKEN: (state, token) => { + state.token = token + }, + SET_NAME: (state, name) => { + state.name = name + }, + SET_AVATAR: (state, avatar) => { + state.avatar = avatar + }, + SET_ROLES: (state, roles) => { + state.roles = roles + }, + SET_PERMISSIONS: (state, permissions) => { + state.permissions = permissions + }, + SET_APPLICATION: (state, applicationInfo) => { + const { appCode } = applicationInfo + state.applicationId = appCode || '' + state.applicationInfo = applicationInfo + } + }, + + actions: { + // 登录 + Login ({ commit }, userInfo) { + const username = userInfo.username.trim() + const password = userInfo.password + const code = userInfo.code + const uuid = userInfo.uuid + return new Promise((resolve, reject) => { + login(username, password, code, uuid).then(res => { + setToken(res.token) + commit('SET_TOKEN', res.token) + resolve() + }).catch(error => { + reject(error) + }) + }) + }, + + // 获取用户信息 + GetInfo ({ commit, state }) { + return new Promise((resolve, reject) => { + getInfo().then(res => { + const user = res.user + const avatar = (user.avatar == '' || user.avatar == null) ? require('@/assets/images/profile.png') : process.env.VUE_APP_BASE_API + user.avatar + if (res.roles && res.roles.length > 0) { // 验证返回的roles是否是一个非空数组 + commit('SET_ROLES', res.roles) + commit('SET_PERMISSIONS', res.permissions) + } else { + commit('SET_ROLES', ['ROLE_DEFAULT']) + } + commit('SET_NAME', user.userName) + commit('SET_AVATAR', avatar) + resolve(res) + }).catch(error => { + reject(error) + }) + }) + }, + + // 退出系统 + LogOut ({ commit, state }) { + return new Promise((resolve, reject) => { + logout(state.token).then(() => { + commit('SET_TOKEN', '') + commit('SET_ROLES', []) + commit('SET_PERMISSIONS', []) + commit('SET_APPLICATION', {}) + removeApplicationId() + removeToken() + resolve() + }).catch(error => { + reject(error) + }) + }) + }, + + // 前端 登出 + FedLogOut ({ commit }) { + return new Promise(resolve => { + commit('SET_TOKEN', '') + commit('SET_APPLICATION', {}) + removeApplicationId() + removeToken() + resolve() + }) + }, + + // 设置选中的项目应用信息 + SetApplication ({ commit }, applicationInfo) { + commit('SET_APPLICATION', applicationInfo) + const { appCode, appName, isAdmin } = applicationInfo || {} + if (appCode) { + setApplicationId(appCode) + Cookies.set('Admin-Application-appCode', applicationInfo.appCode) + } else { + removeApplicationId() + Cookies.remove('Admin-Application-appCode') + } + if (appName) { + setApplicationName(applicationInfo.appName) + } else { + removeApplicationName() + } + + + if (isAdmin) { + Cookies.set('Admin-isAdmin', isAdmin) + } else { + Cookies.set('Admin-isAdmin', 0) + } + + } + } +} + +export default user diff --git a/sf-ui/src/utils/application.js b/sf-ui/src/utils/application.js index bb027b2..6e2e0fc 100644 --- a/sf-ui/src/utils/application.js +++ b/sf-ui/src/utils/application.js @@ -8,7 +8,7 @@ const ApplicationKeywords = 'Admin-Application-Name' * 该函数从Cookie中检索与应用项目相关的关键信息。 * @returns {string} 返回从Cookie中获取的应用项目ID。 */ -export function getApplicationId() { +export function getApplicationId () { return Cookies.get(ApplicationKey) } @@ -17,7 +17,7 @@ export function getApplicationId() { * 该函数从Cookie中检索与应用项目相关的关键信息。 * @returns {string} 返回从Cookie中获取的应用项目ID。 */ -export function getApplicationName() { +export function getApplicationName () { return Cookies.get(ApplicationKeywords) } @@ -26,7 +26,7 @@ export function getApplicationName() { * @param {string} ApplicationId - 需要设置的应用项目ID。 * @return {boolean|Object} 返回Cookie设置的结果。成功则返回true,失败则返回设置失败的对象。 */ -export function setApplicationId(ApplicationId) { +export function setApplicationId (ApplicationId) { return Cookies.set(ApplicationKey, ApplicationId) } @@ -35,7 +35,7 @@ export function setApplicationId(ApplicationId) { * @param {string} ApplicationId - 需要设置的应用项目名称。 * @return {boolean|Object} 返回Cookie设置的结果。成功则返回true,失败则返回设置失败的对象。 */ -export function setApplicationName(ApplicationName) { +export function setApplicationName (ApplicationName) { return Cookies.set(ApplicationKeywords, ApplicationName) } @@ -44,7 +44,7 @@ export function setApplicationName(ApplicationName) { * 本函数用于删除与应用相关的ID Cookie。 * @returns {boolean} 返回删除操作的结果。如果删除成功,则返回true;如果删除失败,则返回false。 */ -export function removeApplicationId() { +export function removeApplicationId () { return Cookies.remove(ApplicationKey) } @@ -53,7 +53,7 @@ export function removeApplicationId() { * 本函数用于删除与应用相关的Name Cookie。 * @returns {boolean} 返回删除操作的结果。如果删除成功,则返回true;如果删除失败,则返回false。 */ -export function removeApplicationName() { +export function removeApplicationName () { return Cookies.remove(ApplicationKeywords) } diff --git a/sf-ui/src/utils/auth.js b/sf-ui/src/utils/auth.js index 88d7b6c..08a43d6 100644 --- a/sf-ui/src/utils/auth.js +++ b/sf-ui/src/utils/auth.js @@ -1,15 +1,15 @@ -import Cookies from 'js-cookie' - -const TokenKey = 'Admin-Token' - -export function getToken() { - return Cookies.get(TokenKey) -} - -export function setToken(token) { - return Cookies.set(TokenKey, token) -} - -export function removeToken() { - return Cookies.remove(TokenKey) -} +import Cookies from 'js-cookie' + +const TokenKey = 'Admin-Token' + +export function getToken() { + return Cookies.get(TokenKey) +} + +export function setToken(token) { + return Cookies.set(TokenKey, token) +} + +export function removeToken() { + return Cookies.remove(TokenKey) +} diff --git a/sf-ui/src/utils/dict/Dict.js b/sf-ui/src/utils/dict/Dict.js index 22db32f..104bd6e 100644 --- a/sf-ui/src/utils/dict/Dict.js +++ b/sf-ui/src/utils/dict/Dict.js @@ -1,82 +1,82 @@ -import Vue from 'vue' -import { mergeRecursive } from "@/utils/ruoyi"; -import DictMeta from './DictMeta' -import DictData from './DictData' - -const DEFAULT_DICT_OPTIONS = { - types: [], -} - -/** - * @classdesc 字典 - * @property {Object} label 标签对象,内部属性名为字典类型名称 - * @property {Object} dict 字段数组,内部属性名为字典类型名称 - * @property {Array.} _dictMetas 字典元数据数组 - */ -export default class Dict { - constructor() { - this.owner = null - this.label = {} - this.type = {} - } - - init(options) { - if (options instanceof Array) { - options = { types: options } - } - const opts = mergeRecursive(DEFAULT_DICT_OPTIONS, options) - if (opts.types === undefined) { - throw new Error('need dict types') - } - const ps = [] - this._dictMetas = opts.types.map(t => DictMeta.parse(t)) - this._dictMetas.forEach(dictMeta => { - const type = dictMeta.type - Vue.set(this.label, type, {}) - Vue.set(this.type, type, []) - if (dictMeta.lazy) { - return - } - ps.push(loadDict(this, dictMeta)) - }) - return Promise.all(ps) - } - - /** - * 重新加载字典 - * @param {String} type 字典类型 - */ - reloadDict(type) { - const dictMeta = this._dictMetas.find(e => e.type === type) - if (dictMeta === undefined) { - return Promise.reject(`the dict meta of ${type} was not found`) - } - return loadDict(this, dictMeta) - } -} - -/** - * 加载字典 - * @param {Dict} dict 字典 - * @param {DictMeta} dictMeta 字典元数据 - * @returns {Promise} - */ -function loadDict(dict, dictMeta) { - return dictMeta.request(dictMeta) - .then(response => { - const type = dictMeta.type - let dicts = dictMeta.responseConverter(response, dictMeta) - if (!(dicts instanceof Array)) { - console.error('the return of responseConverter must be Array.') - dicts = [] - } else if (dicts.filter(d => d instanceof DictData).length !== dicts.length) { - console.error('the type of elements in dicts must be DictData') - dicts = [] - } - dict.type[type].splice(0, Number.MAX_SAFE_INTEGER, ...dicts) - dicts.forEach(d => { - Vue.set(dict.label[type], d.value, d.label) - }) - return dicts - }) -} +import Vue from 'vue' +import { mergeRecursive } from "@/utils/ruoyi"; +import DictMeta from './DictMeta' +import DictData from './DictData' + +const DEFAULT_DICT_OPTIONS = { + types: [], +} + +/** + * @classdesc 字典 + * @property {Object} label 标签对象,内部属性名为字典类型名称 + * @property {Object} dict 字段数组,内部属性名为字典类型名称 + * @property {Array.} _dictMetas 字典元数据数组 + */ +export default class Dict { + constructor() { + this.owner = null + this.label = {} + this.type = {} + } + + init(options) { + if (options instanceof Array) { + options = { types: options } + } + const opts = mergeRecursive(DEFAULT_DICT_OPTIONS, options) + if (opts.types === undefined) { + throw new Error('need dict types') + } + const ps = [] + this._dictMetas = opts.types.map(t => DictMeta.parse(t)) + this._dictMetas.forEach(dictMeta => { + const type = dictMeta.type + Vue.set(this.label, type, {}) + Vue.set(this.type, type, []) + if (dictMeta.lazy) { + return + } + ps.push(loadDict(this, dictMeta)) + }) + return Promise.all(ps) + } + + /** + * 重新加载字典 + * @param {String} type 字典类型 + */ + reloadDict(type) { + const dictMeta = this._dictMetas.find(e => e.type === type) + if (dictMeta === undefined) { + return Promise.reject(`the dict meta of ${type} was not found`) + } + return loadDict(this, dictMeta) + } +} + +/** + * 加载字典 + * @param {Dict} dict 字典 + * @param {DictMeta} dictMeta 字典元数据 + * @returns {Promise} + */ +function loadDict(dict, dictMeta) { + return dictMeta.request(dictMeta) + .then(response => { + const type = dictMeta.type + let dicts = dictMeta.responseConverter(response, dictMeta) + if (!(dicts instanceof Array)) { + console.error('the return of responseConverter must be Array.') + dicts = [] + } else if (dicts.filter(d => d instanceof DictData).length !== dicts.length) { + console.error('the type of elements in dicts must be DictData') + dicts = [] + } + dict.type[type].splice(0, Number.MAX_SAFE_INTEGER, ...dicts) + dicts.forEach(d => { + Vue.set(dict.label[type], d.value, d.label) + }) + return dicts + }) +} diff --git a/sf-ui/src/utils/dict/DictConverter.js b/sf-ui/src/utils/dict/DictConverter.js index 576ff54..0cf5df8 100644 --- a/sf-ui/src/utils/dict/DictConverter.js +++ b/sf-ui/src/utils/dict/DictConverter.js @@ -1,17 +1,17 @@ -import DictOptions from './DictOptions' -import DictData from './DictData' - -export default function(dict, dictMeta) { - const label = determineDictField(dict, dictMeta.labelField, ...DictOptions.DEFAULT_LABEL_FIELDS) - const value = determineDictField(dict, dictMeta.valueField, ...DictOptions.DEFAULT_VALUE_FIELDS) - return new DictData(dict[label], dict[value], dict) -} - -/** - * 确定字典字段 - * @param {DictData} dict - * @param {...String} fields - */ -function determineDictField(dict, ...fields) { - return fields.find(f => Object.prototype.hasOwnProperty.call(dict, f)) -} +import DictOptions from './DictOptions' +import DictData from './DictData' + +export default function(dict, dictMeta) { + const label = determineDictField(dict, dictMeta.labelField, ...DictOptions.DEFAULT_LABEL_FIELDS) + const value = determineDictField(dict, dictMeta.valueField, ...DictOptions.DEFAULT_VALUE_FIELDS) + return new DictData(dict[label], dict[value], dict) +} + +/** + * 确定字典字段 + * @param {DictData} dict + * @param {...String} fields + */ +function determineDictField(dict, ...fields) { + return fields.find(f => Object.prototype.hasOwnProperty.call(dict, f)) +} diff --git a/sf-ui/src/utils/dict/DictData.js b/sf-ui/src/utils/dict/DictData.js index 37a60d5..afc763e 100644 --- a/sf-ui/src/utils/dict/DictData.js +++ b/sf-ui/src/utils/dict/DictData.js @@ -1,13 +1,13 @@ -/** - * @classdesc 字典数据 - * @property {String} label 标签 - * @property {*} value 标签 - * @property {Object} raw 原始数据 - */ -export default class DictData { - constructor(label, value, raw) { - this.label = label - this.value = value - this.raw = raw - } -} +/** + * @classdesc 字典数据 + * @property {String} label 标签 + * @property {*} value 标签 + * @property {Object} raw 原始数据 + */ +export default class DictData { + constructor(label, value, raw) { + this.label = label + this.value = value + this.raw = raw + } +} diff --git a/sf-ui/src/utils/dict/DictMeta.js b/sf-ui/src/utils/dict/DictMeta.js index 2ae0827..9779daa 100644 --- a/sf-ui/src/utils/dict/DictMeta.js +++ b/sf-ui/src/utils/dict/DictMeta.js @@ -1,38 +1,38 @@ -import { mergeRecursive } from "@/utils/ruoyi"; -import DictOptions from './DictOptions' - -/** - * @classdesc 字典元数据 - * @property {String} type 类型 - * @property {Function} request 请求 - * @property {String} label 标签字段 - * @property {String} value 值字段 - */ -export default class DictMeta { - constructor(options) { - this.type = options.type - this.request = options.request - this.responseConverter = options.responseConverter - this.labelField = options.labelField - this.valueField = options.valueField - this.lazy = options.lazy === true - } -} - - -/** - * 解析字典元数据 - * @param {Object} options - * @returns {DictMeta} - */ -DictMeta.parse= function(options) { - let opts = null - if (typeof options === 'string') { - opts = DictOptions.metas[options] || {} - opts.type = options - } else if (typeof options === 'object') { - opts = options - } - opts = mergeRecursive(DictOptions.metas['*'], opts) - return new DictMeta(opts) -} +import { mergeRecursive } from "@/utils/ruoyi"; +import DictOptions from './DictOptions' + +/** + * @classdesc 字典元数据 + * @property {String} type 类型 + * @property {Function} request 请求 + * @property {String} label 标签字段 + * @property {String} value 值字段 + */ +export default class DictMeta { + constructor(options) { + this.type = options.type + this.request = options.request + this.responseConverter = options.responseConverter + this.labelField = options.labelField + this.valueField = options.valueField + this.lazy = options.lazy === true + } +} + + +/** + * 解析字典元数据 + * @param {Object} options + * @returns {DictMeta} + */ +DictMeta.parse= function(options) { + let opts = null + if (typeof options === 'string') { + opts = DictOptions.metas[options] || {} + opts.type = options + } else if (typeof options === 'object') { + opts = options + } + opts = mergeRecursive(DictOptions.metas['*'], opts) + return new DictMeta(opts) +} diff --git a/sf-ui/src/utils/dict/DictOptions.js b/sf-ui/src/utils/dict/DictOptions.js index 5e1cc41..338a94e 100644 --- a/sf-ui/src/utils/dict/DictOptions.js +++ b/sf-ui/src/utils/dict/DictOptions.js @@ -1,51 +1,51 @@ -import { mergeRecursive } from "@/utils/ruoyi"; -import dictConverter from './DictConverter' - -export const options = { - metas: { - '*': { - /** - * 字典请求,方法签名为function(dictMeta: DictMeta): Promise - */ - request: (dictMeta) => { - console.log(`load dict ${dictMeta.type}`) - return Promise.resolve([]) - }, - /** - * 字典响应数据转换器,方法签名为function(response: Object, dictMeta: DictMeta): DictData - */ - responseConverter, - labelField: 'label', - valueField: 'value', - }, - }, - /** - * 默认标签字段 - */ - DEFAULT_LABEL_FIELDS: ['label', 'name', 'title'], - /** - * 默认值字段 - */ - DEFAULT_VALUE_FIELDS: ['value', 'id', 'uid', 'key'], -} - -/** - * 映射字典 - * @param {Object} response 字典数据 - * @param {DictMeta} dictMeta 字典元数据 - * @returns {DictData} - */ -function responseConverter(response, dictMeta) { - const dicts = response.content instanceof Array ? response.content : response - if (dicts === undefined) { - console.warn(`no dict data of "${dictMeta.type}" found in the response`) - return [] - } - return dicts.map(d => dictConverter(d, dictMeta)) -} - -export function mergeOptions(src) { - mergeRecursive(options, src) -} - -export default options +import { mergeRecursive } from "@/utils/ruoyi"; +import dictConverter from './DictConverter' + +export const options = { + metas: { + '*': { + /** + * 字典请求,方法签名为function(dictMeta: DictMeta): Promise + */ + request: (dictMeta) => { + console.log(`load dict ${dictMeta.type}`) + return Promise.resolve([]) + }, + /** + * 字典响应数据转换器,方法签名为function(response: Object, dictMeta: DictMeta): DictData + */ + responseConverter, + labelField: 'label', + valueField: 'value', + }, + }, + /** + * 默认标签字段 + */ + DEFAULT_LABEL_FIELDS: ['label', 'name', 'title'], + /** + * 默认值字段 + */ + DEFAULT_VALUE_FIELDS: ['value', 'id', 'uid', 'key'], +} + +/** + * 映射字典 + * @param {Object} response 字典数据 + * @param {DictMeta} dictMeta 字典元数据 + * @returns {DictData} + */ +function responseConverter(response, dictMeta) { + const dicts = response.content instanceof Array ? response.content : response + if (dicts === undefined) { + console.warn(`no dict data of "${dictMeta.type}" found in the response`) + return [] + } + return dicts.map(d => dictConverter(d, dictMeta)) +} + +export function mergeOptions(src) { + mergeRecursive(options, src) +} + +export default options diff --git a/sf-ui/src/utils/dict/index.js b/sf-ui/src/utils/dict/index.js index d6fdb80..215eb9e 100644 --- a/sf-ui/src/utils/dict/index.js +++ b/sf-ui/src/utils/dict/index.js @@ -1,33 +1,33 @@ -import Dict from './Dict' -import { mergeOptions } from './DictOptions' - -export default function(Vue, options) { - mergeOptions(options) - Vue.mixin({ - data() { - if (this.$options === undefined || this.$options.dicts === undefined || this.$options.dicts === null) { - return {} - } - const dict = new Dict() - dict.owner = this - return { - dict - } - }, - created() { - if (!(this.dict instanceof Dict)) { - return - } - options.onCreated && options.onCreated(this.dict) - this.dict.init(this.$options.dicts).then(() => { - options.onReady && options.onReady(this.dict) - this.$nextTick(() => { - this.$emit('dictReady', this.dict) - if (this.$options.methods && this.$options.methods.onDictReady instanceof Function) { - this.$options.methods.onDictReady.call(this, this.dict) - } - }) - }) - }, - }) -} +import Dict from './Dict' +import { mergeOptions } from './DictOptions' + +export default function(Vue, options) { + mergeOptions(options) + Vue.mixin({ + data() { + if (this.$options === undefined || this.$options.dicts === undefined || this.$options.dicts === null) { + return {} + } + const dict = new Dict() + dict.owner = this + return { + dict + } + }, + created() { + if (!(this.dict instanceof Dict)) { + return + } + options.onCreated && options.onCreated(this.dict) + this.dict.init(this.$options.dicts).then(() => { + options.onReady && options.onReady(this.dict) + this.$nextTick(() => { + this.$emit('dictReady', this.dict) + if (this.$options.methods && this.$options.methods.onDictReady instanceof Function) { + this.$options.methods.onDictReady.call(this, this.dict) + } + }) + }) + }, + }) +} diff --git a/sf-ui/src/utils/eventBus.js b/sf-ui/src/utils/eventBus.js new file mode 100644 index 0000000..b6d5a72 --- /dev/null +++ b/sf-ui/src/utils/eventBus.js @@ -0,0 +1,3 @@ +import vue from 'vue' +const EventBus = new vue(); +export default EventBus; \ No newline at end of file diff --git a/sf-ui/src/utils/generator/config.js b/sf-ui/src/utils/generator/config.js index 005140a..7abf227 100644 --- a/sf-ui/src/utils/generator/config.js +++ b/sf-ui/src/utils/generator/config.js @@ -1,438 +1,438 @@ -export const formConf = { - formRef: 'elForm', - formModel: 'formData', - size: 'medium', - labelPosition: 'right', - labelWidth: 100, - formRules: 'rules', - gutter: 15, - disabled: false, - span: 24, - formBtns: true -} - -export const inputComponents = [ - { - label: '单行文本', - tag: 'el-input', - tagIcon: 'input', - placeholder: '请输入', - defaultValue: undefined, - span: 24, - labelWidth: null, - style: { width: '100%' }, - clearable: true, - prepend: '', - append: '', - 'prefix-icon': '', - 'suffix-icon': '', - maxlength: null, - 'show-word-limit': false, - readonly: false, - disabled: false, - required: true, - regList: [], - changeTag: true, - document: 'https://element.eleme.cn/#/zh-CN/component/input' - }, - { - label: '多行文本', - tag: 'el-input', - tagIcon: 'textarea', - type: 'textarea', - placeholder: '请输入', - defaultValue: undefined, - span: 24, - labelWidth: null, - autosize: { - minRows: 4, - maxRows: 4 - }, - style: { width: '100%' }, - maxlength: null, - 'show-word-limit': false, - readonly: false, - disabled: false, - required: true, - regList: [], - changeTag: true, - document: 'https://element.eleme.cn/#/zh-CN/component/input' - }, - { - label: '密码', - tag: 'el-input', - tagIcon: 'password', - placeholder: '请输入', - defaultValue: undefined, - span: 24, - 'show-password': true, - labelWidth: null, - style: { width: '100%' }, - clearable: true, - prepend: '', - append: '', - 'prefix-icon': '', - 'suffix-icon': '', - maxlength: null, - 'show-word-limit': false, - readonly: false, - disabled: false, - required: true, - regList: [], - changeTag: true, - document: 'https://element.eleme.cn/#/zh-CN/component/input' - }, - { - label: '计数器', - tag: 'el-input-number', - tagIcon: 'number', - placeholder: '', - defaultValue: undefined, - span: 24, - labelWidth: null, - min: undefined, - max: undefined, - step: undefined, - 'step-strictly': false, - precision: undefined, - 'controls-position': '', - disabled: false, - required: true, - regList: [], - changeTag: true, - document: 'https://element.eleme.cn/#/zh-CN/component/input-number' - } -] - -export const selectComponents = [ - { - label: '下拉选择', - tag: 'el-select', - tagIcon: 'select', - placeholder: '请选择', - defaultValue: undefined, - span: 24, - labelWidth: null, - style: { width: '100%' }, - clearable: true, - disabled: false, - required: true, - filterable: false, - multiple: false, - options: [{ - label: '选项一', - value: 1 - }, { - label: '选项二', - value: 2 - }], - regList: [], - changeTag: true, - document: 'https://element.eleme.cn/#/zh-CN/component/select' - }, - { - label: '级联选择', - tag: 'el-cascader', - tagIcon: 'cascader', - placeholder: '请选择', - defaultValue: [], - span: 24, - labelWidth: null, - style: { width: '100%' }, - props: { - props: { - multiple: false - } - }, - 'show-all-levels': true, - disabled: false, - clearable: true, - filterable: false, - required: true, - options: [{ - id: 1, - value: 1, - label: '选项1', - children: [{ - id: 2, - value: 2, - label: '选项1-1' - }] - }], - dataType: 'dynamic', - labelKey: 'label', - valueKey: 'value', - childrenKey: 'children', - separator: '/', - regList: [], - changeTag: true, - document: 'https://element.eleme.cn/#/zh-CN/component/cascader' - }, - { - label: '单选框组', - tag: 'el-radio-group', - tagIcon: 'radio', - defaultValue: undefined, - span: 24, - labelWidth: null, - style: {}, - optionType: 'default', - border: false, - size: 'medium', - disabled: false, - required: true, - options: [{ - label: '选项一', - value: 1 - }, { - label: '选项二', - value: 2 - }], - regList: [], - changeTag: true, - document: 'https://element.eleme.cn/#/zh-CN/component/radio' - }, - { - label: '多选框组', - tag: 'el-checkbox-group', - tagIcon: 'checkbox', - defaultValue: [], - span: 24, - labelWidth: null, - style: {}, - optionType: 'default', - border: false, - size: 'medium', - disabled: false, - required: true, - options: [{ - label: '选项一', - value: 1 - }, { - label: '选项二', - value: 2 - }], - regList: [], - changeTag: true, - document: 'https://element.eleme.cn/#/zh-CN/component/checkbox' - }, - { - label: '开关', - tag: 'el-switch', - tagIcon: 'switch', - defaultValue: false, - span: 24, - labelWidth: null, - style: {}, - disabled: false, - required: true, - 'active-text': '', - 'inactive-text': '', - 'active-color': null, - 'inactive-color': null, - 'active-value': true, - 'inactive-value': false, - regList: [], - changeTag: true, - document: 'https://element.eleme.cn/#/zh-CN/component/switch' - }, - { - label: '滑块', - tag: 'el-slider', - tagIcon: 'slider', - defaultValue: null, - span: 24, - labelWidth: null, - disabled: false, - required: true, - min: 0, - max: 100, - step: 1, - 'show-stops': false, - range: false, - regList: [], - changeTag: true, - document: 'https://element.eleme.cn/#/zh-CN/component/slider' - }, - { - label: '时间选择', - tag: 'el-time-picker', - tagIcon: 'time', - placeholder: '请选择', - defaultValue: null, - span: 24, - labelWidth: null, - style: { width: '100%' }, - disabled: false, - clearable: true, - required: true, - 'picker-options': { - selectableRange: '00:00:00-23:59:59' - }, - format: 'HH:mm:ss', - 'value-format': 'HH:mm:ss', - regList: [], - changeTag: true, - document: 'https://element.eleme.cn/#/zh-CN/component/time-picker' - }, - { - label: '时间范围', - tag: 'el-time-picker', - tagIcon: 'time-range', - defaultValue: null, - span: 24, - labelWidth: null, - style: { width: '100%' }, - disabled: false, - clearable: true, - required: true, - 'is-range': true, - 'range-separator': '至', - 'start-placeholder': '开始时间', - 'end-placeholder': '结束时间', - format: 'HH:mm:ss', - 'value-format': 'HH:mm:ss', - regList: [], - changeTag: true, - document: 'https://element.eleme.cn/#/zh-CN/component/time-picker' - }, - { - label: '日期选择', - tag: 'el-date-picker', - tagIcon: 'date', - placeholder: '请选择', - defaultValue: null, - type: 'date', - span: 24, - labelWidth: null, - style: { width: '100%' }, - disabled: false, - clearable: true, - required: true, - format: 'yyyy-MM-dd', - 'value-format': 'yyyy-MM-dd', - readonly: false, - regList: [], - changeTag: true, - document: 'https://element.eleme.cn/#/zh-CN/component/date-picker' - }, - { - label: '日期范围', - tag: 'el-date-picker', - tagIcon: 'date-range', - defaultValue: null, - span: 24, - labelWidth: null, - style: { width: '100%' }, - type: 'daterange', - 'range-separator': '至', - 'start-placeholder': '开始日期', - 'end-placeholder': '结束日期', - disabled: false, - clearable: true, - required: true, - format: 'yyyy-MM-dd', - 'value-format': 'yyyy-MM-dd', - readonly: false, - regList: [], - changeTag: true, - document: 'https://element.eleme.cn/#/zh-CN/component/date-picker' - }, - { - label: '评分', - tag: 'el-rate', - tagIcon: 'rate', - defaultValue: 0, - span: 24, - labelWidth: null, - style: {}, - max: 5, - 'allow-half': false, - 'show-text': false, - 'show-score': false, - disabled: false, - required: true, - regList: [], - changeTag: true, - document: 'https://element.eleme.cn/#/zh-CN/component/rate' - }, - { - label: '颜色选择', - tag: 'el-color-picker', - tagIcon: 'color', - defaultValue: null, - labelWidth: null, - 'show-alpha': false, - 'color-format': '', - disabled: false, - required: true, - size: 'medium', - regList: [], - changeTag: true, - document: 'https://element.eleme.cn/#/zh-CN/component/color-picker' - }, - { - label: '上传', - tag: 'el-upload', - tagIcon: 'upload', - action: 'https://jsonplaceholder.typicode.com/posts/', - defaultValue: null, - labelWidth: null, - disabled: false, - required: true, - accept: '', - name: 'file', - 'auto-upload': true, - showTip: false, - buttonText: '点击上传', - fileSize: 2, - sizeUnit: 'MB', - 'list-type': 'text', - multiple: false, - regList: [], - changeTag: true, - document: 'https://element.eleme.cn/#/zh-CN/component/upload' - } -] - -export const layoutComponents = [ - { - layout: 'rowFormItem', - tagIcon: 'row', - type: 'default', - justify: 'start', - align: 'top', - label: '行容器', - layoutTree: true, - children: [], - document: 'https://element.eleme.cn/#/zh-CN/component/layout' - }, - { - layout: 'colFormItem', - label: '按钮', - changeTag: true, - labelWidth: null, - tag: 'el-button', - tagIcon: 'button', - span: 24, - default: '主要按钮', - type: 'primary', - icon: 'el-icon-search', - size: 'medium', - disabled: false, - document: 'https://element.eleme.cn/#/zh-CN/component/button' - } -] - -// 组件rule的触发方式,无触发方式的组件不生成rule -export const trigger = { - 'el-input': 'blur', - 'el-input-number': 'blur', - 'el-select': 'change', - 'el-radio-group': 'change', - 'el-checkbox-group': 'change', - 'el-cascader': 'change', - 'el-time-picker': 'change', - 'el-date-picker': 'change', - 'el-rate': 'change' -} +export const formConf = { + formRef: 'elForm', + formModel: 'formData', + size: 'medium', + labelPosition: 'right', + labelWidth: 100, + formRules: 'rules', + gutter: 15, + disabled: false, + span: 24, + formBtns: true +} + +export const inputComponents = [ + { + label: '单行文本', + tag: 'el-input', + tagIcon: 'input', + placeholder: '请输入', + defaultValue: undefined, + span: 24, + labelWidth: null, + style: { width: '100%' }, + clearable: true, + prepend: '', + append: '', + 'prefix-icon': '', + 'suffix-icon': '', + maxlength: null, + 'show-word-limit': false, + readonly: false, + disabled: false, + required: true, + regList: [], + changeTag: true, + document: 'https://element.eleme.cn/#/zh-CN/component/input' + }, + { + label: '多行文本', + tag: 'el-input', + tagIcon: 'textarea', + type: 'textarea', + placeholder: '请输入', + defaultValue: undefined, + span: 24, + labelWidth: null, + autosize: { + minRows: 4, + maxRows: 4 + }, + style: { width: '100%' }, + maxlength: null, + 'show-word-limit': false, + readonly: false, + disabled: false, + required: true, + regList: [], + changeTag: true, + document: 'https://element.eleme.cn/#/zh-CN/component/input' + }, + { + label: '密码', + tag: 'el-input', + tagIcon: 'password', + placeholder: '请输入', + defaultValue: undefined, + span: 24, + 'show-password': true, + labelWidth: null, + style: { width: '100%' }, + clearable: true, + prepend: '', + append: '', + 'prefix-icon': '', + 'suffix-icon': '', + maxlength: null, + 'show-word-limit': false, + readonly: false, + disabled: false, + required: true, + regList: [], + changeTag: true, + document: 'https://element.eleme.cn/#/zh-CN/component/input' + }, + { + label: '计数器', + tag: 'el-input-number', + tagIcon: 'number', + placeholder: '', + defaultValue: undefined, + span: 24, + labelWidth: null, + min: undefined, + max: undefined, + step: undefined, + 'step-strictly': false, + precision: undefined, + 'controls-position': '', + disabled: false, + required: true, + regList: [], + changeTag: true, + document: 'https://element.eleme.cn/#/zh-CN/component/input-number' + } +] + +export const selectComponents = [ + { + label: '下拉选择', + tag: 'el-select', + tagIcon: 'select', + placeholder: '请选择', + defaultValue: undefined, + span: 24, + labelWidth: null, + style: { width: '100%' }, + clearable: true, + disabled: false, + required: true, + filterable: false, + multiple: false, + options: [{ + label: '选项一', + value: 1 + }, { + label: '选项二', + value: 2 + }], + regList: [], + changeTag: true, + document: 'https://element.eleme.cn/#/zh-CN/component/select' + }, + { + label: '级联选择', + tag: 'el-cascader', + tagIcon: 'cascader', + placeholder: '请选择', + defaultValue: [], + span: 24, + labelWidth: null, + style: { width: '100%' }, + props: { + props: { + multiple: false + } + }, + 'show-all-levels': true, + disabled: false, + clearable: true, + filterable: false, + required: true, + options: [{ + id: 1, + value: 1, + label: '选项1', + children: [{ + id: 2, + value: 2, + label: '选项1-1' + }] + }], + dataType: 'dynamic', + labelKey: 'label', + valueKey: 'value', + childrenKey: 'children', + separator: '/', + regList: [], + changeTag: true, + document: 'https://element.eleme.cn/#/zh-CN/component/cascader' + }, + { + label: '单选框组', + tag: 'el-radio-group', + tagIcon: 'radio', + defaultValue: undefined, + span: 24, + labelWidth: null, + style: {}, + optionType: 'default', + border: false, + size: 'medium', + disabled: false, + required: true, + options: [{ + label: '选项一', + value: 1 + }, { + label: '选项二', + value: 2 + }], + regList: [], + changeTag: true, + document: 'https://element.eleme.cn/#/zh-CN/component/radio' + }, + { + label: '多选框组', + tag: 'el-checkbox-group', + tagIcon: 'checkbox', + defaultValue: [], + span: 24, + labelWidth: null, + style: {}, + optionType: 'default', + border: false, + size: 'medium', + disabled: false, + required: true, + options: [{ + label: '选项一', + value: 1 + }, { + label: '选项二', + value: 2 + }], + regList: [], + changeTag: true, + document: 'https://element.eleme.cn/#/zh-CN/component/checkbox' + }, + { + label: '开关', + tag: 'el-switch', + tagIcon: 'switch', + defaultValue: false, + span: 24, + labelWidth: null, + style: {}, + disabled: false, + required: true, + 'active-text': '', + 'inactive-text': '', + 'active-color': null, + 'inactive-color': null, + 'active-value': true, + 'inactive-value': false, + regList: [], + changeTag: true, + document: 'https://element.eleme.cn/#/zh-CN/component/switch' + }, + { + label: '滑块', + tag: 'el-slider', + tagIcon: 'slider', + defaultValue: null, + span: 24, + labelWidth: null, + disabled: false, + required: true, + min: 0, + max: 100, + step: 1, + 'show-stops': false, + range: false, + regList: [], + changeTag: true, + document: 'https://element.eleme.cn/#/zh-CN/component/slider' + }, + { + label: '时间选择', + tag: 'el-time-picker', + tagIcon: 'time', + placeholder: '请选择', + defaultValue: null, + span: 24, + labelWidth: null, + style: { width: '100%' }, + disabled: false, + clearable: true, + required: true, + 'picker-options': { + selectableRange: '00:00:00-23:59:59' + }, + format: 'HH:mm:ss', + 'value-format': 'HH:mm:ss', + regList: [], + changeTag: true, + document: 'https://element.eleme.cn/#/zh-CN/component/time-picker' + }, + { + label: '时间范围', + tag: 'el-time-picker', + tagIcon: 'time-range', + defaultValue: null, + span: 24, + labelWidth: null, + style: { width: '100%' }, + disabled: false, + clearable: true, + required: true, + 'is-range': true, + 'range-separator': '至', + 'start-placeholder': '开始时间', + 'end-placeholder': '结束时间', + format: 'HH:mm:ss', + 'value-format': 'HH:mm:ss', + regList: [], + changeTag: true, + document: 'https://element.eleme.cn/#/zh-CN/component/time-picker' + }, + { + label: '日期选择', + tag: 'el-date-picker', + tagIcon: 'date', + placeholder: '请选择', + defaultValue: null, + type: 'date', + span: 24, + labelWidth: null, + style: { width: '100%' }, + disabled: false, + clearable: true, + required: true, + format: 'yyyy-MM-dd', + 'value-format': 'yyyy-MM-dd', + readonly: false, + regList: [], + changeTag: true, + document: 'https://element.eleme.cn/#/zh-CN/component/date-picker' + }, + { + label: '日期范围', + tag: 'el-date-picker', + tagIcon: 'date-range', + defaultValue: null, + span: 24, + labelWidth: null, + style: { width: '100%' }, + type: 'daterange', + 'range-separator': '至', + 'start-placeholder': '开始日期', + 'end-placeholder': '结束日期', + disabled: false, + clearable: true, + required: true, + format: 'yyyy-MM-dd', + 'value-format': 'yyyy-MM-dd', + readonly: false, + regList: [], + changeTag: true, + document: 'https://element.eleme.cn/#/zh-CN/component/date-picker' + }, + { + label: '评分', + tag: 'el-rate', + tagIcon: 'rate', + defaultValue: 0, + span: 24, + labelWidth: null, + style: {}, + max: 5, + 'allow-half': false, + 'show-text': false, + 'show-score': false, + disabled: false, + required: true, + regList: [], + changeTag: true, + document: 'https://element.eleme.cn/#/zh-CN/component/rate' + }, + { + label: '颜色选择', + tag: 'el-color-picker', + tagIcon: 'color', + defaultValue: null, + labelWidth: null, + 'show-alpha': false, + 'color-format': '', + disabled: false, + required: true, + size: 'medium', + regList: [], + changeTag: true, + document: 'https://element.eleme.cn/#/zh-CN/component/color-picker' + }, + { + label: '上传', + tag: 'el-upload', + tagIcon: 'upload', + action: 'https://jsonplaceholder.typicode.com/posts/', + defaultValue: null, + labelWidth: null, + disabled: false, + required: true, + accept: '', + name: 'file', + 'auto-upload': true, + showTip: false, + buttonText: '点击上传', + fileSize: 2, + sizeUnit: 'MB', + 'list-type': 'text', + multiple: false, + regList: [], + changeTag: true, + document: 'https://element.eleme.cn/#/zh-CN/component/upload' + } +] + +export const layoutComponents = [ + { + layout: 'rowFormItem', + tagIcon: 'row', + type: 'default', + justify: 'start', + align: 'top', + label: '行容器', + layoutTree: true, + children: [], + document: 'https://element.eleme.cn/#/zh-CN/component/layout' + }, + { + layout: 'colFormItem', + label: '按钮', + changeTag: true, + labelWidth: null, + tag: 'el-button', + tagIcon: 'button', + span: 24, + default: '主要按钮', + type: 'primary', + icon: 'el-icon-search', + size: 'medium', + disabled: false, + document: 'https://element.eleme.cn/#/zh-CN/component/button' + } +] + +// 组件rule的触发方式,无触发方式的组件不生成rule +export const trigger = { + 'el-input': 'blur', + 'el-input-number': 'blur', + 'el-select': 'change', + 'el-radio-group': 'change', + 'el-checkbox-group': 'change', + 'el-cascader': 'change', + 'el-time-picker': 'change', + 'el-date-picker': 'change', + 'el-rate': 'change' +} diff --git a/sf-ui/src/utils/generator/css.js b/sf-ui/src/utils/generator/css.js index 0d7f075..c1c62e6 100644 --- a/sf-ui/src/utils/generator/css.js +++ b/sf-ui/src/utils/generator/css.js @@ -1,18 +1,18 @@ -const styles = { - 'el-rate': '.el-rate{display: inline-block; vertical-align: text-top;}', - 'el-upload': '.el-upload__tip{line-height: 1.2;}' -} - -function addCss(cssList, el) { - const css = styles[el.tag] - css && cssList.indexOf(css) === -1 && cssList.push(css) - if (el.children) { - el.children.forEach(el2 => addCss(cssList, el2)) - } -} - -export function makeUpCss(conf) { - const cssList = [] - conf.fields.forEach(el => addCss(cssList, el)) - return cssList.join('\n') -} +const styles = { + 'el-rate': '.el-rate{display: inline-block; vertical-align: text-top;}', + 'el-upload': '.el-upload__tip{line-height: 1.2;}' +} + +function addCss(cssList, el) { + const css = styles[el.tag] + css && cssList.indexOf(css) === -1 && cssList.push(css) + if (el.children) { + el.children.forEach(el2 => addCss(cssList, el2)) + } +} + +export function makeUpCss(conf) { + const cssList = [] + conf.fields.forEach(el => addCss(cssList, el)) + return cssList.join('\n') +} diff --git a/sf-ui/src/utils/generator/render.js b/sf-ui/src/utils/generator/render.js index f187029..e8640f0 100644 --- a/sf-ui/src/utils/generator/render.js +++ b/sf-ui/src/utils/generator/render.js @@ -1,126 +1,126 @@ -import { makeMap } from '@/utils/index' - -// 参考https://github.com/vuejs/vue/blob/v2.6.10/src/platforms/web/server/util.js -const isAttr = makeMap( - 'accept,accept-charset,accesskey,action,align,alt,async,autocomplete,' - + 'autofocus,autoplay,autosave,bgcolor,border,buffered,challenge,charset,' - + 'checked,cite,class,code,codebase,color,cols,colspan,content,http-equiv,' - + 'name,contenteditable,contextmenu,controls,coords,data,datetime,default,' - + 'defer,dir,dirname,disabled,download,draggable,dropzone,enctype,method,for,' - + 'form,formaction,headers,height,hidden,high,href,hreflang,http-equiv,' - + 'icon,id,ismap,itemprop,keytype,kind,label,lang,language,list,loop,low,' - + 'manifest,max,maxlength,media,method,GET,POST,min,multiple,email,file,' - + 'muted,name,novalidate,open,optimum,pattern,ping,placeholder,poster,' - + 'preload,radiogroup,readonly,rel,required,reversed,rows,rowspan,sandbox,' - + 'scope,scoped,seamless,selected,shape,size,type,text,password,sizes,span,' - + 'spellcheck,src,srcdoc,srclang,srcset,start,step,style,summary,tabindex,' - + 'target,title,type,usemap,value,width,wrap' -) - -function vModel(self, dataObject, defaultValue) { - dataObject.props.value = defaultValue - - dataObject.on.input = val => { - self.$emit('input', val) - } -} - -const componentChild = { - 'el-button': { - default(h, conf, key) { - return conf[key] - }, - }, - 'el-input': { - prepend(h, conf, key) { - return - }, - append(h, conf, key) { - return - } - }, - 'el-select': { - options(h, conf, key) { - const list = [] - conf.options.forEach(item => { - list.push() - }) - return list - } - }, - 'el-radio-group': { - options(h, conf, key) { - const list = [] - conf.options.forEach(item => { - if (conf.optionType === 'button') list.push({item.label}) - else list.push({item.label}) - }) - return list - } - }, - 'el-checkbox-group': { - options(h, conf, key) { - const list = [] - conf.options.forEach(item => { - if (conf.optionType === 'button') { - list.push({item.label}) - } else { - list.push({item.label}) - } - }) - return list - } - }, - 'el-upload': { - 'list-type': (h, conf, key) => { - const list = [] - if (conf['list-type'] === 'picture-card') { - list.push() - } else { - list.push({conf.buttonText}) - } - if (conf.showTip) { - list.push(
    只能上传不超过 {conf.fileSize}{conf.sizeUnit} 的{conf.accept}文件
    ) - } - return list - } - } -} - -export default { - render(h) { - const dataObject = { - attrs: {}, - props: {}, - on: {}, - style: {} - } - const confClone = JSON.parse(JSON.stringify(this.conf)) - const children = [] - - const childObjs = componentChild[confClone.tag] - if (childObjs) { - Object.keys(childObjs).forEach(key => { - const childFunc = childObjs[key] - if (confClone[key]) { - children.push(childFunc(h, confClone, key)) - } - }) - } - - Object.keys(confClone).forEach(key => { - const val = confClone[key] - if (key === 'vModel') { - vModel(this, dataObject, confClone.defaultValue) - } else if (dataObject[key]) { - dataObject[key] = val - } else if (!isAttr(key)) { - dataObject.props[key] = val - } else { - dataObject.attrs[key] = val - } - }) - return h(this.conf.tag, dataObject, children) - }, - props: ['conf'] -} +import { makeMap } from '@/utils/index' + +// 参考https://github.com/vuejs/vue/blob/v2.6.10/src/platforms/web/server/util.js +const isAttr = makeMap( + 'accept,accept-charset,accesskey,action,align,alt,async,autocomplete,' + + 'autofocus,autoplay,autosave,bgcolor,border,buffered,challenge,charset,' + + 'checked,cite,class,code,codebase,color,cols,colspan,content,http-equiv,' + + 'name,contenteditable,contextmenu,controls,coords,data,datetime,default,' + + 'defer,dir,dirname,disabled,download,draggable,dropzone,enctype,method,for,' + + 'form,formaction,headers,height,hidden,high,href,hreflang,http-equiv,' + + 'icon,id,ismap,itemprop,keytype,kind,label,lang,language,list,loop,low,' + + 'manifest,max,maxlength,media,method,GET,POST,min,multiple,email,file,' + + 'muted,name,novalidate,open,optimum,pattern,ping,placeholder,poster,' + + 'preload,radiogroup,readonly,rel,required,reversed,rows,rowspan,sandbox,' + + 'scope,scoped,seamless,selected,shape,size,type,text,password,sizes,span,' + + 'spellcheck,src,srcdoc,srclang,srcset,start,step,style,summary,tabindex,' + + 'target,title,type,usemap,value,width,wrap' +) + +function vModel(self, dataObject, defaultValue) { + dataObject.props.value = defaultValue + + dataObject.on.input = val => { + self.$emit('input', val) + } +} + +const componentChild = { + 'el-button': { + default(h, conf, key) { + return conf[key] + }, + }, + 'el-input': { + prepend(h, conf, key) { + return + }, + append(h, conf, key) { + return + } + }, + 'el-select': { + options(h, conf, key) { + const list = [] + conf.options.forEach(item => { + list.push() + }) + return list + } + }, + 'el-radio-group': { + options(h, conf, key) { + const list = [] + conf.options.forEach(item => { + if (conf.optionType === 'button') list.push({item.label}) + else list.push({item.label}) + }) + return list + } + }, + 'el-checkbox-group': { + options(h, conf, key) { + const list = [] + conf.options.forEach(item => { + if (conf.optionType === 'button') { + list.push({item.label}) + } else { + list.push({item.label}) + } + }) + return list + } + }, + 'el-upload': { + 'list-type': (h, conf, key) => { + const list = [] + if (conf['list-type'] === 'picture-card') { + list.push() + } else { + list.push({conf.buttonText}) + } + if (conf.showTip) { + list.push(
    只能上传不超过 {conf.fileSize}{conf.sizeUnit} 的{conf.accept}文件
    ) + } + return list + } + } +} + +export default { + render(h) { + const dataObject = { + attrs: {}, + props: {}, + on: {}, + style: {} + } + const confClone = JSON.parse(JSON.stringify(this.conf)) + const children = [] + + const childObjs = componentChild[confClone.tag] + if (childObjs) { + Object.keys(childObjs).forEach(key => { + const childFunc = childObjs[key] + if (confClone[key]) { + children.push(childFunc(h, confClone, key)) + } + }) + } + + Object.keys(confClone).forEach(key => { + const val = confClone[key] + if (key === 'vModel') { + vModel(this, dataObject, confClone.defaultValue) + } else if (dataObject[key]) { + dataObject[key] = val + } else if (!isAttr(key)) { + dataObject.props[key] = val + } else { + dataObject.attrs[key] = val + } + }) + return h(this.conf.tag, dataObject, children) + }, + props: ['conf'] +} diff --git a/sf-ui/src/utils/index.js b/sf-ui/src/utils/index.js index 9679e75..4e65504 100644 --- a/sf-ui/src/utils/index.js +++ b/sf-ui/src/utils/index.js @@ -1,390 +1,390 @@ -import { parseTime } from './ruoyi' - -/** - * 表格时间格式化 - */ -export function formatDate(cellValue) { - if (cellValue == null || cellValue == "") return ""; - var date = new Date(cellValue) - var year = date.getFullYear() - var month = date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1 - var day = date.getDate() < 10 ? '0' + date.getDate() : date.getDate() - var hours = date.getHours() < 10 ? '0' + date.getHours() : date.getHours() - var minutes = date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes() - var seconds = date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds() - return year + '-' + month + '-' + day + ' ' + hours + ':' + minutes + ':' + seconds -} - -/** - * @param {number} time - * @param {string} option - * @returns {string} - */ -export function formatTime(time, option) { - if (('' + time).length === 10) { - time = parseInt(time) * 1000 - } else { - time = +time - } - const d = new Date(time) - const now = Date.now() - - const diff = (now - d) / 1000 - - if (diff < 30) { - return '刚刚' - } else if (diff < 3600) { - // less 1 hour - return Math.ceil(diff / 60) + '分钟前' - } else if (diff < 3600 * 24) { - return Math.ceil(diff / 3600) + '小时前' - } else if (diff < 3600 * 24 * 2) { - return '1天前' - } - if (option) { - return parseTime(time, option) - } else { - return ( - d.getMonth() + - 1 + - '月' + - d.getDate() + - '日' + - d.getHours() + - '时' + - d.getMinutes() + - '分' - ) - } -} - -/** - * @param {string} url - * @returns {Object} - */ -export function getQueryObject(url) { - url = url == null ? window.location.href : url - const search = url.substring(url.lastIndexOf('?') + 1) - const obj = {} - const reg = /([^?&=]+)=([^?&=]*)/g - search.replace(reg, (rs, $1, $2) => { - const name = decodeURIComponent($1) - let val = decodeURIComponent($2) - val = String(val) - obj[name] = val - return rs - }) - return obj -} - -/** - * @param {string} input value - * @returns {number} output value - */ -export function byteLength(str) { - // returns the byte length of an utf8 string - let s = str.length - for (var i = str.length - 1; i >= 0; i--) { - const code = str.charCodeAt(i) - if (code > 0x7f && code <= 0x7ff) s++ - else if (code > 0x7ff && code <= 0xffff) s += 2 - if (code >= 0xDC00 && code <= 0xDFFF) i-- - } - return s -} - -/** - * @param {Array} actual - * @returns {Array} - */ -export function cleanArray(actual) { - const newArray = [] - for (let i = 0; i < actual.length; i++) { - if (actual[i]) { - newArray.push(actual[i]) - } - } - return newArray -} - -/** - * @param {Object} json - * @returns {Array} - */ -export function param(json) { - if (!json) return '' - return cleanArray( - Object.keys(json).map(key => { - if (json[key] === undefined) return '' - return encodeURIComponent(key) + '=' + encodeURIComponent(json[key]) - }) - ).join('&') -} - -/** - * @param {string} url - * @returns {Object} - */ -export function param2Obj(url) { - const search = decodeURIComponent(url.split('?')[1]).replace(/\+/g, ' ') - if (!search) { - return {} - } - const obj = {} - const searchArr = search.split('&') - searchArr.forEach(v => { - const index = v.indexOf('=') - if (index !== -1) { - const name = v.substring(0, index) - const val = v.substring(index + 1, v.length) - obj[name] = val - } - }) - return obj -} - -/** - * @param {string} val - * @returns {string} - */ -export function html2Text(val) { - const div = document.createElement('div') - div.innerHTML = val - return div.textContent || div.innerText -} - -/** - * Merges two objects, giving the last one precedence - * @param {Object} target - * @param {(Object|Array)} source - * @returns {Object} - */ -export function objectMerge(target, source) { - if (typeof target !== 'object') { - target = {} - } - if (Array.isArray(source)) { - return source.slice() - } - Object.keys(source).forEach(property => { - const sourceProperty = source[property] - if (typeof sourceProperty === 'object') { - target[property] = objectMerge(target[property], sourceProperty) - } else { - target[property] = sourceProperty - } - }) - return target -} - -/** - * @param {HTMLElement} element - * @param {string} className - */ -export function toggleClass(element, className) { - if (!element || !className) { - return - } - let classString = element.className - const nameIndex = classString.indexOf(className) - if (nameIndex === -1) { - classString += '' + className - } else { - classString = - classString.substr(0, nameIndex) + - classString.substr(nameIndex + className.length) - } - element.className = classString -} - -/** - * @param {string} type - * @returns {Date} - */ -export function getTime(type) { - if (type === 'start') { - return new Date().getTime() - 3600 * 1000 * 24 * 90 - } else { - return new Date(new Date().toDateString()) - } -} - -/** - * @param {Function} func - * @param {number} wait - * @param {boolean} immediate - * @return {*} - */ -export function debounce(func, wait, immediate) { - let timeout, args, context, timestamp, result - - const later = function() { - // 据上一次触发时间间隔 - const last = +new Date() - timestamp - - // 上次被包装函数被调用时间间隔 last 小于设定时间间隔 wait - if (last < wait && last > 0) { - timeout = setTimeout(later, wait - last) - } else { - timeout = null - // 如果设定为immediate===true,因为开始边界已经调用过了此处无需调用 - if (!immediate) { - result = func.apply(context, args) - if (!timeout) context = args = null - } - } - } - - return function(...args) { - context = this - timestamp = +new Date() - const callNow = immediate && !timeout - // 如果延时不存在,重新设定延时 - if (!timeout) timeout = setTimeout(later, wait) - if (callNow) { - result = func.apply(context, args) - context = args = null - } - - return result - } -} - -/** - * This is just a simple version of deep copy - * Has a lot of edge cases bug - * If you want to use a perfect deep copy, use lodash's _.cloneDeep - * @param {Object} source - * @returns {Object} - */ -export function deepClone(source) { - if (!source && typeof source !== 'object') { - throw new Error('error arguments', 'deepClone') - } - const targetObj = source.constructor === Array ? [] : {} - Object.keys(source).forEach(keys => { - if (source[keys] && typeof source[keys] === 'object') { - targetObj[keys] = deepClone(source[keys]) - } else { - targetObj[keys] = source[keys] - } - }) - return targetObj -} - -/** - * @param {Array} arr - * @returns {Array} - */ -export function uniqueArr(arr) { - return Array.from(new Set(arr)) -} - -/** - * @returns {string} - */ -export function createUniqueString() { - const timestamp = +new Date() + '' - const randomNum = parseInt((1 + Math.random()) * 65536) + '' - return (+(randomNum + timestamp)).toString(32) -} - -/** - * Check if an element has a class - * @param {HTMLElement} elm - * @param {string} cls - * @returns {boolean} - */ -export function hasClass(ele, cls) { - return !!ele.className.match(new RegExp('(\\s|^)' + cls + '(\\s|$)')) -} - -/** - * Add class to element - * @param {HTMLElement} elm - * @param {string} cls - */ -export function addClass(ele, cls) { - if (!hasClass(ele, cls)) ele.className += ' ' + cls -} - -/** - * Remove class from element - * @param {HTMLElement} elm - * @param {string} cls - */ -export function removeClass(ele, cls) { - if (hasClass(ele, cls)) { - const reg = new RegExp('(\\s|^)' + cls + '(\\s|$)') - ele.className = ele.className.replace(reg, ' ') - } -} - -export function makeMap(str, expectsLowerCase) { - const map = Object.create(null) - const list = str.split(',') - for (let i = 0; i < list.length; i++) { - map[list[i]] = true - } - return expectsLowerCase - ? val => map[val.toLowerCase()] - : val => map[val] -} - -export const exportDefault = 'export default ' - -export const beautifierConf = { - html: { - indent_size: '2', - indent_char: ' ', - max_preserve_newlines: '-1', - preserve_newlines: false, - keep_array_indentation: false, - break_chained_methods: false, - indent_scripts: 'separate', - brace_style: 'end-expand', - space_before_conditional: true, - unescape_strings: false, - jslint_happy: false, - end_with_newline: true, - wrap_line_length: '110', - indent_inner_html: true, - comma_first: false, - e4x: true, - indent_empty_lines: true - }, - js: { - indent_size: '2', - indent_char: ' ', - max_preserve_newlines: '-1', - preserve_newlines: false, - keep_array_indentation: false, - break_chained_methods: false, - indent_scripts: 'normal', - brace_style: 'end-expand', - space_before_conditional: true, - unescape_strings: false, - jslint_happy: true, - end_with_newline: true, - wrap_line_length: '110', - indent_inner_html: true, - comma_first: false, - e4x: true, - indent_empty_lines: true - } -} - -// 首字母大小 -export function titleCase(str) { - return str.replace(/( |^)[a-z]/g, L => L.toUpperCase()) -} - -// 下划转驼峰 -export function camelCase(str) { - return str.replace(/_[a-z]/g, str1 => str1.substr(-1).toUpperCase()) -} - -export function isNumberStr(str) { - return /^[+-]?(0|([1-9]\d*))(\.\d+)?$/g.test(str) -} - +import { parseTime } from './ruoyi' + +/** + * 表格时间格式化 + */ +export function formatDate(cellValue) { + if (cellValue == null || cellValue == "") return ""; + var date = new Date(cellValue) + var year = date.getFullYear() + var month = date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1 + var day = date.getDate() < 10 ? '0' + date.getDate() : date.getDate() + var hours = date.getHours() < 10 ? '0' + date.getHours() : date.getHours() + var minutes = date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes() + var seconds = date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds() + return year + '-' + month + '-' + day + ' ' + hours + ':' + minutes + ':' + seconds +} + +/** + * @param {number} time + * @param {string} option + * @returns {string} + */ +export function formatTime(time, option) { + if (('' + time).length === 10) { + time = parseInt(time) * 1000 + } else { + time = +time + } + const d = new Date(time) + const now = Date.now() + + const diff = (now - d) / 1000 + + if (diff < 30) { + return '刚刚' + } else if (diff < 3600) { + // less 1 hour + return Math.ceil(diff / 60) + '分钟前' + } else if (diff < 3600 * 24) { + return Math.ceil(diff / 3600) + '小时前' + } else if (diff < 3600 * 24 * 2) { + return '1天前' + } + if (option) { + return parseTime(time, option) + } else { + return ( + d.getMonth() + + 1 + + '月' + + d.getDate() + + '日' + + d.getHours() + + '时' + + d.getMinutes() + + '分' + ) + } +} + +/** + * @param {string} url + * @returns {Object} + */ +export function getQueryObject(url) { + url = url == null ? window.location.href : url + const search = url.substring(url.lastIndexOf('?') + 1) + const obj = {} + const reg = /([^?&=]+)=([^?&=]*)/g + search.replace(reg, (rs, $1, $2) => { + const name = decodeURIComponent($1) + let val = decodeURIComponent($2) + val = String(val) + obj[name] = val + return rs + }) + return obj +} + +/** + * @param {string} input value + * @returns {number} output value + */ +export function byteLength(str) { + // returns the byte length of an utf8 string + let s = str.length + for (var i = str.length - 1; i >= 0; i--) { + const code = str.charCodeAt(i) + if (code > 0x7f && code <= 0x7ff) s++ + else if (code > 0x7ff && code <= 0xffff) s += 2 + if (code >= 0xDC00 && code <= 0xDFFF) i-- + } + return s +} + +/** + * @param {Array} actual + * @returns {Array} + */ +export function cleanArray(actual) { + const newArray = [] + for (let i = 0; i < actual.length; i++) { + if (actual[i]) { + newArray.push(actual[i]) + } + } + return newArray +} + +/** + * @param {Object} json + * @returns {Array} + */ +export function param(json) { + if (!json) return '' + return cleanArray( + Object.keys(json).map(key => { + if (json[key] === undefined) return '' + return encodeURIComponent(key) + '=' + encodeURIComponent(json[key]) + }) + ).join('&') +} + +/** + * @param {string} url + * @returns {Object} + */ +export function param2Obj(url) { + const search = decodeURIComponent(url.split('?')[1]).replace(/\+/g, ' ') + if (!search) { + return {} + } + const obj = {} + const searchArr = search.split('&') + searchArr.forEach(v => { + const index = v.indexOf('=') + if (index !== -1) { + const name = v.substring(0, index) + const val = v.substring(index + 1, v.length) + obj[name] = val + } + }) + return obj +} + +/** + * @param {string} val + * @returns {string} + */ +export function html2Text(val) { + const div = document.createElement('div') + div.innerHTML = val + return div.textContent || div.innerText +} + +/** + * Merges two objects, giving the last one precedence + * @param {Object} target + * @param {(Object|Array)} source + * @returns {Object} + */ +export function objectMerge(target, source) { + if (typeof target !== 'object') { + target = {} + } + if (Array.isArray(source)) { + return source.slice() + } + Object.keys(source).forEach(property => { + const sourceProperty = source[property] + if (typeof sourceProperty === 'object') { + target[property] = objectMerge(target[property], sourceProperty) + } else { + target[property] = sourceProperty + } + }) + return target +} + +/** + * @param {HTMLElement} element + * @param {string} className + */ +export function toggleClass(element, className) { + if (!element || !className) { + return + } + let classString = element.className + const nameIndex = classString.indexOf(className) + if (nameIndex === -1) { + classString += '' + className + } else { + classString = + classString.substr(0, nameIndex) + + classString.substr(nameIndex + className.length) + } + element.className = classString +} + +/** + * @param {string} type + * @returns {Date} + */ +export function getTime(type) { + if (type === 'start') { + return new Date().getTime() - 3600 * 1000 * 24 * 90 + } else { + return new Date(new Date().toDateString()) + } +} + +/** + * @param {Function} func + * @param {number} wait + * @param {boolean} immediate + * @return {*} + */ +export function debounce(func, wait, immediate) { + let timeout, args, context, timestamp, result + + const later = function() { + // 据上一次触发时间间隔 + const last = +new Date() - timestamp + + // 上次被包装函数被调用时间间隔 last 小于设定时间间隔 wait + if (last < wait && last > 0) { + timeout = setTimeout(later, wait - last) + } else { + timeout = null + // 如果设定为immediate===true,因为开始边界已经调用过了此处无需调用 + if (!immediate) { + result = func.apply(context, args) + if (!timeout) context = args = null + } + } + } + + return function(...args) { + context = this + timestamp = +new Date() + const callNow = immediate && !timeout + // 如果延时不存在,重新设定延时 + if (!timeout) timeout = setTimeout(later, wait) + if (callNow) { + result = func.apply(context, args) + context = args = null + } + + return result + } +} + +/** + * This is just a simple version of deep copy + * Has a lot of edge cases bug + * If you want to use a perfect deep copy, use lodash's _.cloneDeep + * @param {Object} source + * @returns {Object} + */ +export function deepClone(source) { + if (!source && typeof source !== 'object') { + throw new Error('error arguments', 'deepClone') + } + const targetObj = source.constructor === Array ? [] : {} + Object.keys(source).forEach(keys => { + if (source[keys] && typeof source[keys] === 'object') { + targetObj[keys] = deepClone(source[keys]) + } else { + targetObj[keys] = source[keys] + } + }) + return targetObj +} + +/** + * @param {Array} arr + * @returns {Array} + */ +export function uniqueArr(arr) { + return Array.from(new Set(arr)) +} + +/** + * @returns {string} + */ +export function createUniqueString() { + const timestamp = +new Date() + '' + const randomNum = parseInt((1 + Math.random()) * 65536) + '' + return (+(randomNum + timestamp)).toString(32) +} + +/** + * Check if an element has a class + * @param {HTMLElement} elm + * @param {string} cls + * @returns {boolean} + */ +export function hasClass(ele, cls) { + return !!ele.className.match(new RegExp('(\\s|^)' + cls + '(\\s|$)')) +} + +/** + * Add class to element + * @param {HTMLElement} elm + * @param {string} cls + */ +export function addClass(ele, cls) { + if (!hasClass(ele, cls)) ele.className += ' ' + cls +} + +/** + * Remove class from element + * @param {HTMLElement} elm + * @param {string} cls + */ +export function removeClass(ele, cls) { + if (hasClass(ele, cls)) { + const reg = new RegExp('(\\s|^)' + cls + '(\\s|$)') + ele.className = ele.className.replace(reg, ' ') + } +} + +export function makeMap(str, expectsLowerCase) { + const map = Object.create(null) + const list = str.split(',') + for (let i = 0; i < list.length; i++) { + map[list[i]] = true + } + return expectsLowerCase + ? val => map[val.toLowerCase()] + : val => map[val] +} + +export const exportDefault = 'export default ' + +export const beautifierConf = { + html: { + indent_size: '2', + indent_char: ' ', + max_preserve_newlines: '-1', + preserve_newlines: false, + keep_array_indentation: false, + break_chained_methods: false, + indent_scripts: 'separate', + brace_style: 'end-expand', + space_before_conditional: true, + unescape_strings: false, + jslint_happy: false, + end_with_newline: true, + wrap_line_length: '110', + indent_inner_html: true, + comma_first: false, + e4x: true, + indent_empty_lines: true + }, + js: { + indent_size: '2', + indent_char: ' ', + max_preserve_newlines: '-1', + preserve_newlines: false, + keep_array_indentation: false, + break_chained_methods: false, + indent_scripts: 'normal', + brace_style: 'end-expand', + space_before_conditional: true, + unescape_strings: false, + jslint_happy: true, + end_with_newline: true, + wrap_line_length: '110', + indent_inner_html: true, + comma_first: false, + e4x: true, + indent_empty_lines: true + } +} + +// 首字母大小 +export function titleCase(str) { + return str.replace(/( |^)[a-z]/g, L => L.toUpperCase()) +} + +// 下划转驼峰 +export function camelCase(str) { + return str.replace(/_[a-z]/g, str1 => str1.substr(-1).toUpperCase()) +} + +export function isNumberStr(str) { + return /^[+-]?(0|([1-9]\d*))(\.\d+)?$/g.test(str) +} + diff --git a/sf-ui/src/utils/permission.js b/sf-ui/src/utils/permission.js index 25d1a02..1730e33 100644 --- a/sf-ui/src/utils/permission.js +++ b/sf-ui/src/utils/permission.js @@ -1,51 +1,51 @@ -import store from '@/store' - -/** - * 字符权限校验 - * @param {Array} value 校验值 - * @returns {Boolean} - */ -export function checkPermi(value) { - if (value && value instanceof Array && value.length > 0) { - const permissions = store.getters && store.getters.permissions - const permissionDatas = value - const all_permission = "*:*:*"; - - const hasPermission = permissions.some(permission => { - return all_permission === permission || permissionDatas.includes(permission) - }) - - if (!hasPermission) { - return false - } - return true - } else { - console.error(`need roles! Like checkPermi="['system:user:add','system:user:edit']"`) - return false - } -} - -/** - * 角色权限校验 - * @param {Array} value 校验值 - * @returns {Boolean} - */ -export function checkRole(value) { - if (value && value instanceof Array && value.length > 0) { - const roles = store.getters && store.getters.roles - const permissionRoles = value - const super_admin = "admin"; - - const hasRole = roles.some(role => { - return super_admin === role || permissionRoles.includes(role) - }) - - if (!hasRole) { - return false - } - return true - } else { - console.error(`need roles! Like checkRole="['admin','editor']"`) - return false - } +import store from '@/store' + +/** + * 字符权限校验 + * @param {Array} value 校验值 + * @returns {Boolean} + */ +export function checkPermi(value) { + if (value && value instanceof Array && value.length > 0) { + const permissions = store.getters && store.getters.permissions + const permissionDatas = value + const all_permission = "*:*:*"; + + const hasPermission = permissions.some(permission => { + return all_permission === permission || permissionDatas.includes(permission) + }) + + if (!hasPermission) { + return false + } + return true + } else { + console.error(`need roles! Like checkPermi="['system:user:add','system:user:edit']"`) + return false + } +} + +/** + * 角色权限校验 + * @param {Array} value 校验值 + * @returns {Boolean} + */ +export function checkRole(value) { + if (value && value instanceof Array && value.length > 0) { + const roles = store.getters && store.getters.roles + const permissionRoles = value + const super_admin = "admin"; + + const hasRole = roles.some(role => { + return super_admin === role || permissionRoles.includes(role) + }) + + if (!hasRole) { + return false + } + return true + } else { + console.error(`need roles! Like checkRole="['admin','editor']"`) + return false + } } \ No newline at end of file diff --git a/sf-ui/src/utils/request.js b/sf-ui/src/utils/request.js index 66874e2..296889e 100644 --- a/sf-ui/src/utils/request.js +++ b/sf-ui/src/utils/request.js @@ -7,6 +7,7 @@ import { blobValidate, tansParams } from '@/utils/ruoyi' import cache from '@/plugins/cache' import { saveAs } from 'file-saver' import Cookies from 'js-cookie' +import router from '@/router' let downloadLoadingInstance // 是否显示重新登录 @@ -72,44 +73,53 @@ service.interceptors.request.use(config => { // 响应拦截器 service.interceptors.response.use(res => { - // 未设置状态码则默认成功状态 - const code = res.data.code || 200 - // 获取错误信息 - const msg = errorCode[code] || res.data.msg || errorCode['default'] - // 二进制数据则直接返回 - if (res.request.responseType === 'blob' || res.request.responseType === 'arraybuffer') { - return res.data - } - if (code === 401) { - if (!isRelogin.show) { - isRelogin.show = true - MessageBox.confirm('登录状态已过期,您可以继续留在该页面,或者重新登录', '系统提示', { - confirmButtonText: '重新登录', - cancelButtonText: '取消', - type: 'warning' - }).then(() => { - isRelogin.show = false - store.dispatch('LogOut').then(() => { - location.href = '/index' - }) - }).catch(() => { - isRelogin.show = false + // 未设置状态码则默认成功状态 + const code = res.data.code || 200 + // 获取错误信息 + const msg = errorCode[code] || res.data.msg || errorCode['default'] + // 二进制数据则直接返回 + if (res.request.responseType === 'blob' || res.request.responseType === 'arraybuffer') { + return res.data + } + if (code === 401) { + if (!isRelogin.show) { + isRelogin.show = true + MessageBox.confirm('登录状态已过期,您可以继续留在该页面,或者重新登录', '系统提示', { + confirmButtonText: '重新登录', + cancelButtonText: '取消', + type: 'warning' + }).then(() => { + isRelogin.show = false + store.dispatch('LogOut').then(() => { + location.href = '/index' }) - } - return Promise.reject('无效的会话,或者会话已过期,请重新登录。') - } else if (code === 500) { - Message({ message: msg, type: 'error' }) - return Promise.reject(new Error(msg)) - } else if (code === 601) { - Message({ message: msg, type: 'warning' }) - return Promise.reject('error') - } else if (code !== 200) { - Notification.error({ title: msg }) - return Promise.reject('error') - } else { - return res.data + }).catch(() => { + isRelogin.show = false + }) } - }, + return Promise.reject('无效的会话,或者会话已过期,请重新登录。') + } else if (code === 4030) { + MessageBox.confirm('AppCode未找到,请重新选择项目。', '系统提示', { + confirmButtonText: '重新选择', + cancelButtonText: '取消', + type: 'warning' + }).then(() => { + router.push('/') + }) + return Promise.reject('AppCode未找到,请重新选择项目。') + } else if (code === 500) { + Message({ message: msg, type: 'error' }) + return Promise.reject(new Error(msg)) + } else if (code === 601) { + Message({ message: msg, type: 'warning' }) + return Promise.reject('error') + } else if (code !== 200) { + Notification.error({ title: msg }) + return Promise.reject('error') + } else { + return res.data + } +}, error => { console.log('err' + error) let { message } = error @@ -126,7 +136,7 @@ service.interceptors.response.use(res => { ) // 通用下载方法 -export function download(url, params, filename, config) { +export function download (url, params, filename, config) { downloadLoadingInstance = Loading.service({ text: '正在下载数据,请稍候', spinner: 'el-icon-loading', @@ -139,7 +149,7 @@ export function download(url, params, filename, config) { headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, responseType: 'blob', ...config - }).then(async(data) => { + }).then(async (data) => { const isBlob = blobValidate(data) if (isBlob) { const blob = new Blob([data]) diff --git a/sf-ui/src/utils/ruoyi.js b/sf-ui/src/utils/ruoyi.js index 44bf9c4..b818800 100644 --- a/sf-ui/src/utils/ruoyi.js +++ b/sf-ui/src/utils/ruoyi.js @@ -6,7 +6,7 @@ */ // 日期格式化 -export function parseTime(time, pattern) { +export function parseTime (time, pattern) { if (arguments.length === 0 || !time) { return null } @@ -47,14 +47,14 @@ export function parseTime(time, pattern) { } // 表单重置 -export function resetForm(refName) { +export function resetForm (refName) { if (this.$refs[refName]) { this.$refs[refName].resetFields(); } } // 添加日期范围 -export function addDateRange(params, dateRange, propName) { +export function addDateRange (params, dateRange, propName) { let search = params; search.params = typeof (search.params) === 'object' && search.params !== null && !Array.isArray(search.params) ? search.params : {}; dateRange = Array.isArray(dateRange) ? dateRange : []; @@ -68,8 +68,27 @@ export function addDateRange(params, dateRange, propName) { return search; } + + +// 添加日期范围 +export function addDateRange2 (params, dateRange, propName) { + let search = params; + search.params = typeof (search.params) === 'object' && search.params !== null && !Array.isArray(search.params) ? search.params : {}; + dateRange = Array.isArray(dateRange) ? dateRange : []; + if (typeof (propName) === 'undefined') { + search.beginTime = dateRange[0]; + search.endTime = dateRange[1]; + } else { + search.params['begin' + propName] = dateRange[0]; + search.params['end' + propName] = dateRange[1]; + } + return search; +} + + + // 回显数据字典 -export function selectDictLabel(datas, value) { +export function selectDictLabel (datas, value) { if (value === undefined) { return ""; } @@ -87,8 +106,8 @@ export function selectDictLabel(datas, value) { } // 回显数据字典(字符串、数组) -export function selectDictLabels(datas, value, separator) { - if (value === undefined || value.length ===0) { +export function selectDictLabels (datas, value, separator) { + if (value === undefined || value.length === 0) { return ""; } if (Array.isArray(value)) { @@ -113,7 +132,7 @@ export function selectDictLabels(datas, value, separator) { } // 字符串格式化(%s ) -export function sprintf(str) { +export function sprintf (str) { var args = arguments, flag = true, i = 1; str = str.replace(/%s/g, function () { var arg = args[i++]; @@ -127,7 +146,7 @@ export function sprintf(str) { } // 转换字符串,undefined,null等转化为"" -export function parseStrEmpty(str) { +export function parseStrEmpty (str) { if (!str || str == "undefined" || str == "null") { return ""; } @@ -135,7 +154,7 @@ export function parseStrEmpty(str) { } // 数据合并 -export function mergeRecursive(source, target) { +export function mergeRecursive (source, target) { for (var p in target) { try { if (target[p].constructor == Object) { @@ -157,7 +176,7 @@ export function mergeRecursive(source, target) { * @param {*} parentId 父节点字段 默认 'parentId' * @param {*} children 孩子节点字段 默认 'children' */ -export function handleTree(data, id, parentId, children) { +export function handleTree (data, id, parentId, children) { let config = { id: id || 'id', parentId: parentId || 'parentId', @@ -188,7 +207,7 @@ export function handleTree(data, id, parentId, children) { adaptToChildrenList(t); } - function adaptToChildrenList(o) { + function adaptToChildrenList (o) { if (childrenListMap[o[config.id]] !== null) { o[config.childrenList] = childrenListMap[o[config.id]]; } @@ -205,7 +224,7 @@ export function handleTree(data, id, parentId, children) { * 参数处理 * @param {*} params 参数 */ -export function tansParams(params) { +export function tansParams (params) { let result = '' for (const propName of Object.keys(params)) { const value = params[propName]; @@ -228,6 +247,6 @@ export function tansParams(params) { } // 验证是否为blob格式 -export function blobValidate(data) { +export function blobValidate (data) { return data.type !== 'application/json' } diff --git a/sf-ui/src/utils/scroll-to.js b/sf-ui/src/utils/scroll-to.js index 709fa57..c5d8e04 100644 --- a/sf-ui/src/utils/scroll-to.js +++ b/sf-ui/src/utils/scroll-to.js @@ -1,58 +1,58 @@ -Math.easeInOutQuad = function(t, b, c, d) { - t /= d / 2 - if (t < 1) { - return c / 2 * t * t + b - } - t-- - return -c / 2 * (t * (t - 2) - 1) + b -} - -// requestAnimationFrame for Smart Animating http://goo.gl/sx5sts -var requestAnimFrame = (function() { - return window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || function(callback) { window.setTimeout(callback, 1000 / 60) } -})() - -/** - * Because it's so fucking difficult to detect the scrolling element, just move them all - * @param {number} amount - */ -function move(amount) { - document.documentElement.scrollTop = amount - document.body.parentNode.scrollTop = amount - document.body.scrollTop = amount -} - -function position() { - return document.documentElement.scrollTop || document.body.parentNode.scrollTop || document.body.scrollTop -} - -/** - * @param {number} to - * @param {number} duration - * @param {Function} callback - */ -export function scrollTo(to, duration, callback) { - const start = position() - const change = to - start - const increment = 20 - let currentTime = 0 - duration = (typeof (duration) === 'undefined') ? 500 : duration - var animateScroll = function() { - // increment the time - currentTime += increment - // find the value with the quadratic in-out easing function - var val = Math.easeInOutQuad(currentTime, start, change, duration) - // move the document.body - move(val) - // do the animation unless its over - if (currentTime < duration) { - requestAnimFrame(animateScroll) - } else { - if (callback && typeof (callback) === 'function') { - // the animation is done so lets callback - callback() - } - } - } - animateScroll() -} +Math.easeInOutQuad = function(t, b, c, d) { + t /= d / 2 + if (t < 1) { + return c / 2 * t * t + b + } + t-- + return -c / 2 * (t * (t - 2) - 1) + b +} + +// requestAnimationFrame for Smart Animating http://goo.gl/sx5sts +var requestAnimFrame = (function() { + return window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || function(callback) { window.setTimeout(callback, 1000 / 60) } +})() + +/** + * Because it's so fucking difficult to detect the scrolling element, just move them all + * @param {number} amount + */ +function move(amount) { + document.documentElement.scrollTop = amount + document.body.parentNode.scrollTop = amount + document.body.scrollTop = amount +} + +function position() { + return document.documentElement.scrollTop || document.body.parentNode.scrollTop || document.body.scrollTop +} + +/** + * @param {number} to + * @param {number} duration + * @param {Function} callback + */ +export function scrollTo(to, duration, callback) { + const start = position() + const change = to - start + const increment = 20 + let currentTime = 0 + duration = (typeof (duration) === 'undefined') ? 500 : duration + var animateScroll = function() { + // increment the time + currentTime += increment + // find the value with the quadratic in-out easing function + var val = Math.easeInOutQuad(currentTime, start, change, duration) + // move the document.body + move(val) + // do the animation unless its over + if (currentTime < duration) { + requestAnimFrame(animateScroll) + } else { + if (callback && typeof (callback) === 'function') { + // the animation is done so lets callback + callback() + } + } + } + animateScroll() +} diff --git a/sf-ui/src/utils/validate.js b/sf-ui/src/utils/validate.js index 9c00400..adfa254 100644 --- a/sf-ui/src/utils/validate.js +++ b/sf-ui/src/utils/validate.js @@ -1,83 +1,83 @@ -/** - * @param {string} path - * @returns {Boolean} - */ -export function isExternal(path) { - return /^(https?:|mailto:|tel:)/.test(path) -} - -/** - * @param {string} str - * @returns {Boolean} - */ -export function validUsername(str) { - const valid_map = ['admin', 'editor'] - return valid_map.indexOf(str.trim()) >= 0 -} - -/** - * @param {string} url - * @returns {Boolean} - */ -export function validURL(url) { - const reg = /^(https?|ftp):\/\/([a-zA-Z0-9.-]+(:[a-zA-Z0-9.&%$-]+)*@)*((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9][0-9]?)(\.(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])){3}|([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+\.(com|edu|gov|int|mil|net|org|biz|arpa|info|name|pro|aero|coop|museum|[a-zA-Z]{2}))(:[0-9]+)*(\/($|[a-zA-Z0-9.,?'\\+&%$#=~_-]+))*$/ - return reg.test(url) -} - -/** - * @param {string} str - * @returns {Boolean} - */ -export function validLowerCase(str) { - const reg = /^[a-z]+$/ - return reg.test(str) -} - -/** - * @param {string} str - * @returns {Boolean} - */ -export function validUpperCase(str) { - const reg = /^[A-Z]+$/ - return reg.test(str) -} - -/** - * @param {string} str - * @returns {Boolean} - */ -export function validAlphabets(str) { - const reg = /^[A-Za-z]+$/ - return reg.test(str) -} - -/** - * @param {string} email - * @returns {Boolean} - */ -export function validEmail(email) { - const reg = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/ - return reg.test(email) -} - -/** - * @param {string} str - * @returns {Boolean} - */ -export function isString(str) { - if (typeof str === 'string' || str instanceof String) { - return true - } - return false -} - -/** - * @param {Array} arg - * @returns {Boolean} - */ -export function isArray(arg) { - if (typeof Array.isArray === 'undefined') { - return Object.prototype.toString.call(arg) === '[object Array]' - } - return Array.isArray(arg) -} +/** + * @param {string} path + * @returns {Boolean} + */ +export function isExternal(path) { + return /^(https?:|mailto:|tel:)/.test(path) +} + +/** + * @param {string} str + * @returns {Boolean} + */ +export function validUsername(str) { + const valid_map = ['admin', 'editor'] + return valid_map.indexOf(str.trim()) >= 0 +} + +/** + * @param {string} url + * @returns {Boolean} + */ +export function validURL(url) { + const reg = /^(https?|ftp):\/\/([a-zA-Z0-9.-]+(:[a-zA-Z0-9.&%$-]+)*@)*((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9][0-9]?)(\.(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])){3}|([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+\.(com|edu|gov|int|mil|net|org|biz|arpa|info|name|pro|aero|coop|museum|[a-zA-Z]{2}))(:[0-9]+)*(\/($|[a-zA-Z0-9.,?'\\+&%$#=~_-]+))*$/ + return reg.test(url) +} + +/** + * @param {string} str + * @returns {Boolean} + */ +export function validLowerCase(str) { + const reg = /^[a-z]+$/ + return reg.test(str) +} + +/** + * @param {string} str + * @returns {Boolean} + */ +export function validUpperCase(str) { + const reg = /^[A-Z]+$/ + return reg.test(str) +} + +/** + * @param {string} str + * @returns {Boolean} + */ +export function validAlphabets(str) { + const reg = /^[A-Za-z]+$/ + return reg.test(str) +} + +/** + * @param {string} email + * @returns {Boolean} + */ +export function validEmail(email) { + const reg = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/ + return reg.test(email) +} + +/** + * @param {string} str + * @returns {Boolean} + */ +export function isString(str) { + if (typeof str === 'string' || str instanceof String) { + return true + } + return false +} + +/** + * @param {Array} arg + * @returns {Boolean} + */ +export function isArray(arg) { + if (typeof Array.isArray === 'undefined') { + return Object.prototype.toString.call(arg) === '[object Array]' + } + return Array.isArray(arg) +} diff --git a/sf-ui/src/views/FDS/installationList/add.vue b/sf-ui/src/views/FDS/installationList/add.vue index de16b89..7e26b9c 100644 --- a/sf-ui/src/views/FDS/installationList/add.vue +++ b/sf-ui/src/views/FDS/installationList/add.vue @@ -8,25 +8,29 @@
    - - - - - - - - - + + + {{ item.label }} + + + + + + + - @@ -43,6 +47,16 @@ + + + + + + + + + + 提交 取 消 @@ -63,7 +77,7 @@ export default { data() { return { formData: { - uploadingType: 'OnLineUploading', + uploadingType: 'OffLineUploading', sysApkName: undefined, version: undefined, sysApk: null, @@ -109,7 +123,6 @@ export default { }) }, getSize(e) { - console.log(e) this.formData.sysApkSize = e[0].size + 'kb' }, cancel() { diff --git a/sf-ui/src/views/FDS/installationList/detail.vue b/sf-ui/src/views/FDS/installationList/detail.vue index 8e93a32..2213aa4 100644 --- a/sf-ui/src/views/FDS/installationList/detail.vue +++ b/sf-ui/src/views/FDS/installationList/detail.vue @@ -27,11 +27,11 @@ 登录模块 {{ form.createTime }} - - - + + + {{ form.created }} - + 日志日志 关 闭 diff --git a/sf-ui/src/views/FDS/installationList/edit.vue b/sf-ui/src/views/FDS/installationList/edit.vue index a3cdea0..ba121da 100644 --- a/sf-ui/src/views/FDS/installationList/edit.vue +++ b/sf-ui/src/views/FDS/installationList/edit.vue @@ -8,27 +8,30 @@
    - - - - - - - - - + + + {{ item.label }} + + + + + + + - @@ -45,6 +48,16 @@ + + + + + + + + + + 提交 取 消 diff --git a/sf-ui/src/views/FDS/installationList/index.vue b/sf-ui/src/views/FDS/installationList/index.vue index e356451..1ac9418 100644 --- a/sf-ui/src/views/FDS/installationList/index.vue +++ b/sf-ui/src/views/FDS/installationList/index.vue @@ -1,39 +1,68 @@